Closed p6rt closed 8 years ago
my $a = 'a'; s/(.)/$0/ for $a; $a.perl.say;
Expected result: "a" Actual result: ""
This is perl6 version 2014.09-227-g3448cb1 built on MoarVM version 2014.09-54-g03ac9a7
Version Perl6 2014.09 built on MoarVM 2014.09 Windows 7.
Code
my $string = "ACCB"; for $string { s/A (\<-[B]>*) B/$0/; say $_; }
produces nog output. However, the next fragment produces "CC" as expected.
my $string = "ACCB"; for $string { my $mid; s/A (\<-[B]>*) { $mid = $0 } B/$mid/; say $_; }
-- Theo van den Heuvel Van den Heuvel HLT Consultancy Malden, The Netherlands +31 24 3736356 +31 625492788
See also:
See also:
I added two tests to S04-statements/for.t with commit https://github.com/perl6/roast/commit/ab81dfbdd5
I added two tests to S04-statements/for.t with commit https://github.com/perl6/roast/commit/ab81dfbdd5
@usev6 - Status changed from 'new' to 'open'
This bug came up for discussion today:
labster: m: say ("-AAAA-").map( { my $/; .subst(/(A+)/, { $0.chars } ) }); camelia: rakudo-moar d0a84b: OUTPUT«-4-» Ven: labster: my $/ ? labster: Ven: apparently manually declaring the match variable in that block makes it update $0 labster: m: say ("-AAAA-").map( { .subst(/(A+)/, { $0.chars } ) }); camelia: rakudo-moar d0a84b: OUTPUT«-0-» FROGGS: labster: I guess it is about how we access the caller's $/ in method subst FROGGS: labster: I think we might want to pass the correct $/ from Perl6::Actions to method subst, instead of doing the opposite
Bug appears in .map, .for, and for loop, possibly others.
On Mon Dec 01 09:00:45 2014, raiph wrote:
See also:
118705: [BUG] s/// doesn't update $/ inside for loop
123323: $0 in substitution
Patch: https://github.com/rakudo/rakudo/commit/32d7b08334 Tests: https://github.com/perl6/roast/commit/f665268fde
Closing ticket.
Patch: https://github.com/rakudo/rakudo/commit/32d7b08334 Tests: https://github.com/perl6/roast/commit/f665268fde
Closing ticket.
@FROGGS - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#123005 (status was 'resolved')
Searchable as RT123005$