In push @a, last, it can try to return the @a, copying it like a sca-
lar in the process, resulting in Bizarre copy of ARRAY in last.
In do{{&{sub{"Just another Perl hacker,\n"}},last}}, it returns "Just
another Perl hacker,\n".
The former is clearly a bug. The latter depends on a side-effect of
the same bug.
‘last’ really should not be trying to return the values that the same
statement has accumulated so far.
POPBLOCK(cx,newpm);
cxstack_ix++; /* temporarily protect top context */
- mark = newsp;
switch (CxTYPE(cx)) {
case CXt_LOOP_LAZYIV:
case CXt_LOOP_LAZYSV:
}
TAINT_NOT;
- PL_stack_sp = adjust_stack_on_leave(newsp, PL_stack_sp, MARK, gimme,
- pop2 == CXt_SUB ? SVs_TEMP : 0);
+ PL_stack_sp = newsp;
LEAVE;
cxstack_ix--;
BEGIN {
chdir 't' if -d 't';
@INC = qw(. ../lib);
+ require "test.pl";
}
-require "test.pl";
-plan( tests => 64 );
+plan( tests => 67 );
my $ok;
fail("redo with non-constant label");
}
}
+
+# [perl #3112]
+# The original report, which produced a Bizarre copy
+@a = ();
+eval {
+ for (1) {
+ push @a, last;
+ }
+};
+is @a, 0, 'push @a, last; does not push';
+is $@, "", 'no error, either';
+# And my japh, which relied on the misbehaviour
+is do{{&{sub{"Just another Perl hacker,\n"}},last}}, undef,
+ 'last returns nothing';