Closed brunogirin closed 5 years ago
SSCCE:
$ cat foo.elm
module WhiteSpace exposing (..)
broken : List String
broken =
[ "aa"
, "asd"
[ "asd"
, "bla"
]
$ elm make foo.elm
-- SYNTAX PROBLEM ------------------------------------------------------ foo.elm
I need whitespace, but got stuck on what looks like a new declaration. You are
either missing some stuff in the declaration above or just need to add some
spaces here:
I am looking for one of the following things:
whitespace
Thanks for the report! I have made a bunch of improvements to parse errors, so in the development build @domenkozar's SSCCE is producing:
-- UNFINISHED LIST ---------------------------------------------------- temp.elm
I cannot find the end of this list:
5| [ "aa"
6| , "asd"
7| [ "asd"
8| , "bla"
9| ]
^
You can just add a closing ] right here, and I will be all set!
Note: I may be confused by indentation. For example, if you are trying to define
a list across multiple lines, I recommend using this format:
[ "Alice"
, "Bob"
, "Chuck"
]
Notice that nothing comes directly after a newline. Each line starts with some
spaces. This style can be jarring for people coming from C-like syntax, but
folks generally report that they are used to it (and often prefer it!) after a
week or two of using Elm.
Much more specific to what is going on in this case. This should become available once Elm 0.19.1 is released.
As described in issue #164, the compiler does not provide a line number when some syntax errors occur, in particular when it encounters missing closing brackets. When compiling the attached file, the compiler provides the following message:
Although the problem is obvious in the attached example, it can be very difficult to find the offending line in a complex module so it would help enormously if the compiler could provide the line number where the error was found or the line number where the declaration that it was trying to parse is.
WhitespaceSscce.zip