Skip to content

Conversation

@auduchinok
Copy link
Member

@auduchinok auduchinok commented Jun 12, 2023

Some of the tokens inserted by LexFilter have unexpected ranges. Consider this case:

while true do
    1

()

There's a ODECLEND token inserted at the () range, to mark an end of the while expression. Using this range allows showing an error in a better place during recovery, but it makes impossible to know where the while actually ends when there's an error inside it or an explicit done keyword is used:

while true do
    2
done

()

This PR adds original/fallback ranges to some of the end-like tokens, so they can be used in parser for calculating the correct ranges of the produced nodes. In this PR only some rules with ODECLEND actually use them, but it makes sense to also update similar cases in other PRs where needed when improving recovery/ranges there later.

It also normalizes ranges of the inner expression nodes produced during recovery.

@auduchinok auduchinok requested a review from a team as a code owner June 12, 2023 13:12
@auduchinok auduchinok closed this Jun 12, 2023
@auduchinok auduchinok reopened this Jun 12, 2023
@auduchinok
Copy link
Member Author

This is ready. Please merge it before #15334, and I'll update that PR.

@T-Gro T-Gro merged commit e333828 into dotnet:main Jun 13, 2023
@auduchinok auduchinok deleted the ast-doneRange branch June 13, 2023 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants