Deparse "a::]"->[0], etc., correctly
authorFather Chrysostomos <sprout@cpan.org>
Wed, 21 Dec 2011 21:04:42 +0000 (13:04 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 22 Dec 2011 21:31:22 +0000 (13:31 -0800)
The package name should not be omitted when the name begins with punc-
tuation unless the variable is in the main package.

"]"->[0] is force into the main package.
"a::]"->[0] is not.

dist/B-Deparse/Deparse.pm
dist/B-Deparse/t/deparse.t

index 927afd5..b33a407 100644 (file)
@@ -1259,10 +1259,11 @@ Carp::confess() unless ref($gv) eq "B::GV";
     if ($stash eq 'main' && $name =~ /^::/) {
        $stash = '::';
     }
-    elsif (($stash eq 'main' && $globalnames{$name})
+    elsif (($stash eq 'main'
+           && ($globalnames{$name} || $name =~ /^[^A-Za-z_:]/))
        or ($stash eq $self->{'curstash'} && !$globalnames{$name}
            && ($stash eq 'main' || $name !~ /::/))
-       or $name =~ /^[^A-Za-z_:]/)
+         )
     {
        $stash = "";
     } else {
index 780d8b3..3479706 100644 (file)
@@ -908,27 +908,33 @@ no strict 'vars';
 () = '####'->[0];
 () = '^A'->[0];
 () = "\ca"->[0];
+() = 'a::]b'->[0];
 () = 'open'->[$_]; #aelem
 () = '####'->[$_];
 () = '^A'->[$_];
 () = "\ca"->[$_];
+() = 'a::]b'->[$_];
 () = 'open'->{0}; #helem
 () = '####'->{0};
 () = '^A'->{0};
 () = "\ca"->{0};
+() = 'a::]b'->{0};
 >>>>
 () = $open[0];
 () = '####'->[0];
 () = '^A'->[0];
 () = $^A[0];
+() = 'a::]b'->[0];
 () = $open[$_];
 () = '####'->[$_];
 () = '^A'->[$_];
 () = $^A[$_];
+() = 'a::]b'->[$_];
 () = $open{'0'};
 () = '####'->{'0'};
 () = '^A'->{'0'};
 () = $^A{'0'};
+() = 'a::]b'->{'0'};
 ####
 # [perl #74740] -(f()) vs -f()
 $_ = -(f());