Skip to content

fix(ts): check a unit-returning binding against => undefined - #181

Merged
kixelated merged 3 commits into
mainfrom
quest/m3/ts-bind-gaps
Oct 28, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m3/ts-bind-gaps

Conversation

@kixelated

@kixelated kixelated commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

A binding of a Rust function returning () was checked against => void, which in TS accepts a function returning anything. A binding that returned a value where Rust returns () type-checked, and translated code that holds the result (Vec<()>, Option<()>, {:?}) would see that value. The check now types () as => undefined, as translated code types the unit value itself.

The consumer is raw::skip in the bind fixture, and every unit-returning binding in moq's tree (TaskSet, Tasks).

How it works

  • bind.rs builds the check's function type from ty() of each input and the output, instead of fn_ty, whose () is void for translated function types. fn_ty itself is unchanged: translated code declares unit functions : void, and a bound export typed => undefined is still assignable where those are expected.

Tests

  • Reproduced first: with the old check, wrong/skip.ts, which returns the new position as a usize, translated without error.
  • wrong.toml now binds raw::skip to it, and wrong.txt holds the refusal at raw.rs:26:1: Type 'usize' is not assignable to type 'undefined'.
  • bind/skip.ts is typed : undefined, and the bind differential against native Rust still passes.
  • just check passes. just ts test passes apart from lang, which fails identically on origin/main (dyns.ts unwind blocks differ from the snapshot), unrelated to bindings.

Choices made without asking

  • A unit binding must annotate : undefined. An unannotated function f() {} infers void in TS and is refused. The alternative, discarding a bound call's result and using undefined, would keep the loose check and add code at every call site.

Remaining

The quest is rewritten to its other two pieces: a bound type as a collection key, and a path through a renamed dependency.

Public API:

  • Breaking: a binding of a function returning () is typed : undefined, with a MIGRATE.md entry.

Follow-ups

  • lang's dyns.ts snapshot fails on main.

(written by Opus 5.5)

🤖 Generated with Claude Code

kixelated and others added 2 commits October 28, 2026 07:26
Quest-Claim: 516acccb332ef3c9
`=> void` accepts any return value, so a binding of a function returning
`()` could return a number and still type-check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Binding gaps fix(ts): check a unit-returning binding against => undefined Oct 28, 2026
@kixelated
kixelated marked this pull request as ready for review October 28, 2026 14:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T14:55:39.234234Z be82425 New commits
🔒 Security Review ✅ Completed 2026-10-28T14:57:10.516246Z be82425 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review by review (OpenAI)

Reviewed commit: 438b31d

No actionable bugs found. Checking bound unit returns as undefined matches the existing unit-value representation and closes TypeScript's permissive void assignment hole without changing translated function signatures. This small boundary check is preferable to adding result-discarding wrappers at every call site; the intentional annotation requirement is documented in the migration notes. The reachable wrong-binding fixture covers rejecting a numeric return, while the valid binding is updated consistently.

Verification: static review of the complete diff, binding-check construction, type lowering and fixture call path. I did not run tsc, Rust builds or differential tests, and have not independently verified the reported lang snapshot failure.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Landing be824251: a merge from main with no conflicts, which picks up #172's fix for lang, on top of the reviewed 438b31de. CI passed, Codex 👍 on the head, and the automated review found nothing actionable. Maintainer picked option 1 (wait for main's lang fix, then squash-merge). The quest is rewritten to its two remaining pieces: bound types as collection keys, and paths through renamed dependencies.

(written by Opus 5.5)

@kixelated
kixelated merged commit ca1595d into main Oct 28, 2026
1 check passed
@kixelated
kixelated deleted the quest/m3/ts-bind-gaps branch October 28, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant