-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Format macro decl without crashing #76441
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
Conversation
@swift-ci please smoke test |
UIView() | ||
} | ||
|
||
// RUN: %sourcekitd-test -req=format -line=3 -length=1 %s >%t.response |
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.
If you write the response into %t.response
you should also check its contents.
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.
Without the fix this test crashes, and indent-crashes.swift
which seems to have a goal similar to this did write into %t.response
without checking its content I thought it would be fine like this.
What do you think I should do?
- Do not write into
%t.response
? - Write into
%t.response
and check the content? In that case should I change the test to be badly indented on purpose checking it properly gets into the expected shape?
Thanks
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.
I would unindent UIView()
and then check that the response correctly indents UIView()
to one indentation level.
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.
@ahoppen Thanks for the help! I just made the modifications you asked.
I also checked that running this test without my SourceKit changes still makes SourceKit crash and the test fail.
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.
Great. Thank you for the fix. Looks good to me 👍🏽
@swift-ci Please smoke test |
Resolves #70002
Fix SourceKit crash occurring when formatting a macro with both an available attribute and a trailing closure.
SourceKit's formatting code was expecting trailing closures to only be present on expressions (
Expr
), but an available attribute on a macro makes it a declaration (Decl
).I don't have much knowledge of how SourceKit's formatting works so I wouldn't be surprised if this was incomplete.