Skip to content

[5.9] Avoid creating binding patterns in a couple more positions #1826

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

Conversation

hamishknight
Copy link
Contributor

5.9 cherry-pick of #1804

  • 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 hamishknight requested a review from ahoppen as a code owner June 21, 2023 11:29
@hamishknight
Copy link
Contributor Author

swiftlang/swift#66804

@swift-ci please test

@hamishknight hamishknight merged commit ff75751 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants