Skip to content

Commit 3ad5cb1

Browse files
authored
Untagged error messages (#6290)
* Untagged variants error messages Add tests. See #6272 * format * Better error message for constructor with more than one argument. * refactor: clarity * Treat cases with non-unary payloads uniformly. * Remove unused cases. * Improve error message for unknown case. * Update CHANGELOG.md Fixes #6272
1 parent 53e24ed commit 3ad5cb1

9 files changed

+281
-228
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#### :bug: Bug Fix
2525

2626
- Fix issue where uncurried type internals leak in type error. https://github.com/rescript-lang/rescript-compiler/pull/6264
27+
- Improve error messages for untagged variant definitions https://github.com/rescript-lang/rescript-compiler/pull/6290
2728

2829

2930
# 11.0.0-beta.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
We've found a bug for you!
3+
/.../fixtures/UntaggedNonUnary1.res:2:1-27
4+
5+
1 │ @unboxed
6+
2 │ type t = Tuple(int, string)
7+
3 │
8+
9+
This untagged variant definition is invalid: Constructor Tuple has more than one argument.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
We've found a bug for you!
3+
/.../fixtures/UntaggedNonUnary2.res:2:1-42
4+
5+
1 │ @unboxed
6+
2 │ type t = Tuple(int, string) | Float(float)
7+
3 │
8+
9+
This untagged variant definition is invalid: Constructor Tuple has more than one argument.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
We've found a bug for you!
3+
/.../fixtures/UntaggedUnknown.res:2:10-31
4+
5+
1 │ @unboxed
6+
2 │ type t = Tuple((float, string)) | Float(float)
7+
3 │
8+
9+
This untagged variant definition is invalid: Case Tuple has a payload that is not of one of the recognized shapes (object, array, etc). Then it must be the only case with payloads.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@unboxed
2+
type t = Tuple(int, string)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@unboxed
2+
type t = Tuple(int, string) | Float(float)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@unboxed
2+
type t = Tuple((float, string)) | Float(float)

0 commit comments

Comments
 (0)