From: Rafael Garcia-Suarez Date: Wed, 30 Nov 2005 09:53:11 +0000 (+0000) Subject: Revert change #22520 (optimise away my $foo = undef and similar X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7c8a3dfd3bf64e6ea427f38183b879af54fe8f18;p=p5sagit%2Fp5-mst-13.2.git Revert change #22520 (optimise away my $foo = undef and similar constructs), in order to fix bug perl #37776 p4raw-link: @22520 on //depot/perl: b9d46b3942a9a8cce9cbca1e08f61ac23083a740 p4raw-id: //depot/perl@26226 --- diff --git a/op.c b/op.c index aeedab9..6e37131 100644 --- a/op.c +++ b/op.c @@ -3300,15 +3300,6 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *left, I32 optype, OP *right) /* Result of assignment is always 1 (or we'd be dead already) */ return newSVOP(OP_CONST, 0, newSViv(1)); } - /* optimise C to C, and likewise for hashes */ - if ((left->op_type == OP_PADAV || left->op_type == OP_PADHV) - && right->op_type == OP_STUB - && (left->op_private & OPpLVAL_INTRO)) - { - op_free(right); - left->op_flags &= ~(OPf_REF|OPf_SPECIAL); - return left; - } curop = list(force_list(left)); o = newBINOP(OP_AASSIGN, flags, list(force_list(right)), curop); o->op_private = (U8)(0 | (flags >> 8)); @@ -5802,19 +5793,6 @@ Perl_ck_sassign(pTHX_ OP *o) return kid; } } - /* optimise C to C */ - if (kid->op_type == OP_UNDEF) { - OP * const kkid = kid->op_sibling; - if (kkid && kkid->op_type == OP_PADSV - && (kkid->op_private & OPpLVAL_INTRO)) - { - cLISTOPo->op_first = NULL; - kid->op_sibling = NULL; - op_free(o); - op_free(kid); - return kkid; - } - } return o; } diff --git a/t/op/my.t b/t/op/my.t index d219f80..6a477db 100755 --- a/t/op/my.t +++ b/t/op/my.t @@ -1,6 +1,6 @@ #!./perl -print "1..34\n"; +print "1..36\n"; sub foo { my($a, $b) = @_; @@ -120,3 +120,13 @@ eval { foo3(); foo3(); }; print "not " if $@; print "ok 34\n"; +# my $foo = undef should always assign [perl #37776] +{ + my $count = 35; + loop: + my $test = undef; + print "not " if defined $test; + print "ok $count\n"; + $test = 42; + goto loop if ++$count < 37; +}