Skip to content

[TypeChecker] Fix a problem with rethrows classification. #20927

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 2 commits into from
Dec 1, 2018
Merged

[TypeChecker] Fix a problem with rethrows classification. #20927

merged 2 commits into from
Dec 1, 2018

Conversation

rudkx
Copy link
Contributor

@rudkx rudkx commented Nov 30, 2018

We failed to properly classify arguments that are of optional function
type, in this case leading to a verification failure due to the throws
attribute on the apply expression not being set to some value.

Fixes: SR-9102 / rdar://problem/45615204

…function types.

I have a follow-up change to correctly classify optional arguments,
and with that fix applied we incorrectly emit rethrow diagnostics for
'nil' arguments passed in places where optional throwing functions are
expected.

This change ensures that we strip the throwing bit off of the nested
function type so that we don't consider 'nil' arguments in these
positions as potentially throwing functions.
We failed to properly classify arguments that are of optional function
type, in this case leading to a verification failure due to the throws
attribute on the apply expression not being set to some value.

Fixes: SR-9102 / rdar://problem/45615204
@rudkx
Copy link
Contributor Author

rudkx commented Nov 30, 2018

@swift-ci Please smoke test

@rudkx rudkx requested review from xedin and rjmccall November 30, 2018 22:00
Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

Seems reasonable. The constraint-system part is just to get an easier-to-analyze pattern?

@rudkx
Copy link
Contributor Author

rudkx commented Nov 30, 2018

@rjmccall It's to avoid inferring throwing-function types for nil-literal operands. In decl/func/rethrows.swift there are a couple tests where we start emitting diagnostics about missing try without that change. I suppose it could be pattern-matched as a special-case in the error type checking code as well.

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.

LGTM!

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