Closed sdt closed 6 years ago
This is arguably a bug in Sub::Quote:
use strict;
use warnings;
use Sub::Quote qw( quote_sub );
print "\N{DEGREE SIGN}_\N{DEGREE SIGN}\n";
my $subref = quote_sub 'print "\N{INVERTED EXCLAMATION MARK}Hola, mundo!\n"';
$subref->();
Output:
$ perl try.pl
°_°
Eval went very, very wrong:
1: {
2: my $_QUOTED = ${$_[1]->{"\$_QUOTED"}};
3: my $_UNQUOTED = ${$_[1]->{"\$_UNQUOTED"}};
4: package main;
5: $$_UNQUOTED = sub {
6: ($_QUOTED,$_UNQUOTED) if 0;
7: # BEGIN quote_sub PRELUDE
8: package main;
9: BEGIN {
10: $^H = 133090;
11: ${^WARNING_BITS} = "UUUUUUUUUUUUUUUU\025";
12: %^H = (
13: "charnames" => "CODE(0x91994d0)",
14: "charnames_inverse_ords" => "HASH(0x91665f0)",
15: "charnames_stringified_names" => "",
16: "charnames_loose" => 0,
17: "charnames_short" => 1,
18: "charnames_name_aliases" => "HASH(0x9166010)",
19: "charnames_scripts" => "",
20: "charnames_stringified_ords" => "",
21: "charnames_ord_aliases" => "HASH(0x91493b0)",
22: "charnames_full" => 1,
23: "charnames_stringified_inverse_ords" => "",
24: );
25: }
26: # END quote_sub PRELUDE
27: print "\N{INVERTED EXCLAMATION MARK}Hola, mundo!\n" };
28: }
29: 1;
Undefined subroutine &main::CODE(0x91994d0) called at (eval 6) line 27.
at try.pl line 7.
Reported as https://rt.cpan.org/Ticket/Display.html?id=122698.
I could put a workaround into Function::Parameters. The effect would be to effectively disable Function::Parameters in quote_sub
code. This wouldn't throw an error, but custom keywords wouldn't be available either. Would that be a good thing?
Thanks for looking into this.
Your suggested workaround would work for me, but I can work around this pretty easily, so don't add any hacks just on account of me.
Closing this for now because it's not a bug in Function::Parameters and I don't intend to work on this (unless someone requests it).
The following code causes an internal error in 2.001001
The error is
The error is not present in 2.000007
If I remove
:strict
and just haveuse Function::Parameters qw( );
it works.