Skip to content
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

[SR-12035] Pattern engine sometimes implicitly tuples patterns (?) #54472

Open
typesanitizer opened this issue Jan 15, 2020 · 1 comment
Open
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@typesanitizer
Copy link

Previous ID SR-12035
Radar rdar://problem/58595126
Original Reporter @typesanitizer
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @typesanitizer
Priority Medium

md5: 7407a6de1c05c91acdf78849acf2e3b8

Issue Description:

If you look at PR 29213, you'll notice that after the first commit, we had three very similar test cases func sr11212_content_generic_pattern_untupledN (N = 1, 2, 3) but only the third one triggered an error. Based on the fix in the second commit (implicitly tupling the pattern), one would think that the first two should trigger errors too. But they weren't triggering errors before! This means that there must be some bug in the pattern engine, and the two bugs cancelled each other out.


For the sake of keeping this bug report self-contained, I should point out the main thing:

enum Box<T> {
  case box(T)
}
func f(b: Box<(Int, Int)>) -> (Int, Int) {
  switch b {
  case let .box(x, y): return (x, y)
  // Before PR, pattern was treated as AssociatedValues(x, y) // !!! should've been an error but it wasn't!
  // After PR, pattern is treated as Tuple(x, y) // ok
  }
}

My hunch is that trying to find a test case after PR 29213 might be very tricky. It might help to comment out the fix in PR 29213 while trying to find a test case (at the risk of rediscovering something already fixed by PR 29213).

We need to be careful though, in case we break some buggy behavior someone is relying on.

@typesanitizer
Copy link
Author

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant