-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
[wip] Improve parser error handling #7912
[wip] Improve parser error handling #7912
Conversation
@@ -203,16 +209,14 @@ let parse_string com s p error inlined = | |||
display_position := old_display; | |||
in_display_file := old_in_display_file; | |||
end; | |||
Lexer.restore old; | |||
display_error := old_de | |||
Lexer.restore old |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not save syntax_errors at beginning of parsing and restore them here as well ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, good catch
tests/server/build.hxml
Outdated
-lib utest | ||
--cmd node test.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that seems unrelated to the PR ;)
Something in the grammar is broken. It currently emits this error on every file:
|
There's a travis OS X display test failure:
I cannot reproduce this locally though:
Any idea what could cause this? |
and hope that it gets called
Oh it's this shit again...
|
1f6634e
to
fc1b2ac
Compare
* [parser] start on parser error refactoring * [parser] remove all `in_display` checks from grammar for now * [parser] remove Parser.display_error * [parser] start on parse_result * [parser] remove some hard errors * [tests] add test for broken syntax diagnostics see HaxeFoundation#7793 * [parser] unbreak eval-debugger completion * [parser] adjust Context.parse(InlineString) * [parser] adjust `parse_metadata` * [parser] adjust type_patch parsing * [parser] adjust import.hx parsing * [parser] adjust module parsing * [parser] fix special } resume case * [parser] handle module parsing errors properly * [macro] fix bad macro display settings handling * [tests] add toString to HaxeInvocationException and hope that it gets called * [submodule] try something * [parser] fix syntax_errors handling * [server] remove unused binding * [parser] don't lose exact interpolation parser message * [tests] remove unrelated change
This PR changes how we communicate with our parser. I acknowledge that it looks scary, but I think it's a necessary step and I would like to make that step now rather than later.
First of all, when we're not in display mode, the parser still raises
Parser.Error
early as it did before. However, when we're in display mode (including diagnostics), it returns an element of this ADT:It might still raise
Parser.Error
in some (rare?) cases. The endgame here is to eliminate all these cases so it always parses something. This is going to require some more refactoring though and is not something we have to do for 4.0.The idea is to look at all occurrences of
ParseDisplayFile
and friends (there are only 14 at the moment) and adjust what we want to do. For instance, the compilation server naturally reacts like this:This addresses #7793. Once we cleaned up error handling completely, we could also cache the display file if it has no errors (useful for hover-mode where the AST is often intact).
As another example
--macro
parsing does this:There are some
PARSERTODO
s I have to look at still, but I would like to know if people agree that this is the right way forward.As a more or less unintended side-effect, we collect syntax errors on the diagnostics file which should allow us to address #5306.