| [#33] | project: compiler | priority: medium | category: feature | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Stephane | Martin | won't fix | 2003-07-01 18:58:03.0 | |
| subject | expected pattern does not conform | |||
| code |
object Main {
type Data = Any;
def foo(x: Data): String = x match {
case Nil => ""
case (head :: List(ys)) :: zs =>
val body = ys match {
// case Nil => ""
case List() => ""
case _ => " :- " + ys.toString()
};
head.toString() + body + ".\n"
+ foo(zs)
}
def main(args: Array[String]) = {
val xs = (3 :: List(4)) :: Nil;
System.out.println(foo(xs));
}
}
|
|||
| what happened | |
|||
| what expected | 3 :- 4 is printed out ! | |||
| [back to overview] | ||||
| Martin edited on 2003-07-01 19:00:00.0 |
| That's actually the specified behaviour. A selector of type Any cannot be matched against List(), since Any is not a sequence type. It can only be matched against case classes, and List is not a case class. |