There was code to detect this, but it checked for the returned value being
the same as before, but in this case it was returning a *new* temporary
reference to the same Regexp object; so check for that too.
$| = 1;
BEGIN { require './test.pl' }
-plan tests => 5190;
+plan tests => 5191;
use Scalar::Util qw(tainted);
}
}
+{
+ # Making Regexp class overloaded: avoid infinite recursion.
+ # Do this in a separate process since it, well, overloads Regexp!
+ fresh_perl_is(
+ <<'EOF',
+package Regexp;
+use overload q{""} => sub {$_[0] };
+package main;
+my $r1 = qr/1/;
+my $r2 = qr/ABC$r1/;
+print $r2,"\n";
+EOF
+ '(?^:ABC(?^:1))',
+ { stderr => 1 },
+ 'overloaded REGEXP'
+ );
+}
+
{ # undefining the overload stash -- KEEP THIS TEST LAST
package ant;
use overload '+' => 'onion';
else {
while (SvAMAGIC(msv)
&& (sv = AMG_CALLunary(msv, string_amg))
- && sv != msv)
- {
+ && sv != msv
+ && !( SvROK(msv)
+ && SvROK(sv)
+ && SvRV(msv) == SvRV(sv))
+ ) {
msv = sv;
SvGETMAGIC(msv);
}