Closed danfishgold closed 5 years ago
Thank you for the report! I am finishing up a bunch of work on the parser, so it is much easier to give precise errors for JSON now. I made a tweak in based on your specific case though, so my development build is saying:
-- EXTRA COMMA -------------------------------------------------------- elm.json
I ran into a problem with your elm.json file. I was partway through parsing a
JSON object when I got stuck here:
20| },
^
I saw a comma right before I got stuck here, so I was expecting to see a field
name like "type" or "dependencies" next.
This error is commonly caused by trailing commas in JSON objects. Those are
actually disallowed by <https://json.org> so check the previous line for a
trailing commas that may need to be deleted.
Note: Here is an example of a valid JSON object for reference:
{
"name": "Tom",
"age": 42
}
Notice that (1) the field names are in double quotes and (2) there is no
trailing comma after the last entry. Both are strict requirements in JSON!
I would really like if it included the line above as well though. Let me see if I can add that in as well.
Okay, I made another little tweak to make it produce this:
-- EXTRA COMMA -------------------------------------------------------- elm.json
I ran into a problem with your elm.json file. I was partway through parsing a
JSON object when I got stuck here:
18| "elm-explorations/markdown": "1.0.0",
19| "rtfeldman/elm-iso8601-date-strings": "1.1.0",
20| },
^
I saw a comma right before I got stuck here, so I was expecting to see a field
name like "type" or "dependencies" next.
This error is commonly caused by trailing commas in JSON objects. Those are
actually disallowed by <https://json.org> so check the previous line for a
trailing commas that may need to be deleted.
Note: Here is an example of a valid JSON object for reference:
{
"name": "Tom",
"age": 42
}
Notice that (1) the field names are in double quotes and (2) there is no
trailing comma after the last entry. Both are strict requirements in JSON!
These fixes should be available once Elm 0.19.1 is released. I think it is kind of fun to have really excellent JSON errors (since most parsers are made for speed) so please let me know if you find any more weird ones once you can try out the new messages!
Thanks Evan, that's really nice 😄 There's just one tiny typo: "so check the previous line for a trailing commas"
Oops! Should be fixed by https://github.com/elm/compiler/commit/3698de0101fc6ab058eace2e91f28cf11e3f4967
Description
When there's a parsing issue somewhere in
elm.json
, I get this error message when I runelm make Main.elm
:I figured out eventually that I had an extra comma in my
direct
dependency list.SSCCE
elm init
elm.json
elm make Main.elm
Side Note
The prompt in the error message to add this issue here is 100% the reason I did it. It's wonderful!