Description
The method call-assign syntax is very nice, and widely used in the ecosystem:
https://gist.github.com/lizmat/9b2495d0d5e8fbc59a79e11ca153deb9
However, over the years many issues have been made about the apparent malfunctioning of .= bar.baz
, of which #5803 is the most recent.
The problem is really that when one write $foo .= bar.baz
, one is in fact writing ($foo .= bar).baz
. The normal cause of action in case of precedence issues, is to add parentheses to indicate the precedence wanted. However, that is NOT possible with the methodcall-assign syntax. $foo .= (bar.baz)
will be interpreted as calling the baz
method of the result of the call on the bar
subroutine.
However, the $foo .= bar.baz
syntax is executed without any issues as ($foo .= bar).baz
, which just silently drops the result of the .baz
method call.
So it feels like we should do one or more of these actions:
- document this specific behaviour of
.=
better (as it's different from otherop=
metaops) - allow the
$foo .= (bar.baz)
to actually interpretbar
as a method call on$foo
, instead of a sub call - drop the precedence of
.=
, so that$foo .= bar.baz
DWIM