Skip to content

bugc: compile a void function call as a statement - #351

Merged
gnidan merged 4 commits into
mainfrom
bugc-void-call-statement
Oct 7, 2026
Merged

gnidan merged 4 commits into
mainfrom
bugc-void-call-statement

Conversation

@gnidan

@gnidan gnidan commented Oct 7, 2026

Copy link
Copy Markdown
Member

A call to a function with no return type, as a statement (bump();), failed in IR generation with "Cannot convert type with kind fail to IR type". The type checker gives such a call the type failure("void function"), and buildCall passed that type to fromBugType before it checked whether the function is void. It now checks first, and converts the type only for a call with a result.

Nothing past IR generation needed a change: the call terminator already has an optional dest, and since #349 the exit JUMP's return context leaves out data when the function returns no value.

Tests:

  • behavioral.test.ts: void calls at O0–O3 (a plain call, arguments with an early return;, calls in a loop, a void function calling another, a local live across a void call).
  • call-contexts.test.ts: the caller's JUMP has the invoke, and the callee's exit JUMP has a return with no data.
  • call-timing.test.ts: a void case, so a void callee's frame is on from its entry JUMPDEST through its exit JUMP, at O0–O3. A void exit records undefined in place of a read value.
  • local-variables.soundness.test.ts: a void call with a parameter, a callee local, and a caller local live across the call.

gnidan added a commit that referenced this pull request 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:15 UTC

gnidan added 2 commits October 6, 2026 20:57
irgen converted a call's type to an IR type before it checked for a
void function, whose call type is the type checker's "void function"
failure, so fromBugType threw. Check first and convert only a call
with a result.
@gnidan
gnidan force-pushed the bugc-void-call-statement branch from 5532adc to 9cc00a3 Compare October 7, 2026 00:57
@gnidan
gnidan merged commit ff9f5a9 into main Oct 7, 2026
7 checks passed
@gnidan
gnidan deleted the bugc-void-call-statement branch October 7, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant