summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-05-21 18:38:46 -0700
committerSteffen Mueller <smueller@cpan.org>2011-05-30 22:24:58 +0200
commitfcf32eda80ff91eee19319334969e0c43288555d (patch)
tree3de64db5b2b7593d2a64b9b042cb810b0e164d8d /dist
parent2f77d7b3086360947b6ef3e789059efc6996ea60 (diff)
downloadperl-fcf32eda80ff91eee19319334969e0c43288555d.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 3f3c1e8204..f3c304f826 100644
--- a/dist/B-Deparse/Deparse.pm
+++ b/dist/B-Deparse/Deparse.pm
@@ -480,7 +480,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 c3301a50db..8138ecd7cf 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";