Skip to main content

BUG playground

BUG is a minimal smart contract language for exercising ethdebug/format: small enough to read at a glance, expressive enough to reach the cases a debug format has to handle. bugc is its reference compiler, compiling BUG to EVM bytecode and emitting ethdebug/format debug information alongside the code.

bugc generates ethdebug/format for every program it compiles, so the format here describes real compiled code: the debug annotations in the Bytecode view below are its output.

Edit the source, switch views, and watch each stage update — from parse tree to annotated bytecode.

Loading editor...

About BUG

BUG is intentionally minimal — it provides just enough language features to demonstrate the debugging challenges that ethdebug/format addresses:

  • Storage variables with automatic slot allocation
  • Functions with parameters and return values
  • Control flow (if/else, while loops)
  • Basic types (uint256, bool, address, bytes32)
  • Complex types (arrays, mappings, structs)

Things to try

  1. Edit the source code in the left panel and watch the outputs update. Try adding a new storage variable or changing a loop bound.
  2. Switch between views (AST, IR, CFG, Bytecode) to see how source code transforms through each compilation stage.
  3. Hover over instructions in the IR or Bytecode views to see which source code they correspond to.
  4. Inspect the Bytecode view to see ethdebug/format program annotations — each instruction shows its offset, operation, and context (source ranges, variables in scope).
  5. Look at the CFG to understand control flow structure — useful for seeing how if/while compiles to branching bytecode.

Compilation views

The playground shows several stages of compilation:

  • AST — The abstract syntax tree after parsing
  • IR — The intermediate representation between the AST and bytecode
  • CFG — The control flow graph visualizing program structure
  • Bytecode — The final EVM bytecode with debug annotations