Skip to content

Commit adaaf5a

Browse files
authored
Merge pull request swiftlang#74542 from gregomni/issue-74463
[Sema] Tuple mismatch with argument locator should be handled by ArgumentMismatch
2 parents cd9d202 + 6266564 commit adaaf5a

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
@@ -6473,6 +6473,8 @@ bool ConstraintSystem::repairFailures(
64736473
ConstraintFix *fix;
64746474
if (tupleLocator->isLastElement<LocatorPathElt::FunctionArgument>()) {
64756475
fix = AllowFunctionTypeMismatch::create(*this, lhs, rhs, tupleLocator, index);
6476+
} else if (tupleLocator->isLastElement<LocatorPathElt::ApplyArgToParam>()) {
6477+
fix = AllowArgumentMismatch::create(*this, lhs, rhs, tupleLocator);
64766478
} else {
64776479
fix = AllowTupleTypeMismatch::create(*this, lhs, rhs, tupleLocator, index);
64786480
}

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)