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

Behavior of state vars in variations of do while inconsistent #5102

Open
p6rt opened this issue Jan 29, 2016 · 4 comments
Open

Behavior of state vars in variations of do while inconsistent #5102

p6rt opened this issue Jan 29, 2016 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 29, 2016

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

Searchable as RT127422$

@p6rt
Copy link
Author

p6rt commented Jan 29, 2016

From @ugexe

The following prints an incrementing count (expected)​:
`my $x = do { while ( 1 ) { state $a++; say $a; }; }; say $x;`
`do while ( 1 ) { state $a++; say $a; }; say $x;`

The following only prints `1`s (expected incrementing count)​:
`my $x = do while ( 1 ) state $a++; say $a; }; }; say $x;`

When `do` does not use braces it works as expected unless its also used in assignment.
When `do` does use braces it always works as expected.

@p6rt
Copy link
Author

p6rt commented Jan 29, 2016

From @smls

As another data point, the problem persists also when using parens instead of "do" to enforce return values​:

  (loop { state $a++; say $a; })[^5]

@p6rt
Copy link
Author

p6rt commented Jan 29, 2016

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

@p6rt
Copy link
Author

p6rt commented Feb 11, 2016

From @skids

See also #​117975 which might be related.

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant