| [#35] | project: compiler | priority: medium | category: bug | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Michel | Matthias | fixed | 2003-06-12 11:02:33.0 | |
| subject | bad pattern matching code | |||
| code |
object Main {
def main(args: Array[String]): unit = {
val n = Pair(List(), List(1)) match {
case Pair(Nil, Nil) => 0
case Pair(Nil, _) => 1
case Pair(_, Nil) => 2
case Pair(h1 :: t1, h2 :: t2) => 3
case _ => -1
}
System.out.println(n);
}
} |
|||
| what happened | -1 gets printed |
|||
| what expected | 1 gets printed Looking at the code produced by the pattern matcher, one can see that it is incorrect. | |||
| [back to overview] | ||||