Solidity REPL
Debugging & errors

Yul switch

Use inline assembly control flow and return the selected value.

Solidity 0.8.36REPL modeDebug capture

Why use this example

Use this pattern to reproduce a failure or follow an execution from Solidity source into calls and EVM opcodes. The entry isolates yul switch so its input, result, and state changes stay easy to compare.

Solidity to run

function classify(uint256 value) public pure returns (uint256 result) {
  assembly { switch value case 0 { result := 10 } case 1 { result := 20 } default { result := 30 } }
}

classify(1)

Official Solidity reference

Compare this focused investigation with the complete language definition in the Solidity documentation.

Inline assembly

What to expect

The assembly switch selects case 1, returns 20, and exposes the corresponding opcode steps for inspection.

Continue the investigation

Change a value, add another expression, or open Inspect after the run. Accepted entries remain available to the next entry, and the clean replay keeps the complete result reproducible.

Read about debugging Execution diagnosis