Error codes

E0291: mismatched units of measure

In a terminal: auk explain E0291 prints this page.

On this page

A value's unit differs from the unit expected there: a function argument, a return value, a let with a type, a field or an assignment. The types are otherwise the same (float<m> where float<s> is expected). float(x) (or int(x)) is the explicit way to drop a unit.

Wrong#

auk
fn speed(d: float<m>, t: float<s>): float<m/s> = d * t

Fixed#

auk
fn speed(d: float<m>, t: float<s>): float<m/s> = d / t

Common causes#

  • A formula that multiplies where it should divide (the unit shows the mistake).
  • A plain number where a unit is expected: write the literal with a unit, 2.0<m>.
  • A unit value passed to a function taking a plain float: strip it with float(x).

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