Why does here substr-rw
cut off the trailing 6
?
#!/usr/bin/env perl6
use v6;
my $str = '123';
$str ~= '.' x 30;
$str ~= '456';
say $str; # 123..............................456
$str.substr-rw( 0, 10 ) = '';
say $str; # ........................45
perl6 --version
This is Rakudo version 2016.03-38-g8df1a69 built on MoarVM version 2016.03-46-g50c7f6a implementing Perl 6.c.
UPDATE: A Rakudo/MoarVM built after 2016-07-21 should behave correctly.
Looks like a bug to me. Note that it matters how the string is constructed:
my $a = '.' x 3 ~ 'x';
my $b = sprintf('%s', $a); # or just '...x', but not "$a"
say $a; #=> ..x
say $b; #=> ..x
$a.substr-rw( 0, 2 ) = '';
$b.substr-rw( 0, 2 ) = '';
say $a; #=> ..
say $b; #=> .x
Update: The bug has been reported: RT#127782