if
Structured conditional block.
core0x04
Syntax
if
Stack Effect
[i32] -> block resultsOpcode
- Hex
0x04- Decimal
4- Bytes
[0x04]- Encoding
0x04 <blocktype:block-type>- Immediates
blocktype:block-type— empty | valtype | typeidx (encoded via signed LEB128)
- Category
- control
Browser Support
Core WebAssembly instruction.
Validation Rules
- Operands and result types must match the instruction signature.
- The instruction must appear in a valid structured control context.
Common Mistakes
- Using the instruction with the wrong operand type.
- Forgetting that WAT validation is stack-typed.
(func $example
;; if example
)