-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[4.0] Escalate the warning about the "== Self" type soundness hole to an error #10320
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
[4.0] Escalate the warning about the "== Self" type soundness hole to an error #10320
Conversation
@swift-ci please test |
// Note: while Swift 3.2 originally intended to provide backward | ||
compatibility here, the type-soundness issue was considered so severe | ||
(due to it breaking the optimizer) that that we escalated it to an | ||
error. |
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.
Missing //
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.
muahahaha
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.
thank you
9919a09
to
80f9dd8
Compare
@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.
Sounds like the right tradeoff to me.
Build failed |
…ror. Swift 3 had a type soundness hole in protocol conformance checking where the requirement contained an "== Self" constraint and the witness was a member of a non-final class. We previously closed the type soundness hole in PR swiftlang#9830, but left it as a warning in Swift 3 compatibility mode. Escalate that warning to an error. The optimizers break due to this type soundness hole, and of course it can lead to other runtime breakage because it violates the type system. Fixes rdar://problem/28601761. (cherry picked from commit 8b80681)
Build failed |
80f9dd8
to
5638d92
Compare
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
Explanation: Swift 3 had a type soundness hole in protocol conformance checking where the requirement contained an `== Self" constraint and the witness was a member of a non-final class. We closed this hole in Swift 4, but left it as a warning in Swift 3.2. Unfortunately, this soundness hole breaks invariants that the SIL optimizer depends on, so the optimizer will crash. Escalate the warning to an error even in Swift 3.2 mode to close this type hole, because it's better to reject a program than crash trying to compile it.
Scope: We know of one project that will start to be rejected in Swift 3.2 mode because of this change, because that project is (unintentionally) exploiting the type soundness hole. Today, that project can only compile as Swift 3.2 and only with the optimizers turned off.
Radar: rdar://problem/28601761
Risk: Very low. The risk to anyone not depending on this type soundness hole is zero; some projects that were depending on this type soundness hole will now fail to compile (with a Fix-It to suggest how to avoid the hole).
Testing: Compiler regression testing.