X0100 -- Contract Requires Clause Violated¶
Reserved code:
X0100is not emitted by the current compiler. A contract violation at runtime printsContract violation: requires: <clause>with the file and line, without a diagnostic code; use T001 for compile-time type errors. This page is kept for continuity.
A function's requires: precondition was not satisfied at the call site.
Bad Example¶
fn divide(a: Int, b: Int) -> Int
requires: b != 0;
{
return a / b;
}
fn main() -> Int {
return divide(10, 0); // X0100: requires b != 0 violated
}
Fix¶
Guard the call or adjust the arguments:
fn main() -> Int {
let result = divide(10, 5); // b is 5, satisfies requires
return result;
}
Notes¶
- Contract violations emit
@llvm.trap()in debug mode and are treated as safety violations. - Use
--explain X0100or check contract IR comments (; contract: requires: ...).