-
Notifications
You must be signed in to change notification settings - Fork 471
Make inline record fields that overlap with a variant's tag a compile error #7875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mediremi
merged 14 commits into
rescript-lang:master
from
mediremi:compiler-error-variant-tag-constructor-field
Sep 26, 2025
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6772661
Make it a compile error to have inline record fields whose fields con…
mediremi f65bc01
Handle @as attribute
mediremi 887fc6f
Format code
mediremi 5bba7f8
Add super error fixtures
mediremi 465a30f
Check variants without a @tag decorator
mediremi ae25762
Use effective field name instead of checking actual field name and @a…
mediremi 6c0f9f0
Merge branch 'master' into compiler-error-variant-tag-constructor-field
mediremi c293649
Format OCaml
mediremi 5e98a12
Add CHANGELOG entry
mediremi 314988f
Merge branch 'master' into compiler-error-variant-tag-constructor-field
mediremi 14c1bdb
Merge branch 'master' into compiler-error-variant-tag-constructor-field
mediremi 5c5f2bd
Reuse process_tag_type instead of duplicating logic in process_as_name
mediremi 40d5e14
Clarify tag/as conflict error message by using field name from type i…
mediremi 08afd62
Quote constructor name
mediremi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
tests/build_tests/super_errors/expected/duplicate_as_tag_inline_record.res.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/duplicate_as_tag_inline_record.res[0m:[2m1:35-37[0m | ||
|
||
[1;31m1[0m [2m│[0m type animal = Cat({@as("catName") [1;31m@as[0m("catName2") name: string}) | ||
2 [2m│[0m | ||
|
||
duplicate @as |
10 changes: 10 additions & 0 deletions
10
tests/build_tests/super_errors/expected/variant_tag_overlaps_with_field.res.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/variant_tag_overlaps_with_field.res[0m:[2m2:15-33[0m | ||
|
||
1 [2m│[0m @tag("name") | ||
[1;31m2[0m [2m│[0m type animal = [1;31mCat({name: string})[0m | ||
3 [2m│[0m | ||
4 [2m│[0m let cat = Cat({name: "my cat"}) | ||
|
||
Constructor Cat: the @tag name "name" conflicts with the runtime value of inline record field "name". Use a different @tag name or rename the field. |
10 changes: 10 additions & 0 deletions
10
tests/build_tests/super_errors/expected/variant_tag_overlaps_with_field_as.res.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/variant_tag_overlaps_with_field_as.res[0m:[2m2:15-48[0m | ||
|
||
1 [2m│[0m @tag("name") | ||
[1;31m2[0m [2m│[0m type animal = [1;31mCat({@as("name") catName: string})[0m | ||
3 [2m│[0m | ||
4 [2m│[0m let cat = Cat({catName: "my cat"}) | ||
|
||
Constructor Cat: the @tag name "name" conflicts with the runtime value of inline record field "catName". Use a different @tag name or rename the field. | ||
1 change: 1 addition & 0 deletions
1
tests/build_tests/super_errors/fixtures/duplicate_as_tag_inline_record.res
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type animal = Cat({@as("catName") @as("catName2") name: string}) |
4 changes: 4 additions & 0 deletions
4
tests/build_tests/super_errors/fixtures/variant_tag_overlaps_with_field.res
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@tag("name") | ||
type animal = Cat({name: string}) | ||
|
||
let cat = Cat({name: "my cat"}) |
4 changes: 4 additions & 0 deletions
4
tests/build_tests/super_errors/fixtures/variant_tag_overlaps_with_field_as.res
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@tag("name") | ||
type animal = Cat({@as("name") catName: string}) | ||
|
||
let cat = Cat({catName: "my cat"}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.