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

Spurious exhaustiveness warning on boolean nested in tuple #6008

Closed
scabug opened this issue Jun 29, 2012 · 4 comments
Closed

Spurious exhaustiveness warning on boolean nested in tuple #6008

scabug opened this issue Jun 29, 2012 · 4 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Jun 29, 2012

The warning in the following is unnecessary:

Welcome to Scala version 2.10.0-20120629-080700-cd1e6f94e9
[...]

def x(in: (Int, Boolean)) = in match { case (i: Int, b: Boolean) => 3 }
<console>:7: warning: match may not be exhaustive.
It would fail on the following inputs: (_, false), (_, true)
       def x(in: (Int, Boolean)) = in match { case (i: Int, b: Boolean) => 3 }
                                   ^

There is no warning if the Int is ignored or bound without an explicit type:

scala> def x(in: (Int, Boolean)) = in match { case (_, b: Boolean) => 3 }
x: (in: (Int, Boolean))Int

Keeping the explicit type for the Int but dropping the one for Boolean presents a spurious warning again:

scala> def x(in: (Int, Boolean)) = in match { case (i: Int, b) => 3 }
<console>:7: warning: match may not be exhaustive.
It would fail on the following input: (_, _)
       def x(in: (Int, Boolean)) = in match { case (i: Int, b) => 3 }
                                   ^

scala> x((3,true))
res2: Int = 3
@scabug
Copy link
Author

scabug commented Jun 29, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6008?orig=1
Reporter: @harrah

@scabug
Copy link
Author

scabug commented Jul 5, 2012

@adriaanm said:
scala/scala#824

@scabug
Copy link
Author

scabug commented Jul 6, 2012

@harrah said:
Thank you.

@scabug scabug closed this as completed Jul 6, 2012
@scabug
Copy link
Author

scabug commented Jul 6, 2012

@adriaanm said:
thank you for reporting :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants