Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - js - fix context propagation in if()
  • Loading branch information
fglock committed Nov 1, 2014
1 parent 19efcc6 commit 2aa46bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion perlito5.pl
Expand Up @@ -10447,7 +10447,7 @@ package Perlito5::AST::If;
if (keys(%{$Perlito5::VAR->[0]})) {
$level = $old_level;
shift(@{$Perlito5::VAR});
return Perlito5::Javascript2::emit_wrap_javascript2($level, $wantarray, join(chr(10) . Perlito5::Javascript2::tab($level + 1), @str))
return ($wantarray eq 'runtime' ? 'return ' : '') . Perlito5::Javascript2::emit_wrap_javascript2($level, $wantarray, join(chr(10) . Perlito5::Javascript2::tab($level + 1), @str))
}
else {
shift(@{$Perlito5::VAR});
Expand Down
10 changes: 8 additions & 2 deletions src5/lib/Perlito5/Javascript2/Emitter.pm
Expand Up @@ -2952,8 +2952,14 @@ package Perlito5::AST::If;
$level = $old_level;
shift @{ $Perlito5::VAR }; # exit scope of the 'cond' variables
# create js scope for 'my' variables
return Perlito5::Javascript2::emit_wrap_javascript2($level, $wantarray,
join( "\n" . Perlito5::Javascript2::tab($level+1), @str ) );
return
( $wantarray eq 'runtime'
? "return "
: ""
)
. Perlito5::Javascript2::emit_wrap_javascript2($level, $wantarray,
join( "\n" . Perlito5::Javascript2::tab($level+1), @str )
);
}
else {
shift @{ $Perlito5::VAR }; # exit scope of the 'cond' variables
Expand Down

0 comments on commit 2aa46bf

Please sign in to comment.