scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Compiler crash on undefined symbol in update assignment, symbol value <error> does not exist in #9235

Closed scabug closed 8 years ago

scabug commented 9 years ago
package foo

case class A(var a: Int)
object Test {
  val as = Map[String, A]()
  as(undefined).a += 1
}

Crashes the type checker with

scala.reflect.internal.FatalError: 
  symbol value <error> does not exist in foo.Test.<init>
     while compiling: /home/crc/transcriptic/src/lab/src/mcx/src/main/scala/com/transcriptic/mcx/devices/validation/Foo.scala
        during phase: icode
     library version: version 2.11.5
    compiler version: version 2.11.5
scabug commented 9 years ago

Imported From: https://issues.scala-lang.org/browse/SI-9235?orig=1 Reporter: Carl Chatfiled (carlchatfield) Affected Versions: 2.11.5 See #9781 Duplicates #8763

scabug commented 9 years ago

@adriaanm said: Running under -Xprint:typer points towards https://github.com/scala/scala/blob/2.11.x/src/compiler/scala/tools/nsc/typechecker/Typers.scala#L4617

It looks like the error in the RHS of the val (qualqual) is masked by evalOnce's wrapping?

      <synthetic> val ev$1: A = Test.this.as.apply(<undefined: error>);
      ev$1.a_=(ev$1.a.+(1))
scabug commented 9 years ago

@adriaanm said: When running under -Ytyper-debug, this looks dubious -- an application to an error-typed arg should be error-typed:

|    |    |    |-- as(<undefined: error>).a EXPRmode-POLYmode-QUALmode (site: method test in Test) 
|    |    |    |    |-- String => A EXPRmode-POLYmode-QUALmode (site: method test in Test) 
|    |    |    |    |    |-- as.apply BYVALmode-EXPRmode-FUNmode-POLYmode (silent: method test in Test) 
|    |    |    |    |    |    \-> (v1: String)A
|    |    |    |    |    \-> A
|    |    |    |    \-> Int
scabug commented 8 years ago

@liff said: I think this is duplicate with #9781. The example results in error: not found: value undefined instead of compiler crash on 2.12.x.

scabug commented 8 years ago

@som-snytt said (edited on Nov 1, 2016 6:23:13 AM UTC): I didn't notice these issues until just now. By coincidence I just closed another duplicate because there's a PR on 2.11, https://github.com/scala/scala/pull/5454

Did I already know that? (Yes.) It's all ancient history now. It was before the rains returned.