Specifying the type parameter for the `@Test` macro may not always enable type inference for arguments.
bug
### Description
Type inference for literal arrays in arguments may fail even if the type parameters of the `@Test` macro itself are explicitly specified.
### Reproduction
Specifically, the following code fails to compile.
```swift
@Test<[(String?, Int?)]>(
arguments: [
(nil, 2),
("a", nil),
]
)
func example(a: String?, b: Int?) async throws {}
```
I am encountering the following error:
```
/var/folders/qw/myjd_8ld5lg9qg057bhm467c0000gn/T/swift-generated-sources/@__swiftmacro_7stTests7example4TestfMp_.swift:8:11 Type of expression is ambiguous without a type annotation
```
### Expected behavior
It is expected to compile.
### Environment
```sh
$ swift --version
swift-driver version: 1.127.14.1 Apple Swift version 6.2.3 (swiftlang-6.2.3.3.21 clang-1700.6.3.2)
Target: arm64-apple-macosx26.0
```
### Additional information
It compiles successfully when `.some` is added as shown below.
```swift
@Test<[(String?, Int?)]>(
arguments: [
(nil, 2),
(.some("a"), nil),
]
)
func example(a: String?, b: Int?) async throws {}
```
Also, it compiles successfully even when applying a type directly to the literal itself, as shown below.
```swift
@Test(
arguments: [
(nil, 2),
("a", nil),
] as [(String?, Int?)]
)
func example(a: String?, b: Int?) async throws {}
```
关闭于 2026-03-25 6 条评论