18. Operator and precedence summary
(Working draft; see parser implementation for ground truth.)
| Level | Operators | Assoc |
|---|---|---|
| low | or | left |
and | left | |
not (prefix) | right | |
== != < > <= >= | left | |
+ - | left | |
* / // % | left | |
- (unary), async / await / throw / meta (prefix) | right | |
. (method/assoc-fn call), (...), [...] | left |
async / await / throw / meta bind tighter than every binary operator, so await f == 1i32 is (await f) == 1i32, not await (f == 1i32). The operand is itself a unary expression, so await await f and await -x are also legal.
Operator meaning is type-directed: numerics keep their width-exact opcodes for + - * / // %; ==/!= dispatch through Eq, </<=/>/>= through Ord, and non-numeric +/- through Add/Sub (§10) with the impl's Output as the result type. * / // % have no trait routing (recorded future scope).