=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
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);
}
}
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);
}
}
/(?{${"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.