Aladdin - Scala Bugtracking
[#212] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Stephane Michel fixed 2003-10-27 13:15:11.0
subject ClassCastException
code
<pre>object Test {

    def foo(x: Array[Int]) = {
        def bar(x: Array[Int]): Array[Int] = {
            var newX = new Array[Int](x.length);
            for (val i <- List.range(0, newX.length)) do { newX(i) = x(i) };
            newX
        }
        bar(x)
    }

    def main(args: Array[String]) = {
        val xs = new Array[Int](2);
        xs(0) = 1; xs(1) = 4;
        val ys = foo(xs);
    }

}
</pre>
what happened
scalac -d classes src/Test.scala
Exception in thread "main" java.lang.ClassCastException
        at Test$.bar$0(src/Test.scala:7)
        at Test$.foo(src/Test.scala:10)
        at Test$.main(src/Test.scala:16)
        at Test.main(src/Test.scala)
what expected No runtime error.
[back to overview]
Changes of this bug report
Michel  edited on  2003-11-24 11:06:31.0
I cannot reproduce this with the current CVS. It must have been fixed accidentally (I like that).