Skip to content

[CS] Avoid crashing if we have no contextual type for initialization #66762

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
Jun 20, 2023

Conversation

hamishknight
Copy link
Contributor

For CTP_Initialization, there's no contextual type to record if the pattern is not a TypedPattern. As such, tweak RequirementFailure::getDeclRef to handle this case.

We probably ought to reconsider how we handle contextual types here, using a ContextualType locator when there is no contextual type recorded seems a bit weird, though in most cases we want to treat initializations the same regardless of if a TypedPattern was used. For now I'm leaving that as future work.

rdar://111009224
Resolves #66752

For `CTP_Initialization`, there's no contextual
type to record if the pattern is not a
`TypedPattern`. As such, tweak
`RequirementFailure::getDeclRef` to handle this
case.

We probably ought to reconsider how we handle
contextual types here, using a ContextualType
locator when there is no contextual type recorded
seems a bit weird, though in most cases we want
to treat initializations the same regardless of
if a TypedPattern was used. For now I'm leaving
that as future work.

rdar://111009224
@hamishknight
Copy link
Contributor Author

@swift-ci please test

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.

Compiler crash attempting to type-check invalid pattern match of failure()
2 participants