Repository navigation
fix(ts): diverging calls through closures and generics at ! pass tsc - #48
Conversation
Quest-Claim: 06ccf5d7cd664d3b
A binding of a closure or function pointer that never returns declares its type, so `tsc` sees a call to it diverge. A value of type `!` is never `undefined`: a place of type `!` reads through `rt.unreachable`, a `panic!` block where a value goes leaves an unassigned temp, and from MIR, a `Return` from a function of type `!` is unreachable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
! pass tsc
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: 5cf4ba3
No actionable bugs found. Declaring diverging callee bindings and reusing existing unreachable/temporary lowering is a focused approach, avoiding additional throw statements at every call site. Deterministic fixture inputs meaningfully target the newly supported never-returning closure and generic paths in both lowerings. Destructured closure bindings remain the documented THIR follow-up, not a newly introduced finding.
Verification: static inspection of changed lowering paths, surrounding binding/place handling and added fixtures/snapshots. I did not execute TypeScript checks or native-versus-translated tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
|
Merging. Since the review, the only change is a merge of Decisions, as the maintainer accepted them:
(written by Opus 5.5) |
Regenerates the snapshots for the cases #48 and #49 added, and names `!` and `()` in a suffix (`pass$never`), which printed as an empty part. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Problem
Two shapes #28 left fail
tsc(quest):!.tsctreats a call as diverging only when the callee's binding has a declared type, and THIR bound the closure as an unannotatedconst. A tailfail(b)failed TS2366, andlet x: u8 = if c { fail(b) } else { .. }failed TS2454. Afn(u8) -> !pointer and a closure a function returns had the same problem.!(edition 2024's fallback, as inpass(panic!(..))). From THIR, its body read aneverparameter and fell off the end (TS2534), and apanic!argument lowered toundefined(TS2345). From MIR, a generic of type!that is reachable, such asunwrap_or_bail::<!>(None, b), returnedreturn;(TS2322) and passed a!local asundefined(TS2345).Approach
letof a closure or function pointer whose output is!declares its type. MIR already declares every local's type.!reads throughrt.unreachable(place), asmatch x {}already did. A tail-less block of type!where a value goes, which is whatpanic!(..)expands to, goes through an unassigned temp, asNeverToAnyhas since fix(ts): type-check values of type!where a value goes #28.Returnfrom a function of type!lowers asUnreachabledoes, and a read of a!local isrt.unreachable(undefined)instead ofundefined.New cases in the
langfixture'sdiverging, under both lowerings. A random first byte rarely picks their trigger values, socaller.tsnow exportscasesthat hit each one, with and without a second byte. All 14 panic in the translation with native's message. Each failure above reproduced on this branch before its fix.Impact
tscbefore. Thecodecandtasksnapshots are unchanged, andjust ts moqstill passes.Alternatives
throw f(b)after any call of type!through something other than a function item. It covers every callee form without relying ontsc's declared-type rule, but it adds a statement to every such call site. MIR's typed locals already show the declaration is enough.pass::<!>out of the THIR output entirely, but THIR'sexprhas to return a value, and THIR is going away (quest).return xinstead ofrt.unreachable(x)for a!place. That reads better at a tail, but only works there.Follow-ups
let (f, g) = ..) is still an unannotated binding element in THIR, sotscmay not see a call to it diverge. No fixture hits this, and it goes away with THIR.(written by Opus 5.5)
🤖 Generated with Claude Code
https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn