[#70] | project: compiler | priority: medium | category: feature | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Matthias | Burak | fixed | 2003-07-14 02:06:58.0 | |
subject | Random pattern matching behavior | |||
code |
object T { def last(xs: List[Int]): Int = xs match { case List(_*, x) => x case _ => -1 } def main(args: Array[String]) = { System.out.println(last(List())); System.out.println(last(List(1))); System.out.println(last(List(1, 2))); System.out.println(last(List(1, 2, 3))); } } |
|||
what happened | Expected output:-1 1 2 3 |
|||
what expected | Actual output:
-1 -1 2 -1 |
|||
[back to overview] |
Burak edited on 2003-07-14 10:07:10.0 |
This is the specified behaviour :-) "_*" is a valid identifier name, so is treated like a var. try "_ *" instead. |
Burak edited on 2003-07-14 10:09:43.0 |
I close this bug, even though "_ *" (with a space between _ and *) leads to a crash. |
Burak edited on 2003-07-14 12:18:19.0 |
ok, now the crash on "_ *" is fixed, too. |