Open
Description
(copied from email)
Combining the experimental core class system with experimental refaliasing, here's an attempt to replace a field variable:
$ perl5.37.9 -Mexperimental=refaliasing,class -lwe 'class Foo { field $aa; method bb { print \$aa; } method cc { print \$aa; \$aa = \(my$x); print \$aa; } } $x = Foo->new; $x->bb; $x->cc; $x->bb;'
SCALAR(0x56013fda95f0)
SCALAR(0x56013fda95f0)
SCALAR(0x56013febfd80)
UNKNOWN(0x56013fda95f0)
zsh: segmentation fault perl5.37.9 -Mexperimental=refaliasing,class -lwe
How this ought to behave is up for debate. Maybe the replacement operation should croak, maybe it should affect the pad of the running method without affecting the field variable, and maybe it should replace the field variable in the object representation. But it certainly shouldn't do the above, prematurely freeing an SV and then segfaulting. It looks to me like this is doing a replacement in the pad but getting confused about the refcounting of the pad entry.
https://www.nntp.perl.org/group/perl.perl5.porters/2023/03/msg266060.html