summaryrefslogtreecommitdiff
path: root/lib/overload.t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-05-23 01:05:20 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-05-23 06:01:23 -0700
commit3866ea3be51f0998b848d22c4ef960965bda7199 (patch)
tree0bdd788345c8cb865f6aa7c4358c6896c38867ea /lib/overload.t
parent1204c818c5b6fdbe987017df9f2ce0e68463f315 (diff)
downloadperl-3866ea3be51f0998b848d22c4ef960965bda7199.tar.gz
[perl #113050] Put fallback back under "()"
Unfortunately, there is code all over CPAN that assumes fallback is stored under the "()" stash entry. And that code also assumes that the overloadedness flag (the existence of the CV) is in the same spot. So much for encapsulation. This commit changes overloading itself to use a different key, "((", while having it search for "()" first, and then "((" only if "()" is not found, to preserve compatibility with encapsulation-breaking code. So the "((" key will only be used by gv.c if there is no fallback value specified at all.
Diffstat (limited to 'lib/overload.t')
-rw-r--r--lib/overload.t13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/overload.t b/lib/overload.t
index df3a9b825d..72e3b6e621 100644
--- a/lib/overload.t
+++ b/lib/overload.t
@@ -48,7 +48,7 @@ package main;
$| = 1;
BEGIN { require './test.pl' }
-plan tests => 5081;
+plan tests => 5082;
use Scalar::Util qw(tainted);
@@ -2313,6 +2313,17 @@ $a = bless[], mane::;
is eval { "$a" }, 'twine', ':: in method name' or diag $@;
is eval { !$a }, 1, "' in method name" or diag $@;
+# [perl #113050] Half of CPAN assumes fallback is under "()"
+{
+ package dodo;
+ use overload '+' => sub {};
+ no strict;
+ *{"dodo::()"} = sub{};
+ ${"dodo::()"} = 1;
+}
+$a = bless [],'dodo';
+is eval {"$a"}, overload::StrVal($a), 'fallback is stored under "()"';
+
{ # undefining the overload stash -- KEEP THIS TEST LAST
package ant;