From: Jesse Luehrs Date: Tue, 16 Nov 2010 11:16:44 +0000 (-0600) Subject: fix another edge case X-Git-Tag: 0.15~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4723417a0e4c38ba9bf00a95d70e6872535c4d4c;p=gitmo%2FPackage-Stash.git fix another edge case --- diff --git a/lib/Package/Stash/PP.pm b/lib/Package/Stash/PP.pm index 446642b..55dfddd 100644 --- a/lib/Package/Stash/PP.pm +++ b/lib/Package/Stash/PP.pm @@ -196,13 +196,7 @@ sub get_symbol { } } else { - if ($type eq 'CODE') { - # this effectively "de-vivifies" the code slot. if we don't do - # this, referencing the coderef at the end of this function - # will cause perl to auto-vivify a stub coderef in the slot, - # which isn't what we want - $self->add_symbol($variable); - } + return undef; } } diff --git a/t/07-edge-cases.t b/t/07-edge-cases.t index feec31e..cf75847 100755 --- a/t/07-edge-cases.t +++ b/t/07-edge-cases.t @@ -47,4 +47,9 @@ ok($stash->has_symbol('%added'), '%added'); my $constant = $stash->get_symbol('&FOO'); is(ref($constant), 'CODE', "expanded a constant into a coderef"); +# ensure get doesn't prevent subsequent vivification (not sure what the deal +# was here) +is(ref($stash->get_symbol('$glob')), '', "nothing yet"); +is(ref($stash->get_or_add_symbol('$glob')), 'SCALAR', "got an empty scalar"); + done_testing;