-
Notifications
You must be signed in to change notification settings - Fork 183
Open
Description
We’ve got a couple problems where the line numbers don’t line up.
In this example program, the declarations are on lines ending in 0 (10, 20, 30 etc.) and the calls are on lines ending in 5 (25, 35, 45).
ExceptionThrower.kt
package com.example
class ExceptionThrower {
fun goBoom() {
goBoom1()
}
fun goBoom1() {
goBoom2()
}
fun goBoom2() {
goBoom3()
}
fun goBoom3() {
throw Exception("boom!")
}
}
When executed, it prints a stack trace containing the lines of the declarations instead of the lines of the calls.
Exception: boom!
at captureStack (js/runtime/coreRuntime.kt:148)
at Exception_init_$Create$_0 (kotlin-kotlin-stdlib.js)
at <anonymous> (com/example/ExceptionThrower.kt)
at <anonymous> (com/example/ExceptionThrower.kt:40)
at <anonymous> (com/example/ExceptionThrower.kt:30)
at <anonymous> (com/example/ExceptionThrower.kt:20)
We can get the proper line numbers by adding an additional statement into the code.
ExceptionThrower.kt
package com.example
class ExceptionThrower {
fun goBoom() {
println("goBoom")
goBoom1()
}
fun goBoom1() {
println("goBoom1")
goBoom2()
}
fun goBoom2() {
println("goBoom2")
goBoom3()
}
fun goBoom3() {
println("goBoom3")
throw Exception("boom!")
}
}
Exception: boom!
at captureStack (js/runtime/coreRuntime.kt:148)
at Exception_init_$Create$_0 (kotlin-kotlin-stdlib.js)
at <anonymous> (com/example/ExceptionThrower.kt:55)
at <anonymous> (com/example/ExceptionThrower.kt:45)
at <anonymous> (com/example/ExceptionThrower.kt:35)
at <anonymous> (com/example/ExceptionThrower.kt:25)
Presumably the Kotlin/JS compiler is omitting the proper line number for the first statement of each function.
Metadata
Metadata
Assignees
Labels
No labels