summaryrefslogtreecommitdiff
path: root/t/op/repeat.t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-11-05 22:20:46 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-06 06:11:04 -0800
commit3a100dabd08f34372a052d4a47935f4d713fa0f9 (patch)
treeb7371199e9ff7474f2b41903ae1ae400b411f6ab /t/op/repeat.t
parentd71b73c8676247f407252233c46a3a4862ee988a (diff)
downloadperl-3a100dabd08f34372a052d4a47935f4d713fa0f9.tar.gz
[perl #121827] Fix repeat stack bugs
(...)x... is marked as a list at compile time and given a pushmark, before the context is known. If it turns out to be called in scalar or void context after all, then pp_repeat has to handle the mark that has been pushed on to the markstack. It was not handling the mark for overloading. Nor was it handling void context correctly at all. (The stack may have an empty list, in which case we call FETCH on a potentially tied stack item that has nothing to do with us.) I tested it in void context, because I plan to undo the listification when scalar context is applied, for speed.
Diffstat (limited to 't/op/repeat.t')
-rw-r--r--t/op/repeat.t12
1 files changed, 11 insertions, 1 deletions
diff --git a/t/op/repeat.t b/t/op/repeat.t
index 1174c4e961..15cf66eb89 100644
--- a/t/op/repeat.t
+++ b/t/op/repeat.t
@@ -6,7 +6,7 @@ BEGIN {
}
require './test.pl';
-plan(tests => 46);
+plan(tests => 47);
# compile time
@@ -141,6 +141,16 @@ is($y, undef, ' no extra values on stack');
# operand of the eq binop needs to remain!
is(77, scalar ((1,7)x2), 'stack truncation');
+# ( )x in void context should not read preceding stack items
+package Tiecount {
+ sub TIESCALAR { bless[]} sub FETCH { our $Tiecount++; study; 3 }
+}
+sub nil {}
+tie my $t, "Tiecount";
+{ push my @temp, $t, scalar((nil) x 3, 1) }
+is($Tiecount::Tiecount, 1,
+ '(...)x... in void context in list (via scalar comma)');
+
# perlbug 20011113.110 works in 5.6.1, broken in 5.7.2
{