Skip to content
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

Closed
p6rt opened this issue Jun 21, 2009 · 5 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 21, 2009

Migrated from rt.perl.org#66826 (status was 'resolved')

Searchable as RT66826$

@p6rt
Copy link
Author

p6rt commented Jun 21, 2009

From @moritz

Attached patch implements the eager version of infix​:<...> (the series
operator). It makes rakudo fail like this​:

$ perl6 -e '1...{()}'
Null PMC access in find_method()
current instr.​: '' pc 80114 (src/gen_setting.pir​:0)
(src/gen_setting.pm​:1200)
called from Sub '_block18' pc -1 ((unknown file)​:-1)

However when I apply only the patch to grammar-oper.pg and put the
definition of src/setting/Operators.pm into a script and use the
operator after that, it works just fine.

I don't know yet how general this problem is, but if it appears in all
cases of operators defined in the setting, it will severely limit its
usefulness.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jun 21, 2009

From @moritz

0001-implement-non-lazy-series-operator.patch
From 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

@p6rt
Copy link
Author

p6rt commented Jun 30, 2009

From @pmichaud

Now fixed in e0a9d86, and we now have several operators being defined in
the setting (along with tests using those operators).

Closing ticket, thanks!

Pm

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jun 30, 2009

From @pmichaud

Now fixed in e0a9d86, and we now have several operators being defined in
the setting (along with tests using those operators).

Closing ticket, thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Jun 30, 2009

@pmichaud - Status changed from 'new' to 'resolved'

@p6rt p6rt closed this as completed Jun 30, 2009
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant