Skip to content

Don’t eat closing braces while trying to recover to a declaration start keyword #1023

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

Merged
merged 4 commits into from
Oct 27, 2022

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Oct 26, 2022

Previously, when given

class A {
  ^
}
class B {
}

recovery to the second class (because ^ is unexpected) would also consume the closing } nesting B inside A. That’s unexpected. Recovery of decl keywords inside member decl lists should not consume closing braces.


While doing this, also fix a few miscellaneous bugs in the test infrastructure.

@ahoppen ahoppen requested a review from bnbarham October 26, 2022 10:13
@ahoppen
Copy link
Member Author

ahoppen commented Oct 26, 2022

@swift-ci Please test

Comment on lines 79 to 80
let baselineRootConverter = SourceLocationConverter(file: "Baseline.swift", source: baseline.root.description)
let nodeRootConverter = SourceLocationConverter(file: "Actual.swift", source: node.root.description)
Copy link
Contributor

Choose a reason for hiding this comment

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

May as well use these when printing the nodes above as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea 👍

Comment on lines +163 to +164
|| fileURL.absoluteString.contains("26190-swift-iterabledeclcontext-getmembers.swift")
|| fileURL.absoluteString.contains("26139-swift-abstractclosureexpr-setparams.swift")
Copy link
Contributor

Choose a reason for hiding this comment

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

These aren't even that bad, pretty surprising to me that they cause a stack overflow. Isn't even 100 nested braces!

Copy link
Member Author

Choose a reason for hiding this comment

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

The issue here appears to be debug builds. In release builds, these are just fine.

@ahoppen ahoppen force-pushed the ahoppen/no-nested-class-recovery branch from e2bd89e to 2e7b363 Compare October 27, 2022 09:54
@ahoppen
Copy link
Member Author

ahoppen commented Oct 27, 2022

@swift-ci please test

@ahoppen
Copy link
Member Author

ahoppen commented Oct 27, 2022

@swift-ci Please test

@ahoppen ahoppen merged commit f6db3c5 into swiftlang:main Oct 27, 2022
@ahoppen ahoppen deleted the ahoppen/no-nested-class-recovery branch October 27, 2022 20:16
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.

2 participants