-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hints hash should not store references #37
Comments
The problem can be reproduced without Function::Parameters or Regexp::Grammars: #!/usr/bin/env perl
use strict;
use warnings;
use re 'eval';
use overload ();
BEGIN {
overload::constant qr => sub {
qq{(?{ "\\N{EURO SIGN}" })}
};
}
use charnames qw(:full);
qr/a/;
__END__ Result:
I cribbed the use of %^H from charnames.pm. If Function::Parameters is broken, then so is the PS: |
I've reported it as Perl/perl5#20950 for now. |
I dont really get what you want to do here.
Is it deliberate you are using (?{ ... }) and not (??{ ... }) ? I dont really get what you are trying to do here. You want to change all qr//'s to return a deferred pattern match the euro-sign? It feels like there are multiple ways to do what you want to do that would work. |
@demerphq As mentioned in https://rt.cpan.org/Ticket/Display.html?id=128044, what the user was trying to do was: use Function::Parameters;
use Regexp::Grammars;
qr{ <grammar:Sympa::Scenario> }x; Which results in the this error:
As you can see on https://metacpan.org/release/DCONWAY/Regexp-Grammars-1.058/source/lib/Regexp/Grammars.pm, the Regexp::Grammars module is 2700 lines of code, so naturally I tried to reduce the code to something simpler first. Regexp::Grammars does many different things. Among them:
The code for the latter looks like return qq{(?{
warn "Can't match directly against a pure grammar: <grammar: $grammar_name>\n";
})(*COMMIT)(?!)}; So at this point, we have an overloaded This is what triggers the error inside Function::Parameters. However, despite what Damian claims, you can put references in
Function::Parameters uses a similar mechanism. Thus, as a general rule, any code that breaks because Function::Parameters puts references in That's why my reduced code uses charnames instead of Function::Parameters. All other elements were taken from Regexp::Grammars. I later realized that overloading is not necessary to reproduce the issue:
All you need is dynamically eval'd regex code that tries to read what should be a reference from |
I've put a workaround into Function::Parameters. If the BTW, the reason why this error even happens for
|
This was discussed already on RT:
But I think it worth giving this some visibility there.
It's a bad idea to store references in the Hash Hint a.k.a.
%^H
A quick grep show that both the .pm and .xs code need some fixup
It appears that this is the only CPAN module to store
HINTK_CONFIG
there so this should be safe, to move it to a better location.https://grep.metacpan.org/search?size=20&q=HINTK_CONFIG&qd=&qft=
Maybe a GV in Function::Parameters itself?
The text was updated successfully, but these errors were encountered: