diff options
author | Zefram <zefram@fysh.org> | 2017-11-17 09:03:46 +0000 |
---|---|---|
committer | Zefram <zefram@fysh.org> | 2017-11-17 09:13:30 +0000 |
commit | 257296eb9dbe871f5ba95266c9a55fa0feead316 (patch) | |
tree | 47a73ec94fd031c25989b62a20fbccf12a251932 /lib/B/Deparse.t | |
parent | e2091bb6ea87111c32936c9170405a44995be338 (diff) | |
download | perl-257296eb9dbe871f5ba95266c9a55fa0feead316.tar.gz |
restore deparsing style for \&foo
When deparsing a reference to a sub in the current package, other than in
a call expression, with "use strict 'vars'" in effect and no lexical sub
of the same name in scope, commit dd6661605fe0a54c602f2e55f875acfdcd330b79
accidentally changed the deparsing from "&main::foo" to "&foo".
Both deparsings are correct, and the short one arguably preferable.
In fact, the deparsing was originally of the short form, but changed to
the long form (probably accidentally) in Perl 5.21.7, when the deparser
started adding the package to distinguish package subs from lexical subs
of the same name. Nevertheless, it was not the intention to change this
output in that edit, and it broke a CPAN module's tests. Consequently,
this commit restores the long-form deparsing in this case.
Diffstat (limited to 'lib/B/Deparse.t')
-rw-r--r-- | lib/B/Deparse.t | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t index 27d1b3a2c2..f8da6460e8 100644 --- a/lib/B/Deparse.t +++ b/lib/B/Deparse.t @@ -2864,6 +2864,7 @@ print %CORE::foo, %CORE::foo::bar; print $CORE::foo{'a'}, $CORE::foo::bar{'a'}; print &CORE::foo, &CORE::foo::bar; print &CORE::foo(), &CORE::foo::bar(); +print \&CORE::foo, \&CORE::foo::bar; print *CORE::foo, *CORE::foo::bar; print stat CORE::foo::, stat CORE::foo::bar; print CORE::foo:: 1; @@ -2878,6 +2879,7 @@ print %foo, %foo::, %foo::::; print $foo{'a'}, $foo::{'a'}, $foo::::{'a'}; print &foo, &foo::, &foo::::; print &foo(), &foo::(), &foo::::(); +print \&foo, \&foo::, \&foo::::; print *foo, *foo::, *foo::::; print stat Foo, stat Foo::::; print Foo 1; @@ -2891,6 +2893,7 @@ print %CORE, %CORE::, %CORE::::; print $CORE{'a'}, $CORE::{'a'}, $CORE::::{'a'}; print &CORE, &CORE::, &CORE::::; print &CORE(), &CORE::(), &CORE::::(); +print \&CORE, \&CORE::, \&CORE::::; print *CORE, *CORE::, *CORE::::; print stat CORE, stat CORE::::; print CORE 1; @@ -2901,7 +2904,34 @@ print %CORE::foo, %CORE::foo::, %CORE::foo::::; print $CORE::foo{'a'}, $CORE::foo::{'a'}, $CORE::foo::::{'a'}; print &CORE::foo, &CORE::foo::, &CORE::foo::::; print &CORE::foo(), &CORE::foo::(), &CORE::foo::::(); +print \&CORE::foo, \&CORE::foo::, \&CORE::foo::::; print *CORE::foo, *CORE::foo::, *CORE::foo::::; print stat CORE::foo::, stat CORE::foo::::; print CORE::foo:: 1; print CORE::foo:::: 2; +#### +# \&foo +my sub foo { + 1; +} +no strict 'vars'; +print \&main::foo; +print \&{foo}; +print \&bar; +use strict 'vars'; +print \&main::foo; +print \&{foo}; +print \&main::bar; +#### +# exists(&foo) +my sub foo { + 1; +} +no strict 'vars'; +print exists &main::foo; +print exists &{foo}; +print exists &bar; +use strict 'vars'; +print exists &main::foo; +print exists &{foo}; +print exists &main::bar; |