Skip to content

Commit 976c8a3

Browse files
committed
Retract 11635: close 20011113.110, reopen 20010809.028.
Tiny problem in the test for 20011113.110: I hope 'my $x= [("foo") x 1]' was never going to produce [qw(foo foo)] :-) p4raw-id: //depot/perl@13077
1 parent f36eea1 commit 976c8a3

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

pp.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,10 +1256,33 @@ PP(pp_repeat)
12561256
MEXTEND(MARK, max);
12571257
if (count > 1) {
12581258
while (SP > MARK) {
1259+
#if 0
1260+
/* This code was intended to fix 20010809.028:
1261+
1262+
$x = 'abcd';
1263+
for (($x =~ /./g) x 2) {
1264+
print chop; # "abcdabcd" expected as output.
1265+
}
1266+
1267+
* but that change (#11635) broke this code:
1268+
1269+
$x = [("foo")x2]; # only one "foo" ended up in the anonlist.
1270+
1271+
* I can't think of a better fix that doesn't introduce
1272+
* an efficiency hit by copying the SVs. The stack isn't
1273+
* refcounted, and mortalisation obviously doesn't
1274+
* Do The Right Thing when the stack has more than
1275+
* one pointer to the same mortal value.
1276+
* .robin.
1277+
*/
12591278
if (*SP) {
12601279
*SP = sv_2mortal(newSVsv(*SP));
12611280
SvREADONLY_on(*SP);
12621281
}
1282+
#else
1283+
if (*SP)
1284+
SvTEMP_off((*SP));
1285+
#endif
12631286
SP--;
12641287
}
12651288
MARK++;

t/op/repeat.t

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BEGIN {
66
}
77

88
require './test.pl';
9-
plan(tests => 24);
9+
plan(tests => 25);
1010

1111
# compile time
1212

@@ -118,7 +118,18 @@ is(77, scalar ((1,7)x2), 'stack truncation');
118118

119119
# perlbug 20011113.110 works in 5.6.1, broken in 5.7.2
120120
{
121-
local $TODO = 'list repeat in anon array ref broken [ID 20011113.110]';
122-
my $x= [("foo") x 1];
123-
is( join('', @$x), 'foofoo' );
121+
my $x= [("foo") x 2];
122+
is( join('', @$x), 'foofoo', 'list repeat in anon array ref broken [ID 20011113.110]' );
124123
}
124+
125+
# [ID 20010809.028] x operator not copying elements in 'for' list?
126+
{
127+
local $TODO = "x operator not copying elements in 'for' list? [ID 20010809.028]";
128+
my $x = 'abcd';
129+
my $y = '';
130+
for (($x =~ /./g) x 2) {
131+
$y .= chop;
132+
}
133+
is($y, 'abcdabcd');
134+
}
135+

0 commit comments

Comments
 (0)