|
[#133] |
project: compiler |
priority: high |
category: bug |
|
submitter |
assigned to |
status |
date submitted |
|
Matthias |
Burak |
fixed |
2003-09-11 15:33:33.0 |
subject |
ClassCastExceptions at runtime |
code |
class Expr;
case class One(xs: List[Expr]) extends Expr;
case class Two() extends Expr;
object Foo with Executable {
def test(xs: List[Expr]) = xs match {
case List(a@(Two()*)) => System.out.println("a = " + a);
}
test(List(Two(),Two(),Two(),Two()));
test(List(Two(),Two(),Two()));
test(List(Two(),Two()));
test(List(Two()));
test(List());
} |
what happened |
Compiles, but at runtime it yields the following exception:
Exception in thread "main" java.lang.ExceptionInInitializerError
at Foo.main(Foo.scala)
Caused by: java.lang.ClassCastException
at Foo$.test(Foo.scala:1)
at Foo$.(Foo.scala:8)
at Foo$.(Foo.scala)
... 1 more
|
what expected |
Compiles and runs without errors. |
[back to overview] |
Burak edited on 2003-09-23 18:25:25.0
|
change priority to high
|
Burak edited on 2003-09-24 14:09:25.0
|
this one is not reproducible anymore. Very likely that the
fixing of previous errors fixed also this one, I do not know.
Syntax is now List(a@(Two()*)) .
|
Matthias edited on 2003-10-01 00:42:54.0
|
I just re-opened the bug again, because it seems to be not fully fixed. A small variation of the program above yields the same effect. Here's the program:
case class One();
object Foo with Executable {
def test(xs: List[Any]) = xs match {
case List(x@(One()*), y@(One())) => System.out.println("case");
case _ => System.out.println("default");
}
}
The runtime exception is:
Exception in thread "main" java.lang.ExceptionInInitializerError
at Foo.main(D.scala)
Caused by: java.lang.ClassCastException
at Foo$.test(D.scala:1)
at Foo$.(D.scala:7)
at Foo$.(D.scala)
... 1 more
|
Burak edited on 2003-10-06 19:47:38.0
|
the bug was a wrong condition in Tracer2Scala.
the distinction between bindings x@_ and x@_* is correct now.
|