Hello, why this does not compile? Is it some bytecode limitation? It compiles fine if functions are declared inside a class.
Copy code
fun main() {
fun foo() {
bar()
}
fun bar() {
println("Called")
}
foo()
}
d
Dominaezzz
12/11/2018, 10:01 PM
Local functions must be defined before you use them.
s
serebit
12/11/2018, 10:01 PM
because you're defining foo before bar exists. if the function is in a class, the bytecode can be rearranged to permit this, but not within a function where instructions have to execute sequentially