Change 28488 by [EMAIL PROTECTED] on 2006/07/05 20:00:10
Fix a bug on setting OPpASSIGN_COMMON on a AASSIGN op when the left
side is made out a list declared with our(). In this case OPpLVAL_INTRO
isn't set on the left op, so we just remove that check. Add new tests.
Affected files ...
... //depot/perl/op.c#830 edit
... //depot/perl/t/op/array.t#27 edit
Differences ...
==== //depot/perl/op.c#830 (text) ====
Index: perl/op.c
--- perl/op.c#829~28465~ 2006-07-02 12:30:49.000000000 -0700
+++ perl/op.c 2006-07-05 13:00:10.000000000 -0700
@@ -3783,7 +3783,6 @@
* to store these values, evil chicanery is done with SvCUR().
*/
- if (!(left->op_private & OPpLVAL_INTRO)) {
OP *lastop = o;
PL_generation++;
for (curop = LINKLIST(o); curop != o; curop = LINKLIST(curop)) {
@@ -3837,7 +3836,6 @@
}
if (curop != o)
o->op_private |= OPpASSIGN_COMMON;
- }
if (right && right->op_type == OP_SPLIT) {
OP* tmpop = ((LISTOP*)right)->op_first;
if (tmpop && (tmpop->op_type == OP_PUSHRE)) {
==== //depot/perl/t/op/array.t#27 (xtext) ====
Index: perl/t/op/array.t
--- perl/t/op/array.t#26~26186~ 2005-11-21 19:32:04.000000000 -0800
+++ perl/t/op/array.t 2006-07-05 13:00:10.000000000 -0700
@@ -7,7 +7,7 @@
require 'test.pl';
-plan (117);
+plan (125);
#
# @foo, @bar, and @ary are also used from tie-stdarray after tie-ing them
@@ -176,7 +176,6 @@
# try the same with my
{
-
my @bee = @bee;
is("@bee", "foo bar burbl blah"); # 54
{
@@ -202,6 +201,29 @@
is("@bee", "foo bar burbl blah"); # 63
}
+# try the same with our (except that previous values aren't restored)
+{
+ our @bee = @bee;
+ is("@bee", "foo bar burbl blah");
+ {
+ our (undef,@bee) = @bee;
+ is("@bee", "bar burbl blah");
+ {
+ our @bee = ('XXX',@bee,'YYY');
+ is("@bee", "XXX bar burbl blah YYY");
+ {
+ our @bee = our @bee = qw(foo bar burbl blah);
+ is("@bee", "foo bar burbl blah");
+ {
+ our (@bim) = our(@bee) = qw(foo bar);
+ is("@bee", "foo bar");
+ is("@bim", "foo bar");
+ }
+ }
+ }
+ }
+}
+
# make sure reification behaves
my $t = curr_test();
sub reify { $_[1] = $t++; print "@_\n"; }
@@ -384,4 +406,18 @@
is ($4[8], 23);
}
+# more tests for AASSIGN_COMMON
+
+{
+ our($x,$y,$z) = (1..3);
+ our($y,$z) = ($x,$y);
+ is("$x $y $z", "1 1 2");
+}
+{
+ our($x,$y,$z) = (1..3);
+ (our $y, our $z) = ($x,$y);
+ is("$x $y $z", "1 1 2");
+}
+
+
"We're included by lib/Tie/Array/std.t so we need to return something true";
End of Patch.