summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-11-05 05:45:30 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-05 08:37:14 -0800
commit6b6b21da8e7a4aa561c0b61f5a38769acc035b26 (patch)
treebd54087d40dfc4e0514f2d80e6c7a725b6cd8b40 /lib
parentff48fc9f274e69e433a1c3957a5a38a84acebf2c (diff)
downloadperl-6b6b21da8e7a4aa561c0b61f5a38769acc035b26.tar.gz
Deparse +sub :attr{} correctly at stmt start
Diffstat (limited to 'lib')
-rw-r--r--lib/B/Deparse.pm4
-rw-r--r--lib/B/Deparse.t4
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm
index 009ed31e1f..adfd9f3251 100644
--- a/lib/B/Deparse.pm
+++ b/lib/B/Deparse.pm
@@ -1439,7 +1439,9 @@ sub walk_lineseq {
$i += $kids[$i]->sibling->name eq "unstack" ? 2 : 1);
next;
}
- $expr .= $self->deparse($kids[$i], (@kids != 1)/2);
+ my $expr2 = $self->deparse($kids[$i], (@kids != 1)/2);
+ $expr2 =~ s/^sub :/+sub :/; # statement label otherwise
+ $expr .= $expr2;
$expr =~ s/;\n?\z//;
$callback->($expr, $i);
}
diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t
index a2065292f7..cd3b828195 100644
--- a/lib/B/Deparse.t
+++ b/lib/B/Deparse.t
@@ -377,6 +377,10 @@ $test /= 2 if ++$test;
;
}
####
+# anonsub attrs at statement start
+my $x = do { +sub : lvalue { my $y; } };
+my $z = do { foo: +sub : method { my $a; } };
+####
# block with continue
{
234;