summaryrefslogtreecommitdiff
path: root/dist/B-Deparse
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-06-02 06:01:57 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-06-02 06:05:29 -0700
commit35a99a0826369f896a38d2665db827253fc91e46 (patch)
treea0573a6fd2536b1d022e7e24a1a3543a8fa1093a /dist/B-Deparse
parentb6093575f53d6714dc73dfa7d80b20c008a890bf (diff)
downloadperl-35a99a0826369f896a38d2665db827253fc91e46.tar.gz
Deparse $obj->$meth=... [perl #62498]
When an lvalue method-as-variable is compiled, the method op has a sibling that is an rv2cv: a <2> sassign vKS/2 ->b 3 <$> const[IV 1] s ->4 9 <1> entersub[t3] sKRMS*/NO(),TARG ->a 4 <0> pushmark s ->5 - <1> ex-rv2sv sKM/1 ->6 5 <#> gvsv[*obj] s ->6 7 <1> method sK/1 ->8 - <1> ex-rv2sv sK/1 ->7 6 <#> gvsv[*meth] s ->7 8 <1> rv2cv /NO() ->9 Deparse didn’t know about it, and was iterating through the children of entersub, thinking the last one was the method, stopping at any item named ‘method_named’. So I modified it to stop at ‘method’ as well.
Diffstat (limited to 'dist/B-Deparse')
-rw-r--r--dist/B-Deparse/Deparse.pm2
-rw-r--r--dist/B-Deparse/t/deparse.t1
2 files changed, 2 insertions, 1 deletions
diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm
index 335b3c0a78..e3079ad20b 100644
--- a/dist/B-Deparse/Deparse.pm
+++ b/dist/B-Deparse/Deparse.pm
@@ -3222,7 +3222,7 @@ sub _method {
} else {
$obj = $kid;
$kid = $kid->sibling;
- for (; !null ($kid->sibling) && $kid->name ne "method_named";
+ for (; !null ($kid->sibling) && $kid->name!~/^method(?:_named)?\z/;
$kid = $kid->sibling) {
push @exprs, $kid
}
diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t
index b1bd1e277f..cb0faadd28 100644
--- a/dist/B-Deparse/t/deparse.t
+++ b/dist/B-Deparse/t/deparse.t
@@ -392,6 +392,7 @@ my $f = sub {
# variables as method names
my $bar;
'Foo'->$bar('orz');
+'Foo'->$bar('orz') = 'a stranger stranger than before';
####
# constants as method names
'Foo'->bar('orz');