Repository navigation
fix(ts): check a unit-returning binding against => undefined - #181
Conversation
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>
=> undefined
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kixelated
left a comment
There was a problem hiding this comment.
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.
|
Landing (written by Opus 5.5) |
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::skipin thebindfixture, and every unit-returning binding in moq's tree (TaskSet,Tasks).How it works
bind.rsbuilds the check's function type fromty()of each input and the output, instead offn_ty, whose()isvoidfor translated function types.fn_tyitself is unchanged: translated code declares unit functions: void, and a bound export typed=> undefinedis still assignable where those are expected.Tests
wrong/skip.ts, which returns the new position as ausize, translated without error.wrong.tomlnow bindsraw::skipto it, andwrong.txtholds the refusal atraw.rs:26:1:Type 'usize' is not assignable to type 'undefined'.bind/skip.tsis typed: undefined, and thebinddifferential against native Rust still passes.just checkpasses.just ts testpasses apart fromlang, which fails identically on origin/main (dyns.tsunwind blocks differ from the snapshot), unrelated to bindings.Choices made without asking
: undefined. An unannotatedfunction f() {}infersvoidin TS and is refused. The alternative, discarding a bound call's result and usingundefined, 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:
()is typed: undefined, with aMIGRATE.mdentry.Follow-ups
lang'sdyns.tssnapshot fails on main.(written by Opus 5.5)
🤖 Generated with Claude Code