Permalink
Browse files

Avoid generating symbols for has methods in void context

  • Loading branch information...
1 parent 75a1ba9 commit d39d163a3ce43ce01c1fe1884dffecf9a540eef1 @sorear committed May 23, 2011
Showing with 13 additions and 2 deletions.
  1. +4 −2 src/NieczaPassBegin.pm6
  2. +9 −0 src/NieczaPassSimplifier.pm6
View
@@ -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;
}
}
@@ -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));
@@ -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);

0 comments on commit d39d163

Please sign in to comment.