summaryrefslogtreecommitdiffstats
path: root/lib/Package/Stash.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Package/Stash.pm')
-rw-r--r--lib/Package/Stash.pm11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Package/Stash.pm b/lib/Package/Stash.pm
index 88f921e..132f687 100644
--- a/lib/Package/Stash.pm
+++ b/lib/Package/Stash.pm
@@ -204,7 +204,16 @@ sub has_package_symbol {
my $entry_ref = \$namespace->{$name};
if (reftype($entry_ref) eq 'GLOB') {
- return defined *{$entry_ref}{$type};
+ # XXX: assigning to any typeglob slot also initializes the SCALAR slot,
+ # and saying that an undef scalar variable doesn't exist is probably
+ # vaguely less surprising than a scalar variable popping into existence
+ # without anyone defining it
+ if ($type eq 'SCALAR') {
+ return defined ${ *{$entry_ref}{$type} };
+ }
+ else {
+ return defined *{$entry_ref}{$type};
+ }
}
else {
# a symbol table entry can be -1 (stub), string (stub with prototype),