Change 28499 by [EMAIL PROTECTED] on 2006/07/07 09:50:35
Fix the implementation of list assignment to state().
Affected files ...
... //depot/perl/op.c#833 edit
... //depot/perl/t/lib/warnings/op#31 edit
... //depot/perl/t/op/state.t#10 edit
Differences ...
==== //depot/perl/op.c#833 (text) ====
Index: perl/op.c
--- perl/op.c#832~28496~ 2006-07-06 08:49:30.000000000 -0700
+++ perl/op.c 2006-07-07 02:50:35.000000000 -0700
@@ -3800,17 +3800,6 @@
curop->op_type == OP_PADHV ||
curop->op_type == OP_PADANY)
{
- if (curop->op_private & OPpPAD_STATE) {
- if (left->op_private & OPpLVAL_INTRO) {
- o->op_private |= OPpASSIGN_STATE;
- /* hijacking PADSTALE for uninitialized state
variables */
- SvPADSTALE_on(PAD_SVl(curop->op_targ));
- }
- else if (ckWARN(WARN_MISC)) {
- Perl_warner(aTHX_ packWARN(WARN_MISC), "State
variable %s will be reinitialized",
- PAD_COMPNAME_PV(curop->op_targ));
- }
- }
if (PAD_COMPNAME_GEN(curop->op_targ)
== (STRLEN)PL_generation)
break;
@@ -3849,6 +3838,34 @@
if (curop != o)
o->op_private |= OPpASSIGN_COMMON;
}
+
+ if ( ((left->op_private & OPpLVAL_INTRO) || ckWARN(WARN_MISC))
+ && (left->op_type == OP_LIST
+ || (left->op_type == OP_NULL && left->op_targ == OP_LIST)))
+ {
+ OP* lop = ((LISTOP*)left)->op_first;
+ while (lop) {
+ if (lop->op_type == OP_PADSV ||
+ lop->op_type == OP_PADAV ||
+ lop->op_type == OP_PADHV ||
+ lop->op_type == OP_PADANY)
+ {
+ if (lop->op_private & OPpPAD_STATE) {
+ if (left->op_private & OPpLVAL_INTRO) {
+ o->op_private |= OPpASSIGN_STATE;
+ /* hijacking PADSTALE for uninitialized state
variables */
+ SvPADSTALE_on(PAD_SVl(lop->op_targ));
+ }
+ else { /* we already checked for WARN_MISC before */
+ Perl_warner(aTHX_ packWARN(WARN_MISC), "State
variable %s will be reinitialized",
+ PAD_COMPNAME_PV(lop->op_targ));
+ }
+ }
+ }
+ lop = lop->op_sibling;
+ }
+ }
+
if (right && right->op_type == OP_SPLIT) {
OP* tmpop = ((LISTOP*)right)->op_first;
if (tmpop && (tmpop->op_type == OP_PUSHRE)) {
==== //depot/perl/t/lib/warnings/op#31 (text) ====
Index: perl/t/lib/warnings/op
--- perl/t/lib/warnings/op#30~28496~ 2006-07-06 08:49:30.000000000 -0700
+++ perl/t/lib/warnings/op 2006-07-07 02:50:35.000000000 -0700
@@ -1089,12 +1089,15 @@
(state $y) = 2;
(state $z, my $t) = (3, 4);
(state $foo, state $bar) = (5, 6);
+(undef, my $v, state $w) = (7 .. 9);
no warnings 'misc';
state($x) = 1;
(state $y) = 2;
(state $z, my $t) = (3, 4);
(state $foo, state $bar) = (5, 6);
+(undef, my $v, state $w) = (7 .. 9);
EXPECT
State variable $z will be reinitialized at - line 6.
State variable $foo will be reinitialized at - line 7.
State variable $bar will be reinitialized at - line 7.
+State variable $w will be reinitialized at - line 8.
==== //depot/perl/t/op/state.t#10 (text) ====
Index: perl/t/op/state.t
--- perl/t/op/state.t#9~28498~ 2006-07-06 09:55:57.000000000 -0700
+++ perl/t/op/state.t 2006-07-07 02:50:35.000000000 -0700
@@ -164,6 +164,4 @@
$ls = statelist2();
is($ls, "2/3", 'list assignment to state scalars');
$ls = statelist2();
-{ local our $TODO = 'detection of state vars is misplaced in newASSIGNOP';
is($ls, "3/4", 'list assignment to state scalars');
-}
End of Patch.