Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always check exhaustivity of custom extractors/guards
- Loading branch information
Showing
25 changed files
with
322 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
t5365.scala:3: warning: match may not be exhaustive. | ||
It would fail on the following input: None | ||
It would fail on the following inputs: None, Some(_) | ||
def nonExhautiveIfWeAssumeGuardsTrueOrFalse(x: Option[Int]): Int = x match { | ||
^ | ||
t5365.scala:7: warning: match may not be exhaustive. | ||
It would fail on the following input: Some(_) | ||
def nonExhautiveIfWeAssumeGuardsFalse(x: Option[Int]): Int = x match { | ||
^ | ||
t5365.scala:12: warning: match may not be exhaustive. | ||
It would fail on the following input: Some(_) | ||
def inverseGuards(x: Option[Int]): Int = x match { | ||
^ | ||
t5365.scala:18: warning: match may not be exhaustive. | ||
It would fail on the following input: None | ||
It would fail on the following inputs: None, Some(_) | ||
def extractor(x: Option[Int]) = x match { | ||
^ | ||
t5365.scala:21: warning: match may not be exhaustive. | ||
It would fail on the following input: None | ||
It would fail on the following inputs: None, Some(_) | ||
def repeatedExtractor(x: Option[Int]) = x match { | ||
^ | ||
t5365.scala:24: warning: match may not be exhaustive. | ||
It would fail on the following input: Some(_) | ||
def extractorStrict(x: Option[Int]) = x match { | ||
^ | ||
t5365.scala:28: warning: match may not be exhaustive. | ||
It would fail on the following input: Some(_) | ||
def repeatedExtractorStrict(x: Option[Int]) = x match { | ||
^ | ||
error: No warnings can be incurred under -Xfatal-warnings. | ||
three warnings found | ||
7 warnings found | ||
one error found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lists-run.scala:177: warning: match may not be exhaustive. | ||
It would fail on the following input: List((x: String forSome x not in "foo")) | ||
def show(xs: List[String]) = xs match { | ||
^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
Test_2.scala:5: warning: match may not be exhaustive. | ||
It would fail on the following input: _ | ||
List(1, 2) match { case UnapplyMacro(x, y) => println((x, y)) } | ||
^ | ||
Test_2.scala:6: warning: match may not be exhaustive. | ||
It would fail on the following input: _ | ||
List(1, 2, 3) match { case UnapplyMacro(x, y, z) => println((x, y, z)) } | ||
^ | ||
(1,2) | ||
(1,2,3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
matchonstream.scala:2: warning: match may not be exhaustive. | ||
It would fail on the following input: _ | ||
Stream.from(1) match { case Stream(1, 2, x @_*) => println("It worked!") } | ||
^ | ||
It worked! |
Oops, something went wrong.