128. Moves, overlapping mut places, and map defaults (2026-11-21)
- Decision. Returning a container is always O(1): returns move, never
copy.
let b = aon a heap value (List,Map,Str, structs holding them) is a move when it isa's last use and otherwise an error whose fix isa.clone(). Using a moved-from variable is a compile error; moving out of a place that stays alive isx.take(), which leaves it empty. Functions never take ownership of an argument: parameters are lends,mutparameters may mutate (andabsorb(mut other)may drain) but the caller keeps the variable. - Decision. Two
mutplaces in one container in the same call (f(mut a[i], mut a[j])) are a compile error unless the compiler proves them distinct. Changing a container's length while a place in it is lent (let x = mut xs[i]thenxs.push(...)) is a compile error, the same rule as overlapping slices (E0602). Both are "for now": a runtime distinctness check can relax the first later. - Decision.
m[k] += 1(any compound assignment into a map) inserts the value type's default for a missingkfirst. A plain read of a missing key isnoneforMapand the default forCounter. - Why. Costs stay visible (no silent deep copy), invalidation and aliasing bugs can't be written, and counting reads like the idea.
- Reverse. Implicit copies for
let b = a; runtime overlap checks;m[k] += 1on a missing key as an error. - Status. Accepted (Ryan, 2026-11-21). Audit current checker behaviour against each rule; implement the gaps with compile-fail tests.