New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implementing an operator in the setting causes Null PMC access in find_method() #1085
Comments
From @moritzAttached patch implements the eager version of infix:<...> (the series $ perl6 -e '1...{()}' However when I apply only the patch to grammar-oper.pg and put the I don't know yet how general this problem is, but if it appears in all Cheers, |
From @moritz0001-implement-non-lazy-series-operator.patchFrom f232e8ea7f16d46eb284946483a530708bf905b6 Mon Sep 17 00:00:00 2001
From: Moritz Lenz <moritz@faui2k3.org>
Date: Sun, 21 Jun 2009 21:17:33 +0200
Subject: [PATCH] implement (non-lazy) series operator
---
build/Makefile.in | 1 +
src/parser/grammar-oper.pg | 4 ++++
src/setting/Operators.pm | 25 +++++++++++++++++++++++++
3 files changed, 30 insertions(+), 0 deletions(-)
create mode 100644 src/setting/Operators.pm
diff --git a/build/Makefile.in b/build/Makefile.in
index 2ec0b9a..9365d2f 100644
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -122,6 +122,7 @@ SETTING = \
src/setting/Match.pm \
src/setting/Num.pm \
src/setting/Object.pm \
+ src/setting/Operators.pm \
src/setting/Pair.pm \
src/setting/Range.pm \
src/setting/Temporal.pm \
diff --git a/src/parser/grammar-oper.pg b/src/parser/grammar-oper.pg
index 4866f84..7343540 100644
--- a/src/parser/grammar-oper.pg
+++ b/src/parser/grammar-oper.pg
@@ -161,6 +161,10 @@ proto infix:«p5=>» is equiv(infix:<,>) is subname('infix:,') { ... }
## list infix
proto infix:<X> is precedence('f=')
is assoc('list')
+ { ... }
+# needs to come before the others because of missing LTM
+proto infix:<...> is equiv(infix:<X>)
+ is assoc('list')
{ ... }
proto infix:<X,X> is equiv(infix:<X>)
is assoc('list')
diff --git a/src/setting/Operators.pm b/src/setting/Operators.pm
new file mode 100644
index 0000000..d6b9e06
--- /dev/null
+++ b/src/setting/Operators.pm
@@ -0,0 +1,25 @@
+# operators defined in the setting
+
+multi sub infix:<...> (@lhs, Code $generator) {
+ my $c = $generator.count;
+ if $c > @lhs {
+ fail 'the closure wants more parameters than given on the LHS';
+ }
+ my @result = @lhs;
+ my @r;
+ # XXX work around http://rt.perl.org/rt3/Ticket/Display.html?id=66824
+ # this is a bit ugly.. since @a[1..1] returns a single item and not
+ # an array, |@result[$one-item-range] throws the error
+ # "argument doesn't array"
+ while @r = $generator(|@(@result[*-$c..*-1])) {
+ @result.push: @r;
+ }
+ return @result;
+}
+
+my @a = 1, 2 ... { $_ > 3 ?? () !! $_+1};
+say @a.perl;
+
+
+
+# vim: ft=perl6
--
1.5.6.5
|
From @pmichaudNow fixed in e0a9d86, and we now have several operators being defined in Closing ticket, thanks! Pm |
1 similar comment
From @pmichaudNow fixed in e0a9d86, and we now have several operators being defined in Closing ticket, thanks! Pm |
@pmichaud - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#66826 (status was 'resolved')
Searchable as RT66826$
The text was updated successfully, but these errors were encountered: