Skip to content

Conversation

hamishknight
Copy link
Contributor

5.9 cherry-pick of #66718

  • Explanation: Allows the parser to correctly parse the patterns case let E<Int>.foo(x) and case let (y[0], x), where only x becomes a binding. Previously we would attempt to treat E and y as bindings.
  • Scope: Affects parsing of patterns
  • Issue: rdar://108738034
  • Risk: Low, only affects code that was previously invalid
  • Testing: Added tests to test suite
  • Reviewer: Alex Hoppen

If we have an identifier followed by either `[` or
a generic argument list, avoid turning it into a
binding pattern, as that would be invalid. This
is similar to the existing rule we have where a
following `(` prevents a binding pattern from
being formed.

This allows patterns such as `let E<Int>.foo(x)` and
`let (y[0], x)` to compile, where `x` is treated
as a binding, but no other identifier is.

rdar://108738034
@hamishknight
Copy link
Contributor Author

swiftlang/swift-syntax#1826

@swift-ci please test

@hamishknight hamishknight merged commit f4dbf0f into swiftlang:release/5.9 Jun 21, 2023
@hamishknight hamishknight deleted the getting-out-of-a-bind-5.9 branch June 21, 2023 16:14
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