-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ConstraintSystem] Allow fixing missing conformance failures for Void
and uninhabited types.
#27123
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
`Void` and uninhabited types.
and no return statements.
@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.
Great!
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 have an optional suggestion -- feel free to ignore.
fatalError() | ||
} | ||
|
||
let _ = foo() {fatalError()} & nil // expected-error {{generic parameter 'T' could not be inferred}} | ||
let _ = foo() {fatalError()} & nil // expected-error {{global function 'foo' requires that 'Never' conform to 'P'}} |
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 is a clear improvement!
However I can't help but wonder about 'Void'. The diagnostic would say "global function 'foo' requires that 'Void' conform to 'P'", which is a true statement, but 'Void' cannot ever conform to 'P'. Same if it's a function type or a metatype. As a follow-up you might want to add some test cases for non-nominal types and see if the diagnostic could be tailored a bit.
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 agree that there should be a tailored diagnostic. For example, this code:
protocol P {}
func genericFunc<T: P>(_ x: T) {}
genericFunc { return }
currently produces the error "Argument type '() -> ()' does not conform to expected type 'P'".
We already give a good error message for protocol types - "Protocol type 'P' cannot conform to 'P' because only concrete types can conform to protocols" - we could use a similar error message for non-nominal types.
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'll do this in a separate PR
I think #27133 should have fixed the crash here... |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
Tests are still failing because of one validation test that I need to update the diagnostics for |
missing conformance diagnostics.
@swift-ci please smoke test |
…sing conformance diagnostics.
@swift-ci please smoke test |
No description provided.