Error codes

E0292: the unit of a power or root can't be computed

In a terminal: auk explain E0292 prints this page.

On this page

The compiler computes units at compile time, so x ** n on a value with a unit needs n to be an integer literal (d ** 2.0 is m^2), an exponent can't have a unit, and sqrt needs every exponent to be even (sqrt of m^2 is m, of m it has no unit).

Wrong#

auk
fn side(area: float<m>): float<m> = sqrt(area)

Fixed#

auk
fn side(area: float<m^2>): float<m> = sqrt(area)

Common causes#

  • A variable exponent: strip the unit first, float(x) ** n.
  • sqrt of a value whose unit has an odd exponent.

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