set for all state vars in the pad.
(Nicholas worked up the same fix - spooky action at a distance!)
p4raw-id: //depot/perl@31835
else
sv = newSV(0);
SvPADMY_on(sv);
+ /* reset the 'assign only once' flag on each state var */
+ if (SvPAD_STATE(namesv))
+ SvPADSTALE_on(sv);
}
}
else if (IS_PADGV(ppad[ix]) || IS_PADCONST(ppad[ix])) {
use strict;
use feature ":5.10";
-plan tests => 119;
+plan tests => 123;
ok( ! defined state $uninit, q(state vars are undef by default) );
is $f[1]->(), 1;
}
+# each copy of an anon sub should get its own 'once block'
+
+{
+ my $x; # used to force a closure
+ my @f;
+ push @f, sub { $x; state $s = $_[0]; $s } for 1..2;
+ is $f[0]->(1), 1;
+ is $f[0]->(2), 1;
+ is $f[1]->(3), 3;
+ is $f[1]->(4), 3;
+}
+
+
+
+
foreach my $forbidden (<DATA>) {
chomp $forbidden;
no strict 'vars';