summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/overloading.t15
-rw-r--r--sv.c5
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/overloading.t b/lib/overloading.t
index 2e1fb40ffc..787edb1b9d 100644
--- a/lib/overloading.t
+++ b/lib/overloading.t
@@ -1,6 +1,6 @@
#./perl
-use Test::More tests => 35;
+use Test::More tests => 46;
use Scalar::Util qw(refaddr);
@@ -18,20 +18,25 @@ use Scalar::Util qw(refaddr);
}
my $x = Stringifies->new;
+my $y = qr//;
+my $ystr = "$y";
is( "$x", "foo", "stringifies" );
+is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, 42, "numifies" );
is( cos($x), "far side of overload table", "cosinusfies" );
{
no overloading;
is( "$x", overload::StrVal($x), "no stringification" );
+ is( "$y", overload::StrVal($y), "no stringification of qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), cos(refaddr($x)), "no cosinusfication" );
{
no overloading '""';
is( "$x", overload::StrVal($x), "no stringification" );
+ is( "$y", overload::StrVal($y), "no stringification of qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), cos(refaddr($x)), "no cosinusfication" );
}
@@ -41,12 +46,14 @@ is( cos($x), "far side of overload table", "cosinusfies" );
no overloading '""';
is( "$x", overload::StrVal($x), "no stringification" );
+ is( "$y", overload::StrVal($y), "no stringification of qr//" );
is( 0 + $x, 42, "numifies" );
is( cos($x), "far side of overload table", "cosinusfies" );
{
no overloading;
is( "$x", overload::StrVal($x), "no stringification" );
+ is( "$y", overload::StrVal($y), "no stringification of qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), cos(refaddr($x)), "no cosinusfication" );
}
@@ -54,34 +61,40 @@ is( cos($x), "far side of overload table", "cosinusfies" );
use overloading '""';
is( "$x", "foo", "stringifies" );
+ is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, 42, "numifies" );
is( cos($x), "far side of overload table", "cosinusfies" );
no overloading '0+';
is( "$x", "foo", "stringifies" );
+ is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), "far side of overload table", "cosinusfies" );
{
no overloading '""';
is( "$x", overload::StrVal($x), "no stringification" );
+ is( "$y", overload::StrVal($y), "no stringification of qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), "far side of overload table", "cosinusfies" );
{
use overloading;
is( "$x", "foo", "stringifies" );
+ is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, 42, "numifies" );
is( cos($x), "far side of overload table", "cosinusfies" );
}
}
is( "$x", "foo", "stringifies" );
+ is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), "far side of overload table", "cosinusfies" );
no overloading "cos";
is( "$x", "foo", "stringifies" );
+ is( "$y", $ystr, "stringifies qr//" );
is( 0 + $x, refaddr($x), "no numification" );
is( cos($x), cos(refaddr($x)), "no cosinusfication" );
diff --git a/sv.c b/sv.c
index c1ece77d99..2dce137220 100644
--- a/sv.c
+++ b/sv.c
@@ -2809,7 +2809,10 @@ Perl_sv_2pv_flags(pTHX_ register SV *const sv, STRLEN *const lp, const I32 flags
if (!referent) {
len = 7;
retval = buffer = savepvn("NULLREF", len);
- } else if (SvTYPE(referent) == SVt_REGEXP) {
+ } else if (SvTYPE(referent) == SVt_REGEXP && (
+ !(PL_curcop->cop_hints & HINT_NO_AMAGIC)
+ || amagic_is_enabled(string_amg)
+ )) {
REGEXP * const re = (REGEXP *)MUTABLE_PTR(referent);
I32 seen_evals = 0;