Skip to content
TE129 · Type · error

Tuple-assignment value-count mismatch

A tuple-destructuring assignment (`(a, b, c) = expr`) has a different number of targets than `expr` has values.

Why this fires

A tuple-destructuring assignment ((a, b, c) = expr) has a different number of targets than expr has values.

fn pair() -> (int, int) { return (1, 2) }

fn f() {
    var a = 1
    var b = 2
    var c = 3
    (a, b, c) = pair()
    //          ^^^^^^ error[TE129]: tuple assignment expects 3 values, got 2
}

Fix it

Match the target count to the value count:

fn f() {
    var a = 1
    var b = 2
    (a, b) = pair()          // ok — 2 targets for a 2-tuple
}

Use _ to discard a value you don't need without changing the count:

fn f() {
    var a = 0
    (a, _) = pair()          // ok — discards the second value
    print(a)
}

See also

  • TE005 — a type mismatch in one tuple-assignment slot.
  • TE130 — destructuring assignment only supports =.
  • /docs/pattern-matching — destructuring assignment.

See also

Search Zolo

9 results

en