You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
iflet x =nonOptionalStruct(){} // expected-error{{initializer for conditional binding must have Optional type, not 'NonOptionalStruct'}}
27
-
iflet x =nonOptionalEnum(){} // expected-error{{initializer for conditional binding must have Optional type, not 'NonOptionalEnum'}}
26
+
iflet x =nonOptionalStruct(){_ = x} // expected-error{{initializer for conditional binding must have Optional type, not 'NonOptionalStruct'}}
27
+
iflet x =nonOptionalEnum(){_ = x} // expected-error{{initializer for conditional binding must have Optional type, not 'NonOptionalEnum'}}
28
28
29
29
guardlet _ =nonOptionalStruct()else{fatalError()} // expected-error{{initializer for conditional binding must have Optional type, not 'NonOptionalStruct'}}
30
30
guardlet _ =nonOptionalEnum()else{fatalError()} // expected-error{{initializer for conditional binding must have Optional type, not 'NonOptionalEnum'}}
31
31
32
-
if case let x?=nonOptionalStruct(){} // expected-error{{'?' pattern cannot match values of type 'NonOptionalStruct'}}
33
-
if case let x?=nonOptionalEnum(){} // expected-error{{'?' pattern cannot match values of type 'NonOptionalEnum'}}
32
+
if case let x?=nonOptionalStruct(){_ = x } // expected-error{{'?' pattern cannot match values of type 'NonOptionalStruct'}}
33
+
if case let x?=nonOptionalEnum(){_ = x } // expected-error{{'?' pattern cannot match values of type 'NonOptionalEnum'}}
34
34
35
35
classB{} // expected-note * {{did you mean 'B'?}}
36
36
classD:B{}// expected-note * {{did you mean 'D'?}}
37
37
38
38
// TODO poor recovery in these cases
39
39
iflet{} // expected-error {{expected '{' after 'if' condition}} expected-error {{pattern matching in a condition requires the 'case' keyword}}
40
-
iflet x ={} // expected-error{{'{' after 'if'}} expected-error {{variable binding in a condition requires an initializer}} expected-error{{initializer for conditional binding must have Optional type, not '() -> ()'}}
40
+
iflet x ={} // expected-error{{'{' after 'if'}} expected-error {{variable binding in a condition requires an initializer}} expected-error{{initializer for conditional binding must have Optional type, not '() -> ()'}}
41
+
// expected-warning@-1{{value 'x' was defined but never used}}
41
42
42
43
if let x =foo(){
44
+
_ = x
43
45
} else {
44
46
// TODO: more contextual error? "x is only available on the true branch"?
0 commit comments