Skip to content

Commit

Permalink
Fix spurious warnings in try thunks inside blocks
Browse files Browse the repository at this point in the history
Fixes RT#131331: https://rt.perl.org/Ticket/Display.html?id=131331
Fixes RT#131123: https://rt.perl.org/Ticket/Display.html?id=131123

When we got a thunky `try` in a block, the QAST chain we make
contains `nqp::handle` op inside a QAST::Want, but ::Want doesn't
know how to propagate wantedness through handle ops. Fix by adding that.
  • Loading branch information
zoffixznet committed Jan 13, 2018
1 parent 2805b15 commit ef2dc1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Perl6/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ sub wanted($ast,$by) {
$node.annotate('past_block', WANTED($node.ann('past_block'), $byby));
}
}
elsif $node.op eq 'call' {
elsif $node.op eq 'call' || $node.op eq 'handle' {
$ast[0] := WANTED($node,$byby);
}
elsif $node.op eq 'callstatic' || $node.op eq 'hllize' {
Expand Down
7 changes: 6 additions & 1 deletion t/05-messages/10-warnings.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use lib <t/packages/>;
use Test;
use Test::Helpers;

plan 5;
plan 6;

subtest 'Supply.interval with negative value warns' => {
plan 2;
Expand Down Expand Up @@ -71,4 +71,9 @@ is-run 「
is-run my $a; $a [R~]= "b"; $a [Z~]= "b"; $a [X~]= "b",
'metaops + metaassign op do not produce spurious warnings';

# RT # 131331
# RT # 131123
is-run my $ = ^2 .grep: {try 1 after 0}; my $ = {try 5 == 5}(),
'no spurious warnings with `try` thunks in blocks';

# vim: ft=perl6 expandtab sw=4

0 comments on commit ef2dc1b

Please sign in to comment.