Perl_croak(aTHX_ "Constant is not %s reference", badtype);
return o;
}
- if ((PL_hints & HINT_STRICT_REFS) && (kid->op_private & OPpCONST_BARE)) {
+ else if ((o->op_type == OP_RV2HV || o->op_type == OP_RV2SV) &&
+ (PL_hints & HINT_STRICT_REFS) && SvPOK(kidsv)) {
+ /* If this is an access to a stash, disable "strict refs", because
+ * stashes aren't auto-vivified at compile-time (unless we store
+ * symbols in them), and we don't want to produce a run-time
+ * stricture error when auto-vivifying the stash. */
+ const char *s = SvPV_nolen(kidsv);
+ const STRLEN l = SvCUR(kidsv);
+ if (l > 1 && s[l-1] == ':' && s[l-2] == ':')
+ o->op_private &= ~HINT_STRICT_REFS;
+ }
+ if ((o->op_private & HINT_STRICT_REFS) && (kid->op_private & OPpCONST_BARE)) {
const char *badthing = Nullch;
switch (o->op_type) {
case OP_RV2SV:
require "./test.pl";
-plan( tests => 9 );
+plan( tests => 11 );
# Used to segfault (bug #15479)
fresh_perl_is(
'',
);
}
+
+# now tests with strictures
+
+use strict;
+ok( !defined %pig::, q(referencing a non-existent stash doesn't produce stricture errors) );
+ok( !exists $pig::{bodine}, q(referencing a non-existent stash element doesn't produce stricture errors) );