Skip to content

Modeled C: callback contracts on free functions (#1644) - #1672

Merged
ehartford merged 1 commit into
mainfrom
modeled-c-completion
Sep 25, 2026
Merged

ehartford merged 1 commit into
mainfrom
modeled-c-completion

Conversation

@ehartford

@ehartford ehartford commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

A valid callback param N userdata param M contract was rejected when the C function had no modeled receiver. Free functions now render safe generic bridges and share methods' contextual callback typing, nullable-pair validation, and thread/effect checks.

Regressions cover both C parameter orders, renamed functions, void returns, nullable callbacks, and mutable collection through a capturing callable borrowed as userdata. Negative cases retain pairing, Send/Sync, and call-once checks. LLDB located the original rejection in Sema.verify_facade_callback_items; the commit records the evidence.

Validation of this PR plus #1675, at exact head 590aa2be, with the pinned seed:

  • Full build and byte-identical fixpoint passed.
  • Drop and move audits passed.
  • Full :test, :test-green, and :last-green passed, including 1,282 behavior files and 20 example steps.
  • :user-programs-safe passed.
  • A second full test pass with a fresh C-import cache passed: all 1,282 behavior files ran with zero cached verdicts, followed by green test/last-green/user-programs-safe gates.

Rebased cleanly onto main c5aaf76f: this PR is now b1a1cf0d, and #1675 is 78edfb7a. The combined stable patch ID is unchanged (9bfe49f5d021fa84ec5606b207841e33cd94fef4). Per the handoff's rebase rule, the recorded battery applies to the unchanged patches; an integrated main battery remains required before installation.

This lower stack is being validated independently of unfinished #1652. Refs #1644; #1675 completes the tally migration.

Share callback rendering, userdata-first contextual typing, nullable pair
validation, and thread/effect checks between free and receiver calls.
Typed callable userdata permits a collecting callback to mutate a captured
Vec without granting mutation through a shared Vec reference.

Root-cause proof: LLDB stopped in Sema.verify_facade_callback_items after
facade_method_host returned x0=0; its length comparison at +668 branched
from +672 to the no-resource diagnostic at +940 (SemaFacade.w:3641).
The contract was rejected solely because presentation had no receiver.

Validation: pinned-seed :dev, compiler source check, free callback runtime
regression, existing scope/nullable method regressions, thread/pair/call-once
negative probes, audit:all (643344 facts, 0 violations). Void free bridges
have explicit Unit returns, as required by the public-function validator.
Element buffers and the tally integration follow in the next stack layer.
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