diff options
author | David Mitchell <davem@iabyn.com> | 2012-09-12 12:36:08 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2012-09-12 12:36:08 +0100 |
commit | 00bf6ed28afa283a66a5789008ed58cb0f9079e8 (patch) | |
tree | c2362b5c50d17fd8264b210f2a95d1d88f3a96b3 /lib/overload.t | |
parent | 610272b504c200c56babb5b7c6f94c27509aba15 (diff) | |
download | perl-00bf6ed28afa283a66a5789008ed58cb0f9079e8.tar.gz |
stop ""-overloaded Regex recursing
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.
Diffstat (limited to 'lib/overload.t')
-rw-r--r-- | lib/overload.t | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/overload.t b/lib/overload.t index 597c1f7d24..afbe99971b 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -48,7 +48,7 @@ package main; $| = 1; BEGIN { require './test.pl' } -plan tests => 5190; +plan tests => 5191; use Scalar::Util qw(tainted); @@ -2669,6 +2669,24 @@ is eval {"$a"}, overload::StrVal($a), 'fallback is stored under "()"'; } } +{ + # 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'; |