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.
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.
Walk through a function#
- 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.
- 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.
- 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. - Change an input and watch the path move.
Double-click a parameter on the signature, such as
subtotal, and give itMoney(cents = 20000). The walk is made again from the new value, so you can see which branch a different input takes. - 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:
| Tag | Means |
|---|---|
| exact | Worked out by WTFCode’s evaluator from the code and the values given. |
| AI | Written by the model, which read the function and its callees. Assumed values are said to be assumed. |
| source | Not evaluated: past a value it couldn’t tell, the walk carries on through the lines in source order. |
| Recorded | From 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#
- 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")givescode = "BULK20". - 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.
- 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#
| Key | Does |
|---|---|
| ↓ or F8 | Next step |
| ↑ | Back one step |
| → or F7 | Step into the call on this line |
| ← or ⇧F8 | Back to the caller, at the step that called |
| Space | Play or pause |
| Esc | Close; ↩ 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
switchand Rustmatchand 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.