From: Jesse Luehrs Date: Thu, 6 Jan 2011 05:05:37 +0000 (-0600) Subject: fix another edge case with initial values X-Git-Tag: 0.19~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=57011a68cc3bc9ed5443e3089fe73d46fa38a779;p=gitmo%2FPackage-Stash-XS.git fix another edge case with initial values --- diff --git a/XS.xs b/XS.xs index a32ca45..b0519de 100644 --- a/XS.xs +++ b/XS.xs @@ -213,6 +213,10 @@ int _valid_for_type(SV *value, vartype_t type) switch (type) { case VAR_SCALAR: + /* XXX: something weird is going on here - apparently values can + * be SVt_NULL but also be SvROK (and also, SVt_NULL isn't SvOK) */ + if (sv_type == SVt_NULL) + return 1; return SvROK(value) ? SvOK(SvRV(value)) : SvOK(value); case VAR_ARRAY: return sv_type == SVt_PVAV; diff --git a/t/07-edge-cases.t b/t/07-edge-cases.t index 02e281b..4f61ca2 100755 --- a/t/07-edge-cases.t +++ b/t/07-edge-cases.t @@ -64,4 +64,6 @@ is(exception { $Bar->add_symbol('$foo', \$foo) }, undef, is(exception { $Bar->add_symbol('$bar', \$bar) }, undef, "can add PVNV values"); +use_ok('CompileTime'); + done_testing; diff --git a/t/lib/CompileTime.pm b/t/lib/CompileTime.pm new file mode 100644 index 0000000..925bc18 --- /dev/null +++ b/t/lib/CompileTime.pm @@ -0,0 +1,15 @@ +package CompileTime; +use strict; +use warnings; + +use Package::Stash; + +our $foo = 23; + +BEGIN { + my $stash = Package::Stash->new(__PACKAGE__); + $stash->add_symbol('$bar', $foo); + $stash->add_symbol('$baz', $stash->get_symbol('$foo')); +} + +1;