From: Jesse Luehrs Date: Wed, 27 Oct 2010 18:13:40 +0000 (-0500) Subject: actually, only do the weird special casing on broken perl versions X-Git-Tag: 0.10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Ftags%2F0.10;p=gitmo%2FPackage-Stash-XS.git actually, only do the weird special casing on broken perl versions --- diff --git a/Changes b/Changes index 91069cc..fb7b9ec 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for Package-Stash {{$NEXT}} + - only do the weird ISA special-casing on perl versions where it's broken 0.09 2010-10-27 - clean up the vivication code a lot, make it behave more sanely diff --git a/lib/Package/Stash.pm b/lib/Package/Stash.pm index f708bbc..6c361c1 100644 --- a/lib/Package/Stash.pm +++ b/lib/Package/Stash.pm @@ -6,6 +6,9 @@ use warnings; use Carp qw(confess); use Scalar::Util qw(reftype); use Symbol; +# before 5.12, assigning to the ISA glob would make it lose its magical ->isa +# powers +use constant BROKEN_ISA_ASSIGNMENT => ($] < 5.012); =head1 SYNOPSIS @@ -233,12 +236,15 @@ sub get_package_symbol { if (!exists $namespace->{$name}) { if ($opts{vivify}) { if ($type eq 'ARRAY') { - $self->add_package_symbol( - $variable, - # setting our own arrayref manually loses the magicalness - # or something - $name eq 'ISA' ? () : ([]) - ); + if (BROKEN_ISA_ASSIGNMENT) { + $self->add_package_symbol( + $variable, + $name eq 'ISA' ? () : ([]) + ); + } + else { + $self->add_package_symbol($variable, []); + } } elsif ($type eq 'HASH') { $self->add_package_symbol($variable, {});