-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(compiler): Introduce warning if non-void expression value not us…
…ed or ignored (#2141)
- Loading branch information
1 parent
f97c011
commit 43ce8f5
Showing
33 changed files
with
295 additions
and
225 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ match (Process.env()) { | |
Err(err) => throw err, | ||
} | ||
|
||
Process.exit(5) | ||
let _ = Process.exit(5) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
open Grain_tests.TestFramework; | ||
open Grain_tests.Runner; | ||
|
||
let {describe} = | ||
describeConfig |> withCustomMatchers(customMatchers) |> build; | ||
|
||
describe("expressions", ({test, testSkip}) => { | ||
let assertNoWarning = makeNoWarningRunner(test); | ||
let assertWarning = makeWarningRunner(test); | ||
|
||
assertWarning( | ||
"non_void_non_returning_expression1", | ||
{| | ||
1 | ||
print(2) | ||
|}, | ||
Grain_utils.Warnings.StatementType, | ||
); | ||
|
||
assertWarning( | ||
"non_void_non_returning_expression2", | ||
{| | ||
let f = () => { | ||
1 | ||
print(2) | ||
} | ||
|}, | ||
Grain_utils.Warnings.StatementType, | ||
); | ||
|
||
assertNoWarning( | ||
"non_void_non_returning_expression3", | ||
{| | ||
ignore(1) | ||
print(2) | ||
|}, | ||
); | ||
|
||
assertNoWarning( | ||
"non_void_non_returning_expression4", | ||
{| | ||
let f = () => { | ||
ignore(1) | ||
print(2) | ||
} | ||
|}, | ||
); | ||
|
||
assertNoWarning( | ||
"non_void_non_returning_expression5", | ||
{| | ||
let rec f = () => { | ||
if (true) { | ||
f() | ||
void | ||
} | ||
} | ||
|}, | ||
); | ||
}); |
Oops, something went wrong.