summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-09-20 01:34:31 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-09-20 12:44:39 -0700
commit0c0c317c3b754aee8ee3ef271d17aab2fdbe5140 (patch)
tree93c4ddd53821b00ca7ab91058743a48e7dcea88d /t
parent7497b91fbd38419c3d11a21866233566db7a3c10 (diff)
downloadperl-0c0c317c3b754aee8ee3ef271d17aab2fdbe5140.tar.gz
[perl #3112] Stop last from returning values
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.
Diffstat (limited to 't')
-rw-r--r--t/op/loopctl.t18
1 files changed, 16 insertions, 2 deletions
diff --git a/t/op/loopctl.t b/t/op/loopctl.t
index fcb1237846..d520a7fa31 100644
--- a/t/op/loopctl.t
+++ b/t/op/loopctl.t
@@ -33,10 +33,10 @@
BEGIN {
chdir 't' if -d 't';
@INC = qw(. ../lib);
+ require "test.pl";
}
-require "test.pl";
-plan( tests => 64 );
+plan( tests => 67 );
my $ok;
@@ -1104,3 +1104,17 @@ redo_113684:
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';