From: Nicholas Clark Date: Sat, 20 Jan 2007 23:40:23 +0000 (+0000) Subject: defined @$foo and defined %$bar should be subject to strict 'refs'; X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d9f30342f9de4793189d81b85a5e32057393e428;p=p5sagit%2Fp5-mst-13.2.git defined @$foo and defined %$bar should be subject to strict 'refs'; p4raw-id: //depot/perl@29900 --- diff --git a/lib/DBM_Filter.pm b/lib/DBM_Filter.pm index 7385ddd..8947c0c 100644 --- a/lib/DBM_Filter.pm +++ b/lib/DBM_Filter.pm @@ -2,7 +2,7 @@ package DBM_Filter ; use strict; use warnings; -our $VERSION = '0.01'; +our $VERSION = '0.02'; package Tie::Hash ; @@ -91,6 +91,7 @@ sub _do_Filter_Push # if $class already contains "::", don't prefix "DBM_Filter::" $class = "DBM_Filter::$class" unless $class =~ /::/; + no strict 'refs'; # does the "DBM_Filter::$class" exist? if ( ! defined %{ "${class}::"} ) { # Nope, so try to load it. @@ -98,7 +99,6 @@ sub _do_Filter_Push croak "$caller: Cannot Load DBM Filter '$class': $@" if $@; } - no strict 'refs'; my $fetch = *{ "${class}::Fetch" }{CODE}; my $store = *{ "${class}::Store" }{CODE}; my $filter = *{ "${class}::Filter" }{CODE}; diff --git a/pp_hot.c b/pp_hot.c index 5dd8104..821f3b1 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -836,9 +836,15 @@ PP(pp_rv2av) if (SvROK(sv)) goto wasref; } + if (PL_op->op_private & HINT_STRICT_REFS) { + if (SvOK(sv)) + DIE(aTHX_ PL_no_symref_sv, sv, + is_pp_rv2av ? an_array : a_hash); + else + DIE(aTHX_ PL_no_usym, is_pp_rv2av ? an_array : a_hash); + } if (!SvOK(sv)) { - if (PL_op->op_flags & OPf_REF || - PL_op->op_private & HINT_STRICT_REFS) + if (PL_op->op_flags & OPf_REF) DIE(aTHX_ PL_no_usym, is_pp_rv2av ? an_array : a_hash); if (ckWARN(WARN_UNINITIALIZED)) report_uninit(sv); @@ -860,9 +866,6 @@ PP(pp_rv2av) } } else { - if (PL_op->op_private & HINT_STRICT_REFS) - DIE(aTHX_ PL_no_symref_sv, sv, - is_pp_rv2av ? an_array : a_hash); gv = (GV*)gv_fetchsv(sv, GV_ADD, type); } } diff --git a/t/lib/strict/refs b/t/lib/strict/refs index dee95e8..6237d6d 100644 --- a/t/lib/strict/refs +++ b/t/lib/strict/refs @@ -308,3 +308,17 @@ my $x = "foo"; defined $$x; EXPECT Can't use string ("foo") as a SCALAR ref while "strict refs" in use at - line 4. +######## +# [perl #37886] strict 'refs' doesn't apply inside defined +use strict 'refs'; +my $x = "foo"; +defined @$x; +EXPECT +Can't use string ("foo") as an ARRAY ref while "strict refs" in use at - line 4. +######## +# [perl #37886] strict 'refs' doesn't apply inside defined +use strict 'refs'; +my $x = "foo"; +defined %$x; +EXPECT +Can't use string ("foo") as a HASH ref while "strict refs" in use at - line 4.