Skip to content

[IDE] Fix SyntaxModel crash due to out-of-order walking of EnumElementDecls #26270

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 2 commits into from
Jul 24, 2019

Conversation

nathawes
Copy link
Contributor

@nathawes nathawes commented Jul 22, 2019

ModelASTWalker was previously constructing SyntaxNodes for EnumElementDecls manually when visiting their associated EnumCaseDecl so that they would appear as its children rather than its siblings. It wasn't actually walking these nodes though, so missed handling some things, e.g. closures passed as default argument values. It was also still walking the same EnumElementDecls again in the sibling position. Because the TokenNodes in the range of each EnumElementDecl were consumed when they were manually constructed, this second visit was triggering some recently added assertions in the handling of custom attributes, which expected the corresponding TokenNodes to still be present.

Resolves rdar://problem/53313197

@nathawes
Copy link
Contributor Author

@swift-ci please test

@nathawes
Copy link
Contributor Author

@swift-ci please stress test

…tDecls

ModelASTWalker was previously constructing SyntaxNodes for EnumElementDecls
manually when visiting their associated EnumCaseDecl so that they would appear
as children rather than siblings. It wasn't actually walking these nodes
though, so missed handling some things, e.g. closures passed as default
argument values. These were also still being visited later, and because the
first visit consumed all the associated TokenNodes, this was triggering an
assertion due to the associated TokenNodes not matching expectations.
@nathawes nathawes force-pushed the 53313197-syntaxmodel-crash branch from c2b7d92 to 218f490 Compare July 23, 2019 16:34
@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c2b7d92f0a472d757436b851dec7a702a19b27a8

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - c2b7d92f0a472d757436b851dec7a702a19b27a8

Assert 0 and return a default kind, rather than calling unreachable
as a defensive fix for rdar://problem/53343735.
@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 218f490

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 218f490

@nathawes
Copy link
Contributor Author

@swift-ci please test OS X Platform

@nathawes nathawes marked this pull request as ready for review July 23, 2019 23:39
@nathawes nathawes requested a review from akyrtzi July 23, 2019 23:40
@nathawes nathawes merged commit 71c4c16 into swiftlang:master Jul 24, 2019
@nathawes nathawes deleted the 53313197-syntaxmodel-crash branch July 24, 2019 16:45
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.

3 participants