summaryrefslogtreecommitdiff
path: root/lib
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 /lib
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 'lib')
-rw-r--r--lib/overload.t8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/overload.t b/lib/overload.t
index 2371c71a3f..524d99f4e4 100644
--- a/lib/overload.t
+++ b/lib/overload.t
@@ -48,7 +48,7 @@ package main;
$| = 1;
BEGIN { require './test.pl' }
-plan tests => 5198;
+plan tests => 5199;
use Scalar::Util qw(tainted);
@@ -2748,6 +2748,12 @@ package refsgalore {
is ioref->(), 46, '(overloaded constant that is not a sub ref)->()';
}
+package xstack { use overload 'x' => sub { shift . " x " . shift },
+ '""'=> sub { "xstack" } }
+is join(",", 1..3, scalar((bless([], 'xstack')) x 3, 1), 4..6),
+ "1,2,3,1,4,5,6",
+ '(...)x... in void cx with x overloaded [perl #121827]';
+
{ # undefining the overload stash -- KEEP THIS TEST LAST
package ant;
use overload '+' => 'onion';