diff options
-rw-r--r-- | lib/overload.pm | 2 | ||||
-rw-r--r-- | lib/overload.t | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/overload.pm b/lib/overload.pm index 109b7c5d86..71aeb7537f 100644 --- a/lib/overload.pm +++ b/lib/overload.pm @@ -63,6 +63,8 @@ sub unimport { $package = (caller())[0]; shift; for (@_) { + warnings::warnif("overload arg '$_' is invalid") + unless $ops_seen{$_}; delete $ {$package . "::"}{"(" . $_}; } } diff --git a/lib/overload.t b/lib/overload.t index a622cf7fc3..390ffab9c2 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -48,7 +48,7 @@ package main; $| = 1; BEGIN { require './test.pl' } -plan tests => 5050; +plan tests => 5051; use Scalar::Util qw(tainted); @@ -962,11 +962,16 @@ unless ($aaa) { my $a = "" ; local $SIG{__WARN__} = sub {$a = $_[0]} ; $x = eval ' use overload "~|_|~" => sub{} ' ; + eval ' no overload "~|_|~" ' ; is($a, ""); use warnings 'overload' ; $x = eval ' use overload "~|_|~" => sub{} ' ; like($a, qr/^overload arg '~\|_\|~' is invalid at \(eval \d+\) line /, 'invalid arg warning'); + undef $a; + eval ' no overload "~|_|~" ' ; + like($a, qr/^overload arg '~\|_\|~' is invalid at \(eval \d+\) line /, + 'invalid arg warning'); } { |