Improve error recovery in delimited groups when can't parse anything inside#601
Merged
AntonyBlakey merged 3 commits intoNomicFoundation:mainfrom Sep 27, 2023
Merged
Conversation
TerminatedBy can be a bit too greedy, i.e. we recovered some unexpected item definition just because... we recovered at a terminator. However, the delimited group is a reasonable boundary since it's simple (2-3 kinds of delimiters) and the opening delimiter must always match the closing one, so it produces more reliable and self-contained recovered phrases, so attempting to recover from a null parse in a delimited group makes more sense.
🦋 Changeset detectedLatest commit: 0246fa5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
AntonyBlakey
approved these changes
Sep 26, 2023
Contributor
Author
|
Updated and added a changeset file (for this and for delimited error recovery in general) |
Merged
github-merge-queue bot
pushed a commit
that referenced
this pull request
Sep 27, 2023
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @nomicfoundation/slang@0.10.0 ### Minor Changes - [#595](#595) [`1a258c4`](1a258c4) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery when parsing incomplete lists - [#564](#564) [`e326a06`](e326a06) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing operators with missing operands should no longer panic - [#564](#564) [`e326a06`](e326a06) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse rules are no longer exposed to the API. - [#564](#564) [`e326a06`](e326a06) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are no longer available as methods - use next_token instead - [#564](#564) [`e326a06`](e326a06) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are now grouped into contexts to deal with contextual scanning ### Patch Changes - [#601](#601) [`cbd2a79`](cbd2a79) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error recovery between bracket delimiters - [#599](#599) [`4bbad48`](4bbad48) Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions for the `revert` and `global` keywords - [#561](#561) [`cb6a138`](cb6a138) Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary documentation for the `solidity_language` Rust package Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
rollup-smithbm0p
added a commit
to rollup-smithbm0p/slang
that referenced
this pull request
Dec 26, 2025
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @nomicfoundation/slang@0.10.0 ### Minor Changes - [#595](NomicFoundation/slang#595) [`1a258c4`](NomicFoundation/slang@1a258c4) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery when parsing incomplete lists - [#564](NomicFoundation/slang#564) [`e326a06`](NomicFoundation/slang@e326a06) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing operators with missing operands should no longer panic - [#564](NomicFoundation/slang#564) [`e326a06`](NomicFoundation/slang@e326a06) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse rules are no longer exposed to the API. - [#564](NomicFoundation/slang#564) [`e326a06`](NomicFoundation/slang@e326a06) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are no longer available as methods - use next_token instead - [#564](NomicFoundation/slang#564) [`e326a06`](NomicFoundation/slang@e326a06) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are now grouped into contexts to deal with contextual scanning ### Patch Changes - [#601](NomicFoundation/slang#601) [`cbd2a79`](NomicFoundation/slang@cbd2a79) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error recovery between bracket delimiters - [#599](NomicFoundation/slang#599) [`4bbad48`](NomicFoundation/slang@4bbad48) Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions for the `revert` and `global` keywords - [#561](NomicFoundation/slang#561) [`cb6a138`](NomicFoundation/slang@cb6a138) Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary documentation for the `solidity_language` Rust package Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Simpler variant of #594.
While writing an issue for the potential null parse recovery, it just hit me that we might not need to support that generally but rather just limiting that to the delimited group would give us enough bang for the buck.
TerminatedBy null parse recovery can be a bit too greedy, i.e. we might recover some unexpected item definition just because... we recovered at the final terminator. However, the delimited group is a reasonable boundary since it's simple (2-3 kinds of general delimiters versus different kinds of potentially versioned terminated statements) and the opening delimiter must always match the closing one, so it produces more reliable and self-contained recovered phrases, hence attempting to recover from a null parse in a delimited group makes more sense.