swift
04bf4327 - SILGen: Diagnose invalid captures of top-level bindings

Commit
6 years ago
SILGen: Diagnose invalid captures of top-level bindings A method of a nominal type is not allowed to capture anything. If we did compute a capture list, clear it out to preserve downstream invariants. This can happen because not all invalid captures involving nominal types in local context can be diagnosed in Sema. In particular, we allow a method of a local type to reference a local function from an outer scope, as long as that local function does not have any (transitive) captures. Since Sema cannot validate the latter condition, it punts and allows any reference to a FuncDecl in local context. When emitting the captures in this situation, SILGen will diagnose the problem using the existing 'forward reference' logic. The diagnostic is sub-optimal -- it should talk about a reference from inside a local type, and not a 'forward reference'. But still better than crashing.
Author
Committer
Parents
Loading