CC: | anazawa [...] cpan.org |
Subject: | [PATCH] Compatibility with constants and with CV-in-stash optimisation |
Not every stash element is a typeglob. This has been the case at least as far back as perl 5.6. Hence, this module fails with packages containing constants declared via ‘use constant’. It also fails with a new optimization in bleadperl (details below). The attached patch fixed it to work on both counts.
From perl5276delta:
=head2 Subroutines no longer need typeglobs
Perl 5.22.0 introduced an optimization allowing subroutines to be stored in
packages as simple sub refs, not requiring a full typeglob (thus
potentially saving large amounts of memeory). However, the optimization
was flawed: it only applied to the main package.
This optimization has now been extended to all packages. This may break
compatibility with introspection code that looks inside stashes and expects
everything in them to be a typeglob.
When this optimization happens, the typeglob still notionally exists, so
accessing it will cause the stash entry to be upgraded to a typeglob. The
optimization does not apply to XSUBs or exported subroutines, and calling a
method will undo it, since method calls cache things in typeglobs.