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

state variables are no longer working as expected in regex code blocks (/^ <?{ say $++ }> /) #6174

Open
p6rt opened this issue Apr 5, 2017 · 6 comments
Labels

Comments

@p6rt
Copy link

@p6rt p6rt commented Apr 5, 2017

Migrated from rt.perl.org#131102 (status was 'open')

Searchable as RT131102$

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Apr 5, 2017

From @AlexDaniel

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 rakudo/rakudo@7a456ff

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Apr 7, 2017

From @jnthn

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
rakudo/rakudo@7a456ff

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.

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Apr 7, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Apr 7, 2017

From @AlexDaniel

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​:

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
rakudo/rakudo@7a456ff

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.

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Aug 6, 2017

From joshuamy@gmail.com

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> $ /;

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Oct 11, 2017

From @AlexDaniel

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​:

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> $ /;

@p6rt p6rt added the regression label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.