Home / Docs / Diagnostics

U2001: Type mismatch

Release v0.4.0

An expression does not have the type expected where it appears. The message names the type expected and the type found.

Why Una rejects it

Every expression has a type, and where a type is expected, by a declaration, a parameter, an operator or the other branches of an if or when, the expression must have that type (spec/10).

Types are compared by their base: a refined kind such as Seats is its base Int, so its refinement becomes a proof obligation rather than a mismatch (spec/03 §6).

U2001 also reports:

The repair at a glance

diff
  module demo

- pub label(count: Int) -> Text = count
+ pub label(count: Int) -> Text = "{count}"

Failing example

una
module demo

pub label(count: Int) -> Text = count

Fixed example

una
module demo

pub label(count: Int) -> Text = "{count}"