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:
- values that
==cannot compare because they hold functions, <on a type without an order,- interpolation, in edition
0.1, of a type other thanInt,BoolandText, and from edition0.2, of a value whose type holds a function or aHashed, - a call with the wrong number of arguments,
attempton something other than one call,- a type that inference cannot determine, such as the element type of an unused empty list.
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 = countFixed example
una
module demo
pub label(count: Int) -> Text = "{count}"