Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

nqp-rx fix for contextuals

View gist:1013096

In NQP, all variables get declared at the beginning of the block. This makes the following code fail:

my $old  := $*VAR;
my $*VAR := $new;

Instead of the old (outer) value of the contextual $*VAR, $old contains Undef. The following one line fix to nqp-rx seems to solve this problem by making NQP declare variables at the same point in the generated PIR as they are in the NQP code.

View gist:1013096
1 2 3 4 5 6 7 8 9 10 11 12 13
diff --git i/src/NQP/Actions.pm w/src/NQP/Actions.pm
index d7c7602..2aba92a 100644
--- i/src/NQP/Actions.pm
+++ w/src/NQP/Actions.pm
@@ -438,7 +438,7 @@ method variable_declarator($/) {
:lvalue(1), :viviself( vivitype($sigil) ),
:node($/) );
$BLOCK.symbol($name, :scope($scope) );
- $BLOCK[0].push($decl);
+ $BLOCK.push($decl);
}
make $past;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.