Skip to content

Fix wrong missing-return error message for an initializer returning an implicitly unwrapped optional #14272

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
Jan 30, 2018

Conversation

eeckstein
Copy link
Contributor

The problem was that the unreachable instruction after the IUO unwrapping error call was interpreted as missing-return-unreachable.

rdar://problem/36611041

…n implicitly unwrapped optional

The problem was that the unreachable instruction after the IUO unwrapping error call was interpreted as missing-return-unreachable.

rdar://problem/36611041
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein eeckstein requested review from graydon and rudkx January 30, 2018 17:09
@eeckstein
Copy link
Contributor Author

@graydon @rudkx can you please review this?

@@ -97,7 +97,7 @@ func whileLoop(flag: Bool) -> Int {
struct S {}
extension S:ExpressibleByStringLiteral {
init!(stringLiteral:String) {
} // expected-error {{missing return in a function expected to return 'S!'}}
} // no error
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@graydon This error is printed since your fix #11765
But I think the error message was wrong. Please confirm.

Copy link
Contributor

Choose a reason for hiding this comment

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

@eeckstein Perhaps! I have no idea whether an IUO initializer with no body is legal, I was mainly concerned with making it stop crashing in #11765 by handling the case, and the existing diagnostic seemed to fit my understanding of the meaning of an IUO initializer with no body. But by all means confirm with someone who knows IUO semantics better than me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Returning successfully (i.e. a non-optional, properly-initialized S) would be the correct semantics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it returns an S (implicitly, not with a return statement)

Copy link
Contributor

@graydon graydon left a comment

Choose a reason for hiding this comment

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

If this is the correct semantics, +1

@eeckstein eeckstein merged commit b1092f8 into swiftlang:master Jan 30, 2018
@eeckstein eeckstein deleted the fix-error-msg branch January 30, 2018 21:26
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