From: Jesse Luehrs Date: Wed, 12 May 2010 05:23:13 +0000 (-0500) Subject: always save and restore scalars, since has_package_symbol isn't reliable X-Git-Tag: 0.01~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=42fa5cfc8a6f9bac3780011ad11896bc107ed47c;p=gitmo%2FPackage-Stash-XS.git always save and restore scalars, since has_package_symbol isn't reliable it returns false even if a scalar has been declared but not initialized yet, which is inconsistent with how has_package_symbol works for all other types, but I think it's unavoidable --- diff --git a/lib/Stash/Manip.pm b/lib/Stash/Manip.pm index 40e9567..3055d1d 100644 --- a/lib/Stash/Manip.pm +++ b/lib/Stash/Manip.pm @@ -263,25 +263,25 @@ sub remove_package_symbol { $io = $self->get_package_symbol($io_desc) if $self->has_package_symbol($io_desc); } elsif ($type eq 'ARRAY') { - $scalar = $self->get_package_symbol($scalar_desc) if $self->has_package_symbol($scalar_desc); + $scalar = $self->get_package_symbol($scalar_desc); $hash = $self->get_package_symbol($hash_desc) if $self->has_package_symbol($hash_desc); $code = $self->get_package_symbol($code_desc) if $self->has_package_symbol($code_desc); $io = $self->get_package_symbol($io_desc) if $self->has_package_symbol($io_desc); } elsif ($type eq 'HASH') { - $scalar = $self->get_package_symbol($scalar_desc) if $self->has_package_symbol($scalar_desc); + $scalar = $self->get_package_symbol($scalar_desc); $array = $self->get_package_symbol($array_desc) if $self->has_package_symbol($array_desc); $code = $self->get_package_symbol($code_desc) if $self->has_package_symbol($code_desc); $io = $self->get_package_symbol($io_desc) if $self->has_package_symbol($io_desc); } elsif ($type eq 'CODE') { - $scalar = $self->get_package_symbol($scalar_desc) if $self->has_package_symbol($scalar_desc); + $scalar = $self->get_package_symbol($scalar_desc); $array = $self->get_package_symbol($array_desc) if $self->has_package_symbol($array_desc); $hash = $self->get_package_symbol($hash_desc) if $self->has_package_symbol($hash_desc); $io = $self->get_package_symbol($io_desc) if $self->has_package_symbol($io_desc); } elsif ($type eq 'IO') { - $scalar = $self->get_package_symbol($scalar_desc) if $self->has_package_symbol($scalar_desc); + $scalar = $self->get_package_symbol($scalar_desc); $array = $self->get_package_symbol($array_desc) if $self->has_package_symbol($array_desc); $hash = $self->get_package_symbol($hash_desc) if $self->has_package_symbol($hash_desc); $code = $self->get_package_symbol($code_desc) if $self->has_package_symbol($code_desc); @@ -292,7 +292,7 @@ sub remove_package_symbol { $self->remove_package_glob($name); - $self->add_package_symbol($scalar_desc => $scalar) if defined $scalar; + $self->add_package_symbol($scalar_desc => $scalar); $self->add_package_symbol($array_desc => $array) if defined $array; $self->add_package_symbol($hash_desc => $hash) if defined $hash; $self->add_package_symbol($code_desc => $code) if defined $code;