-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error message when an object is passed where a record is expe…
…cted (#7101) * improve error message when an object is passed where a record is expected * changelog
- Loading branch information
Showing
5 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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
15 changes: 15 additions & 0 deletions
15
tests/build_tests/super_errors/expected/object_passed_when_record_expected.res.expected
This file contains 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,15 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/object_passed_when_record_expected.res[0m:[2m4:14-26[0m | ||
|
||
2 [2m│[0m type xx = array<x> | ||
3 [2m│[0m | ||
[1;31m4[0m [2m│[0m let x: xx = [[1;31m{"one": true}[0m] | ||
5 [2m│[0m | ||
|
||
This has type: [1;31m{"one": bool}[0m | ||
But it's expected to have type: [1;33mx[0m | ||
|
||
You're passing a [1;31mReScript object[0m where a [1;33mrecord[0m is expected. | ||
|
||
- Did you mean to pass a record instead of an object? Objects are written with quoted keys, and records with unquoted keys. Remove the quotes from the object keys to pass it as a record instead of object. |
4 changes: 4 additions & 0 deletions
4
tests/build_tests/super_errors/fixtures/object_passed_when_record_expected.res
This file contains 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 @@ | ||
type x = {one: bool} | ||
type xx = array<x> | ||
|
||
let x: xx = [{"one": true}] |