← Back to AILP Home

assert_static

assert_static is a compile-time assertion with a runtime fallback for dynamic facts. It is stricter than before v0.34.6 when the expression is known false at compile time.

Syntax

Both statement forms are accepted:

assert_static comptime(2i32 + 2i32 == 4i32);
assert_static x > 0i32;

When Z3 proves the condition, the statement is erased.

CTFE-known false is a hard error

As of v0.34.6, user-authored assert_static fails compilation when the compiler can see that the expression is false during CTFE or verification:

func:main = int32() {
    assert_static comptime(false);
    exit 0;
};

Diagnostic:

This catches literal false and evaluated comptime(false) forms before IR codegen.

Dynamic fallback remains

If the condition depends on runtime data and cannot be proven statically, assert_static may remain as a runtime guard:

func:check = NIL(int32:x) {
    assert_static x > 0i32;
    pass(NIL);
};

Use this when a property is expected but still needs a safety net outside the solver's current reach.

Difference from prove

Directive Proven CTFE false / disproven Unknown or dynamic
prove(expr); erased compile error compile error
assert_static expr; erased ARIA-075 compile error when known false warning/runtime guard path

Built-in macro compatibility

The v0.23.6 built-ins assert!, unreachable!, and todo! synthesize assertion nodes for runtime fallback behavior. v0.34.6 preserves that compatibility by marking those compiler-generated nodes as fallback-compatible. User-authored assert_static false remains a hard CTFE failure.

See also