function
Declares executable code with parameters, results, locals, and a validated instruction body.
corestructural
Syntax
(func $name (param i32) (result i32) ... )
Stack Effect
Function body must leave values matching its result types.Opcode
no executable opcode`func` (function declaration) has no single executable opcode. It is encoded across the type, function, code, and (optionally) export sections.
Browser Support
Core WebAssembly function declaration.
Validation Rules
- Parameter, local, and result types must be valid.
- The body must type-check and terminate with an implicit or explicit end.
Common Mistakes
- Expecting function names to exist in the binary without name/custom sections.
- Returning a value that is not on the operand stack.
(func $add (param $a i32) (param $b i32) (result i32)
local.get $a
local.get $b
i32.add)