Skip to content

[SILGen] Output a different message for failed IUO force-unwraps #17826

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 3 commits into from
Jul 20, 2018
Merged

[SILGen] Output a different message for failed IUO force-unwraps #17826

merged 3 commits into from
Jul 20, 2018

Conversation

beccadax
Copy link
Contributor

@beccadax beccadax commented Jul 8, 2018

Modifies SILGen and the Swift._diagnoseUnexpectedNilOptional call to print a slightly different message for force unwraps which were implicitly inserted by the compiler for IUOs. That is, these two lines will produce different messages:

myOptional!.foo()    // => "Fatal error: Unexpectedly found nil while unwrapping an Optional value"
myIUO.foo()    // => "Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value"

The message is chosen based on the presence of certain flags in the ForceValueExpr, not on the type of the value being unwrapped, so myIUO!.foo() would print the first message, not the second.

Resolves SR-8170.

@beccadax
Copy link
Contributor Author

beccadax commented Jul 8, 2018

@swift-ci please smoke test

@beccadax beccadax requested a review from jckarter July 8, 2018 02:56
@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

beccadax added 3 commits July 12, 2018 19:09
Modifies SILGen and the `Swift._diagnoseUnexpectedNilOptional` call to print a slightly different message for force unwraps which were implicitly inserted by the compiler for IUOs. The message is chosen based on the presence of certain flags in the `ForceValueExpr`, not on the type of the value being unwrapped.
@jckarter pointed out that force unwraps emitted in thunks are always for IUOs and should use the implicit unwrap message.
@beccadax
Copy link
Contributor Author

Rebased on master.

@swift-ci please smoke test

@beccadax
Copy link
Contributor Author

@jckarter Is there anything I should do before this can be merged?

@jckarter
Copy link
Contributor

Looks good!

@beccadax
Copy link
Contributor Author

@swift-ci Please smoke test and merge

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