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

Improve error messages when keywords are misspelled #1420

Open
MinekPo1 opened this issue Sep 8, 2024 · 1 comment
Open

Improve error messages when keywords are misspelled #1420

MinekPo1 opened this issue Sep 8, 2024 · 1 comment
Labels
Accepted Accepted Request Enhancement Request New feature or request

Comments

@MinekPo1
Copy link

MinekPo1 commented Sep 8, 2024

Currently when a keyword like interface are misspelled, the error is difficult to connect to a typo:

Error: A type name was expected, but this looks a variable or function name (as it doesn't start with an uppercase letter).

This error message can be replaced by contextually checking if the token is close (see edit distance) to a keyword.

in the case of keywords used for top level statement, since IDENT tokens cannot be used in global variable declarations, (as builtin types like int are keywords and custom types are IDENT_TYPE) when encountering an IDENT token in parse_top_level_statement, before calling parse_global_declaration, we can first go through the keywords we could expect and calculating the edit distance to the value and showing a message which explicitly suggests a typo.

@lerno lerno added the Enhancement Request New feature or request label Sep 8, 2024
@lerno
Copy link
Collaborator

lerno commented Sep 8, 2024

Yes, this is good and there is already something related to find function names.

@lerno lerno added this to the First release (v1.0) milestone Sep 14, 2024
@lerno lerno added the Accepted Accepted Request label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted Request Enhancement Request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants