Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler crash during parsing because of while condition lacks parentheses #7385

Closed
scabug opened this issue Apr 18, 2013 · 4 comments
Closed

Compiler crash during parsing because of while condition lacks parentheses #7385

scabug opened this issue Apr 18, 2013 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Apr 18, 2013

Compile the following using Scala 2.10.1

object Foo {
  while i<10 { () }
}

And you'll get a "nice" compiler crash during parsing.

This is a regression wrt Scala 2.10.0. Indeed, the Scala 2.10.0 compiler correctly reports a syntax error for the above snippet.

Below follows the full stack-trace as reported by the Scala 2.10.1 compiler:

error: 
     while compiling: Main.scala
        during phase: parser
     library version: version 2.10.1
    compiler version: version 2.10.1
  reconstructed args: 

  last tree to typer: EmptyTree
              symbol: null
   symbol definition: null
                 tpe: <notype>
       symbol owners: 
      context owners: package <root>

== Enclosing template or block ==

Template(
  // parents
  ValDef(
    private
    "_"
    <tpt>
    <empty>
  )
  {}
)

== Expanded type of tree ==

<notype>

uncaught exception during compilation: java.lang.UnsupportedOperationException
error: java.lang.UnsupportedOperationException: Position.point on class scala.reflect.internal.util.NoPosition$
	at scala.reflect.internal.util.Position.point(Position.scala:120)
	at scala.reflect.internal.util.Position.endOrPoint(Position.scala:129)
	at scala.tools.nsc.ast.parser.TreeBuilder.makeWhile(TreeBuilder.scala:255)
	at scala.tools.nsc.ast.parser.Parsers$Parser.parseWhile$1(Parsers.scala:1339)
	at scala.tools.nsc.ast.parser.Parsers$Parser.expr0(Parsers.scala:1342)
	at scala.tools.nsc.ast.parser.Parsers$Parser.expr(Parsers.scala:1285)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStatSeq$1.apply(Parsers.scala:2971)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStatSeq$1.apply(Parsers.scala:2966)
	at scala.tools.nsc.ast.parser.Parsers$Parser.checkNoEscapingPlaceholders(Parsers.scala:428)
	at scala.tools.nsc.ast.parser.Parsers$Parser.templateStatSeq(Parsers.scala:2966)
	at scala.tools.nsc.ast.parser.Parsers$Parser.templateBody(Parsers.scala:2846)
	at scala.tools.nsc.ast.parser.Parsers$Parser.templateBodyOpt(Parsers.scala:2853)
	at scala.tools.nsc.ast.parser.Parsers$Parser.templateOpt(Parsers.scala:2812)
	at scala.tools.nsc.ast.parser.Parsers$Parser.objectDef(Parsers.scala:2732)
	at scala.tools.nsc.ast.parser.Parsers$Parser.tmplDef(Parsers.scala:2670)
	at scala.tools.nsc.ast.parser.Parsers$Parser.topLevelTmplDef(Parsers.scala:2651)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$topStatSeq$2.apply(Parsers.scala:2937)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$topStatSeq$2.apply(Parsers.scala:2937)
	at scala.tools.nsc.ast.parser.Parsers$Parser.joinComment(Parsers.scala:683)
	at scala.tools.nsc.ast.parser.Parsers$Parser.topStatSeq(Parsers.scala:2937)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.topstats$1(Parsers.scala:3132)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.apply(Parsers.scala:3138)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.apply(Parsers.scala:3102)
	at scala.tools.nsc.ast.parser.Parsers$Parser.checkNoEscapingPlaceholders(Parsers.scala:428)
	at scala.tools.nsc.ast.parser.Parsers$Parser.compilationUnit(Parsers.scala:3102)
	at scala.tools.nsc.ast.parser.Parsers$SourceFileParser$$anonfun$parseStartRule$1.apply(Parsers.scala:141)
	at scala.tools.nsc.ast.parser.Parsers$SourceFileParser$$anonfun$parseStartRule$1.apply(Parsers.scala:141)
	at scala.tools.nsc.ast.parser.Parsers$Parser.parse(Parsers.scala:313)
	at scala.tools.nsc.ast.parser.Parsers$UnitParser.smartParse(Parsers.scala:242)
	at scala.tools.nsc.ast.parser.SyntaxAnalyzer$ParserPhase.apply(SyntaxAnalyzer.scala:29)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:463)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:430)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:430)
	at scala.collection.Iterator$class.foreach(Iterator.scala:727)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
	at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:430)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1582)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1556)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1552)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1661)
	at scala.tools.nsc.Driver.doCompile(Driver.scala:33)
	at scala.tools.nsc.Main$.doCompile(Main.scala:79)
	at scala.tools.nsc.Driver.process(Driver.scala:54)
	at scala.tools.nsc.Driver.main(Driver.scala:67)
	at scala.tools.nsc.Main.main(Main.scala)

