Skip to main content

Module throw

Module throw 

Source
Expand description

Shared emission for raising a catchable Error: the native-throw tail used by every wasm throw site (user throw, array bounds, as cast mismatch, JSON shape mismatch), plus the TypeError and ReferenceError raises built on it and their messages.

A throw whose message belongs to one subsystem keeps its constructor and constant there — bounds::emit_index_oob_throw does. What lands here is what has no better home: the shared tail, and messages raised from emitters that don’t own a module of their own.

Every constant here must also be interned by codegen::analysis. The throw reads its message out of the string pool; a missing entry is an internal compile failure rather than a guest exception.

Constants§

MISSING_RETURN_VALUE_MESSAGE
Thrown when a function that must return a value reaches its end. The missing-return rule leaves that possible only through an exhaustive switch whose value a call or closure moved outside the type a narrowing gave it. JavaScript returns undefined there, which the declared return type cannot hold.
NON_NULL_ASSERT_MESSAGE
Thrown by x! when the value turns out to be null or undefined.
READ_ONLY_PROPERTY_MESSAGE
Thrown when a property write resolves, at runtime, to a getter with no setter — reachable only through a receiver whose static type does not say which implementation backs the property.