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 inside trait/abi #4979

Merged
merged 13 commits into from
Aug 23, 2023
Merged

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Aug 18, 2023

Description

Closes #4729.

The trick part of this PR is that TraitItems were being parsed as (TraitItem, SemicolonToken). The problem is that to recover from an error we call the error method of the Parser trait. And it is very hard to come up with a generic implementation for the tuple. Which type of tuple do we call its error method, and how do we return a valid tuple in all cases? Impossible.

So that is why I moved the SemicolonToken to inside the TraitItem. Another benefit is that we can recover from missing semicolons with nice error messages.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@xunilrj xunilrj self-assigned this Aug 18, 2023
@xunilrj xunilrj marked this pull request as draft August 18, 2023 14:40
@xunilrj xunilrj marked this pull request as ready for review August 21, 2023 14:39
@xunilrj xunilrj requested a review from a team August 21, 2023 14:39
@xunilrj xunilrj changed the title Parser recovery inside trait Parser recovery inside trait/abi Aug 21, 2023
@xunilrj xunilrj force-pushed the xunilrj/parser-recovery-inside-trait branch from 0fadddb to 9bf4029 Compare August 22, 2023 08:20
@xunilrj xunilrj requested a review from JoshuaBatty August 22, 2023 11:32
Copy link
Member

@JoshuaBatty JoshuaBatty left a comment

Choose a reason for hiding this comment

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

thanks, seems like a reasonable approach.

@JoshuaBatty JoshuaBatty requested a review from a team August 23, 2023 00:19
@xunilrj xunilrj force-pushed the xunilrj/parser-recovery-inside-trait branch from ecef273 to 5e78494 Compare August 23, 2023 14:05
@xunilrj xunilrj enabled auto-merge (squash) August 23, 2023 14:10
@xunilrj xunilrj merged commit 122fb0b into master Aug 23, 2023
@xunilrj xunilrj deleted the xunilrj/parser-recovery-inside-trait branch August 23, 2023 14:32
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.

parser recovery: failing on parsing ItemTraitItem
3 participants