elm / error-message-catalog

A catalog of broken Elm programs / data to improve error messages
BSD 3-Clause "New" or "Revised" License
173 stars 17 forks source link

Forgot list brackets #261

Closed bdukes closed 5 years ago

bdukes commented 6 years ago

This is from an issue on Stackoverflow, which ended with the OP commenting "Elm errors are confusing", so I thought I'd check if the situation is improved with the parser changes in 0.19, and it seemed to be quite a bit worse (especially if I imagine a beginner's perspective).

The Program

import Html exposing (..)
import Html.Attributes exposing (..)

main : Html a
main =
    span [ class "welcome-message" ] [ text "Hello, World!" ]
    , h1 [ class "headline" ] [ text "Hello" ]

The 0.18 output

-- SYNTAX PROBLEM ------------------------------------------------ .\example.elm

I ran into something unexpected when parsing your code!

7|     , h1 [ class "headline" ] [ text "Hello" ]
       ^
I am looking for one of the following things:

    end of input
    whitespace

Detected errors in 1 module.

The 0.19 output

Detected errors in 1 module.
-- PARSE ERROR --------------------------------------------------- .\example.elm

Something went wrong while parsing main's definition.

5| main =
6|     span [ class "welcome-message" ] [ text "Hellow, World!" ]
7|     , h1 [ class "headline" ] [ text "Hello" ]
       ^
I was expecting:

  - an argument, like `name` or `total`
  - an infix operator, like (+) or (==)
  - the rest of main's definition. Maybe you forgot some code? Or maybe the body
    of `main` needs to be indented?
evancz commented 5 years ago

Thanks for the report! I am finishing up a revamp of the parser which is making it a lot easier to produce specific error messages. So my development build is currently producing:

-- UNEXPECTED COMMA --------------------------------------------------- temp.elm

I got stuck on this comma:

7|     , h1 [ class "headline" ] [ text "Hello" ]
       ^
I do not think I am parsing a list or tuple right now. Try deleting the comma?

Note: If this is supposed to be part of a list, the problem may be a bit
earlier. Perhaps the opening [ is missing? Or perhaps some value in the list has
an extra closing ] that is making me think the list ended earlier? The same
kinds of things could be going wrong if this is supposed to be a tuple.

I have been going through the catalog now that the parser is pretty much done, and the messages often benefit from some slight tweaks based on the real life examples. This one is pretty specific though!

Thanks again for reporting this! The new message should be available once Elm 0.19.1 is released.