Compiler bug or feature?

I think this old thread is related.

It includes similar (single file) examples like:

func foo() -> Int {
    return x
}
let x = foo()
print(x)

which still compiles, and prints 0.
And if you change Int to [Int] it will crash at runtime.

Here's one of the replies in that old thread:


Some possibly related bugs:

4 Likes