From d8c7d8798418b6e39f77dc4f2356b5e28e24cf0b Mon Sep 17 00:00:00 2001 From: Rod Taylor Date: Fri, 10 Jan 2020 16:42:32 -0500 Subject: [PATCH] Pull add_phasers_handling_code up from methodize_block 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 --- src/Perl6/Actions.nqp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Perl6/Actions.nqp b/src/Perl6/Actions.nqp index 312fbd16959..3ed02b4186d 100644 --- a/src/Perl6/Actions.nqp +++ b/src/Perl6/Actions.nqp @@ -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); } @@ -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 } @@ -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(