mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Merge pull request #4281 from lucacervello/suggest-lambda-operator
Add suggest lambda operator instead of when
This commit is contained in:
commit
bc2ec738a0
2 changed files with 15 additions and 4 deletions
|
@ -259,6 +259,17 @@ fn to_expr_report<'a>(
|
||||||
Context::InNode(Node::WhenBranch, _pos, _) => {
|
Context::InNode(Node::WhenBranch, _pos, _) => {
|
||||||
return to_unexpected_arrow_report(alloc, lines, filename, *pos, start);
|
return to_unexpected_arrow_report(alloc, lines, filename, *pos, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context::InDef(_pos) => {
|
||||||
|
vec![alloc.stack([
|
||||||
|
alloc.reflow("Looks like you are trying to define a function. "),
|
||||||
|
alloc.reflow("In roc, functions are always written as a lambda, like "),
|
||||||
|
alloc
|
||||||
|
.parser_suggestion("increment = \\n -> n + 1")
|
||||||
|
.indent(4),
|
||||||
|
])]
|
||||||
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
vec![alloc.stack([
|
vec![alloc.stack([
|
||||||
alloc.concat([
|
alloc.concat([
|
||||||
|
|
|
@ -5653,11 +5653,11 @@ All branches in an `if` must have the same type!
|
||||||
4│ main = 5 -> 3
|
4│ main = 5 -> 3
|
||||||
^^
|
^^
|
||||||
|
|
||||||
The arrow -> is only used to define cases in a `when`.
|
Looks like you are trying to define a function.
|
||||||
|
|
||||||
when color is
|
In roc, functions are always written as a lambda, like
|
||||||
Red -> "stop!"
|
|
||||||
Green -> "go!"
|
increment = \n -> n + 1
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue