Jens
1
The following program compiles:
struct S {
static func f() -> Int { return S.c }
static let c = S.f()
}
print(S.c)
When running it, there will be a runtime error:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
at this line:
static let c = S.f()
Should this program compile (like it currently does), or should there be a compile time error?
1 Like
It's impossible to statically detect every case of infinite recursion without imposing some pretty heavy constraints on code. Of course we could do a better job of trying to catch it in the common case, though.
2 Likes
We should also produce a better error at runtime when it is detected.
5 Likes