Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$/ broken for replacement inside for loop #3560

Closed
p6rt opened this issue Oct 18, 2014 · 11 comments
Closed

$/ broken for replacement inside for loop #3560

p6rt opened this issue Oct 18, 2014 · 11 comments

Comments

@p6rt
Copy link

p6rt commented Oct 18, 2014

Migrated from rt.perl.org#123005 (status was 'resolved')

Searchable as RT123005$

@p6rt
Copy link
Author

p6rt commented Oct 18, 2014

From @raydiak

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

@p6rt
Copy link
Author

p6rt commented Nov 29, 2014

From vdheuvel@heuvelhlt.nl

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

@p6rt
Copy link
Author

p6rt commented Dec 1, 2014

From @raiph

See also​:

#​118705​: [BUG] s/// doesn't update $/ inside for loop

#​123005​: [BUG] $/ broken for replacement inside for loop

@p6rt
Copy link
Author

p6rt commented Dec 1, 2014

From @raiph

See also​:

#​118705​: [BUG] s/// doesn't update $/ inside for loop

#​123323​: $0 in substitution

@p6rt
Copy link
Author

p6rt commented Dec 4, 2014

From @usev6

I added two tests to S04-statements/for.t with commit Raku/roast@ab81dfbdd5

1 similar comment
@p6rt
Copy link
Author

p6rt commented Dec 4, 2014

From @usev6

I added two tests to S04-statements/for.t with commit Raku/roast@ab81dfbdd5

@p6rt
Copy link
Author

p6rt commented Dec 4, 2014

@usev6 - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Apr 26, 2015

From @labster

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

@p6rt
Copy link
Author

p6rt commented Oct 18, 2015

From @FROGGS

Patch​: rakudo/rakudo@32d7b08334
Tests​: Raku/roast@f665268fde

Closing ticket.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 18, 2015

From @FROGGS

Patch​: rakudo/rakudo@32d7b08334
Tests​: Raku/roast@f665268fde

Closing ticket.

@p6rt
Copy link
Author

p6rt commented Oct 18, 2015

@FROGGS - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant