diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-01-20 23:40:23 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-01-20 23:40:23 +0000 |
commit | d9f30342f9de4793189d81b85a5e32057393e428 (patch) | |
tree | e0204e2a19983ec6fe2e13a6518faf3b19dbc4a2 | |
parent | a36504e104c75cce0ab1c54edce368a9f9f9b78f (diff) | |
download | perl-d9f30342f9de4793189d81b85a5e32057393e428.tar.gz |
defined @$foo and defined %$bar should be subject to strict 'refs';
p4raw-id: //depot/perl@29900
-rw-r--r-- | lib/DBM_Filter.pm | 4 | ||||
-rw-r--r-- | pp_hot.c | 13 | ||||
-rw-r--r-- | t/lib/strict/refs | 14 |
3 files changed, 24 insertions, 7 deletions
diff --git a/lib/DBM_Filter.pm b/lib/DBM_Filter.pm index 7385ddd3a3..8947c0c3d4 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}; @@ -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 dee95e8c8f..6237d6d3a9 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. |