Xo is experimental. The source code is not public yet; it will be soon. Read the release notes
Menu · XO0520

Docs

XO0520: mutation of a copied or stored collection element is never written back

error · reported by the checker

Xo collections hold values, not references. A local var initialized from a collection element (m.get(k), m[k], xs[i], first, find, optionally with ??, ?, or .or_err(...)?) and then mutated changes only the copy; the collection keeps the old value. The same holds for a var mutated after being pushed or put into a collection. Store it again (m.put(k, b)), or use m.update(k, init, fn(var b) { ... }). Reading or returning the copy does not count as storing. See core 5.2.

Example

struct Bucket { tokens: Int }

fn take(m: Map[Str, Bucket], k: Str) {
  var b = m.get(k) ?? Bucket{tokens: 3}
  b.tokens -= 1
}

Fix

struct Bucket { tokens: Int }

fn take(var m: Map[Str, Bucket], k: Str) {
  var b = m.get(k) ?? Bucket{tokens: 3}
  b.tokens -= 1
  m.put(k, b)
}

Run xo explain XO0520 for this text in a terminal, or see section 10.6 of the specification.