-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Require MainActor isolation on main() function #39503
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 test |
Build failed |
Build failed |
41efb85
to
e96b3f0
Compare
@swift-ci please test |
@swift-ci please test Windows platform |
@swift-ci please test Linux platform |
@swift-ci please test macOS platform |
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.
Looks good!
This patch forces the main function to be protected behind MainActor isolation. If no actor isolation is specified, the main function will implicitly have MainActor isolation.
Putting the main function under the MainActor appears to have accidentally "fixed" the resilience tests on Windows. I've put the entry to those tests under a separate task to try and avoid accidentally hiding the bug behind the main actor.
7ee8ea6
to
fa00a32
Compare
@swift-ci please test |
ASTContext &ctx = fnDecl->getASTContext(); | ||
|
||
const bool isMainMain = fnDecl->isMainTypeMainMethod(); | ||
const bool isMain$Main = |
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.
In theory, I think a C compiler can reject this.
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.
*pulls out C++ spec*
Yes you are correct. $
is not a valid C++14 identifier-nondigit
per 2.10. Will fix.
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.
This patch forces the main function to be protected behind MainActor
isolation.
This implements the other part of SE-0323.