| [#587] | project: compiler | priority: medium | category: bug | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Stephane | Martin | noise | 2006-05-05 18:00:41.0 | |
| subject | Type mismatch error | |||
| code |
object test {
case class Foo(name: String)
case class Bar(xs: List[Foo])
val xs = List(Bar(List(Foo("a"), Foo("b"))))
//for (val Bar(hd :: tl) <- xs) yield Bar(hd :: tl) // OK
for (val Bar(hd @ Foo(name) :: tl) <- xs) yield Bar(hd :: tl)
} |
|||
| what happened | |
|||
| what expected | compiles with no error | |||
| [back to overview] | ||||
| Martin edited on 2006-05-05 19:35:58.0 |
| You need to write (hd @ Foo(name)), otherwise hd will scope over the whole pattern that follows. I have not tried this out, though, so you should still verify that it's OK. |