summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-05-21 18:38:46 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-05-21 18:38:46 -0700
commitd1dc589de16981f247132e8e7b3ecaa472913d8a (patch)
tree940ec5f9cc4f2a4e2769f2ce4b3011beb9dc4a63 /dist
parentbdabb2d5e95e614c681c9c1c6a410f5f0096a4f8 (diff)
downloadperl-d1dc589de16981f247132e8e7b3ecaa472913d8a.tar.gz
Fix deparsing of subs named :::: and ::::::
Since a name like :::: is now divided up as ::/:: (since commit 088225f), there can be a package called ‘::’. But %:: returns %main::, not %main::::. The result is that the main package is searched again and again recursively and stash_subs hangs. The easiest fix is to put main:: at the beginning of a substash’s name when fetching the stash.
Diffstat (limited to 'dist')
-rw-r--r--dist/B-Deparse/Deparse.pm2
-rw-r--r--dist/B-Deparse/t/deparse.t12
2 files changed, 13 insertions, 1 deletions
diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm
index 81c918c545..a147ed4487 100644
--- a/dist/B-Deparse/Deparse.pm
+++ b/dist/B-Deparse/Deparse.pm
@@ -481,7 +481,7 @@ sub stash_subs {
else {
$pack =~ s/(::)?$/::/;
no strict 'refs';
- $stash = \%$pack;
+ $stash = \%{"main::$pack"};
}
my %stash = svref_2object($stash)->ARRAY;
while (my ($key, $val) = each %stash) {
diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t
index 5ea240a74b..49487738d9 100644
--- a/dist/B-Deparse/t/deparse.t
+++ b/dist/B-Deparse/t/deparse.t
@@ -170,6 +170,18 @@ eval <<EOFCODE and test($x);
1
EOFCODE
+# Exotic sub declarations
+$a = `$^X $path "-MO=Deparse" -e "sub ::::{}sub ::::::{}" 2>&1`;
+$a =~ s/-e syntax OK\n//g;
+is($a, <<'EOCODG', "sub :::: and sub ::::::");
+sub :::: {
+
+}
+sub :::::: {
+
+}
+EOCODG
+
# [perl #33752]
{
my $code = <<"EOCODE";