Error codes

E0302: wrong number of values for a variant

In a terminal: auk explain E0302 prints this page.

On this page

Building an enum variant takes exactly one value per field, in order. The message says how many this variant has.

Wrong#

auk
enum Shape { Circle(r: float), Rect(w: float, h: float) }
fn square(): Shape = Rect(2.0)

Fixed#

auk
enum Shape { Circle(r: float), Rect(w: float, h: float) }
fn square(): Shape = Rect(2.0, 2.0)

Common causes#

  • A field added to the variant but not to every place that builds it.
  • A field-less variant called with (): write just Eof.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page