Skip to content

Commit

Permalink
Make all cases of statementlist loop eval to Nil
Browse files Browse the repository at this point in the history
Previously, `loop { }` and `loop (; $++ < 3;) { }` would evaluate to
Nil, but `loop (my $i = 0; $i < 3; $i++) { }` would evaluate to an
`nqp::null` due to the oversight that is corrected in this commit. This
bug was made more visible when recent changes to return handling removed
the `nqp::null` mapping into Mu, resulting in the problem observed in
issue #2069. Since all other loop cases evaluated to Nil, this created a
discontinuity where one particular case of `loop` would instead evaluate
to Mu. Therefore, there was already a bug; the recent changes just made
it problematic in more cases.
  • Loading branch information
jnthn committed Jul 15, 2018
1 parent 1ad3432 commit aff96ba
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Perl6/Actions.nqp
Expand Up @@ -2227,7 +2227,12 @@ class Perl6::Actions is HLL::Actions does STDActions {
$loop := QAST::Stmts.new( UNWANTED($<e1>.ast, 'statement_control/e1'), $loop, :node($/) );
}
my $sinkee := $loop[1];
$loop.annotate('statement_level', -> { UNWANTED($sinkee,'force loop') });
$loop.annotate('statement_level', -> {
UNWANTED($sinkee,'force loop');
if $<e1> {
$loop.push(QAST::WVal.new( :value($*W.find_symbol(['Nil'])) ));
}
});
make $loop;
}

Expand Down

0 comments on commit aff96ba

Please sign in to comment.