Internal error: don't know how to generate reference


#1

Couldn't find a separate bug report thread, so it's going in the main discussion.

The following

fun main(args: Array<String>) {   val items = listOf(1, 2, 3, 4, 5)   var i = 0   do {   val k = items[i++]   println(k)   } while (k != 4) }

compiles fine in the IDE (IntelliJ IDEA 12.0.2 - Kotlin plugin 0.4.297), but gives the following error when you 'make':

``

13:15:07 Throwable
  Kotlin: [Internal Error] org.jetbrains.jet.codegen.CompilationException: Back-end (JVM) Internal error: don’t know how to generate reference val k : jet.Int defined in main[LocalVariableDescriptor@720c1f32]
  Cause: don’t know how to generate reference val k : jet.Int defined in main[LocalVariableDescriptor@720c1f32]
  File being compiled and position: (7,14) in C:UsersTomDropboxProjectsArmilsrcTest.kt
  The root cause was thrown at: ExpressionCodegen.java:1510
  at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:250)
  at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:222)
  at org.jetbrains.jet.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:256)
  … rest is cut …

Probably a problem with the scope in the do-while, since this works fine:

``

fun main(args: Array<String>) {
  val items = listOf(1, 2, 3, 4, 5)
  var i = 0
  while (true) {
  val k = items[i++]
  println(k)
  if (k == 4) break
  }
}


#2

I replicate this on   0.4.438 as well.   


#3

We have public issue tracker, you can report bugs directly there. I have posted your bug there: KT-3280


#4

Thanks I'll use that in future :-)