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

parser recovery: fails when there is no item to attach doc comments to. #4908

Closed
JoshuaBatty opened this issue Aug 4, 2023 · 0 comments · Fixed by #4964
Closed

parser recovery: fails when there is no item to attach doc comments to. #4908

JoshuaBatty opened this issue Aug 4, 2023 · 0 comments · Fixed by #4964
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser

Comments

@JoshuaBatty
Copy link
Member

Just noticed that starting a doc comment without a fully formed item underneath also causes the compiler to return an empty AST to the language server.

The below doesn't work

/// text

neither does this.

/// text
fn function(

this works though because the function is fully formed.

/// text
fn function() {}
@JoshuaBatty JoshuaBatty added compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser labels Aug 4, 2023
tritao pushed a commit that referenced this issue Aug 18, 2023
## Description

Closes #4910.
Closes #4909.
Closes #4908

The trait `Parse` now contains a do-nothing `error` function that
returns the error variant for that item, if it has one. This allows
generic parsing functions like `Vec`, `Annotated` etc... to be able to
recover and continue if desired.

Now the parser continues even if strange things at the item level.


![image](https://github.com/FuelLabs/sway/assets/83425/5ce00e01-5eb5-48db-b163-f3245cb6e5fe)

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant