Skip to content

crash on compilable code: at dotty.tools.dotc.util.Positions$Position$.start$extension #1707

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

Closed
helloqirun opened this issue Nov 13, 2016 · 1 comment

Comments

@helloqirun
Copy link

scalac can compile it but dotc crashes.

$ cat abc.scala

object DepBug {
  class A {
    class B
    def mkB = new B
    def m(b: B) = b
  }
  trait Dep {
    val a: A
    val b: a.B
  }
  val dep = new {
    val a = new A
    val b = a mkB
  }
  def useDep(d: Dep) {
    import d._
    a m (b)
  }
  {
    import dep._
    a m (b)
  }
  dep.a m (dep b)
}

$ dotc abc.scala

-- Error: abc.scala ----------------------------------------------------------------------------------------------------
15 |  def useDep(d: Dep) {
   |                     ^
   |                     '=' expected but '{' found
-- Error: abc.scala ----------------------------------------------------------------------------------------------------
19 |  {
   |  ^
   |  '}' expected but '{' found

exception occurred while parsing abc.scala

exception occurred while compiling abc.scala
Exception in thread "main" java.lang.AssertionError: assertion failed
	at scala.Predef$.assert(Predef.scala:151)
	at dotty.tools.dotc.util.Positions$Position$.start$extension(Positions.scala:40)
	at dotty.tools.dotc.parsing.Parsers$Parser.simpleExprRest(Parsers.scala:1199)
	at dotty.tools.dotc.parsing.Parsers$Parser.simpleExpr(Parsers.scala:1186)
	at dotty.tools.dotc.parsing.Parsers$Parser$$anonfun$8.apply(Parsers.scala:1137)
	at dotty.tools.dotc.parsing.Parsers$Parser$$anonfun$8.apply(Parsers.scala:1128)
	at dotty.tools.dotc.parsing.Parsers$Parser.postfixExpr(Parsers.scala:1124)
<snipped>
@liufengyun
Copy link
Contributor

Thanks @helloqirun , report confirmed.

Here there are several problems here:

  1. Compiling without -language:Scala2 would crash compiler
  2. When compile with -language:Scala2, dep.a can't be resolved, where dep is the anonymous class instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants