Back to Content

unreachable: Wasm text instruction

files/en-us/webassembly/reference/control_flow/unreachable/index.md

latest712 B
Original Source

unreachable is used to denote a point in code that should not be reachable. unreachable is an unconditional trap: in the case where an unreachable is reached and executed, the instruction traps.

{{InteractiveExample("Wat Demo: unreachable", "tabbed-shorter")}}

wat
(module
  (func (export "throw")
    unreachable
  )
)
js
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url)).then((result) => {
  result.instance.exports.throw();
  // Expected output: RuntimeError: unreachable
});

Syntax

wat
unreachable
InstructionBinary opcode
unreachable0x00