switch (o->op_type) {
case OP_REPEAT:
- if (o->op_private & OPpREPEAT_DOLIST)
- null(((LISTOP*)cBINOPo->op_first)->op_first);
scalar(cBINOPo->op_first);
break;
case OP_OR:
(void)SvPOK_only_UTF8(TARG);
else
(void)SvPOK_only(TARG);
+
+ if (PL_op->op_private & OPpREPEAT_DOLIST) {
+ /* The parser saw this as a list repeat, and there
+ are probably several items on the stack. But we're
+ in scalar context, and there's no pp_list to save us
+ now. So drop the rest of the items -- robin@kitsite.com
+ */
+ dMARK;
+ SP = MARK;
+ }
PUSHTARG;
}
RETURN;
use strict;
use Config;
-print "1..17\n";
+print "1..18\n";
my $test = 1;
print "not " if "{\n \$test /= 2 if ++\$test;\n}" ne
$deparse->coderef2text(sub {++$test and $test/=2;});
ok;
+
+print "not " if "{\n -((1, 2) x 2);\n}" ne
+ $deparse->coderef2text(sub {-((1,2)x2)});
+ok;
+
{
my $a = <<'EOF';
{
# $RCSfile: repeat.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:21 $
-print "1..20\n";
+print "1..23\n";
# compile time
# jhi@iki.fi
#
print "\xdd" x 24 eq "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" ? "ok 20\n" : "not ok 20\n";
+
+# When we use a list repeat in a scalar context, it behaves like
+# a scalar repeat. Make sure that works properly, and doesn't leave
+# extraneous values on the stack.
+# -- robin@kitsite.com
+
+my ($x, $y) = scalar ((1,2)x2);
+print $x eq "22" ? "ok 21\n" : "not ok 21\n";
+print !defined $y ? "ok 22\n" : "not ok 22\n";
+
+# Make sure the stack doesn't get truncated too much - the left
+# operand of the eq binop needs to remain!
+print (77 eq scalar ((1,7)x2) ? "ok 23\n" : "not ok 23\n");