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
If I implement a function that uses parameter packs in swift-testing, and it fails to compile if there is only one element.
If I don't use swift-testing, it will compile successfully.
The example code is shown below.
structParameterPackTests{func lessThan<eachElement:Comparable>(lhs:(repeateachElement), rhs:(repeateachElement))->Bool{varhasElement=falsefor(leftHandSide, rightHandSide)inrepeat(each lhs,each rhs){
hasElement =trueguard leftHandSide < rightHandSide else{returnfalse}}return hasElement
}@Test("")func test(){print(lessThan(lhs:0, rhs:1)) // true
#expect(lessThan(lhs:(0,1), rhs:(1,2)) // Success
// 🟥 ERROR: No exact matches in call to global function '__checkFunctionCall'
// 🟥 ERROR: Generic parameter 'each Element' could not be inferred
#expect(lessThan(lhs:0, rhs:1))
// Testing.__checkFunctionCall((),calling: {
// lessThan(lhs: $1,rhs: $2)
// },0,1,expression: .__fromFunctionCall(nil,"lessThan",("lhs",.__fromSyntaxNode("0")),("rhs",.__fromSyntaxNode("1"))),comments: [],isRequired: false,sourceLocation: Testing.SourceLocation.__here()).__expected()
}}
Expected behavior
If I implement a function that uses parameter packs in swift-testing, it will compile successfully even if there is only one element.
Actual behavior
If I implement a function that uses parameter packs in swift-testing, and it fails to compile if there is only one element.
Steps to reproduce
Run the test for the example code.
Compilation fails.
swift-testing version/commit hash
main (1747fb0c795ca490463aad8c3b2d8815f7c3222f)
Swift & OS version (output of swift --version ; uname -a)
$ swift --version
swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0
$ uname -a
Darwin M1-Mac-Book-Pro.local 24.1.0 Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:15 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6000 arm64
The text was updated successfully, but these errors were encountered:
Description
If I implement a function that uses parameter packs in swift-testing, and it fails to compile if there is only one element.
If I don't use swift-testing, it will compile successfully.
The example code is shown below.
Expected behavior
If I implement a function that uses parameter packs in swift-testing, it will compile successfully even if there is only one element.
Actual behavior
If I implement a function that uses parameter packs in swift-testing, and it fails to compile if there is only one element.
Steps to reproduce
swift-testing version/commit hash
main (
1747fb0c795ca490463aad8c3b2d8815f7c3222f
)Swift & OS version (output of
swift --version ; uname -a
)The text was updated successfully, but these errors were encountered: