develooper Front page | perl.perl5.porters | Postings from March 2013

Re: [perl #116823] Regexp::Grammars broken since 5.17.1

Thread Previous | Thread Next
March 27, 2013 10:58
Re: [perl #116823] Regexp::Grammars broken since 5.17.1
Message ID:
Dave Mitchell wrote:
>1) the test script (and thus presumably Regexp::Grammars) only worked
>because it was inadvertently exploiting a hole in the "use re eval"
>mechanism, and that perl 5.17.x is correctly refusing to execute the code;

The qr constant overloading behaves in a rather strange way, compared to
operator overloading.  After the R:G:Precursor object has been built up
by the constant-overload function, it gets stringified, invoking the ""
operator overload on R:G:Precursor.  The problem is that the resulting
string gets compiled to a regexp object by the core, not by the module
or the calling program: where the re-eval setting matters, there's no
way to set it.

You'd think you could avoid this problem by making R:G return a compiled
regexp somewhere instead of a string: it can set re-eval for its explicit
compilation.  But the core is apparently quite insistent on reducing
the qr-constant to a string.  If the constant-overload function returns
a compiled regexp, that gets stringified.  If the "" operator overload
returns a compiled regexp, that gets stringified.  If the "" operator
overload returns a ref to an object with more operator overloading,
that gets stringified.  qr operator overloading never gets invoked.

I reckon the qr constant overload should be allowed to return a compiled
regexp, to be used as-is rather than stringified.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About