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
[Diagnostics] Add a diagnostic for single parameter tuple splat
Diagnose situation when a single "tuple" parameter is given N arguments e.g.
```swift
func foo<T>(_ x: (T, Bool)) {}
foo(1, false) // foo exptects a single argument of tuple type `(1, false)`
```
Copy file name to clipboardExpand all lines: test/Constraints/tuple_arguments.swift
+26-26Lines changed: 26 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -466,7 +466,7 @@ do {
466
466
s.functionTwo(3,4)
467
467
s.functionTwo((3,4)) // expected-error {{missing argument for parameter #2 in call}}
468
468
469
-
s.functionTuple(3,4) // expected-error {{single parameter of type '(Int, Int)' is expected in call}} {{19-19=(}} {{23-23=)}}
469
+
s.functionTuple(3,4) // expected-error {{property 'functionTuple' expects a single parameter of type '(Int, Int)'}} {{19-19=(}} {{23-23=)}}
470
470
s.functionTuple((3,4))
471
471
}
472
472
@@ -487,7 +487,7 @@ do {
487
487
s.functionTwo(d) // expected-error {{missing argument for parameter #2 in call}}
488
488
489
489
490
-
s.functionTuple(a, b) // expected-error {{single parameter of type '(Int, Int)' is expected in call}} {{19-19=(}} {{23-23=)}}
490
+
s.functionTuple(a, b) // expected-error {{property 'functionTuple' expects a single parameter of type '(Int, Int)'}} {{19-19=(}} {{23-23=)}}
491
491
s.functionTuple((a, b))
492
492
s.functionTuple(d)
493
493
}
@@ -508,7 +508,7 @@ do {
508
508
s.functionTwo((a, b)) // expected-error {{missing argument for parameter #2 in call}}
509
509
s.functionTwo(d) // expected-error {{missing argument for parameter #2 in call}}
510
510
511
-
s.functionTuple(a, b) // expected-error {{single parameter of type '(Int, Int)' is expected in call}} {{19-19=(}} {{23-23=)}}
511
+
s.functionTuple(a, b) // expected-error {{property 'functionTuple' expects a single parameter of type '(Int, Int)'}} {{19-19=(}} {{23-23=)}}
512
512
s.functionTuple((a, b))
513
513
s.functionTuple(d)
514
514
}
@@ -848,12 +848,12 @@ do {
848
848
s.genericFunctionTwo(3.0,4.0)
849
849
s.genericFunctionTwo((3.0,4.0)) // expected-error {{missing argument for parameter #2 in call}}
850
850
851
-
s.genericFunctionTuple(3.0,4.0) // expected-error {{single parameter of type '(Double, Double)' is expected in call}} {{26-26=(}} {{34-34=)}}
851
+
s.genericFunctionTuple(3.0,4.0) // expected-error {{property 'genericFunctionTuple' expects a single parameter of type '(Double, Double)'}} {{26-26=(}} {{34-34=)}}
852
852
s.genericFunctionTuple((3.0,4.0))
853
853
854
854
letsTwo=Generic<(Double,Double)>()
855
855
856
-
sTwo.genericFunction(3.0,4.0) // expected-error {{single parameter of type '(Double, Double)' is expected in call}} {{24-24=(}} {{32-32=)}}
856
+
sTwo.genericFunction(3.0,4.0) // expected-error {{property 'genericFunction' expects a single parameter of type '(Double, Double)'}} {{24-24=(}} {{32-32=)}}
857
857
sTwo.genericFunction((3.0,4.0))
858
858
}
859
859
@@ -872,12 +872,12 @@ do {
872
872
s.genericFunctionTwo(a, b)
873
873
s.genericFunctionTwo((a, b)) // expected-error {{missing argument for parameter #2 in call}}
874
874
875
-
s.genericFunctionTuple(a, b) // expected-error {{single parameter of type '(Double, Double)' is expected in call}} {{26-26=(}} {{30-30=)}}
875
+
s.genericFunctionTuple(a, b) // expected-error {{property 'genericFunctionTuple' expects a single parameter of type '(Double, Double)'}} {{26-26=(}} {{30-30=)}}
876
876
s.genericFunctionTuple((a, b))
877
877
878
878
letsTwo=Generic<(Double,Double)>()
879
879
880
-
sTwo.genericFunction(a, b) // expected-error {{single parameter of type '(Double, Double)' is expected in call}} {{24-24=(}} {{28-28=)}}
880
+
sTwo.genericFunction(a, b) // expected-error {{property 'genericFunction' expects a single parameter of type '(Double, Double)'}} {{24-24=(}} {{28-28=)}}
881
881
sTwo.genericFunction((a, b))
882
882
sTwo.genericFunction(d)
883
883
}
@@ -897,12 +897,12 @@ do {
897
897
s.genericFunctionTwo(a, b)
898
898
s.genericFunctionTwo((a, b)) // expected-error {{missing argument for parameter #2 in call}}
899
899
900
-
s.genericFunctionTuple(a, b) // expected-error {{single parameter of type '(Double, Double)' is expected in call}} {{26-26=(}} {{30-30=)}}
900
+
s.genericFunctionTuple(a, b) // expected-error {{property 'genericFunctionTuple' expects a single parameter of type '(Double, Double)'}} {{26-26=(}} {{30-30=)}}
901
901
s.genericFunctionTuple((a, b))
902
902
903
903
varsTwo=Generic<(Double,Double)>()
904
904
905
-
sTwo.genericFunction(a, b) // expected-error {{single parameter of type '(Double, Double)' is expected in call}} {{24-24=(}} {{28-28=)}}
905
+
sTwo.genericFunction(a, b) // expected-error {{property 'genericFunction' expects a single parameter of type '(Double, Double)'}} {{24-24=(}} {{28-28=)}}
906
906
sTwo.genericFunction((a, b))
907
907
sTwo.genericFunction(d)
908
908
}
@@ -945,19 +945,19 @@ do {
945
945
}
946
946
947
947
do{
948
-
_ =GenericInit<(Int,Int)>(3,4) // expected-error {{extra argument in call}}
948
+
_ =GenericInit<(Int,Int)>(3,4) // expected-error {{initializer expects a single parameter of type '(Int, Int)'}}
949
949
_ =GenericInit<(Int,Int)>((3,4))
950
950
951
-
_ =GenericInitLabeled<(Int,Int)>(x:3,4) // expected-error {{extra argument in call}}
951
+
_ =GenericInitLabeled<(Int,Int)>(x:3,4) // expected-error {{initializer expects a single parameter of type '(Int, Int)'}}
952
952
_ =GenericInitLabeled<(Int,Int)>(x:(3,4))
953
953
954
954
_ =GenericInitTwo<Int>(3,4)
955
955
_ =GenericInitTwo<Int>((3,4)) // expected-error {{missing argument for parameter #2 in call}}
956
956
957
-
_ =GenericInitTuple<Int>(3,4) // expected-error {{initializer expects a single parameter of type '(T, T)'}} {{29-29=(}} {{33-33=)}}
957
+
_ =GenericInitTuple<Int>(3,4) // expected-error {{initializer expects a single parameter of type '(Int, Int)'}} {{29-29=(}} {{33-33=)}}
958
958
_ =GenericInitTuple<Int>((3,4))
959
959
960
-
_ =GenericInitLabeledTuple<Int>(x:3,4) // expected-error {{initializer expects a single parameter of type '(T, T)'}}
960
+
_ =GenericInitLabeledTuple<Int>(x:3,4) // expected-error {{initializer expects a single parameter of type '(Int, Int)'}}
961
961
_ =GenericInitLabeledTuple<Int>(x:(3,4))
962
962
}
963
963
@@ -984,15 +984,15 @@ do {
984
984
letb=4
985
985
letc=(a, b)
986
986
987
-
_ =GenericInit<(Int,Int)>(a, b) // expected-error {{extra argument in call}}
987
+
_ =GenericInit<(Int,Int)>(a, b) // expected-error {{initializer expects a single parameter of type '(Int, Int)'}}
988
988
_ =GenericInit<(Int,Int)>((a, b))
989
989
_ =GenericInit<(Int,Int)>(c)
990
990
991
991
_ =GenericInitTwo<Int>(a, b)
992
992
_ =GenericInitTwo<Int>((a, b)) // expected-error {{missing argument for parameter #2 in call}}
993
993
_ =GenericInitTwo<Int>(c) // expected-error {{missing argument for parameter #2 in call}}
994
994
995
-
_ =GenericInitTuple<Int>(a, b) // expected-error {{initializer expects a single parameter of type '(T, T)'}} {{29-29=(}} {{33-33=)}}
995
+
_ =GenericInitTuple<Int>(a, b) // expected-error {{initializer expects a single parameter of type '(Int, Int)'}} {{29-29=(}} {{33-33=)}}
996
996
_ =GenericInitTuple<Int>((a, b))
997
997
_ =GenericInitTuple<Int>(c)
998
998
}
@@ -1020,15 +1020,15 @@ do {
1020
1020
varb=4
1021
1021
varc=(a, b)
1022
1022
1023
-
_ =GenericInit<(Int,Int)>(a, b) // expected-error {{extra argument in call}}
1023
+
_ =GenericInit<(Int,Int)>(a, b) // expected-error {{initializer expects a single parameter of type '(Int, Int)'}}
1024
1024
_ =GenericInit<(Int,Int)>((a, b))
1025
1025
_ =GenericInit<(Int,Int)>(c)
1026
1026
1027
1027
_ =GenericInitTwo<Int>(a, b)
1028
1028
_ =GenericInitTwo<Int>((a, b)) // expected-error {{missing argument for parameter #2 in call}}
1029
1029
_ =GenericInitTwo<Int>(c) // expected-error {{missing argument for parameter #2 in call}}
1030
1030
1031
-
_ =GenericInitTuple<Int>(a, b) // expected-error {{initializer expects a single parameter of type '(T, T)'}} {{29-29=(}} {{33-33=)}}
1031
+
_ =GenericInitTuple<Int>(a, b) // expected-error {{initializer expects a single parameter of type '(Int, Int)'}} {{29-29=(}} {{33-33=)}}
0 commit comments