Skip to content

[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

Merged
merged 4 commits into from
Sep 13, 2019

Conversation

hborla
Copy link
Member

@hborla hborla commented Sep 11, 2019

No description provided.

@hborla hborla requested a review from xedin September 11, 2019 19:41
@hborla
Copy link
Member Author

hborla commented Sep 11, 2019

@swift-ci please smoke test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Copy link
Contributor

@slavapestov slavapestov left a 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'}}
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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

@xedin
Copy link
Contributor

xedin commented Sep 12, 2019

I think #27133 should have fixed the crash here...

@DougGregor
Copy link
Member

@swift-ci please smoke test

1 similar comment
@DougGregor
Copy link
Member

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Sep 12, 2019

Tests are still failing because of one validation test that I need to update the diagnostics for

@hborla
Copy link
Member Author

hborla commented Sep 12, 2019

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Sep 12, 2019

@swift-ci please smoke test

@hborla hborla merged commit 0434d58 into swiftlang:master Sep 13, 2019
@hborla hborla deleted the missing-conformance-diag branch September 13, 2019 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants