Skip to content

Commit

Permalink
Avoid using a PAST::Var register node as the result of a smart-match,…
Browse files Browse the repository at this point in the history
… since it ends up with the code-gen wrong if we use a PAST::Stmts to hold them. This avoids issues that the block trick introduced.
  • Loading branch information
jnthn committed Jul 25, 2010
1 parent e991c43 commit b46a3b3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Perl6/Actions.pm
Expand Up @@ -2300,11 +2300,8 @@ sub make_smartmatch($/) {
my $rhs := $/[1].ast;
my $old_topic_var := $lhs.unique('old_topic');
my $result_var := $lhs.unique('sm_result');
# XXX I'd be nice to emit a PAST::Stmts here, but sadly that causes the
# code-gen to go horribly awry in things like 42 && 42 ~~ 42 (e.g. when
# we have if and unless chains), so for now it's PAST::Block.
PAST::Block.new(
:blocktype('immediate'),
PAST::Op.new(
:pasttype('stmts'),

# Stash original $_.
PAST::Op.new( :pasttype('bind'),
Expand All @@ -2321,7 +2318,7 @@ sub make_smartmatch($/) {
# Evaluate RHS and call ACCEPTS on it, passing in $_. Bind the
# return value to a result variable.
PAST::Op.new( :pasttype('bind'),
PAST::Var.new( :name($result_var), :scope('register'), :isdecl(1) ),
PAST::Var.new( :name($result_var), :scope('lexical'), :isdecl(1) ),
PAST::Op.new( :pasttype('callmethod'), :name('ACCEPTS'),
$rhs,
PAST::Var.new( :name('$_'), :scope('lexical') )
Expand All @@ -2335,7 +2332,7 @@ sub make_smartmatch($/) {
),

# And finally evaluate to the smart-match result.
PAST::Var.new( :name($result_var), :scope('register') )
PAST::Var.new( :name($result_var), :scope('lexical') )
);
}

Expand Down

0 comments on commit b46a3b3

Please sign in to comment.