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=}}
1559
1562
1560
1563
let _ ="" // This is a comment
1561
-
??"" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1560:13-1561:10=}}
1564
+
??"" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1563:13-1564:10=}}
1562
1565
1563
1566
let _ ="" // This is a comment
1564
1567
/*
1565
1568
* The blank line below is part of the test case, do not delete it
1566
1569
*/
1567
-
??"" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1563:13-1567:10=}}
1570
+
??"" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1566:13-1570:10=}}
1568
1571
1569
-
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-1570:9=}}
1572
+
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-1573:9=}}
1570
1573
"").isEmpty {}
1571
1574
1572
1575
if("" // This is a comment
1573
-
??"").isEmpty {} // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1572:9-1573:12=}}
1576
+
??"").isEmpty {} // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1575:9-1576:12=}}
init<C>(_ data:Binding<C>, content:(Binding<C.Element>)->Content)where Data ==Array<C>, ID ==C.Element.ID, C :MutableCollection, C :RandomAccessCollection, C.Element :Idable, C.Index :Hashable{}
// ?? should have higher precedence than logical operators like || and comparisons.
786
786
if cond || (a ??42>0){} // Ok.
787
787
if(cond || a)??42>0{} // expected-error {{cannot be used as a boolean}} {{15-15=(}} {{16-16= != nil)}}
788
-
// expected-error@-1 {{binary operator '>' cannot be applied to operands of type 'Bool' and 'Int'}} expected-note@-1 {{overloads for '>' exist with these partially matching parameter list}}
789
-
// expected-error@-2 {{binary operator '??' cannot be applied to operands of type 'Bool' and 'Int'}}
788
+
// expected-error@-1 {{cannot convert value of type 'Int' to expected argument type 'Bool'}}
789
+
// expected-error@-2 {{cannot convert value of type 'Bool' to expected argument type 'Int'}}
790
790
if(cond || a)??(42>0){} // expected-error {{cannot be used as a boolean}} {{15-15=(}} {{16-16= != nil)}}
791
791
792
792
if cond || a ??42>0{} // Parses as the first one, not the others.
793
793
794
794
795
795
// ?? should have lower precedence than range and arithmetic operators.
796
796
letr1= r ??(0...42) // ok
797
-
letr2=(r ??0)...42 // not ok: expected-error {{binary operator '??' cannot be applied to operands of type 'ClosedRange<Int>?' and 'Int'}}
797
+
letr2=(r ??0)...42 // not ok: expected-error {{cannot convert value of type 'Int' to expected argument type 'ClosedRange<Int>'}}
798
+
// expected-error@-1 {{cannot convert value of type 'ClosedRange<Int>' to expected argument type 'Int'}}
798
799
letr3= r ??0...42 // parses as the first one, not the second.
0 commit comments