---
title: "U1002: Duplicate definition"
url: https://una-lang.org/en/docs/errors/U1002/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U1002.md
---

# U1002: Duplicate definition

U1002 reports a name that is defined more than once in its scope.

## Why Una rejects it

A name is defined once in its scope:

- the declarations of a module (kinds, variants and capabilities share one namespace; functions, predicates, handlers and policies another),
- the parameters, fields and operations of one declaration,
- the requirements of a package,
- the examples of a module (the tests, written `test` in edition 0.3).

A local binding cannot rebind another local that is still in scope, so every use of a name inside a function means one binding. A module may reuse a prelude name, and a local may reuse any name that is not local: the inner one wins.

In edition 0.2, a kind, a variant or a capability cannot take the name of a built-in type (`Int`, `Nat`, `Bool`, `Text`, `Unit`, `Hashed`, `List`, `Option`, `Result`, the fixed-width integer types, `Map` and `Entry`): `pub kind Text = Short | Long` is U1002, since it would silently replace `Text` in its module (ADR 0079).

## The repair at a glance

```diff
  module demo

  pub double(x: Int) -> Int
  =
-   let x = x * 2
-   x
+   let doubled = x * 2
+   doubled
```

## Failing example

```una
module demo

pub double(x: Int) -> Int
=
  let x = x * 2
  x
```

## Fixed example

```una
module demo

pub double(x: Int) -> Int
=
  let doubled = x * 2
  doubled
```
