Skip to main content

field

Function field 

Source
pub fn field(out: &mut CodeValue, obj: &CodeValue, name: &str)
Expand description

obj.field field access. Total: a missing field, or an obj that is not an Object at all, writes Null into out.

Total is where this differs from the language, and deliberately. .code source treats a non-Object operand as an error ("abc".length fails, which the README states as a rule), and runtime.c still has a code_field that does exactly that — for the compiler. It is not in code_abi.h, and this no longer calls it.

The reason is that a module cannot use a fallible accessor safely. Since phase 3 (2026-08-28) a runtime failure travels by a flag that only the host’s generated code reads, and a .so carries its own copy of the runtime — so a failure raised inside a module sets the module’s flag and is never seen. One function cannot be both fallible for the language and total for modules, so the ABI keeps the total one. A module that wants to refuse a wrong-typed operand says so itself, with exception.