mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Test tag destructure suffixes
This commit is contained in:
parent
2c208f9389
commit
a0783c3132
1 changed files with 72 additions and 0 deletions
|
@ -15142,5 +15142,77 @@ All branches in an `if` must have the same type!
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test_report!(
|
||||||
|
unsuffixed_tag_fx_field,
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
app [main!] { pf: platform "../../../../../examples/cli/effects-platform/main.roc" }
|
||||||
|
|
||||||
|
import pf.Effect
|
||||||
|
|
||||||
|
main! = \{} ->
|
||||||
|
Tag get put = Tag Effect.getLine! Effect.putLine!
|
||||||
|
|
||||||
|
name = get {}
|
||||||
|
put "Hi, $(name)"
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
@r###"
|
||||||
|
── MISSING EXCLAMATION in /code/proj/Main.roc ──────────────────────────────────
|
||||||
|
|
||||||
|
This function is effectful, but its name does not indicate so:
|
||||||
|
|
||||||
|
6│ Tag get put = Tag Effect.getLine! Effect.putLine!
|
||||||
|
^^^
|
||||||
|
|
||||||
|
Add an exclamation mark at the end, like:
|
||||||
|
|
||||||
|
get!
|
||||||
|
|
||||||
|
This will help readers identify it as a source of effects.
|
||||||
|
|
||||||
|
── MISSING EXCLAMATION in /code/proj/Main.roc ──────────────────────────────────
|
||||||
|
|
||||||
|
This function is effectful, but its name does not indicate so:
|
||||||
|
|
||||||
|
6│ Tag get put = Tag Effect.getLine! Effect.putLine!
|
||||||
|
^^^
|
||||||
|
|
||||||
|
Add an exclamation mark at the end, like:
|
||||||
|
|
||||||
|
put!
|
||||||
|
|
||||||
|
This will help readers identify it as a source of effects.
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
|
||||||
|
test_report!(
|
||||||
|
suffixed_tag_pure_field,
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
app [main!] { pf: platform "../../../../../examples/cli/effects-platform/main.roc" }
|
||||||
|
|
||||||
|
import pf.Effect
|
||||||
|
|
||||||
|
main! = \{} ->
|
||||||
|
Tag msg trim! = Tag " hi " Str.trim
|
||||||
|
|
||||||
|
Effect.putLine! (trim! msg)
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
@r###"
|
||||||
|
── UNNECESSARY EXCLAMATION in /code/proj/Main.roc ──────────────────────────────
|
||||||
|
|
||||||
|
This function is pure, but its name suggests otherwise:
|
||||||
|
|
||||||
|
6│ Tag msg trim! = Tag " hi " Str.trim
|
||||||
|
^^^^^
|
||||||
|
|
||||||
|
The exclamation mark at the end is reserved for effectful functions.
|
||||||
|
|
||||||
|
Hint: Did you forget to run an effect? Is the type annotation wrong?
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
|
||||||
// [purity-inference] TODO: check ! in records, tuples, tags, opaques, and arguments
|
// [purity-inference] TODO: check ! in records, tuples, tags, opaques, and arguments
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue