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 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

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jun 29, 2012

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 5, 2012

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 6, 2012

@harrah said:
Thank you.

@scabug scabug closed this Jul 6, 2012
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 6, 2012

@adriaanm said:
thank you for reporting :-)

@scabug scabug added this to the 2.10.0-M4 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.