summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-01-05 23:05:37 -0600
committerJesse Luehrs <doy@tozt.net>2011-01-05 23:05:37 -0600
commit57011a68cc3bc9ed5443e3089fe73d46fa38a779 (patch)
tree00c1fb5b7bdbbc5bc79f1c3c89cdd855d3f1f1dc
parentfbef4983066edbde84d915b4968e65b0efb59534 (diff)
downloadpackage-stash-xs-57011a68cc3bc9ed5443e3089fe73d46fa38a779.tar.gz
package-stash-xs-57011a68cc3bc9ed5443e3089fe73d46fa38a779.zip
fix another edge case with initial values
-rw-r--r--XS.xs4
-rwxr-xr-xt/07-edge-cases.t2
-rw-r--r--t/lib/CompileTime.pm15
3 files changed, 21 insertions, 0 deletions
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;