Aladdin - Scala Bugtracking
[#365] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Matthias Burak fixed 2004-09-29 09:48:22.0
subject Unbalanced XML literals
code
object T {
  val x = <a><b></b>;
}
what happened
Crashes the compiler:
T.scala:4: unclosed XML literal


Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 36
        at scala.tools.scalac.ast.parser.Scanner$SourceIterator$class.raw(Scanner.scala:93)
        at scala.tools.scalac.ast.parser.Scanner$class.xNext(Scanner.scala:916)
        at scala.tools.scalac.ast.parser.MarkupParser$class.nextch(MarkupParser.scala:472)
        at scala.tools.scalac.ast.parser.MarkupParser$class.xText(MarkupParser.scala:377)
        at scala.tools.scalac.ast.parser.MarkupParser$class.content(MarkupParser.scala:279)
        at scala.tools.scalac.ast.parser.MarkupParser$class.element(MarkupParser.scala:299)
        at scala.tools.scalac.ast.parser.MarkupParser$class.xLiteral(MarkupParser.scala:408)
        at scala.tools.scalac.ast.parser.Parser$class.simpleExpr(Parser.scala:1019)
        at scala.tools.scalac.ast.parser.Parser$class.prefixExpr(Parser.scala:998)
        at scala.tools.scalac.ast.parser.Parser$class.postfixExpr(Parser.scala:961)
        at scala.tools.scalac.ast.parser.Parser$class.expr(Parser.scala:919)
        at scala.tools.scalac.ast.parser.Parser$class.expr(Parser.scala:845)
        at scala.tools.scalac.ast.parser.Parser$class.equalsExpr(Parser.scala:797)
        at scala.tools.scalac.ast.parser.Parser$class.patDefOrDcl(Parser.scala:1743)
        at scala.tools.scalac.ast.parser.Parser$class.defOrDcl(Parser.scala:1697)
        at scala.tools.scalac.ast.parser.Parser$$anon$7.apply(Parser.scala:2085)
        at scala.tools.scalac.ast.parser.Parser$$anon$7.apply(Parser.scala:2085)
        at scala.tools.scalac.ast.parser.Parser$class.joinComment(Parser.scala:173)
        at scala.tools.scalac.ast.parser.Parser$class.templateStatSeq(Parser.scala:2085)
        at scala.tools.scalac.ast.parser.Parser$class.templateBody(Parser.scala:2006)
        at scala.tools.scalac.ast.parser.Parser$class.classTemplate(Parser.scala:1963)
        at scala.tools.scalac.ast.parser.Parser$class.objectDef(Parser.scala:1933)
        at scala.tools.scalac.ast.parser.Parser$class.clsDef(Parser.scala:1724)
        at scala.tools.scalac.ast.parser.Parser$$anon$6.apply(Parser.scala:2058)
        at scala.tools.scalac.ast.parser.Parser$$anon$6.apply(Parser.scala:2058)
        at scala.tools.scalac.ast.parser.Parser$class.joinComment(Parser.scala:173)
        at scala.tools.scalac.ast.parser.Parser$class.topStatSeq(Parser.scala:2058)
        at scala.tools.scalac.ast.parser.Parser$class.compilationUnit(Parser.scala:2195)
        at scala.tools.scalac.ast.parser.Parser$class.parse(Parser.scala:64)
        at scala.tools.scalac.ast.parser.ParserPhase$$anon$0.apply(ParserPhase.scala:21)
        at scala.tools.scalac.ast.parser.ParserPhase$$anon$0.apply(ParserPhase.scala:19)
        at scala.Iterator$class.foreach(Iterator.scala:252)
        at scala.tools.scalac.ast.parser.ParserPhase$class.apply(ParserPhase.scala:19)
        at scalac.Global.compile(Global.java:390)
        at scalac.Global.compile(Global.java:360)
        at scala.tools.scalac.Main$.main1(Main.scala:45)
        at scala.tools.scalac.Main$.main(Main.scala:28)
        at scala.tools.scalac.Main.main(Main.scala:28)
what expected A useful error message.
[back to overview]
Changes of this bug report
Matthias  edited on  2004-09-29 10:08:59.0
Burak  edited on  2004-09-30 12:04:16.0
I fixed this to the following. The second error message is garbage, but not easy to avoid.
te.scala:2: missing end tag in XML literal for 
  val x = ;
          ^
te.scala:4: ';' expected but something found.

^
two errors found
Matthias  edited on  2004-10-12 10:20:53.0
I still get exceptions for unbalanced XML literals. Here's an example:
object T {
  val x = ;
}
Matthias  edited on  2004-10-12 10:22:25.0
Oops, my brackets got lost. Ok, here's another try:
object T {
  val x = <a>;
}
Burak  edited on  2004-10-12 10:35:12.0
not reproducible, are you using the latest check-out? I get:
test.scala:2: missing end tag in XML literal for 
  val x = <a>
          ^
test.scala:4: ';' expected but something found.

^