mozilla/rust — Issue #1597: Associativity
Author: mikesamuel
Created: 2012-01-21 18:26:47+00:00
State: open

http://doc.rust-lang.org/doc/rust.html#operator-precedence says

"""
The precedence of Rust binary operators is ordered as follows, going from strong to weak:

...
= <- <->

Operators at the same precedence level are evaluated left-to-right.
"""

IMO, unparenthesized assignment operators should either be banned outright or should be right-associative as in other languages that have C-style operators.

The associativity mismatch will be especially confusing with the swap operator:

a.x <-> b.y <-> z

which when treated as left-associative will end up swapping what started in a.x into z instead of swapping what started in z into a.x.