From: Dave Mitchell Date: Tue, 4 May 2004 19:20:36 +0000 (+0000) Subject: [perl #29340] Bizarre copy of ARRAY X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9ff53bc97fe2246e61874ffc409d9e547337a471;p=p5sagit%2Fp5-mst-13.2.git [perl #29340] Bizarre copy of ARRAY make sure a pad op's flags are updated after optimising away the assignment in my @a = () (see change 22520). p4raw-id: //depot/perl@22781 --- diff --git a/op.c b/op.c index 02144e8..b3b5c44 100644 --- a/op.c +++ b/op.c @@ -3130,6 +3130,7 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *left, I32 optype, OP *right) && (left->op_private & OPpLVAL_INTRO)) { op_free(right); + left->op_flags &= ~(OPf_REF|OPf_SPECIAL); return left; } curop = list(force_list(left)); diff --git a/t/op/my.t b/t/op/my.t index 601e1d6..bf5b6db 100755 --- a/t/op/my.t +++ b/t/op/my.t @@ -2,7 +2,7 @@ # $RCSfile: my.t,v $ -print "1..31\n"; +print "1..33\n"; sub foo { my($a, $b) = @_; @@ -99,3 +99,15 @@ for my $full (keys %fonts) { # Supposed to be copy-on-write via force_normal after a THINKFIRST check. print "$full $fonts{nok}\n"; } + +# [perl #29340] optimising away the = () left the padav returning the +# array rather than the contents, leading to 'Bizarre copy of array' error + +sub opta { my @a=() } +sub opth { my %h=() } +eval { my $x = opta }; +print "not " if $@; +print "ok 32\n"; +eval { my $x = opth }; +print "not " if $@; +print "ok 33\n";