Files
swift-mirror/test/default-initialization.swift
Doug Gregor fde45ac199 Default-initialize variables that don't have initializers.
Whenever a variable is written without an initializer,
default-initialize the variable (e.g., by calling the default
constructor) or produce an error. Fixes <rdar://problem/13134629>,
<rdar://problem/11941389>, and the majority of
<rdar://problem/11619148>.

Missing still is the default initialization of struct members within
user-written constructors. That's the last part of
<rdar://problem/11619148>.




Swift SVN r4974
2013-04-29 17:45:16 +00:00

27 lines
506 B
Swift

// RUN: %swift %s -verify
struct A {
var i : Int
constructor(i : Int) { this.i = i }
}
struct B {
var a : A
}
func locals() {
var al : A // expected-error{{cannot default-initialize variable of type 'A'}}
var bl : B // expected-error{{cannot default-initialize variable of type 'B'}}
}
var ag : A // expected-error{{cannot default-initialize variable of type 'A'}}
var bg : B // expected-error{{cannot default-initialize variable of type 'B'}}
struct C {
var x : (Int, Int)
}
var c : C