diff options
Diffstat (limited to 'dist')
-rw-r--r-- | dist/Carp/lib/Carp.pm | 6 | ||||
-rw-r--r-- | dist/Carp/t/vivify_gv.t | 5 | ||||
-rw-r--r-- | dist/Carp/t/vivify_stash.t | 5 |
3 files changed, 13 insertions, 3 deletions
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm index 44dc0fbfb3..60df58ff1b 100644 --- a/dist/Carp/lib/Carp.pm +++ b/dist/Carp/lib/Carp.pm @@ -236,7 +236,11 @@ sub format_arg { } else { - $arg = defined(&overload::StrVal) ? overload::StrVal($arg) : "$arg"; + no strict "refs"; + $arg = exists($::{"overload::"}) && + exists(*{$::{"overload::"}}{HASH}->{"StrVal"}) && + defined(*{*{$::{"overload::"}}{HASH}->{"StrVal"}}{CODE}) ? + &{"overload::StrVal"}($arg) : "$arg"; } } if ( defined($arg) ) { diff --git a/dist/Carp/t/vivify_gv.t b/dist/Carp/t/vivify_gv.t index 3ed9912093..62602a4e88 100644 --- a/dist/Carp/t/vivify_gv.t +++ b/dist/Carp/t/vivify_gv.t @@ -1,11 +1,14 @@ -BEGIN { print "1..2\n"; } +BEGIN { print "1..3\n"; } our $has_is_utf8; BEGIN { $has_is_utf8 = exists($utf8::{"is_utf8"}); } our $has_dgrade; BEGIN { $has_dgrade = exists($utf8::{"downgrade"}); } +our $has_strval; BEGIN { $has_strval = exists($overload::{"StrVal"}); } use Carp; +sub { Carp::longmess() }->(\1); print !(exists($utf8::{"is_utf8"}) xor $has_is_utf8) ? "" : "not ", "ok 1\n"; print !(exists($utf8::{"downgrade"}) xor $has_dgrade) ? "" : "not ", "ok 2\n"; +print !(exists($overload::{"StrVal"}) xor $has_strval) ? "" : "not ", "ok 3\n"; 1; diff --git a/dist/Carp/t/vivify_stash.t b/dist/Carp/t/vivify_stash.t index 7906748a4f..226f960446 100644 --- a/dist/Carp/t/vivify_stash.t +++ b/dist/Carp/t/vivify_stash.t @@ -1,9 +1,12 @@ -BEGIN { print "1..1\n"; } +BEGIN { print "1..2\n"; } our $has_utf8; BEGIN { $has_utf8 = exists($::{"utf8::"}); } +our $has_overload; BEGIN { $has_overload = exists($::{"overload::"}); } use Carp; +sub { Carp::longmess() }->(\1); print !(exists($::{"utf8::"}) xor $has_utf8) ? "" : "not ", "ok 1\n"; +print !(exists($::{"overload::"}) xor $has_overload) ? "" : "not ", "ok 2\n"; 1; |