feat: suggest lambda operator

This commit is contained in:
Luca Cervello 2022-10-10 12:43:38 +02:00
parent 8ada13cc3b
commit 1c0b1ba0af
No known key found for this signature in database
GPG key ID: 05180DD59F7580C4
2 changed files with 12 additions and 4 deletions

View file

@ -246,6 +246,16 @@ 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.concat([alloc.reflow(
"Did you mean to define a function? Condider defining this as",
)]),
alloc.vcat(vec![alloc.text("id = \\x -> x")]),
])]
}
_ => { _ => {
vec![alloc.stack([ vec![alloc.stack([
alloc.concat([ alloc.concat([

View file

@ -5653,11 +5653,9 @@ 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`. Did you mean to define a function? Condider defining this as
when color is id = \x -> x
Red -> "stop!"
Green -> "go!"
"### "###
); );