Since we no longer autovivify stashes (change #26370), we need
[p5sagit/p5-mst-13.2.git] / op.c
diff --git a/op.c b/op.c
index fde4f9e..8f8cb02 100644 (file)
--- a/op.c
+++ b/op.c
@@ -5408,7 +5408,18 @@ Perl_ck_rvconst(pTHX_ register OP *o)
                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: