Skip to content

bugc: test exit counts, tail calls, and exits without data - #350

Merged
gnidan merged 1 commit into
mainfrom
bugc-call-timing-tests
Oct 7, 2026
Merged

gnidan merged 1 commit into
mainfrom
bugc-call-timing-tests

Conversation

@gnidan

@gnidan gnidan commented Oct 7, 2026

Copy link
Copy Markdown
Member

Follow-up to #349, closing test gaps found in its review. Tests only.

expectExits in optimizer-contexts.test.ts compared only the names of functions with an exit return, so a second return on another JUMP in the same function would pass unnoticed. It now takes exact counts per function. The counts follow return terminators in the IR, which can be one more than the source shows: an if/else whose branches both return leaves an empty merge block with an implicit void return, until the optimizer drops it at O2. I checked the counts for fact, check and the others against the IR blocks.

call-timing.test.ts gains a tail-call program (count/succ). From O2 the back-edge JUMP carries a return with no data and the frame depth stays constant, which the replay now covers against real traces. It also asserts that no exit with a return and no data is ever executed. Those exits are the empty merge blocks above at O0 and O1.

On whether a reachable exit can lack data: not through any code the tests use, and the check above fails if one is reached. A void function cannot be called (its call has a failure type), so the only way to reach a void return in a value-returning function is to run off its end, which the type checker accepts today without a diagnostic. That is a missing-return check, not a context bug, so it is left out of this PR.

@gnidan gnidan added the changelog: skip This PR changes schemas/ or a published package without a changelog entry on purpose label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-07 01:00 UTC

@gnidan
gnidan merged commit db7d0e4 into main Oct 7, 2026
8 checks passed
@gnidan
gnidan deleted the bugc-call-timing-tests branch October 7, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: skip This PR changes schemas/ or a published package without a changelog entry on purpose

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant