diff options
-rw-r--r-- | lib/overload.pm | 2 | ||||
-rw-r--r-- | lib/overload.t | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/overload.pm b/lib/overload.pm index 8954551aa6..ed69440438 100644 --- a/lib/overload.pm +++ b/lib/overload.pm @@ -42,7 +42,7 @@ sub OVERLOAD { warnings::warnif("overload arg '$_' is invalid") unless $ops_seen{$_}; $sub = $arg{$_}; - if (not ref $sub and $sub !~ /::/) { + if (not ref $sub) { $ {$package . "::(" . $_} = $sub; $sub = \&nil; } diff --git a/lib/overload.t b/lib/overload.t index fed261dafb..7657010a2a 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -48,7 +48,7 @@ package main; $| = 1; BEGIN { require './test.pl' } -plan tests => 5051; +plan tests => 5053; use Scalar::Util qw(tainted); @@ -2297,6 +2297,20 @@ is eval {"$a"}, overload::StrVal($a), 'fallback is inherited by classes that have their own overloading' or diag $@; +# package separators in method names +{ + package mane; + use overload q\""\ => "bear::strength"; + use overload bool => "bear'bouillon"; +} +@bear::ISA = 'food'; +sub food::strength { 'twine' } +sub food::bouillon { 0 } +$a = bless[], mane::; +is eval { "$a" }, 'twine', ':: in method name' or diag $@; +is eval { !$a }, 1, "' in method name" or diag $@; + + { # undefining the overload stash -- KEEP THIS TEST LAST package ant; use overload '+' => 'onion'; |