From 98517ccb8d5e8751980561f66bf6a58aca163de1 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Fri, 5 Nov 2010 11:28:12 +0000 Subject: [PATCH] B::Concise was failing to traverse some children of PMOPs Notably the substcont of s/// was being missed. The bug was introduced as part of c0939ceec1b3e902, "Re: [patch] teach B::Concise to see XS code", which did rather more than it said on the tin. --- ext/B/B/Concise.pm | 4 ++-- ext/B/t/optree_misc.t | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ext/B/B/Concise.pm b/ext/B/B/Concise.pm index 27668f5..6d06956 100644 --- a/ext/B/B/Concise.pm +++ b/ext/B/B/Concise.pm @@ -14,7 +14,7 @@ use warnings; # uses #3 and #4, since warnings uses Carp use Exporter (); # use #5 -our $VERSION = "0.80"; +our $VERSION = "0.81"; our @ISA = qw(Exporter); our @EXPORT_OK = qw( set_style set_style_standard add_callback concise_subref concise_cv concise_main @@ -462,7 +462,7 @@ sub walk_topdown { walk_topdown($kid, $sub, $level + 1); } } - elsif (class($op) eq "PMOP") { + if (class($op) eq "PMOP") { my $maybe_root = $op->pmreplroot; if (ref($maybe_root) and $maybe_root->isa("B::OP")) { # It really is the root of the replacement, not something diff --git a/ext/B/t/optree_misc.t b/ext/B/t/optree_misc.t index 7a8f25a..c5d4e2e 100644 --- a/ext/B/t/optree_misc.t +++ b/ext/B/t/optree_misc.t @@ -10,7 +10,7 @@ BEGIN { } use OptreeCheck; use Config; -plan tests => 2; +plan tests => 3; SKIP: { skip "no perlio in this build", 1 unless $Config::Config{useperlio}; @@ -98,5 +98,29 @@ checkOptree ( name => 'index and PVBM', strip_open_hints => 1, expect => $t, expect_nt => $nt); -__END__ +checkOptree ( name => 'PMOP children', + code => sub { $foo =~ s/(a)/$1/ }, + strip_open_hints => 1, + expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); +# 6 <1> leavesub[1 ref] K/REFC,1 ->(end) +# - <@> lineseq KP ->6 +# 1 <;> nextstate(main 1 -e:1) v:{ ->2 +# 3 subst(/"(a)"/ replstart->4) KS ->6 +# - <1> ex-rv2sv sKRM/1 ->3 +# 2 <#> gvsv[*foo] s ->3 +# 5 <|> substcont(other->3) sK/1 ->(end) +# - <1> ex-rv2sv sK/1 ->5 +# 4 <#> gvsv[*1] s ->5 +EOT_EOT +# 6 <1> leavesub[1 ref] K/REFC,1 ->(end) +# - <@> lineseq KP ->6 +# 1 <;> nextstate(main 1 -e:1) v:{ ->2 +# 3 subst(/"(a)"/ replstart->4) KS ->6 +# - <1> ex-rv2sv sKRM/1 ->3 +# 2 <$> gvsv(*foo) s ->3 +# 5 <|> substcont(other->3) sK/1 ->(end) +# - <1> ex-rv2sv sK/1 ->5 +# 4 <$> gvsv(*1) s ->5 +EONT_EONT +__END__ -- 1.8.3.1