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
let _ ="" /* This is a comment */ ??"" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{13-43=}}
1553
1552
1554
1553
let _ ="" // This is a comment
1555
-
??"" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1554:13-1555:10=}}
1554
+
??"" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{-1:13-+0:10=}}
1556
1555
1557
1556
let _ ="" // This is a comment
1558
1557
/*
1559
1558
* The blank line below is part of the test case, do not delete it
1560
1559
*/
1561
-
??"" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1557:13-1561:10=}}
1560
+
??"" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{-4:13-+0:10=}}
1562
1561
1563
-
if(""?? // This is a comment // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{9-1564:9=}}
1562
+
if(""?? // This is a comment // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{9-+1:9=}}
1564
1563
"").isEmpty {}
1565
1564
1566
1565
if("" // This is a comment
1567
-
??"").isEmpty {} // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1566:9-1567:12=}}
1566
+
??"").isEmpty {} // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{-1:9-+0:12=}}
func foo(_ arr:[_]=[0]){} // expected-error {{type placeholder may not appear in top-level parameter}}
14
14
// expected-note@-1 {{replace the placeholder with the inferred type 'Int'}}
15
15
16
-
letfoo= _.foo // expected-error {{type placeholder not allowed here}} expected-error {{could not infer type for placeholder}}
16
+
letfoo= _.foo // expected-error {{type placeholder not allowed here}}
17
17
letzero:_=.zero // expected-error {{cannot infer contextual base in reference to member 'zero'}}
18
18
19
19
structS<T>{
@@ -110,15 +110,15 @@ extension Bar {
110
110
}
111
111
112
112
// FIXME: We should probably have better diagnostics for these situations--the user probably meant to use implicit member syntax
113
-
let _:Int=_() // expected-error {{type placeholder not allowed here}} expected-error {{could not infer type for placeholder}}
114
-
let _:()->Int={_()} // expected-error 2 {{type placeholder not allowed here}} expected-error {{could not infer type for placeholder}}
115
-
let _:Int= _.init() // expected-error {{type placeholder not allowed here}} expected-error {{could not infer type for placeholder}}
116
-
let _:()->Int={ _.init()} // expected-error 2 {{type placeholder not allowed here}} expected-error {{could not infer type for placeholder}}
113
+
let _:Int=_() // expected-error {{type placeholder not allowed here}}
114
+
let _:()->Int={_()} // expected-error {{type placeholder not allowed here}}
115
+
let _:Int= _.init() // expected-error {{type placeholder not allowed here}}
116
+
let _:()->Int={ _.init()} // expected-error {{type placeholder not allowed here}}
117
117
118
-
func returnsInt()->Int{_()} // expected-error {{type placeholder not allowed here}} expected-error {{could not infer type for placeholder}}
119
-
func returnsIntClosure()->()->Int{{_()}} // expected-error 2 {{type placeholder not allowed here}} expected-error {{could not infer type for placeholder}}
120
-
func returnsInt2()->Int{ _.init()} // expected-error {{type placeholder not allowed here}} expected-error {{could not infer type for placeholder}}
121
-
func returnsIntClosure2()->()->Int{{ _.init()}} // expected-error 2 {{type placeholder not allowed here}} expected-error {{could not infer type for placeholder}}
118
+
func returnsInt()->Int{_()} // expected-error {{type placeholder not allowed here}}
119
+
func returnsIntClosure()->()->Int{{_()}} // expected-error {{type placeholder not allowed here}}
120
+
func returnsInt2()->Int{ _.init()} // expected-error {{type placeholder not allowed here}}
121
+
func returnsIntClosure2()->()->Int{{ _.init()}} // expected-error {{type placeholder not allowed here}}
122
122
123
123
let _:Int.Type= _ // expected-error {{'_' can only appear in a pattern or on the left side of an assignment}}
124
124
let _:Int.Type= _.self // expected-error {{type placeholder not allowed here}}
@@ -145,17 +145,17 @@ let _ = [_].otherStaticMember.member
145
145
let _ =[_].otherStaticMember.method()
146
146
147
147
func f(x:Any, arr:[Int]){
148
-
// FIXME: Better diagnostics here. Maybe we should suggest replacing placeholders with 'Any'?
149
-
150
-
if x is _{} // expected-error {{type placeholder not allowed here}} expected-error {{type of expression is ambiguous without a type annotation}}
151
-
if x is [_]{} // expected-error {{type of expression is ambiguous without a type annotation}}
152
-
if x is ()->_{} // expected-error {{type of expression is ambiguous without a type annotation}}
153
-
iflet y = x as?_{} // expected-error {{type placeholder not allowed here}} expected-error {{type of expression is ambiguous without a type annotation}}
154
-
iflet y = x as?[_]{} // expected-error {{type of expression is ambiguous without a type annotation}}
155
-
iflet y = x as?()->_{} // expected-error {{type of expression is ambiguous without a type annotation}}
156
-
lety1= x as!_ // expected-error {{type placeholder not allowed here}} expected-error {{type of expression is ambiguous without a type annotation}}
157
-
lety2= x as![_] // expected-error {{type of expression is ambiguous without a type annotation}}
158
-
lety3= x as!()->_ // expected-error {{type of expression is ambiguous without a type annotation}}
148
+
// TODO: Maybe we should suggest replacing placeholders with 'Any'?
149
+
150
+
if x is _{} // expected-error {{type placeholder not allowed here}}
151
+
if x is [_]{} // expected-error {{could not infer type for placeholder}}
152
+
if x is ()->_{} // expected-error {{could not infer type for placeholder}}
153
+
iflet y = x as?_{} // expected-error {{type placeholder not allowed here}}
154
+
iflet y = x as?[_]{} // expected-error {{could not infer type for placeholder}}
155
+
iflet y = x as?()->_{} // expected-error {{could not infer type for placeholder}}
156
+
lety1= x as!_ // expected-error {{type placeholder not allowed here}}
157
+
lety2= x as![_] // expected-error {{could not infer type for placeholder}}
158
+
lety3= x as!()->_ // expected-error {{could not infer type for placeholder}}
159
159
160
160
switch x {
161
161
case is _:break // expected-error {{type placeholder not allowed here}}
caselety as ()->_:break // expected-error {{type placeholder not allowed here}}
167
167
}
168
168
169
-
if arr is _{} // expected-error {{type placeholder not allowed here}} expected-error {{type of expression is ambiguous without a type annotation}}
170
-
if arr is [_]{} // expected-error {{type of expression is ambiguous without a type annotation}}
171
-
if arr is ()->_{} // expected-error {{type of expression is ambiguous without a type annotation}}
172
-
iflet y = arr as?_{} // expected-error {{type placeholder not allowed here}} expected-error {{type of expression is ambiguous without a type annotation}}
173
-
iflet y = arr as?[_]{} // expected-error {{type of expression is ambiguous without a type annotation}}
174
-
iflet y = arr as?()->_{} // expected-error {{type of expression is ambiguous without a type annotation}}
175
-
lety1= arr as!_ // expected-error {{type placeholder not allowed here}} expected-error {{type of expression is ambiguous without a type annotation}}
176
-
lety2= arr as![_] // expected-error {{type of expression is ambiguous without a type annotation}}
177
-
lety3= arr as!()->_ // expected-error {{type of expression is ambiguous without a type annotation}}
169
+
if case is _= x {} // expected-error {{type placeholder not allowed here}}
170
+
if case is [_]= x {} // expected-error {{could not infer type for placeholder}}
171
+
if case is ()->_= x {} // expected-error {{could not infer type for placeholder}}
172
+
if case let y as _= x {} // expected-error {{type placeholder not allowed here}}
173
+
if case let y as [_]= x {} // expected-error {{could not infer type for placeholder}}
174
+
if case let y as ()->_= x {} // expected-error {{could not infer type for placeholder}}
175
+
176
+
if arr is _{} // expected-error {{type placeholder not allowed here}}
177
+
if arr is [_]{} // expected-error {{could not infer type for placeholder}}
178
+
if arr is ()->_{} // expected-error {{could not infer type for placeholder}}
179
+
iflet y = arr as?_{} // expected-error {{type placeholder not allowed here}}
180
+
iflet y = arr as?[_]{} // expected-error {{could not infer type for placeholder}}
181
+
iflet y = arr as?()->_{} // expected-error {{could not infer type for placeholder}}
182
+
lety1= arr as!_ // expected-error {{type placeholder not allowed here}}
183
+
lety2= arr as![_] // expected-error {{could not infer type for placeholder}}
184
+
lety3= arr as!()->_ // expected-error {{could not infer type for placeholder}}
178
185
179
186
switch arr {
180
187
case is _:break // expected-error {{type placeholder not allowed here}}
0 commit comments