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
Giving a sub to a map fails #5719
Comments
From @zoffixznetAttempting to give a map some invalid arg or a sub gives an error: zoffix@VirtualBox:~/CPANPRC/rakudo$ ./perl6 -e '^4 .map: {};' However, everything works fine, if we turn off the optimizer: zoffix@VirtualBox:~/CPANPRC/rakudo$ ./perl6 --optimize=off -e '^4 zoffix@VirtualBox:~/CPANPRC/rakudo$ ./perl6 --optimize=off -e '^4 zoffix@VirtualBox:~/CPANPRC/rakudo$ ./perl6 --optimize=off -e Or, if we wrap the range into parenths: zoffix@VirtualBox:~/CPANPRC/rakudo$ ./perl6 -e '(^4).map: {};' zoffix@VirtualBox:~/CPANPRC/rakudo$ ./perl6 -e '(^4).map: 42;' zoffix@VirtualBox:~/CPANPRC/rakudo$ ./perl6 -e 'sub foo ($) {say |
From @usev6Playing around I found that the following change made your examples work as expected: Inline Patchdiff --git a/src/Perl6/Optimizer.nqp b/src/Perl6/Optimizer.nqp
index 12398ba..9102b7f 100644
--- a/src/Perl6/Optimizer.nqp
+++ b/src/Perl6/Optimizer.nqp
@@ -1082,7 +1082,8 @@ class Perl6::Optimizer {
|| nqp::istype($op[0][0], QAST::Stmts) &&
nqp::istype(($c1 := $op[0][0][0]), QAST::Op) &&
nqp::existskey(%range_bounds, $c1.name)) &&
- $!symbols.is_from_core($c1.name) {
+ $!symbols.is_from_core($c1.name) &&
+ nqp::defined($op[0][1].ann('code_object')) {
self.optimize_for_range($op, $op[0][1], $c1);
self.visit_op_children($op);
return $op;
$ ./perl6 -e '^4 .map: 42;' $ ./perl6 -e 'sub foo ($) {say "meow"}; ^4 .map: &foo;' The original error came from the first two lines in 'method optimize_for_ranges' in src/Perl6/Optimizer.nqp. For some reason $callee.ann('code_object') did not return a code object as expected. method optimize_for_range($op, $callee, $c2) { Now, I have no idea whether my change from above makes sense or whether the annotation for 'code_object' was wrong in the first place. |
1 similar comment
From @usev6Playing around I found that the following change made your examples work as expected: Inline Patchdiff --git a/src/Perl6/Optimizer.nqp b/src/Perl6/Optimizer.nqp
index 12398ba..9102b7f 100644
--- a/src/Perl6/Optimizer.nqp
+++ b/src/Perl6/Optimizer.nqp
@@ -1082,7 +1082,8 @@ class Perl6::Optimizer {
|| nqp::istype($op[0][0], QAST::Stmts) &&
nqp::istype(($c1 := $op[0][0][0]), QAST::Op) &&
nqp::existskey(%range_bounds, $c1.name)) &&
- $!symbols.is_from_core($c1.name) {
+ $!symbols.is_from_core($c1.name) &&
+ nqp::defined($op[0][1].ann('code_object')) {
self.optimize_for_range($op, $op[0][1], $c1);
self.visit_op_children($op);
return $op;
$ ./perl6 -e '^4 .map: 42;' $ ./perl6 -e 'sub foo ($) {say "meow"}; ^4 .map: &foo;' The original error came from the first two lines in 'method optimize_for_ranges' in src/Perl6/Optimizer.nqp. For some reason $callee.ann('code_object') did not return a code object as expected. method optimize_for_range($op, $callee, $c2) { Now, I have no idea whether my change from above makes sense or whether the annotation for 'code_object' was wrong in the first place. |
@usev6 - Status changed from 'new' to 'open' |
From @AlexDanielMaybe it is worth noting that this is pretty much a regression (even though an old one, and caused by a non-optimizer change). (2016-08-09) rakudo/rakudo@3284025 Output before and after: https://gist.github.com/75b15f93438bd038cf0bec26c43eaa9f On 2016-10-03 01:32:09, bartolin@gmx.de wrote:
|
From @zoffixznetOn Sat, 14 Oct 2017 18:38:47 -0700, alex.jakimenko@gmail.com wrote:
Thank you for the report. This is now fixed in branch `post-release`. Fix: rakudo/rakudo@f3efe5e6b4a9ee5 |
@zoffixznet - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#129790 (status was 'resolved')
Searchable as RT129790$
The text was updated successfully, but these errors were encountered: