summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-01-02 15:19:59 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-01-02 15:19:59 +0000
commitce10b5d1ec5b5f68b0811018a415bc37bb6bfe5e (patch)
tree8fcfaa5786d83e361d7f05ef1cca6f1770fb0014 /op.c
parentd05e821b371c26b65a55f4dc84c58ab20a15d923 (diff)
downloadperl-ce10b5d1ec5b5f68b0811018a415bc37bb6bfe5e.tar.gz
Since we no longer autovivify stashes (change #26370), we need
to turn off strict-refs on them, or we'll have a stricture error the first time we'd try to access them (when they'll be actually autovivified). p4raw-link: @26370 on //depot/perl: adc51b978ed1b2e9d4512c9bfa80386ac917d05a p4raw-id: //depot/perl@26574
Diffstat (limited to 'op.c')
-rw-r--r--op.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/op.c b/op.c
index fde4f9e27f..8f8cb02cc2 100644
--- 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: