Revert "Lookup overloaded assignment operators when trying to swap the arguments"
authorRicardo Signes <rjbs@cpan.org>
Mon, 25 Feb 2013 16:01:17 +0000 (11:01 -0500)
committerRicardo Signes <rjbs@cpan.org>
Tue, 26 Feb 2013 15:40:57 +0000 (10:40 -0500)
This reverts commit f041cf0f9c6469c41de8b73d5f7b426710c3ff8b.

This is reverted in reference to [perl #113834].  Although this commit
does fix a real bug, it introduces a new one that is arguably worse.
More importantly, it is a regression from 5.16.0.  We should produce a
test case that solves both bugs, then solve them both, then get that in
place.  Before 5.18.0 would be nice.  After 5.18.0 may have to do.

gv.c
lib/overload.t

diff --git a/gv.c b/gv.c
index b8f0488..e8f5402 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -2736,16 +2736,9 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags)
               && (cvp = (AMT_AMAGIC((AMT*)mg->mg_ptr)
                          ? (amtp = (AMT*)mg->mg_ptr)->table
                          : NULL))
-              && ((cv = cvp[off=method+assignshift])
-                  || (assign && amtp->fallback > AMGfallNEVER && /* fallback to
-                                                                  * usual method */
-                      (
-#ifdef DEBUGGING
-                       fl = 1,
-#endif
-                       cv = cvp[off=method])))) { /* Method for right
-                                                   * argument found */
-       lr=1;
+              && (cv = cvp[off=method])) { /* Method for right
+                                            * argument found */
+      lr=1;
     } else if (((cvp && amtp->fallback > AMGfallNEVER)
                 || (ocvp && oamtp->fallback > AMGfallNEVER))
               && !(flags & AMGf_unary)) {
index afbe999..a90005d 100644 (file)
@@ -202,7 +202,7 @@ is($b, "89");
 is(ref $a, "Oscalar");
 is($copies, 1);
 
-eval q[package Oscalar; use overload ('+=' => sub {$ {$_[0]} += 3*"$_[1]";
+eval q[package Oscalar; use overload ('+=' => sub {$ {$_[0]} += 3*$_[1];
                                                   $_[0] } ) ];
 $c=new Oscalar;                        # Cause rehash