-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Fix SyntaxModel assertion failure due to consuming tokens twice or out of order #29769
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
[SourceKit] Fix SyntaxModel assertion failure due to consuming tokens twice or out of order #29769
Conversation
@swift-ci please test |
dcd0159
to
7e66dab
Compare
@swift-ci please test |
Build failed |
Build failed |
Build failed |
Build failed |
7e66dab
to
fcbb779
Compare
@swift-ci please smoke test |
…s twice or prematurely The SyntaxModel walker would end up visiting the attributes attached to a PatternBindingDecl twice if it contained more than one VarDecl, hitting the below assertion on the second visit because the tokens corresponding to the attribute had already been consumed the first time around: ``` Assertion failed: (0 && "Attribute's TokenNodes already consumed?"), function handleSpecialDeclAttribute ``` It would also hit the same assertion for attributes on an EnumCaseDecl, but even when it only had a single child EnumElementDecl. This because when we visited the EnumCaseDecl and pushed its structure node, we'd consume and emit any tokens before it's start position. This meant that when we tried to process the attributes attached to the child EnumElementDecl its tokens had already been consumed, triggering the assertion. In both cases the attributes syntactically attach to the parent PatternBindingDecl or EnumCaseDecl, but in the AST they're accessed via their child VarDecls or EnumElementDecls. Resolves rdar://problem/53747546
fcbb779
to
5e1985c
Compare
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
The SyntaxModel walker would end up visiting the attributes attached to a PatternBindingDecl twice if it contained more than one VarDecl, hitting the below assertion on the second visit because the tokens corresponding to the attribute had already been consumed the first time around:
It would also hit the same assertion for attributes on an EnumCaseDecl, but even when it only had a single child EnumElementDecl. This because when we visited the EnumCaseDecl and pushed its structure node, we'd consume and emit any tokens before it's start position. This meant that when we tried to process the attributes attached to the child EnumElementDecl its tokens had already been consumed, triggering the assertion.
In both cases the attributes syntactically attach to the parent PatternBindingDecl or EnumCaseDecl, but in the AST they're accessed via their child VarDecls or EnumElementDecls.
Resolves rdar://problem/53747546