You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the following elm program that does nothing but fail to compile:
type alias Stuff = {
a : String,
bananas : Int
}
myStuff : Stuff
myStuff = {
a = "Hi",
bananas = 5
}
Compiler error says:
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:
This is definitely a correct error message ✔️, but it doesn't necessarily clearly explain why to new comers (ie me), and in the spirit of improving the error messages I'd like to submit this reasoning:
In some areas in the docs about records it would seem that records aren't indentation or white-space sensitive, but maybe the error message could give an example of a style-guide-conforming record definition, like this:
And perhaps a link, reference, or a short blurb on the reasoning about this, or maybe just something like "record definitions like this example one are definitively unambiguous, and sticking to it will ensure your program is readable by other elm programmers and quickly compilable"..? 😕
❓ Idk, maybe it's a non issue, feel free to close since the existing error message does mention white-space, which is what is needed to change to clear the error, I just spent a few minute fighting the compiler on it though.
One thing that's interesting is the type alias definition compiles fine, but to get the record definition to work you just need to add at least one space on the last line.
The text was updated successfully, but these errors were encountered:
I am finishing up an overhaul of the parser that makes it easier to give more precise error messages for syntax problems. This report encouraged me to make one last tweak in elm/compiler@11ffbf5 so my development build is now giving the following message for your code:
-- NEED MORE INDENTATION ---------------------------------------------- temp.elm
I was partway through parsing a record type, but I got stuck here:
1| type alias Stuff = {
2| a : String,
3| bananas : Int
4| }
^
I need this curly brace to be indented more. Try adding some spaces before it!
Note: If you are trying to define a record type across multiple lines, I
recommend using this format:
{ name : String
, age : Int
, height : Float
}
Notice that each line starts with some indentation. Usually two or four spaces.
This is the stylistic convention in the Elm ecosystem.
Thanks for reporting this case! The improved version should become available along with a bunch of other improvements once Elm 0.19.1 is released.
Consider the following elm program that does nothing but fail to compile:
Compiler error says:
This is definitely a correct error message ✔️, but it doesn't necessarily clearly explain why to new comers (ie me), and in the spirit of improving the error messages I'd like to submit this reasoning:
In some areas in the docs about records it would seem that records aren't indentation or white-space sensitive, but maybe the error message could give an example of a style-guide-conforming record definition, like this:
And perhaps a link, reference, or a short blurb on the reasoning about this, or maybe just something like "record definitions like this example one are definitively unambiguous, and sticking to it will ensure your program is readable by other elm programmers and quickly compilable"..? 😕
❓ Idk, maybe it's a non issue, feel free to close since the existing error message does mention white-space, which is what is needed to change to clear the error, I just spent a few minute fighting the compiler on it though.
One thing that's interesting is the type alias definition compiles fine, but to get the record definition to work you just need to add at least one space on the last line.
The text was updated successfully, but these errors were encountered: