Subject: | Re: v0.04 breaks Keyword::Declare under Perl 5.16.3 |
Date: | Sun, 10 Jun 2018 14:59:50 +1000 |
To: | bug-Keyword-Simple [...] rt.cpan.org |
From: | Damian Conway <damian [...] conway.org> |
Hi Lukas,
I reported this bug back in December and I now have more information
for you (because I am getting downstream bug reports against
Keyword::Declare, which uses this module).
Keyword::Simple 0.04 fails because you are attempting to store a hash
reference in $^H{"Keyword::Simple/keywords"}.
However, the perlpragma manpage states:
Implementation details
The optree is shared between threads. This means there is a
possibility that the optree will outlive the particular thread (and
therefore the interpreter instance) that created it,
*so true Perl scalars cannot be stored in the optree*. Instead a
compact form is
used, which can only store values that are integers (signed and
unsigned), strings or "undef" −
*references and floating point values are stringified*. If you need
to store multiple values or complex
structures, you should serialise them, for example with "pack".
And, indeed, under Perl 5.14 and 5.16 the error message is:
Keyword::Simple: internal error: $^H{'Keyword::Simple/keywords'} not a
hashref: HASH(0x7feec6822d98)
presumably because the hashref was stringified within the optree, as the
manpage says.
I don't know why it works under 5.18 and later, but that may be fragile too,
unless the internal %^H mechanism was changed and manpage is now out of
date
with respect to those Perl releases.
Meanwhile I have appended the simplest example I could construct that
demonstrates
the problem.
Damian
-----cut----------cut----------cut----------cut----------cut----------cut----------cut-----
#! /usr/bin/env perl
use Keyword::Declare;
keyword test (Int* @n) {{{ print "ok\n" if <{ $n[0] }> == 3; }}}
BEGIN {
use Data::Dumper 'Dumper';
warn Dumper \%^H;
}
test 3;