Step through a function without running it

Walk a function like a paused debugger, with values at the line ends and one compact card under the line, and fill in what the code alone can’t tell.

3 min read · Video walkthrough

Before you start

  • A function or test you want to follow, in any language WTFCode reads.
  • Nothing to run. Without a model the walk works out values from the code; with one under Settings → AI, it also explains each step.
From a pricing test into the discount function: the walk can’t tell the subtotal or the bulk threshold, is given both, and shows which branch a bulk order takes. Recorded with AI off.

Walk through a function#

  1. Start the walk.

    Click ▶ Walk through above a function or test, or put the caret in it and press ⌘⌥W. The walk pauses on the first line like a breakpoint: the ninja sits in the gutter, values appear at the line ends, and the parameters show on the signature.

  2. Step.

    Press ↓ for the next line. On a line that calls your code, the card offers Step into →; press → to follow the call. Once you’ve stepped in, the card shows the call stack. ← goes back to the caller, ↑ back one step.

  3. Fill in what it can’t tell.

    Where a value depends on something outside the function, the line says so, such as BULK_FROM.cents = ?, and the card reads “Can’t tell…”. Double-click the value and type one in. The walk works the line out again, for example → true, and stays on it.

  4. Change an input and watch the path move.

    Double-click a parameter on the signature, such as subtotal, and give it Money(cents = 20000). The walk is made again from the new value, so you can see which branch a different input takes.

  5. Leave and come back.

    Esc closes the walk and keeps its place. ↩ Resume walkthrough in the status bar reopens it on the same line.

Reading the card#

One compact card sits under the paused line. Its top row says what the step does in a few words, where you are (Line 16 · 3 of 5), and where the values came from:

TagMeans
exactWorked out by WTFCode’s evaluator from the code and the values given.
AIWritten by the model, which read the function and its callees. Assumed values are said to be assumed.
sourceNot evaluated: past a value it couldn’t tell, the walk carries on through the lines in source order.
RecordedFrom a real run, played by the AI debugger.

Below the top row is only what this line needs: its explanation, an error in red when the function throws here, and the result on the last step. A ✦ on the signature marks a parameter the model chose because no caller gave one.

Where the inputs come from#

  1. The code first. Stepping into a call, the parameters are the caller’s values. Otherwise they’re the literal arguments at the call site that spells out the most of them, usually a test: Pricing.discount(Money(20_000), "BULK20") gives code = "BULK20".
  2. With a model, an agent writes the walk. It follows the function’s real control flow, step by step, and reads callers and callees as it needs. The first step is an overview: what the function is for, who calls it, what goes in and out, and its logic in two to five stages, each a link to where it starts.
  3. Without one, WTFCode’s evaluator runs the function where it can. Where it can’t tell a value, it says so on that line, and ↓ carries on in source order, marked not evaluated.

Keys#

KeyDoes
↓ or F8Next step
↑Back one step
→ or F7Step into the call on this line
← or ⇧F8Back to the caller, at the step that called
SpacePlay or pause
EscClose; ↩ Resume walkthrough brings it back

While a walk is open, the code is read-only and the keys step the walk, as in a debugger. Typing in a box inside the code (a value you’re changing, a question under a line) never steps it. Every key can be rebound in Settings → Keyboard.

Current limits#

  • A value decided two calls deep can still be guessed wrong. When it matters, check it with the AI debugger.
  • Go switch and Rust match and loops are one step each for now; the walk can’t step inside them.
  • With a model, steps arrive a stage or two at a time rather than all at once.

Next steps#

Something unclear or out of date? Tell us; a person on the team reads every note.

Search every guide: features, settings, keys and troubleshooting.

Try