Skip to main content

Module failcode

Module failcode 

Source
Expand description

The failure codes a compiled module reports, each mapped onto its sentence in logicaffeine_data::failure, the one place every tier’s failure wording lives.

A runtime failure comes in two shapes. Most carry a message the compiler already wrote and interned (Op::FailWith { msg: ConstIdx }), so the wasm backend hands that Text straight to the host. But an INLINE check — a bounds test, a division guard — has no constant: the tree-walker builds its message while running, from a value that does not exist until then (Index 9 out of bounds). There is nothing to hand over.

So those report a CODE and the offending VALUE, and the host renders the sentence.

★ WHICH PUTS THE WORDING IN A HOST AS WELL, AND THAT IS THE WHOLE DANGER. The browser saying something subtly different from the reference tier is exactly the drift every lock in this campaign exists to prevent. So message is what the interpreter formats with, what the Node host is generated from (js_cases), and what runtime.js is checked against (fail_code_lock reads its cases and holds them to this function). A new code that the host does not render fails that lock rather than reaching a visitor as a blank page.

The codes are APPEND-ONLY for the same reason the host-import list is: the emitter is compiled into a module and the host ships separately, so renumbering silently re-labels every failure a previously-built module reports.

Enums§

FailCode
Why a compiled module stopped, for the failures whose message needs a runtime value.

Constants§

ALL
Every code, in wire order — so a lock can enumerate them rather than trusting a hand-written list.

Functions§

js_cases
Every code’s sentence as JavaScript: one case arm per code assigning target, then a default arm, with the offending value spliced in from the variable value (a JS string) and an unknown code from the variable code. Rendered from message itself, so a host written out as JavaScript cannot word a failure differently from the reference tier.
message
The sentence a failure reports, from its code and the value that caused it.