We only create our hints as UVs, but we may still be getting non-numeric SVs
if e.g. the autovivification introduction was generated from B::Deparse.
This fixes RT #55154.
t/32-array-kv.t
t/40-scope.t
t/41-padsv.t
+t/42-deparse.t
t/91-pod.t
t/92-pod-coverage.t
t/95-portability-files.t
#else /* A_WORKAROUND_REQUIRE_PROPAGATION */
#define a_tag(B) newSVuv(B)
-#define a_detag(H) (((H) && SvOK(H)) ? SvUVX(H) : 0)
+/* PVs fetched from the hints chain have their SvLEN set to zero, so get the UV
+ * from a copy. */
+#define a_detag(H) \
+ ((H) \
+ ? (SvIOK(H) \
+ ? SvUVX(H) \
+ : (SvPOK(H) \
+ ? sv_2uv(SvLEN(H) ? (H) : sv_mortalcopy(H)) \
+ : 0 \
+ ) \
+ ) \
+ : 0)
#endif /* !A_WORKAROUND_REQUIRE_PROPAGATION */
--- /dev/null
+#!perl -T
+
+use strict;
+use warnings;
+
+use Test::More;
+
+if (eval 'use B::Deparse; 1') {
+ plan tests => 2;
+} else {
+ plan skip_all => 'B::Deparse is not available';
+}
+
+my $bd = B::Deparse->new;
+
+{
+ no autovivification qw/fetch strict/;
+
+ sub blech { my $key = $_[0]->{key} }
+}
+
+{
+ my $undef;
+ eval 'blech($undef)';
+ like $@, qr/Reference vivification forbidden/, 'Original blech() works';
+}
+
+{
+ my $code = $bd->coderef2text(\&blech);
+ my $undef;
+ eval "$code; blech(\$undef)";
+ like $@, qr/Reference vivification forbidden/, 'Deparsed blech() works';
+}