-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema][MiscDiag] Fix constantness diag to handle result builder patterns #40579
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
[Sema][MiscDiag] Fix constantness diag to handle result builder patterns #40579
Conversation
@swift-ci please test |
We currently have a problem with how constantness diagnostics traverse the AST to look for function calls to diagnose. We special case closure bodies and don't check them (unless they're single expression closures) because closure bodies are type- checked separately and will be covered later. This poses a problem in certain AST structures, such as what we see with result builders, because the call expressions are rooted in declarations, which aren't checked in the closure body type-checking covered by MiscDiag. This patch fixes the problem by manually checking all closure bodies and stopping misc diagnostics from checking the bodies separately. rdar://85737300
b36ca49
to
f748c84
Compare
@swift-ci please test |
Build failed |
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.
@guitard0g I think this is going to be fixed once I re-enable SE-0326 since all of the closures are going to be type-checked together with expression - so the check you have removed is always going to be true. Could you please give it a try and see if that works with -Xfrontend -experimental-multi-statement-closures
flag set?
@xedin This does seem to stop some of the exiting early, but not in all instances, so we may still need this check. |
@swift-ci please 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.
Alright, we can revisit this once result builders are ported to use conjunction mechanism.
Build failed |
@swift-ci please test macOS platform |
…patterns (This is a cherry-pick of PR swiftlang#40579 to the release/5.6 branch.) We currently have a problem with how constantness diagnostics traverse the AST to look for function calls to diagnose. We special case closure bodies and don't check them (unless they're single expression closures) because closure bodies are type- checked separately and will be covered later. This poses a problem in certain AST structures, such as what we see with result builders, because the call expressions are rooted in declarations, which aren't checked in the closure body type-checking covered by MiscDiag. This patch fixes the problem by manually checking all closure bodies and stopping misc diagnostics from checking the bodies separately. rdar://85737300
We currently have a problem with how constantness diagnostics
traverse the AST to look for function calls to diagnose. We
special case closure bodies and don't check them (unless they're
single expression closures) because closure bodies are type-
checked separately and will be covered later. This poses a problem
in certain AST structures, such as what we see with result builders,
because the call expressions are rooted in declarations, which aren't
checked in the closure body type-checking covered by MiscDiag.
This patch fixes the problem by manually checking all closure bodies
and stopping misc diagnostics from checking the bodies separately.
rdar://85737300