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
Pattern matching tuples fails to produce exhaustivity warning #10019
Comments
Imported From: https://issues.scala-lang.org/browse/SI-10019?orig=1 |
@SethTisue said: |
@refried said (edited on Nov 7, 2016 8:37:19 PM UTC): #10019 (this ticket) shows a false-negative in a seemingly very simple case. |
@SethTisue said: |
@SethTisue said: |
@refried said: |
@refried said (edited on Nov 11, 2016 10:43:07 PM UTC): def foo(t1: List[T], t2: List[T]) = (t1, t2) match {
case (Nil, Nil) => ()
} This code issues a warning: [warn] It would fail on the following inputs: (List(_), List(_)), (List(_), Nil), (Nil, List(_))} But this code issues no warnings: def foo(t1: List[T], t2: List[T]) = (t1, t2) match {
case (Nil, Nil) => ()
case (List(_), List(_)) => ()
} even though there are still missing cases. Do you think it's related? |
@refried said: |
Here's another similar case:
Note that removing the |
Yep I agree. |
It's |
Btw, that's because that's using (I'm going to consider this issue specific to tuples.) |
Relevant commentary in the pattern matcher:
😄 I'm going to leave out this part, as, as I said, it's more generally covered by #9232. |
Fixed in scala/scala#9147. |
Problem Supporting latest https://github.com/scala/scala/releases/tag/v2.12.13 includes a feature change in the scala compiler that will fail to compile when case matching is not exhaustive on tuples. Issues - scala/bug#10680 - scala/bug#10373 - scala/bug#10019 Resolved - scala/scala#9163 - scala/scala#9147 Solution Add `case _ => throw new MatchError` to case matching statement that is non-exhaustive JIRA Issues: SCALA-25 Differential Revision: https://phabricator.twitter.biz/D609046
This feels like a bug?
Compare:
to this, which is also not exhaustive but produces no warning:
I know
Tuple2
isn't sealed, but that doesn't seem to explain it (problem occurs even using a custom sealed replacement forTuple2
, plus the stdlib tuples participate successfully in match exhaustivity checks in some other contexts).Any ideas?
The text was updated successfully, but these errors were encountered: