diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-09-23 06:02:58 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-09-23 06:03:50 -0700 |
commit | 518618af9da07b079c1585df2b7c76a1aed0f19c (patch) | |
tree | cf07652a1d714b64d2e0b62b1d0720f46e856a00 | |
parent | 02a7bbbc28f17133923631eccec205b5a0c2c52d (diff) | |
download | perl-518618af9da07b079c1585df2b7c76a1aed0f19c.tar.gz |
[perl #97466] Stop defined from propagating ref cx too far
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | op.c | 2 | ||||
-rw-r--r-- | t/op/defined.t | 20 |
3 files changed, 22 insertions, 1 deletions
@@ -5245,6 +5245,7 @@ t/op/cproto.t Check builtin prototypes t/op/crypt.t See if crypt works t/op/current_sub.t __SUB__ tests t/op/dbm.t See if dbmopen/dbmclose work +t/op/defined.t See if defined() edge cases work t/op/defins.t See if auto-insert of defined() works t/op/delete.t See if delete works t/op/die_except.t See if die/eval avoids $@ clobberage @@ -2386,7 +2386,7 @@ Perl_doref(pTHX_ OP *o, I32 type, bool set_op_ref) case OP_SCALAR: case OP_NULL: - if (!(o->op_flags & OPf_KIDS)) + if (!(o->op_flags & OPf_KIDS) || type == OP_DEFINED) break; doref(cBINOPo->op_first, type, set_op_ref); break; diff --git a/t/op/defined.t b/t/op/defined.t new file mode 100644 index 0000000000..7129e47a88 --- /dev/null +++ b/t/op/defined.t @@ -0,0 +1,20 @@ +#!perl +BEGIN { + chdir 't'; + require './test.pl'; +} + +plan 5; + +sub notdef { undef } + +# [perl #97466] +# These should actually call the sub, instead of testing the sub itself +ok !defined do { ¬def }, 'defined do { &sub }'; +ok !defined(scalar(42,¬def)), 'defined(scalar(42,&sub))'; +ok !defined do{();¬def}, '!defined do{();&sub}'; + +# Likewise, these should evaluate @array in scalar context +no warnings "deprecated"; +ok defined($false ? $scalar : @array), 'defined( ... ? ... : @array)'; +ok defined(scalar @array), 'defined(scalar @array)'; |