Skip Menu |

This queue is for tickets about the Keyword-Simple CPAN distribution.

Report information
The Basics
Id: 125540
Status: open
Priority: 0/
Queue: Keyword-Simple

People
Owner: Nobody in particular
Requestors: damian [...] conway.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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;
The documentation is not entirely clear, but it is saying that the storage /in the optree/ cannot be references. The %^H variable is perfectly capable of storing references, andthey can be used at compile time. They just aren't accessibly at runtime via caller. Several built in perl features rely on this feature, including constant overloads and custom charnames translators. There is no real problem with what Keyword::Simple is doing. Keyword::Declare is bypassing Keyword::Simple's interface and playing with its internals. It shouldn't be surprising that this can break.