Files
swift-mirror/test/Sema/call_function_with_tuple.swift
Alex Hoppen fa9f3f3337 [Sema] Correctly diagnose passing tuple as only argument to function with multiple parameters
If a tuple is passed as the only argument to a function that takes two unnamed arguments, we try to diagnose the missing argument label. However, in the old diagnose code we didn’t distinguish between non-existing arguments and arguments without labels; both behaved the same.

Thus, the missing second argument in the function call would line up with the empty second argument label, not producing a diagnostic, but hitting an assertion later on.

Distinguish between the two to fix the issue.

Fixes rdar://64319340
2021-03-19 12:58:17 +01:00

12 lines
441 B
Swift

// RUN: %target-typecheck-verify-swift
func twoArgs(_ a: Int, _ b: Int) -> Void { //expected-note{{'twoArgs' declared here}}
}
func call() {
// Call a function that takes two unnamed arguments with a tuple that has two
// named arguments
let namedTuple: (x: Int, y: Int) = (1, 1)
twoArgs(namedTuple) // expected-error{{global function 'twoArgs' expects 2 separate arguments}} expected-error{{missing argument label ':' in call}}
}