Skip Menu |
Report information
Id: 131102
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: alex.jakimenko [at] gmail.com
joshuamy [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [REGRESSION] anonymous variables are no longer working as expected in regex code blocks
Download (untitled) / with headers
text/plain 241b
Code: (^10).grep: /^ <?{ say $++ }> / Result (2015.12,2016.10): 0 1 2 3 4 5 6 7 8 9 Result (2016.11,HEAD(099512b)): 0 0 0 0 0 0 0 0 0 0 Bisectable points to https://github.com/rakudo/rakudo/commit/7a456ff80183a6e26dc91d811d992112c68ddb6d
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 610b
On Tue, 04 Apr 2017 18:43:14 -0700, alex.jakimenko@gmail.com wrote: Show quoted text
> Code: > (^10).grep: /^ <?{ say $++ }> / > > Result (2015.12,2016.10): > 0 > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > > Result (2016.11,HEAD(099512b)): > 0 > 0 > 0 > 0 > 0 > 0 > 0 > 0 > 0 > 0 > > > Bisectable points to > https://github.com/rakudo/rakudo/commit/7a456ff80183a6e26dc91d811d992112c68ddb6d
A state variable works per closure clone, but we must re-clone the inner blocks in a regex to avoid threads stomping on each other's state. So this only "worked" previously thanks to a code-gen bug, which I fixed in the referenced commit.
Which basically means that state variables are useless in this case. Is there any potential possibility to detect this and print some kind of a warning?

On 2017-04-07 05:34:38, jnthn@jnthn.net wrote:
Show quoted text
> On Tue, 04 Apr 2017 18:43:14 -0700, alex.jakimenko@gmail.com wrote:
> > Code:
> > (^10).grep: /^ <?{ say $++ }> /
> >
> > Result (2015.12,2016.10):
> > 0
> > 1
> > 2
> > 3
> > 4
> > 5
> > 6
> > 7
> > 8
> > 9
> >
> > Result (2016.11,HEAD(099512b)):
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> > 0
> >
> >
> > Bisectable points to
> > https://github.com/rakudo/rakudo/commit/7a456ff80183a6e26dc91d811d992112c68ddb6d
>
> A state variable works per closure clone, but we must re-clone the
> inner blocks in a regex to avoid threads stomping on each other's
> state. So this only "worked" previously thanks to a code-gen bug,
> which I fixed in the referenced commit.


Subject: [BUG] Anon state var doesn't work in regex (Regression)
Download (untitled) / with headers
text/plain 507b
An array of tokens used to be able to match like this: my token foo { 'foo' }; my token bar { 'bar' }; my token baz { 'baz' }; my @tokens = /<foo>/, /<bar>/, /<baz>/; say 'foo bar baz' ~~ / ^ <{ @tokens[$++] }> ** { +@tokens } % <.ws> $ /; OUTPUT: 「foo bar baz」 This no longer work since commit 7a456ff80183a6e26dc91d811d992112c68ddb6d You can simulate how it should work by providing your own state variable state $i = 0; say 'foo bar baz' ~~ / ^ <{ @tokens[$i++] }> ** { +@tokens } % <.ws> $ /;
I'm fairly sure that the ship for this has sailed, we've had this “issue” for a year now.

I guess during that year everyone has adapted their code to the new behavior.

So if you're reading this comment and you think that the ticket should be closed, please just mark it as 「testneeded」 so that we have the new behavior cast in stone. And that'll be it.

On 2017-08-06 08:32:55, joshuamy@gmail.com wrote:
Show quoted text
> An array of tokens used to be able to match like this:
>
> my token foo { 'foo' };
> my token bar { 'bar' };
> my token baz { 'baz' };
> my @tokens = /<foo>/, /<bar>/, /<baz>/;
> say 'foo bar baz' ~~ / ^ <{ @tokens[$++] }> ** { +@tokens } % <.ws> $ /;
>
> OUTPUT: 「foo bar baz」
>
> This no longer work since commit 7a456ff80183a6e26dc91d811d992112c68ddb6d
>
> You can simulate how it should work by providing your own state variable
>
> state $i = 0;
> say 'foo bar baz' ~~ / ^ <{ @tokens[$i++] }> ** { +@tokens } % <.ws> $ /;




This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org