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 never initialized if the first call of the containing block does not reach them #2548
Comments
From @moritz16:28 < moritz> perl6: sub f($x) { return if $x == 1; state %h = a => 1; I'm pretty sure that's a bug (and not limited to hashes, same for scalar I've added a test to S04-declarations/state.t |
From @cokeOn Sat Nov 05 09:12:36 2011, moritz wrote:
Bug still present in rakudo-moar 079da9 -- |
The RT System itself - Status changed from 'new' to 'open' |
From @nwc10On Fri, Aug 19, 2016 at 11:05:07AM -0700, Will Coleda via RT wrote:
$ perl -E 'sub f { my $x = shift; return if $x == 1; state $h = 42; say $h; }; f 1; f 2;' Works on Perl 5 :-) I thought that the Perl 6 implementation of state had overtaken the Perl 5 The Perl 5 implementation (which is a hack) stores the START-ness as a flag It's the 'once' op at position 'f', which the first time branches to 'g' Note that the 'once' op has the lexical $h as an argument, so that it can $ perl -MO=Concise,f,-exec -E 'sub f { my $x = shift; return if $x == 1; state $h = 42; say $h; }; f 1; f 2;' Nicholas Clark |
Rakudo is still returning the same thing: |
This probably comes down to |
Migrated from rt.perl.org#102994 (status was 'open')
Searchable as RT102994$
The text was updated successfully, but these errors were encountered: