mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-14 07:29:02 +03:00
Revise wording on unnecessary wildcard warning
My concern with the previous wording is that: - Beginners will be confused by "these are always open" - Users advanced enough to understand what that actually means won't benefit from seeing it in this warning message!
This commit is contained in:
parent
2f54e46909
commit
6c4e2c8738
@ -1017,9 +1017,20 @@ pub fn can_problem<'b>(
|
||||
}
|
||||
Problem::UnnecessaryOutputWildcard { region } => {
|
||||
doc = alloc.stack([
|
||||
alloc.reflow("I see you annotated a wildcard in a place where it's not needed:"),
|
||||
alloc.concat([
|
||||
alloc.reflow("This type annotation has a wildcard type variable ("),
|
||||
alloc.keyword("*"),
|
||||
alloc.reflow(") that isn't needed."),
|
||||
]),
|
||||
alloc.region(lines.convert_region(region)),
|
||||
alloc.reflow("Tag unions that are constants, or the return values of functions, are always inferred to be open by default! You can remove this annotation safely."),
|
||||
alloc.concat([
|
||||
alloc.reflow("Annotations for tag unions which are constants, or which are returned from functions, work the same way with or without a "),
|
||||
alloc.keyword("*"),
|
||||
alloc.reflow(" at the end. (The "),
|
||||
alloc.keyword("*"),
|
||||
alloc.reflow(" means something different when the tag union is an argument to a function, though!)"),
|
||||
]),
|
||||
alloc.reflow("You can safely remove this to make the code more concise without changing what it means."),
|
||||
]);
|
||||
title = "UNNECESSARY WILDCARD".to_string();
|
||||
severity = Severity::Warning;
|
||||
|
@ -11772,14 +11772,19 @@ All branches in an `if` must have the same type!
|
||||
@r###"
|
||||
── UNNECESSARY WILDCARD ────────────────────────────────── /code/proj/Main.roc ─
|
||||
|
||||
I see you annotated a wildcard in a place where it's not needed:
|
||||
This type annotation has a wildcard type variable (`*`) that isn't
|
||||
needed.
|
||||
|
||||
4│ f : {} -> [A, B]*
|
||||
^
|
||||
|
||||
Tag unions that are constants, or the return values of functions, are
|
||||
always inferred to be open by default! You can remove this annotation
|
||||
safely.
|
||||
Annotations for tag unions which are constants, or which are returned
|
||||
from functions, work the same way with or without a `*` at the end. (The
|
||||
`*` means something different when the tag union is an argument to a
|
||||
function, though!)
|
||||
|
||||
You can safely remove this to make the code more concise without
|
||||
changing what it means.
|
||||
"###
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user