Home / Docs / Diagnostics
U0101: Unexpected token
Release v0.4.0
The parser found a token that the grammar of spec/02 does not allow at that point. The message names the token found and what was expected. After the error, parsing resumes at the next declaration, so the rest of the file is still checked.
Why Una rejects it
U0101 also reports:
- brackets left unbalanced within a declaration,
- chained comparisons such as
a < b < c(spec/01 §7), - keywords such as
ifused as names, - nested patterns such as
is Some(Circle(radius)), which no edition supports, - literal patterns such as
is Some(0), - nesting deeper than 256 levels, where each chained operator counts as one level (ADR 0019).
How to fix it
- For a nested pattern such as
is Some(Circle(radius)), bind the field to a name, then match that name in a secondwheninside the arm. - For a literal pattern such as
is Some(0), bind the field to a name, then match it in a secondwhenwith a literal arm andelse, or compare it inside the arm.
The repair at a glance
diff
module demo
- pub between(x: Int) -> Bool = 0 < x < 10
+ pub between(x: Int) -> Bool = 0 < x and x < 10Failing example
una
module demo
pub between(x: Int) -> Bool = 0 < x < 10Fixed example
una
module demo
pub between(x: Int) -> Bool = 0 < x and x < 10