Skip to content
ZOLO / TE830 Type · error

enum pattern has the wrong payload shape

Compiler diagnostic TE830: enum pattern has the wrong payload shape.

Why this fires

An enum pattern names a real variant but destructures it with the wrong payload shape. Unit, tuple, and struct variants have distinct pattern forms, and tuple arity and struct fields must agree with the declaration.

enum Event {
    Done,
    Pair(int, int),
    Click { x: int, y: int },
}

match event {
    Event::Done(value) => value,       // TE830: `Done` is unit
    Event::Pair(value) => value,       // TE830: expected two elements
    Event::Click(value) => value,      // TE830: use `{ ... }`
}

TE830 also reports unknown or duplicate named fields and omitted fields when the pattern has no .. rest marker.

Fix it

Mirror the variant declaration in the pattern:

match event {
    Event::Done => 0,
    Event::Pair(left, right) => left + right,
    Event::Click { x, y } => x + y,
}

Use .. when intentionally ignoring named fields:

Event::Click { x, .. } => x

Notes

  • Tuple variants require exactly the declared number of subpatterns.
  • Unit variants accept no tuple or struct payload.
  • Struct variants reject unknown and duplicate field names.
  • Omitting declared struct fields is allowed only with an explicit ...
  • An unknown variant name is reported separately as TE133.

See also

  • TE829 — a closed match does not cover every value.
  • TE831 — or-pattern alternatives expose incompatible bindings.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

en