Aladdin - Scala Bugtracking
[#1011] project: compiler priority: high category: bug
submitter assigned to status date submitted
Sean Martin fixed 2007-03-23 07:53:40.0
subject Exponential-time to report type error embedded in XML code
code
package test;
import scala.xml._;

abstract class Test {
  //val entity : String;
  def primitiveHeader : NodeSeq = 
    Group({
       <dl><code>{Text(entity)}</code>
           <code>{Text(entity)}</code>
           <code>{Text(entity)}</code>
           <code>{Text(entity)}</code>
           <code>{Text(entity)}</code></dl>
    } ++ // 3 seconds
    {}++ // 5 seconds
    {}++ // 10 seconds
    {}++ // 20 seconds
    //{}++ // 40 seconds
    <hr/>);
}
what happened
sean-mcdirmid:~/workspace/test12 mcdirmid$ ../scala/build/quick/bin/scalac -verbose src/test/Test.scala
src/test/Test.scala:10: error: not found: value entity
          {Text(entity.flagsString)}
                      ^
[typer in 20753ms]
[total in 20908ms]
one error found
I thought this was an infinite loop problem, but it turned out to be an exponential time problem. Add more XML c\ ode with more type errors, and the compiler won't terminate within a reasonable amount of time. Also, you can ta\ ke a couple of statements away from the above code to get it to run in 4 seconds rather than 20 seconds.
what expected This code should compile a lot more quickly (shouldn't spend 20 seconds in typers!).
[back to overview]
Changes of this bug report
Sean  edited on  2007-03-23 12:15:20.0
Better example code.
Martin  edited on  2007-03-23 14:30:54.0