You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To elaborate, currently the parser will usually issue an error in the form "failed trying to parse a [foo]" where [foo] may be term, expression, pattern, etc. Sometimes it will give even worse errors resembling "parser expected end of input, but got ..." which does not explain well what the user did that was wrong. The parser also stops after 1 error currently. A recoverable parser is desirable such that parsing never actually fails. Instead expressions that fail to parse should either be left out or replaced with a new Ast::Error construct so we can continue to name resolution and type checking. This greatly helps IDE support since most of the time when a user is typing code there will be parse errors and we don't want that to cause other type errors to no longer appear. To recover from a statement/expression that failed to parse, the parser can skip to the next Newline token.
This is a larger change, but I'm marking it as a good first issue because the parser is early enough in the compiler that you don't have to learn about earlier passes first.
To summarize, there are a few issues here that should probably be addressed separately:
Improve quality of parser error messages
Make parser recoverable
Make parser infallible, and update name resolution and type checking to operate on Error terms.
The text was updated successfully, but these errors were encountered:
I'm not set on the current parser and we can replace it if beneficial. That being said I've used chumsky and while it would give us some of these things it is not a silver bullet and would still be a large effort to setup, use, and maintain.
They are awful.
To elaborate, currently the parser will usually issue an error in the form "failed trying to parse a [foo]" where [foo] may be term, expression, pattern, etc. Sometimes it will give even worse errors resembling "parser expected end of input, but got ..." which does not explain well what the user did that was wrong. The parser also stops after 1 error currently. A recoverable parser is desirable such that parsing never actually fails. Instead expressions that fail to parse should either be left out or replaced with a new Ast::Error construct so we can continue to name resolution and type checking. This greatly helps IDE support since most of the time when a user is typing code there will be parse errors and we don't want that to cause other type errors to no longer appear. To recover from a statement/expression that failed to parse, the parser can skip to the next Newline token.
This is a larger change, but I'm marking it as a good first issue because the parser is early enough in the compiler that you don't have to learn about earlier passes first.
To summarize, there are a few issues here that should probably be addressed separately:
The text was updated successfully, but these errors were encountered: