for the cases $x x -1.
p4raw-id: //depot/perl@22543
operand is not enclosed in parentheses, it returns a string consisting
of the left operand repeated the number of times specified by the right
operand. In list context, if the left operand is enclosed in
-parentheses, it repeats the list.
+parentheses, it repeats the list. If the right operand is zero or
+negative, it returns an empty string or an empty list, depending on the
+context.
print '-' x 80; # print row of dashes
dSP; dATARGET; tryAMAGICbin(repeat,opASSIGN);
{
register IV count = POPi;
+ if (count < 0) {
+ if (ckWARN(WARN_MISC))
+ Perl_warner(aTHX_ packWARN(WARN_MISC), "Negative repeat count");
+ count = 0;
+ }
if (GIMME == G_ARRAY && PL_op->op_private & OPpREPEAT_DOLIST) {
dMARK;
I32 items = SP - MARK;
$_ = "\x80 \xff" ;
reverse ;
EXPECT
+########
+# pp.c
+use warnings;
+$a = "b" x -1;
+$a = "b" x 0;
+no warnings;
+$a = "b" x -1;
+EXPECT
+Negative repeat count at - line 3.