Home / Docs / Diagnostics
U2014: Expression outside the refinement language
Release v0.4.0
A clause or a predicate of checked holds an expression outside the refinement language. The diagnostic points at the outermost sub-expression outside the language.
Why Una rejects it
where, requires and ensures clauses, and the predicate of checked, are written in the refinement language, which the verifier decides (spec/03 §3). The language has:
- integer, boolean and text literals;
- parameters,
it,result, field access,.len; +,-,*with a literal operand,/andmodby a nonzero literal;- comparisons,
in,iswith a variant; and,or,not,implies;- calls of predicates.
How to fix it
- When the fix is mechanical, such as
x is Vforx == Vorx == 1forx is 1, the diagnostic carries an edit. - To use a function in a contract, state what it computes in the contract, or as a predicate.
The repair at a glance
diff
module demo
pub shift(x: Int) -> Int
- requires abs(x) < 100
+ requires x > -100 and x < 100
=
xFailing example
una
module demo
pub shift(x: Int) -> Int
requires abs(x) < 100
=
xFixed example
una
module demo
pub shift(x: Int) -> Int
requires x > -100 and x < 100
=
x