# New Ticket Created by Paweł Murias
# Please include the string: [perl #129817]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=129817 >
The contents of state variables is not preserved when serializing closures.
Bug is present b3c92baad264146f9e7dd7308f3064c3d7e18be2 and has been
implemented this way.
### Foo.pm
use v6;
# works when you turn precompilation off
#no precompilation;
module Foo {
my $closure = BEGIN {
say("compiling");
my $c := -> {
state $foo = 100;
$foo++;
$foo;
};
$c();
$c();
$c();
$c;
}
sub foo is export {
$closure();
}
}
### foo.p6
use Foo;
say(foo);