Aladdin - Scala Bugtracking
[#322] project: compiler priority: medium category: feature
submitter assigned to status date submitted
Stephane Matthias won't fix 2004-04-27 18:02:42.0
subject StackOverflowError with array
code
object Main with Application {

   def view[a](xs: Array[a]): List[a] =
     for (val x <- xs) yield x;

   val xs = Array(10, 23, 23);
   Console.println(xs:List[Int])
}
what happened
Exception in thread "main" java.lang.StackOverflowError
what expected List(10,23,23) is printed out.
[back to overview]
Changes of this bug report
Martin  edited on  2004-04-30 11:30:35.0
Look at the code after analysis. You will find that a view is inserted in the result of the view method. The error is that the for-comprehension in the view returns an array, not a list, hence the view is applied recursively, and a stackoverflow results.