Skip to content
Permalink
Browse files

Don't retain lexicals for contvar lowerings

We retain parameter ones so we can use them in forming errors, but
we needn't do that for variable declarations.
  • Loading branch information...
jnthn committed Nov 1, 2018
1 parent 4202453 commit 2468dea7617e449e665712e45575d15556b0bea8
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/Perl6/Optimizer.nqp
@@ -671,11 +671,14 @@ my class BlockVarOptimizer {
next if $ref'd;

# Seems good; lower it. Note we need to retain a lexical in
# case of binder failover to generate errors. (TODO: only
# retain them for parameters.)
# case of binder failover to generate errors for parameters
# (we don't do this for contvar, which is a decent heuristic
# for "not a parameter").
my $new_name := $qast.unique('__lowered_lex');
$block[0].unshift(QAST::Var.new( :name($qast.name), :scope('lexical'),
:decl('var'), :returns($qast.returns) ));
unless $is_contvar {
$block[0].unshift(QAST::Var.new( :name($qast.name), :scope('lexical'),
:decl('var'), :returns($qast.returns) ));
}
$qast.name($new_name);
$qast.scope('local');
if $is_contvar {

0 comments on commit 2468dea

Please sign in to comment.
You can’t perform that action at this time.