Repository navigation
Conversation
Changelog💅 Polish
Semantic Diff1 commit · Full page Type a let destructuring a GADT without switch diagnostics829f98b · cknitt + Claude · Oct 27, 2026, 12:45 UTC
Diagnostic modified (let destructuring a GADT) type rec any = Any('a, 'a => string): any
let get = value => {
let Any(x, _) = value
x
}
This has type: $a
-But this switch is expected to return: 'a
+But it's expected to have type: 'a
$a is an existential type bound by the constructor Any.
It is only known in the scope of the pattern that matches Any.
-
-All branches in a switch must return the same type.
-To fix this, change your branch to return the expected type. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fix-9068-existential-names #9081 +/- ##
===========================================================
Coverage 81.52% 81.52%
===========================================================
Files 460 460
Lines 64659 64661 +2
===========================================================
+ Hits 52713 52717 +4
+ Misses 11946 11944 -2
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
@codex review |
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. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Why:
A `let` whose pattern contains a GADT constructor is typed as a
one-case match. Its body was then checked as a switch branch, so a
type error there said "But this switch is expected to return" and
added the hint about switch branches, although the source has no
switch. The synthesized match is now marked like the one for optional
argument defaults and gets function-style diagnostics.
Diagnostic modified (let destructuring a GADT):
Example:
type rec any = Any('a, 'a => string): any
let get = value => {
let Any(x, _) = value
x
}
Before (diagnostic):
This has type: $a
But this switch is expected to return: 'a
$a is an existential type bound by the constructor Any.
It is only known in the scope of the pattern that matches Any.
All branches in a switch must return the same type.
To fix this, change your branch to return the expected type.
After (diagnostic):
This has type: $a
But it's expected to have type: 'a
$a is an existential type bound by the constructor Any.
It is only known in the scope of the pattern that matches Any.
Fixes: #9069
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gLMawVgtmiKy3TMBc3
Signed-off-by: Christoph Knittel <ck@cca.io>
adfceb2 to
829f98b
Compare
Fixes #9069. Stacked on #9080, whose message appears in this fixture.
A
letdestructuring a GADT constructor is typed as a one-case match, so a type error in the rest of the block said "But this switch is expected to return" and added the hint about switch branches. The synthesized match is now marked like the one for optional argument defaults and gets function-style diagnostics.New fixture:
gadt_existential_let.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gLMawVgtmiKy3TMBc3