From: Rafael Garcia-Suarez Date: Thu, 15 Dec 2005 18:00:34 +0000 (+0000) Subject: Fix for [perl #37886] strict 'refs' doesn't apply inside defined X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2e6a7e23333d305fb863f36ae0c2231e95e85865;p=p5sagit%2Fp5-mst-13.2.git Fix for [perl #37886] strict 'refs' doesn't apply inside defined p4raw-id: //depot/perl@26374 --- diff --git a/pod/perl593delta.pod b/pod/perl593delta.pod index 9ebc819..b6f7b40 100644 --- a/pod/perl593delta.pod +++ b/pod/perl593delta.pod @@ -29,6 +29,20 @@ a number of misparsing issues when a global C<_> subroutine is defined. =head1 Selected Bug Fixes +=head2 C + +C was ignoring taking a hard reference in an argument +to defined(), as in : + + use strict "refs"; + my $x = "foo"; + if (defined $$x) {...} + +This now correctly produces the run-time error C. (However, C and +C are still allowed. Those constructs are discouraged +anyway.) + =head1 New or Changed Diagnostics =head1 Changed Internals diff --git a/pp.c b/pp.c index 254e840..eeb82c0 100644 --- a/pp.c +++ b/pp.c @@ -238,9 +238,14 @@ PP(pp_rv2sv) if (SvROK(sv)) goto wasref; } + if (PL_op->op_private & HINT_STRICT_REFS) { + if (SvOK(sv)) + DIE(aTHX_ PL_no_symref_sv, sv, "a SCALAR"); + else + DIE(aTHX_ PL_no_usym, "a SCALAR"); + } 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, "a SCALAR"); if (ckWARN(WARN_UNINITIALIZED)) report_uninit(sv); @@ -258,8 +263,6 @@ PP(pp_rv2sv) } } else { - if (PL_op->op_private & HINT_STRICT_REFS) - DIE(aTHX_ PL_no_symref_sv, sv, "a SCALAR"); gv = (GV*)gv_fetchsv(sv, TRUE, SVt_PV); } } diff --git a/t/lib/strict/refs b/t/lib/strict/refs index b6a2753..dee95e8 100644 --- a/t/lib/strict/refs +++ b/t/lib/strict/refs @@ -301,3 +301,10 @@ use strict 'refs'; /(?{${"foo"}++})/; EXPECT Can't use string ("foo") as a SCALAR ref while "strict refs" in use at (re_eval 1) line 1. +######## +# [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 SCALAR ref while "strict refs" in use at - line 4.