Hello, why this does not compile? Is it some bytec...
# announcements
g
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
Local functions must be defined before you use them.
s
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