summaryrefslogtreecommitdiff
path: root/lib/overload.pm
diff options
context:
space:
mode:
authorGraham Knop <haarg@haarg.org>2022-10-19 17:30:26 +0200
committerGraham Knop <haarg@haarg.org>2022-10-24 15:40:43 +0200
commitdd770c51a6cb49a3f8d99bd2c9918b4e692a298c (patch)
treeb845239980f884fabf1ddd9e5ef7df723299466d /lib/overload.pm
parent7bbbab6355eb372544cd7b8c9e17b2396f4c6362 (diff)
downloadperl-dd770c51a6cb49a3f8d99bd2c9918b4e692a298c.tar.gz
overload: only disable builtin warnings where blessed is called
Until recently, overload did not enable or disable any warnings. Instead, it would rely on the value of $^W, or the -w flag. When switching to use the builtin::blessed function, the code was changed to disable 'experimental::builtin' warnings. Since no other warnings are changed, the current active warning set is combined with this one disabled category, and baked in for the entire module. The currently active warning set is determined by $^W, so whatever its value was when overload was compiled would get baked in, and any runtime changes to $^W would no longer have any impact. The particular warning that would most commonly be emitted by overload is the sub redefinition warning, in case an overload was being overwritten. Various modules, such as JSON::PP and Cpanel::JSON::XS, were expecting to be able to overwrite overloads without any warnings. They would set $^W to false to prevent them. After the "no warnings 'experimental::builtin';" line was added, it became impossible to disable these warnings at runtime. Move the disabling of the experimental warnings to a smaller scope. This means that the rest of the module is restored to its previous state of having warnings controlled by $^W.
Diffstat (limited to 'lib/overload.pm')
-rw-r--r--lib/overload.pm2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/overload.pm b/lib/overload.pm
index 11df8e08d6..f70678958c 100644
--- a/lib/overload.pm
+++ b/lib/overload.pm
@@ -2,7 +2,6 @@ package overload;
use strict;
no strict 'refs';
-no warnings 'experimental::builtin';
our $VERSION = '1.35';
@@ -100,6 +99,7 @@ sub OverloadedStringify {
sub Method {
my $package = shift;
if (ref $package) {
+ no warnings 'experimental::builtin';
$package = builtin::blessed($package);
return undef if !defined $package;
}