Home / Docs / Diagnostics
U7003: Escape budget exceeded
Release v0.4.0
A module uses checked more times than its budget allows. U7003 reports the first use beyond the budget, with the later uses as related locations.
Why Una rejects it
checked replaces a static proof with a runtime test, so each module may use it only as many times as [escape_budget] checked_per_module in una.toml, or from edition 0.4 checked per module in the escapes section of ita.una, allows. The default is 0, and a file checked on its own has the default (spec/06 §6).
How to fix it
Its repairs keep the proof first:
- State the fact in a refined type or a
requiresclause, so that the solver proves it, or handle the values where it does not hold with a guard, and remove thechecked. - Raising the budget is the last repair, marked as an escape (ADR 0095): it allows more runtime tests in place of proofs, and each one is listed in the build report and needs review.
The repair at a glance
diff
module demo
kind ParseError = | Empty
pub nonempty(raw: Text) -> Text
fails ParseError
=
- checked(raw, raw.len > 0) else fail Empty
+ if raw.len > 0 then raw else fail EmptyFailing example
una
module demo
kind ParseError = | Empty
pub nonempty(raw: Text) -> Text
fails ParseError
=
checked(raw, raw.len > 0) else fail EmptyFixed example
una
module demo
kind ParseError = | Empty
pub nonempty(raw: Text) -> Text
fails ParseError
=
if raw.len > 0 then raw else fail Empty