:wave: i was running a kotlin script (.kts) nicely...
# scripting
n
👋 i was running a kotlin script (.kts) nicely on kotlin 1.4 and it breaks on 1.5 because this is on github actions the stack trace is pretty limited
Copy code
error: backend Internal error: Exception during code generation
File being compiled: update.main.kts
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:54) (update.main.kts): org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during code generation
File being compiled: update.main.kts
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:54)
Error: Process completed with exit code 1.
i searched to open a bug on kotlin youtrack but didn’t find a way 😬 if a jetbrains employee finds this message, please ping me
i
Hi! Does it reproduce locally? Can you share the code? BTW this RuntimeException should have a message, but for some reason it's missing from your stacktrace 😞 https://github.com/JetBrains/kotlin/blob/95d95f9a9bd75853ffce342c8a24ec4c550055bc/[…]src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt cc @ilya.chernikov
You may also try to add
-Xuse-old-backend
for the script compilation, there is a chance it will be fixed
n
Does it reproduce locally?
yes
Can you share the code?
https://github.com/nfrankel/nfrankel/blob/master/update.main.kts
BTW this RuntimeException should have a message, but for some reason it’s missing from your stacktrace 😞
i inferred it was github truncating but i’ve got the same log locally
You may also try to add 
-Xuse-old-backend
 for the script compilation, there is a chance it will be fixed
i set the version to 1.4.32 for now thank for your quick feedback
i
I created an issue in youtrack https://youtrack.jetbrains.com/issue/KT-46645
👍 1
i
Temporary workaround - use
-Xuse-old-backend
cli option. It should actually be the default behavior for now, but for some reason scripts are being compiled with the IR backend, and some rough edges are showing up.
👍 1
👍🏼 1
Please also see the last comment to the issue, the fact that this code works on the old backend (Kotlin < 1.5) is surprising, and I guess we'll not be able to reproduce this magic in the new version before fixing the root issue.
n
thanks for your feedback is it related to scripting? or is it just because
Talk
is an inner class of the
*Kt
file class?
i
It is related to scripting because in JVM the script is compiled to a class, so variables becoming properties of this class, and therefore nested classes cannot access them without being inner. This is a peculiarity of the implementation and we're quite likely going to fix it in the future, but for a moment this is a unfortunate limitation.
n
makes sense thanks for the feedback