Skip to content

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

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

5.9 cherry-pick of #66762

  • Explanation: Fixes a constraint system crash when attempting to diagnose an invalid pattern match.
  • Scope: Affects diagnostic logic for patterns
  • Radar: rdar://111009224
  • Risk: Low, only affects invalid code, and the fix is defensive in nature
  • Testing: Added tests to test suite
  • Reviewer: Pavel Yaskevich

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 hamishknight requested a review from a team as a code owner June 20, 2023 17:04
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit b0dd6f8 into swiftlang:release/5.9 Jun 20, 2023
@hamishknight hamishknight deleted the out-of-context-5.9 branch June 20, 2023 21:58
@hamishknight hamishknight added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9 labels Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants