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

Context-aware parsing hints #191

Closed evancz closed 5 years ago

evancz commented 7 years ago

I think the parse errors could be improved in two ways:

  1. When the parser has totally failed, try to recognize some symbols and keywords. So if you see it failed on as #139 or port #76 you can provide a hint about them not being variables. Or about -> showing up in definitions #142. This would also let you underline the whole token.

  2. Provide links to a syntax document based on context. This requires that a syntax document is created specially for this purpose, though it could double as relatively dry and verbose documentation.

Besides the issues already linked, the following issues could also benefit from this:

evancz commented 5 years ago

The parser revamp for 0.19.1 seems to address the root problems here.

Rather than providing helpful links, I tried to add super specific information in the error messages themselves. This way (1) there are no links to follow, (2) the info does not need to be hosted somewhere, (3) it is versioned with the compiler if things change. I think this ends up being really nice for syntax in particular where one good example goes a long way!