Repository navigation
Compare the @as tags of variant cases with payloads across signatures - #9009
Conversation
Why:
Interface inclusion compared the `@as` literal of nullary cases only. An
implementation could swap the tags of two cases with payloads, and its
clients then matched `M.A(_)` as `C` (#8956).
The tags of tagged cases with a payload are compared as those of nullary
cases are. An untagged case's `@as` does not change its representation and
is not compared. Type declarations in messages now print the `@as` of a
tagged case with a payload too, so the mismatch shows.
Diagnostic added:
Example:
module M: {
type t = A({x: int}) | C({x: int})
} = {
type t = | @as("C") A({x: int}) | @as("A") C({x: int})
}
After (diagnostic):
Type declarations do not match:
type t = @as("C") A({x: int}) | @as("A") C({x: int})
is not included in
type t = A({x: int}) | C({x: int})
The internal representations for case A are not equal.
Fixes: #8956
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMkrYaktctdKc4M41WF36t
Signed-off-by: Christoph Knittel <ck@cca.io>
Changelog
Semantic Diff1 commit · Full page Compare the
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9009 +/- ##
=======================================
Coverage 81.29% 81.29%
=======================================
Files 456 456
Lines 63836 63843 +7
=======================================
+ Hits 51893 51899 +6
- Misses 11943 11944 +1
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9009 |
|
@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. More of your lovely PRs please. 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". |
Fixes #8956.
Interface inclusion compared the
@asliteral of nullary cases only. An implementation could swap the tags of two cases with payloads, and its clients then matchedM.A(_)asC:Includecore.compare_variantsnow compares the tags of tagged cases with a payload as it does those of nullary cases. An untagged case's@asdoes not change its representation (spec rule 2) and is not compared. Type declarations in messages now print the@asof tagged cases with a payload too (printtyp.ml:tree_of_constructor); before, both sides of this mismatch printed asA({x: int}) | C({x: int}):UntaggedVariants.md: rule 14 states the comparison, and the known bug is removed.New test:
super_errors/variant_payload_tag_mismatch.🤖 Generated with Claude Code
https://claude.ai/code/session_01CMkrYaktctdKc4M41WF36t