Skip to content

Commit 7974977

Browse files
authored
Merge pull request #3659 from rintaro/args-order-diag
2 parents 4a57e64 + 17ec1ac commit 7974977

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,11 +763,11 @@ ERROR(extra_named_single_element_tuple,none,
763763
ERROR(argument_out_of_order_named_named,none,
764764
"argument %0 must precede argument %1", (Identifier, Identifier))
765765
ERROR(argument_out_of_order_named_unnamed,none,
766-
"argument %0 must precede unnamed parameter #%1", (Identifier, unsigned))
766+
"argument %0 must precede unnamed argument #%1", (Identifier, unsigned))
767767
ERROR(argument_out_of_order_unnamed_named,none,
768-
"unnamed parameter #%0 must precede argument %1", (unsigned, Identifier))
768+
"unnamed argument #%0 must precede argument %1", (unsigned, Identifier))
769769
ERROR(argument_out_of_order_unnamed_unnamed,none,
770-
"unnamed parameter #%0 must precede unnamed parameter #%1",
770+
"unnamed argument #%0 must precede unnamed argument #%1",
771771
(unsigned, unsigned))
772772

773773
ERROR(instance_member_use_on_type,none,

lib/Sema/CSDiag.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4424,15 +4424,15 @@ static bool diagnoseSingleCandidateFailures(CalleeCandidateInfo &CCI,
44244424

44254425
if (first.empty() && second.empty()) {
44264426
TC.diagnose(diagLoc, diag::argument_out_of_order_unnamed_unnamed,
4427-
OOOArgIdx, OOOPrevArgIdx)
4427+
OOOArgIdx + 1, OOOPrevArgIdx + 1)
44284428
.fixItExchange(firstRange, secondRange);
44294429
} else if (first.empty() && !second.empty()) {
44304430
TC.diagnose(diagLoc, diag::argument_out_of_order_unnamed_named,
4431-
OOOArgIdx, second)
4431+
OOOArgIdx + 1, second)
44324432
.fixItExchange(firstRange, secondRange);
44334433
} else if (!first.empty() && second.empty()) {
44344434
TC.diagnose(diagLoc, diag::argument_out_of_order_named_unnamed,
4435-
first, OOOPrevArgIdx)
4435+
first, OOOPrevArgIdx + 1)
44364436
.fixItExchange(firstRange, secondRange);
44374437
} else {
44384438
TC.diagnose(diagLoc, diag::argument_out_of_order_named_named,

test/Constraints/diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ func nilComparison(i: Int, o: AnyObject) {
805805
// FIXME: Bad diagnostic
806806
func secondArgumentNotLabeled(a:Int, _ b: Int) { }
807807
secondArgumentNotLabeled(10, 20)
808-
// expected-error@-1 {{unnamed parameter #1 must precede unnamed parameter #0}}
808+
// expected-error@-1 {{unnamed argument #2 must precede unnamed argument #1}}
809809

810810
// <rdar://problem/23709100> QoI: incorrect ambiguity error due to implicit conversion
811811
func testImplConversion(a : Float?) -> Bool {}

test/Constraints/function.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var s: String = optFunc("hi")
3636
// <rdar://problem/17652759> Default arguments cause crash with tuple permutation
3737
func testArgumentShuffle(_ first: Int = 7, third: Int = 9) {
3838
}
39-
testArgumentShuffle(third: 1, 2) // expected-error {{unnamed parameter #1 must precede argument 'third'}} {{21-29=2}} {{31-32=third: 1}}
39+
testArgumentShuffle(third: 1, 2) // expected-error {{unnamed argument #2 must precede argument 'third'}} {{21-29=2}} {{31-32=third: 1}}
4040

4141

4242

test/Constraints/keyword_arguments.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ variadics1(x: 1, y: 2, 1, 2)
135135
variadics1(x: 1, y: 2, 1, 2, 3)
136136

137137
// Using various (out-of-order)
138-
variadics1(1, 2, 3, 4, 5, x: 6, y: 7) // expected-error{{argument 'x' must precede unnamed parameter #0}} {{12-25=x: 6}} {{27-31=1, 2, 3, 4, 5}}
138+
variadics1(1, 2, 3, 4, 5, x: 6, y: 7) // expected-error{{argument 'x' must precede unnamed argument #1}} {{12-25=x: 6}} {{27-31=1, 2, 3, 4, 5}}
139139

140140
func variadics2(x: Int, y: Int = 2, z: Int...) { }
141141

@@ -173,8 +173,8 @@ variadics3(1)
173173
variadics3()
174174

175175
// Using variadics (out-of-order)
176-
variadics3(y: 0, 1, 2, 3) // expected-error{{unnamed parameter #1 must precede argument 'y'}} {{12-16=1, 2, 3}} {{18-25=y: 0}}
177-
variadics3(z: 1, 1) // expected-error{{unnamed parameter #1 must precede argument 'z'}} {{12-16=1}} {{18-19=z: 1}}
176+
variadics3(y: 0, 1, 2, 3) // expected-error{{unnamed argument #2 must precede argument 'y'}} {{12-16=1, 2, 3}} {{18-25=y: 0}}
177+
variadics3(z: 1, 1) // expected-error{{unnamed argument #2 must precede argument 'z'}} {{12-16=1}} {{18-19=z: 1}}
178178

179179
func variadics4(x: Int..., y: Int = 2, z: Int = 3) { }
180180

@@ -209,7 +209,7 @@ variadics5(1, y: 2, 1, 2)
209209
variadics5(1, y: 2, 1, 2, 3)
210210

211211
// Using various (out-of-order)
212-
variadics5(1, 2, 3, 4, 5, 6, y: 7) // expected-error{{argument 'y' must precede unnamed parameter #1}} {{15-28=y: 7}} {{30-34=2, 3, 4, 5, 6}}
212+
variadics5(1, 2, 3, 4, 5, 6, y: 7) // expected-error{{argument 'y' must precede unnamed argument #2}} {{15-28=y: 7}} {{30-34=2, 3, 4, 5, 6}}
213213
variadics5(y: 1, 2, 3, 4, 5, 6, 7) // expected-error{{missing argument for parameter #1 in call}}
214214

215215
func variadics6(x: Int..., y: Int = 2, z: Int) { }
@@ -233,7 +233,7 @@ variadics6(x: 1) // expected-error{{missing argument for parameter 'z' in call}}
233233
variadics6() // expected-error{{missing argument for parameter 'z' in call}}
234234

235235
func outOfOrder(_ a : Int, b: Int) {
236-
outOfOrder(b: 42, 52) // expected-error {{unnamed parameter #1 must precede argument 'b'}} {{14-19=52}} {{21-23=b: 42}}
236+
outOfOrder(b: 42, 52) // expected-error {{unnamed argument #2 must precede argument 'b'}} {{14-19=52}} {{21-23=b: 42}}
237237
}
238238

239239
// -------------------------------------------

0 commit comments

Comments
 (0)