Closed Janiczek closed 5 years ago
I am wondering, if parser can be clever enough to understand that it is lambda missing backslash, then why backslash is needed in the first place?
Thanks for the report! I am finishing up an overhaul of the parser that makes it a bunch easier to give very specific error messages. My development build is currently producing:
-- UNEXPECTED ARROW --------------------------------------------------- temp.elm
I was not expecting an arrow here:
1| id = a -> a
^^
Arrows should only appear in `case` expressions and anonymous functions. Maybe
you want > or >= instead?
I think it's possible to do a bit better though, so I'll see what I can do!
Okay, based on this issue, I made some tweaks in https://github.com/elm/compiler/commit/00ee15406890dd8a3aeed2a30ed64b5b11772ebc to produce the following:
-- UNEXPECTED ARROW --------------------------------------------------- temp.elm
I was partway through parsing an expression when I got stuck on this arrow:
1| id = a -> a
^^
Arrows should only appear in `case` expressions and anonymous functions.
Maybe it was supposed to be a > sign instead?
Note: The syntax for anonymous functions is (\x -> x + 1) so the arguments all
appear after the backslash and before the arrow. Maybe you forgot the backslash
earlier?
It doesn't directly address the scenario where someone wanted to write a type annotation and wrote =
instead of :
, but I think it makes sense to wait for someone to report that scenario organically.
This should become available once Elm 0.19.1 is released.
I think that solves this issue pretty well :+1: thanks!
If somebody forgets to put the backslash before the arguments of an anonymous function, they get an error about arrows. They should(?) get an error about the missing backslash.