This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
overloading: make qr fallback to "" better
authorDavid Mitchell <davem@iabyn.com>
Mon, 18 Jun 2012 21:40:25 +0000 (22:40 +0100)
committerDavid Mitchell <davem@iabyn.com>
Tue, 19 Jun 2012 11:23:26 +0000 (12:23 +0100)
commite03b874abb33f381913aa76467fee51dbdc78263
tree8fca8f8e87d0e480fcbf75979029ab22f6b69544
parent5729ffdda207fd02149cc5ed14dbfdce8c47cac3
overloading: make qr fallback to "" better

With the re_eval jumbo fix, the behaviour of overloaded objects in
runtime patterns, such /^$overloaded/ has changed, such that the stringify
overload ("") no longer avoids the need for 'use re "eval"': for example,

    use overload "" => sub { qr/(??{1})/ }
    my $o = bless [];
    "1" =~ /^$o/;

works in 5.16.0, but dies with "Eval-group not allowed" in blead.

Change this back to the former behaviour, such that if qr and concat
ops aren't overloaded, then use "" overloading, and if the return from
that is a qr object, extract any code blocks from it.

This is achieved by:
* moving the concat/stringify code ahead of the regex block extraction
  code,
* making the overloaded stringify call be explicit (rather than
  being invoked implicitly by sv_catsv()),
* looping to re-apply overloading to any object returned by "".
* applying those last two steps in the case of a single arg too

This is a partial fix for
[perl #113682] Bleadperl v5.17.0-424-gd24ca0c breaks
    ABIGAIL/Regexp-Common-2011121001.tar.gz
regcomp.c
t/re/pat.t