Spent quite a few minutes now before realising that global declaration must be placed before "foo()":
// main.swift
func foo() {
dict["hello"] = "world" // 🛑 Thread 1: EXC_BAD_ACCESS (code=1, address=0x8)
}
foo()
var dict: [String : String] = [:]
Could we improve it?
- either make it a compilation error
- or make it work without crashing
- if not the above then improve the crash diagnostic to make it more obvious what's going on.
Minimal example:
// main.swift
let x = hello == "world" // 🛑 Thread 1: EXC_BAD_ACCESS (code=1, address=0x18)
var hello = "world"