diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-08-27 11:15:51 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-08-27 11:23:24 -0500 |
commit | f8e7797c12671e47664c32b6c00b5ee4c8993504 (patch) | |
tree | ccf7d4177cd3d6db35e95f7810ca3c722e1ad5a0 /lib | |
parent | 0a5166afdae1044a3722b5d241ecdc3228dbd370 (diff) | |
download | package-stash-f8e7797c12671e47664c32b6c00b5ee4c8993504.tar.gz package-stash-f8e7797c12671e47664c32b6c00b5ee4c8993504.zip |
make the ISA special-casing more sane
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Package/Stash.pm | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/Package/Stash.pm b/lib/Package/Stash.pm index 32e5d30..b990f55 100644 --- a/lib/Package/Stash.pm +++ b/lib/Package/Stash.pm @@ -229,17 +229,16 @@ sub get_package_symbol { my $namespace = $self->namespace; - if (!exists $namespace->{$name}) { - # assigning to the result of this function like - # @{$stash->get_package_symbol('@ISA')} = @new_ISA - # makes the result not visible until the variable is explicitly - # accessed... in the case of @ISA, this might never happen - # for instance, assigning like that and then calling $obj->isa - # will fail. see t/005-isa.t - if ($opts{vivify} && $type eq 'ARRAY' && $name ne 'ISA') { - $self->add_package_symbol($variable, []); + if ($opts{vivify} && !exists $namespace->{$name}) { + if ($type eq 'ARRAY') { + $self->add_package_symbol( + $variable, + # setting our own arrayref manually loses the magicalness or + # something + $name eq 'ISA' ? () : ([]) + ); } - elsif ($opts{vivify} && $type eq 'HASH') { + elsif ($type eq 'HASH') { $self->add_package_symbol($variable, {}); } else { |