Skip to content

[DiagnosticsQoI] Bail on nil literal diagnostics if the source is Optional #15701

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 1 commit into from
Apr 3, 2018

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Apr 3, 2018

A tiny change to get back some QoI because it isn't sufficient to just observe that the initializer of a pattern binding failed a contextual conversion from nil. If we fire the existing diagnostic, it would pile on optional sugar and never tell the user what actually went wrong.

// Before
var _: Array? = nil // nil cannot initialize specified type 'Array?', add '?' to form the optional type 'Array??'
var _: Array?? = nil // nil cannot initialize specified type 'Array??', add '?' to form the optional type 'Array???'
var _: Array??? = nil // nil cannot initialize specified type 'Array???', add '?' to form the optional type 'Array????'
// ...

// After
var _: Array? = nil // generic parameter 'Element' could not be inferred

"Reported" by a Redditor.

@CodaFi CodaFi requested a review from xedin April 3, 2018 06:12
@CodaFi
Copy link
Contributor Author

CodaFi commented Apr 3, 2018

@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.

Makes sense, thanks @CodaFi!

@CodaFi
Copy link
Contributor Author

CodaFi commented Apr 3, 2018

⛵️

@CodaFi CodaFi merged commit f466e29 into swiftlang:master Apr 3, 2018
@CodaFi CodaFi deleted the humdinger branch April 3, 2018 07:19
@krypt-lynx
Copy link

Wow, it was fast.

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.

3 participants