Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser Improvement: Better error messages #113

Open
achreto opened this issue Aug 11, 2023 · 0 comments
Open

Parser Improvement: Better error messages #113

achreto opened this issue Aug 11, 2023 · 0 comments
Labels
improvement anything that can be improved parser Everything that is related to the parser

Comments

@achreto
Copy link
Collaborator

achreto commented Aug 11, 2023

Right now we rely on the NOM parser components to produce an error message. This work OK-ish but by times this could be improved through custom error messages.

Current State

This is the current error message. Indicating that it has expected a : but found a ) this is fine, it tells us what's needed on a token level.

error: expected `:`, found `)`
     --> tests/vrs/methods/methods_05_arguments_no_types.vrs:3:15
      |
    3 |      fn foo(bar) -> bool
      |                ^ help: add `:` here.

Desired Output

An improved error message would tell the user that the type information is missing, for example:

error: expected `type spec`, found `)`
     --> tests/vrs/methods/methods_05_arguments_no_types.vrs:3:15
      |
    3 |      fn foo(bar) -> bool
      |                ^ help: add `: type` here.

There are more such examples through out the parser.

@achreto achreto added parser Everything that is related to the parser improvement anything that can be improved labels Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement anything that can be improved parser Everything that is related to the parser
Projects
None yet
Development

No branches or pull requests

1 participant