Commits

Chris Lattner committed a048b078e37
Implement: <rdar://problem/16181314> don't require immediate initialization of 'let' values ... now that we have an exquisitely shaved yak. This provides a simple and uniform model for "let" constants: they are always either immediately initialized in their declaration, or they are initialized dynamically exactly once before any use. This is a simple generalization of our current model for initializers, but enables the use of let constants in more cases in local context, e.g. patterns like this: let x : SomeThing if condition { x = foo() } else { x = bar() } use(x) Previously this would have to be declared a "var" for no good reason: the value is only ever initialized, never actually mutated. The implementation of this is reasonably straight-forward now that the infrastructure is in place: Sema treats 'let' constants as "settable" if they lack an initializer (either in the declaration or in a non-PBD binding). This exposes them as an lvalue at the AST level. SILGen then lowers these things to an alloc_stack, and DI enforces the "initialization only" requirement that it already enforces for uninitialized 'let' properties in structs/classes. Swift SVN r23916