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

Error recovery between parsing phases #1220

Merged
merged 9 commits into from
Oct 16, 2023
Merged

Conversation

bugarela
Copy link
Collaborator

@bugarela bugarela commented Oct 11, 2023

Hello :octocat:

This PR makes it so we accumulate errors between parsing phases, instead of giving up after the first phase that results in error. In order to do that, we stop using Either monads, and instead using records with an errors field that accumulates the errors.

There are also some changes to ToIrListener.ts so we have some error recovery - that is, we produce valid IR even if parsing fails. I'm trying to play with some specs to see if I can cause any of the assertions to fail, but for some reason it is looking pretty stable after my few changes.

There's also a change in the JSON assets for testing, since now we are able to produce modules even if there are parsing errors.

Example:

module A {
  val syntaxErrorEx = 1(2)
  val nameErrorEx = syntaxErrorEx + missing
}

yields

/home/gabriela/projects/quint/local/test.qnt:2:24 - error: [QNT000] extraneous input '(' expecting {'}', 'const', 'var', 'assume', 'type', 'val', 'def', 'pure', 'action', 'run', 'temporal', 'import', 'export', DOCCOMMENT}
2:   val syntaxErrorEx = 1(2)
                          ^

/home/gabriela/projects/quint/local/test.qnt:3:37 - error: [QNT404] Name 'missing' not found
3:   val nameErrorEx = syntaxErrorEx + missing
                                       ^^^^^^^

error: parsing failed
  • [-] Tests added for any new code
  • [-] Documentation added for any new functionality
  • Entries added to the respective CHANGELOG.md for any new functionality
  • [-] Feature table on README.md updated for any listed functionality

@bugarela bugarela marked this pull request as ready for review October 11, 2023 18:56
@bugarela bugarela requested review from thpani and konnov October 11, 2023 18:57
@bugarela bugarela self-assigned this Oct 11, 2023
Copy link
Contributor

@konnov konnov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great refactoring! I believe it makes it easier to understand what's going on. Also, the ability to accumulate errors is nice

quint/src/cliCommands.ts Outdated Show resolved Hide resolved
quint/test/parsing/quintParserFrontend.test.ts Outdated Show resolved Hide resolved
@bugarela bugarela merged commit 01c5f83 into main Oct 16, 2023
15 checks passed
@bugarela bugarela deleted the gabriela/parsing-partial-results branch October 16, 2023 19:20
This was referenced Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants