mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
Add hint about forgetting to call a function
This commit is contained in:
parent
cfc4be5254
commit
175a2b5683
2 changed files with 58 additions and 9 deletions
|
@ -14839,6 +14839,48 @@ All branches in an `if` must have the same type!
|
|||
"###
|
||||
);
|
||||
|
||||
test_report!(
|
||||
ignored_stmt_forgot_to_call,
|
||||
indoc!(
|
||||
r#"
|
||||
app [main!] { pf: platform "../../../../../examples/cli/effects-platform/main.roc" }
|
||||
|
||||
import pf.Effect
|
||||
|
||||
main! = \{} ->
|
||||
Effect.getLine!
|
||||
Effect.putLine! "hi"
|
||||
"#
|
||||
),
|
||||
@r###"
|
||||
── IGNORED RESULT in /code/proj/Main.roc ───────────────────────────────────────
|
||||
|
||||
The result of this expression is ignored:
|
||||
|
||||
6│ Effect.getLine!
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Standalone statements are required to produce an empty record, but the
|
||||
type of this one is:
|
||||
|
||||
{} => Str
|
||||
|
||||
Hint: Did you forget to call the function?
|
||||
|
||||
── LEFTOVER STATEMENT in /code/proj/Main.roc ───────────────────────────────────
|
||||
|
||||
This statement does not produce any effects:
|
||||
|
||||
6│ Effect.getLine!
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Standalone statements are only useful if they call effectful
|
||||
functions.
|
||||
|
||||
Did you forget to use its result? If not, feel free to remove it.
|
||||
"###
|
||||
);
|
||||
|
||||
test_report!(
|
||||
function_def_leftover_bang,
|
||||
indoc!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue