Skip to content

Commit

Permalink
Pull add_phasers_handling_code up from methodize_block
Browse files Browse the repository at this point in the history
This prevents it from being called twice for method_def and solves the below trouble code:

class A {
    method f() {
        ENTER say "foo";
    }
}
A.f;   # foo foo

Thanks to Elizabeth Mattijsen for pointing me at the problem code.

Closes #3411
  • Loading branch information
rbt committed Jan 10, 2020
1 parent 3e332a1 commit d8c7d87
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Perl6/Actions.nqp
Expand Up @@ -3913,6 +3913,8 @@ class Perl6::Actions is HLL::Actions does STDActions {
:method, :$invocant_type);
my $code := methodize_block($/, $*W.stub_code_object('Method'),
$a_past, $signature, %sig_info);
$*W.add_phasers_handling_code($code, $a_past);

install_method($/, $meth_name, 'has', $code, $install_in, :gen-accessor);
}

Expand Down Expand Up @@ -4629,7 +4631,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
# Finish up code object.
$*W.attach_signature($code, $signature);
$*W.finish_code_object($code, $past, $*MULTINESS eq 'proto', :yada($yada));
$*W.add_phasers_handling_code($code, $past);

$code
}

Expand Down Expand Up @@ -4831,6 +4833,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
my $signature := $*W.create_signature_and_params($/, %sig_info, $past, 'Any',
:method, :$invocant_type);
methodize_block($/, $code, $past, $signature, %sig_info);
$*W.add_phasers_handling_code($code, $past);

# Need to put self into a register for the regex engine.
$past[0].push(QAST::Op.new(
Expand Down

0 comments on commit d8c7d87

Please sign in to comment.