settarg:
o->op_private |= (varop->op_private & (OPpLVAL_INTRO|OPpPAD_STATE));
o->op_targ = varop->op_targ;
- varop->op_targ = 0;
+ if (!(o->op_private & (OPpPAD_STATE|OPpLVAL_INTRO)))
+ varop->op_targ = 0;
PAD_COMPNAME_GEN_set(o->op_targ, PERL_INT_MAX);
break;
o->op_flags &=~ OPf_STACKED;
op_sibling_splice(o, right, 1, NULL);
}
+ if (o->op_private & OPpPAD_STATE && o->op_private & OPpLVAL_INTRO) {
+ o = S_newONCEOP(aTHX_ o, varop);
+ }
op_free(left);
return o;
}
set_up_inc("../lib");
}
-plan 167;
+plan 170;
eval '\$x = \$y';
like $@, qr/^Experimental aliasing via reference not enabled/,
\my($y) = \3,
\state $a = \3,
\state($b) = \3 if $_ == 1;
+ \state $c = \$_;
if ($_ == 2) {
is $x, undef, '\my $x = ... clears $x on scope exit';
is $y, undef, '\my($x) = ... clears $x on scope exit';
is $a, 3, '\state $x = ... does not clear $x on scope exit';
is $b, 3, '\state($x) = ... does not clear $x on scope exit';
+ is $c, 1, '\state $x = ... can be used with refaliasing';
}
}
\my(@y) = \3,
\state @a = [1..3],
\state(@b) = \3 if $_ == 1;
+ \state @c = [$_];
if ($_ == 2) {
is @x, 0, '\my @x = ... clears @x on scope exit';
is @y, 0, '\my(@x) = ... clears @x on scope exit';
is "@a", "1 2 3", '\state @x = ... does not clear @x on scope exit';
is "@b", 3, '\state(@x) = ... does not clear @x on scope exit';
+ is $c[0], 1, '\state @x = ... can be used with refaliasing';
}
}
for (1,2) {
\state %y = {1,2},
\my %x = {1,2} if $_ == 1;
+ \state %c = {X => $_};
if ($_ == 2) {
is %x, 0, '\my %x = ... clears %x on scope exit';
is "@{[%y]}", "1 2", '\state %x = ... does not clear %x on scope exit';
+ is $c{X}, 1, '\state %x = ... can be used with refaliasing';
}
}