def script live = (
val i: String = new String("Hello")
{println(i)}
)
On compilation, the compiler will fail with the following exception:
[ant:scalac] java.lang.OutOfMemoryError: Java heap space
[ant:scalac] at java.lang.Integer.valueOf(Integer.java:625)
[ant:scalac] at scala.runtime.BoxesRunTime.boxToInteger(BoxesRunTime.java:69)
[ant:scalac] at scala.tools.nsc.ast.parser.Parsers$UnitParser.syntaxError(Parsers.scala:233)
[ant:scalac] at scala.tools.nsc.ast.parser.Parsers$Parser.simpleScriptTerm(Parsers.scala:2600)
...
In general, it seems that every script variable/value declaration that involves the new keyword on its right-hand side will cause such an exception.
A workaround is to enclose the right-hand side in the parentheses:
def script live = (
val i: String = (new String("Hello"))
{println(i)}
)
Consider the following script:
On compilation, the compiler will fail with the following exception:
In general, it seems that every script variable/value declaration that involves the
new
keyword on its right-hand side will cause such an exception.A workaround is to enclose the right-hand side in the parentheses: