summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-12-15 18:00:34 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-12-15 18:00:34 +0000
commit2e6a7e23333d305fb863f36ae0c2231e95e85865 (patch)
treefd2be062bdf11d7ba1d78c2596ddb61702f74754
parentce8abf5f5d2e5b19646ab17c24a3ea87c70428c8 (diff)
downloadperl-2e6a7e23333d305fb863f36ae0c2231e95e85865.tar.gz
Fix for [perl #37886] strict 'refs' doesn't apply inside defined
p4raw-id: //depot/perl@26374
-rw-r--r--pod/perl593delta.pod14
-rw-r--r--pp.c11
-rw-r--r--t/lib/strict/refs7
3 files changed, 28 insertions, 4 deletions
diff --git a/pod/perl593delta.pod b/pod/perl593delta.pod
index 9ebc819865..b6f7b40756 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<defined $$x>
+
+C<use strict "refs"> 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<Can't use string as a
+SCALAR ref while "strict refs" in use>. (However, C<defined @$foo> and
+C<defined %$foo> 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 254e840be9..eeb82c0d82 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 b6a2753360..dee95e8c8f 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.