---
title: "U2022: Integer literal does not fit its type"
url: https://una-lang.org/en/docs/errors/U2022/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U2022.md
---

# U2022: Integer literal does not fit its type

An integer literal is outside the range of the type it takes.

## Why Una rejects it

In edition 0.2, an integer literal takes the fixed-width type its context expects, such as an annotated `let`, a parameter, a field, a return or the other operand of an operator (`spec/18 §2`). A literal outside that type's range is U2022: `U8` holds `0` to `255`, `I8` holds `-128` to `127`, and so on.

A computed value that may leave the range is not U2022 but an `overflow` obligation (`spec/18 §3`).

In `requires`, `ensures` and `where` clauses, literals are mathematical integers, so U2022 does not apply there.

## How to fix it

- Write a literal that fits.
- Or give the value a wider type.

## The repair at a glance

`src/demo.una`

```diff
  module demo

- pub port() -> U16 = 70000
+ pub port() -> U16 = 8080
```

## Failing example

`una.toml`

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

`src/demo.una`

```una
module demo

pub port() -> U16 = 70000
```

## Fixed example

`una.toml`

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

`src/demo.una`

```una
module demo

pub port() -> U16 = 8080
```
