Skip to content

Commit 6266564

Browse files
author
Greg Titus
committed
Tuple mismatch with argument locator should be handled by ArgumentMismatch
1 parent 25830d6 commit 6266564

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6452,6 +6452,8 @@ bool ConstraintSystem::repairFailures(
64526452
ConstraintFix *fix;
64536453
if (tupleLocator->isLastElement<LocatorPathElt::FunctionArgument>()) {
64546454
fix = AllowFunctionTypeMismatch::create(*this, lhs, rhs, tupleLocator, index);
6455+
} else if (tupleLocator->isLastElement<LocatorPathElt::ApplyArgToParam>()) {
6456+
fix = AllowArgumentMismatch::create(*this, lhs, rhs, tupleLocator);
64556457
} else {
64566458
fix = AllowTupleTypeMismatch::create(*this, lhs, rhs, tupleLocator, index);
64576459
}

test/Sema/call_function_with_tuple.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ func call() {
99
let namedTuple: (x: Int, y: Int) = (1, 1)
1010
twoArgs(namedTuple) // expected-error{{global function 'twoArgs' expects 2 separate arguments}} expected-error{{missing argument label ':' in call}}
1111
}
12+
13+
func foo(_: (Int, Int)) -> String {}
14+
15+
func test() -> String {
16+
return foo((0, true))
17+
// expected-error@-1 {{cannot convert value of type '(Int, Bool)' to expected argument type '(Int, Int)'}}
18+
}
19+
20+
func bar(_: (Int,Int), _: (Int,Bool)) {} // expected-note {{'bar' declared here}}
21+
bar((0,false)) // expected-error {{missing argument for parameter #1 in call}}

test/Sema/diag_non_ephemeral.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,5 +537,5 @@ func testTuplingNonEphemeral(_ ptr: UnsafePointer<Int>) {
537537

538538
// Note we can't perform X-to-pointer conversions in this case even if we
539539
// wanted to.
540-
fn(([1], ptr)) // expected-error {{tuple type '([Int], UnsafePointer<Int>)' is not convertible to tuple type '(UnsafePointer<Int>, UnsafePointer<Int>)'}}
540+
fn(([1], ptr)) // expected-error {{cannot convert value of type '([Int], UnsafePointer<Int>)' to expected argument type '(UnsafePointer<Int>, UnsafePointer<Int>)'}}
541541
}

0 commit comments

Comments
 (0)