[perl #129114] [BUG] state variable declared inside of a {} interpolation in a string, attaches to wrong scope <[email protected]>

[email protected] ("Aleks-Daniel Jakimenko-Aleksejev via RT")
Newsgroups perl.perl6.compiler
Message-ID <[email protected]>
Just to clarify, the last snippet now produces 0 0 0 0, which is indeed
correct.

There are tests for this change in general, but possibly not for that
particular case. Can we get it covered just in case?

「testneeded」

On 2018-02-06 05:51:23, [email protected] wrote:
> On Sun, 28 Aug 2016 02:56:47 -0700, [email protected] wrote:
> > This is how a state variable normally works:
> >
> > ➜ for ^2 { for ^2 { say (state $a)++ } }
> > 0
> > 1
> > 0
> > 1
> >
> > But when it is declared inside a {} interpolation in a string, it
> > misbehaves:
> >
> > ➜ for ^2 { for ^2 { say "{ (state $a)++ }" } }
> > 0
> > 1
> > 2
> > 3
> >
> > It's as if the state variable attaches to the scope of the outer loop
> > or mainline, instead of the inner loop like it should.
>
> Looks as if the code behaves as expected according to jnthn. See
> https://irclog.perlgeek.de/perl6-dev/2018-02-06#i_15783359
>
> Rejecting issue.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.