Subject: | Regexp references confuse Const::Fast |
This code:
say "zero level deep";
const my $zero => qr{123};
say "one level deep";
const my $one => { a => qr{123} };
say "two levels deep";
const my $two => { a => { b => qr{123} } };
dies while making C<$two> read-only.
The reason is a bit complicated:
- that inner hash has a refcount > 1 when seen from C<_make_readonly>
- so C<_make_readonly> tries to clone it
- but Storable refuses to touch regexes
I haven't been able to figure out exactly where all those references
are coming from, but one is definitely from C<@args> in C<const>.
Using L<Clone/clone> instead of L<Storable/dclone> makes the whole
thing work, regardless of refcounts.