diff options
author | Rafael Garcia-Suarez <rgs@consttype.org> | 2012-03-20 09:17:02 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2012-05-22 09:51:28 +0200 |
commit | f041cf0f9c6469c41de8b73d5f7b426710c3ff8b (patch) | |
tree | 48959402387eaa4240dbb8f6bccfdbdc4e8848bb /lib/overload.t | |
parent | 12578451ab3883e1692ecd2814459f3e9f083028 (diff) | |
download | perl-f041cf0f9c6469c41de8b73d5f7b426710c3ff8b.tar.gz |
Lookup overloaded assignment operators when trying to swap the arguments
This is in the case where we search for an overloaded operator when
passing the AMGf_assign flag (we're executing an assignment operator
like +=).
At the very beginning of Perl_amagic_call, if the flag AMGf_noleft is
not passed, we first try to look up the overload method corresponding
to the assignment operator, then the normal one if fallback is
authorized. However, if this fails, when trying later to find
overload magic with the arguments swapped (if AMGf_noright is not
passed), this procedure was not used and we looked up directly the base
operation from which the assignment operator might be derived.
As a consequence of what an operator like += might have looked
autogenerated even when fallback=>0 was passed.
This change only necessitates a minor adjustment in lib/overload.t,
where an overloaded += method wasn't corresponding semantically to the
overloaded + method of the same class, which can be seen as a
pathological case.
Diffstat (limited to 'lib/overload.t')
-rw-r--r-- | lib/overload.t | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/overload.t b/lib/overload.t index df3a9b825d..0304714356 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -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 |