-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
try making top level unit error message clearer
- Loading branch information
Showing
8 changed files
with
78 additions
and
9 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
16 changes: 16 additions & 0 deletions
16
jscomp/build_tests/super_errors/expected/top_level_fn_call_not_unit.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,16 @@ | ||
|
||
[1;31mWarning number 109[0m (configured as error) | ||
[36m/.../fixtures/top_level_fn_call_not_unit.res[0m:[2m3:1-18[0m | ||
|
||
1 [2m│[0m let returnsSomething = () => 123 | ||
2 [2m│[0m | ||
[1;31m3[0m [2m│[0m [1;31mreturnsSomething()[0m | ||
4 [2m│[0m | ||
|
||
This function call is at the top level and is expected to return `unit`. But, it's returning `int`. | ||
|
||
In ReScript, anything at the top level must evaluate to `unit`. You can fix this by assigning the expression to a value, or piping it into the `ignore` function. | ||
|
||
Possible solutions: | ||
- Assigning to a value that is then ignored: `let _ = yourFunctionCall()` | ||
- Piping into the built-in ignore function to ignore the result: `yourFunctionCall()->ignore` |
14 changes: 14 additions & 0 deletions
14
jscomp/build_tests/super_errors/expected/top_level_value_not_unit.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,14 @@ | ||
|
||
[1;31mWarning number 109[0m (configured as error) | ||
[36m/.../fixtures/top_level_value_not_unit.res[0m:[2m1:1-4[0m | ||
|
||
[1;31m1[0m [2m│[0m [1;31m1234[0m | ||
2 [2m│[0m | ||
|
||
This is at the top level and is expected to return `unit`. But, it's returning `int`. | ||
|
||
In ReScript, anything at the top level must evaluate to `unit`. You can fix this by assigning the expression to a value, or piping it into the `ignore` function. | ||
|
||
Possible solutions: | ||
- Assigning to a value that is then ignored: `let _ = yourExpression` | ||
- Piping into the built-in ignore function to ignore the result: `yourExpression->ignore` |
3 changes: 3 additions & 0 deletions
3
jscomp/build_tests/super_errors/fixtures/top_level_fn_call_not_unit.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,3 @@ | ||
let returnsSomething = () => 123 | ||
|
||
returnsSomething() |
1 change: 1 addition & 0 deletions
1
jscomp/build_tests/super_errors/fixtures/top_level_value_not_unit.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 @@ | ||
1234 |
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