[Bps-public-commit] Symbol-Global-Name branch, master, updated. 0.04-1-gf8b706e
Alex Vandiver
alexmv at bestpractical.com
Thu Feb 13 15:41:26 EST 2014
The branch, master has been updated
via f8b706e2825280375378d530c083f7de30d42905 (commit)
from 1b8a6dbc41509b839a2588a1b77cc1edd5e42771 (commit)
Summary of changes:
lib/Symbol/Global/Name.pm | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit f8b706e2825280375378d530c083f7de30d42905
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Feb 12 18:53:49 2014 -0500
Avoid errors on inlined constant lists, used in 5.19.3 and up
Perl 5.19.3 (as of 15635cbf in perl.git) inlines list constants; that
is:
use constant FOO => qw(bar baz);
...stores an array reference in the symbol table instead of a GLOB, so
long as there is no $FOO, @FOO, or so forth in the package as well.
This is not entirely new; perl 5.10.0 began inlining scalar values,
which led to aaf2bb34, followed shortly by 3d835f0d.
Inlined arrays appearing in the symbol table bypasses the existing ref()
check, and causes the following error:
Not a GLOB reference at lib/Symbol/Global/Name.pm line 109.
The only case in which we can later de-reference $entry as a GLOB using
*{$entry} is if it _is_ a GLOB; GLOBs have ref($entry) eq '', which
makes them easy to distinguish from inlined constants, which are all
references of some form. Rather than continue adding to the
laundry-list blacklist of ref types, simply skip _all_ non-globs found
in the symbol table.
diff --git a/lib/Symbol/Global/Name.pm b/lib/Symbol/Global/Name.pm
index 0f2d669..b336f35 100644
--- a/lib/Symbol/Global/Name.pm
+++ b/lib/Symbol/Global/Name.pm
@@ -94,12 +94,14 @@ sub _find {
my $entry = ${$pack}{$k};
next unless $entry;
- # get entry for type we are looking for
-
- # XXX skip references to scalars or other references.
- # Otherwise 5.10 goes boom. maybe we should skip any
- # reference
- next if ref($entry) eq 'SCALAR' || ref($entry) eq 'REF';
+ # Inlined constants are simplified in the symbol table --
+ # namely, when possible, you only get a reference back in
+ # $entry, rather than a full GLOB. In 5.10, scalar
+ # constants began being inlined this way; starting in 5.20,
+ # list constants are also inlined. Notably, ref(GLOB) is
+ # undef, but inlined constants are currently either REF,
+ # SCALAR, or ARRAY.
+ next if ref($entry);
my $ref_type = ref($ref);
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list