Exception in thread "main" java.lang.UnsupportedOperationException: Position.point on class scala.reflect.internal.util.NoPosition$
	at scala.reflect.internal.util.Position.point(Position.scala:120)
	at scala.reflect.internal.util.Position.endOrPoint(Position.scala:129)
	at scala.tools.nsc.ast.parser.TreeBuilder.makeWhile(TreeBuilder.scala:255)
	at scala.tools.nsc.ast.parser.Parsers$Parser.parseWhile$1(Parsers.scala:1339)
	at scala.tools.nsc.ast.parser.Parsers$Parser.expr0(Parsers.scala:1342)
	at scala.tools.nsc.ast.parser.Parsers$Parser.expr(Parsers.scala:1285)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStatSeq$1.apply(Parsers.scala:2971)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStatSeq$1.apply(Parsers.scala:2966)
	at scala.tools.nsc.ast.parser.Parsers$Parser.checkNoEscapingPlaceholders(Parsers.scala:428)
	at scala.tools.nsc.ast.parser.Parsers$Parser.templateStatSeq(Parsers.scala:2966)
	at scala.tools.nsc.ast.parser.Parsers$Parser.templateBody(Parsers.scala:2846)
	at scala.tools.nsc.ast.parser.Parsers$Parser.templateBodyOpt(Parsers.scala:2853)
	at scala.tools.nsc.ast.parser.Parsers$Parser.templateOpt(Parsers.scala:2812)
	at scala.tools.nsc.ast.parser.Parsers$Parser.objectDef(Parsers.scala:2732)
	at scala.tools.nsc.ast.parser.Parsers$Parser.tmplDef(Parsers.scala:2670)
	at scala.tools.nsc.ast.parser.Parsers$Parser.topLevelTmplDef(Parsers.scala:2651)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$topStatSeq$2.apply(Parsers.scala:2937)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$topStatSeq$2.apply(Parsers.scala:2937)
	at scala.tools.nsc.ast.parser.Parsers$Parser.joinComment(Parsers.scala:683)
	at scala.tools.nsc.ast.parser.Parsers$Parser.topStatSeq(Parsers.scala:2937)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.topstats$1(Parsers.scala:3132)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.apply(Parsers.scala:3138)
	at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.apply(Parsers.scala:3102)
	at scala.tools.nsc.ast.parser.Parsers$Parser.checkNoEscapingPlaceholders(Parsers.scala:428)
	at scala.tools.nsc.ast.parser.Parsers$Parser.compilationUnit(Parsers.scala:3102)
	at scala.tools.nsc.ast.parser.Parsers$SourceFileParser$$anonfun$parseStartRule$1.apply(Parsers.scala:141)
	at scala.tools.nsc.ast.parser.Parsers$SourceFileParser$$anonfun$parseStartRule$1.apply(Parsers.scala:141)
	at scala.tools.nsc.ast.parser.Parsers$Parser.parse(Parsers.scala:313)
	at scala.tools.nsc.ast.parser.Parsers$UnitParser.smartParse(Parsers.scala:242)
	at scala.tools.nsc.ast.parser.SyntaxAnalyzer$ParserPhase.apply(SyntaxAnalyzer.scala:29)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:463)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:430)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:430)
	at scala.collection.Iterator$class.foreach(Iterator.scala:727)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
	at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:430)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1582)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1556)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1552)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1661)
	at scala.tools.nsc.Driver.doCompile(Driver.scala:33)
	at scala.tools.nsc.Main$.doCompile(Main.scala:79)
	at scala.tools.nsc.Driver.process(Driver.scala:54)
	at scala.tools.nsc.Driver.main(Driver.scala:67)
	at scala.tools.nsc.Main.main(Main.scala)
@scabug
Copy link
Author

@scabug scabug commented Apr 18, 2013

@scabug
Copy link
Author

@scabug scabug commented Apr 21, 2013

@paulp said:
Regressed in 80a814d82c courtesy of a certain J. Iry.

@scabug
Copy link
Author

@scabug scabug commented Apr 30, 2013

@paulp said (edited on Apr 30, 2013 8:16:31 AM UTC):
scala/scala#2472

@scabug
Copy link
Author

@scabug scabug commented May 22, 2013

@paulp said:
5c77e01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants