---
title: "U2029: An invalid unit declaration or unit expression"
url: https://una-lang.org/en/docs/errors/U2029/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U2029.md
---

# U2029: An invalid unit declaration or unit expression

A unit declaration or a unit expression is invalid.

## Why Una rejects it

A unit is declared with `measure` (ADR 0104):

- a base unit by its name;
- a derived unit by an expression of declared units and positive integer factors, as `measure Kilometer = 1000 * Meter`.

A unit expression names only declared units, a derived unit does not refer to itself, and one with no base unit and scale 1 is refused, since it would be no unit at all.

`of` follows only a number type: an integer type or `F64`, and in edition `0.5` (preview) `F32`, `Decimal[s]`, `Complex[F64]` and `Complex[F32]`.

## The repair at a glance

`src/demo.una`

```diff
  module demo

  pub measure Meter

- pub distance(d: Int of Meters) -> Int of Meter = d
+ pub distance(d: Int of Meter) -> Int of Meter = d
```

## Failing example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"
```

`src/demo.una`

```una
module demo

pub measure Meter

pub distance(d: Int of Meters) -> Int of Meter = d
```

## Fixed example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"
```

`src/demo.una`

```una
module demo

pub measure Meter

pub distance(d: Int of Meter) -> Int of Meter = d
```
