Skip empty statements around end markers #11602
Merged
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.
Fixes #11581
When we encounter two end markers one after another we parse it as an end marker, then one or more empty statements then another end marker. Since empty statements are not added to the list of opened statements, the last not empty statement still can be closed with an end marker, regardless if it was closed before. This PR adds skipping empty statements around end markers. That way, every end marker after the first one is treated as a new statement, which will in all sane cases result in compilation error.
This PR is not touching the question if an end marker should be allowed after the right brace, as it seems to be controversial.