Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid generating symbols for has methods in void context
  • Loading branch information
sorear committed May 23, 2011
1 parent 75a1ba9 commit d39d163
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/NieczaPassBegin.pm6
Expand Up @@ -325,9 +325,11 @@ augment class Op::SubDef { #OK exist
}
push @*opensubs[*-1].augment_hack,
[ $.multiness, @$.bindmethod, $.symbol, $r ];
$!bindlex = True; # need to keep the symbol
} else {
$*unit.deref(@*opensubs[*-1].body_of)\
.add_method($.multiness, |$.bindmethod, $.symbol, $r);
my $in = $*unit.deref(@*opensubs[*-1].body_of);
$in.add_method($.multiness, |$.bindmethod, $.symbol, $r);
$!bindlex = True if $in ~~ ::Metamodel::ParametricRole;
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/NieczaPassSimplifier.pm6
Expand Up @@ -165,6 +165,13 @@ sub do_atpos($body, $nv, $invname, $op) {
return ::Op::Builtin.new(name => 'at_pos', args => $args);
}

sub run_subdef($body, $op, $nv) {
return $op if $op.bindlex || $nv || $op.bindpackages;
$body.delete_lex($op.symbol);
$op.symbol = 'Nil';
$op
}

sub run_optree($body, $op, $nv) {
die "WTF" if !defined $nv;
my @kids := flat($op.ctxzyg($nv));
Expand All @@ -174,6 +181,8 @@ sub run_optree($body, $op, $nv) {
$i = $i + 2;
}

return run_subdef($body,$op,$nv) if $op.^isa(::Op::SubDef);

return $op unless $op.^isa(::Op::CallSub);
my $inv = $op.invocant;
return $op unless $inv.^isa(::Op::Lexical);
Expand Down

0 comments on commit d39d163

Please sign in to comment.