swiftlang / swiftlang/swift-syntax
makeUniqueName() produces tokens that cannot be used as closure arguments
- Dominant language
- Swift
- Stars
- 3.7k
- Forks
- 553
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 16
Description
### Description
If I attempt to label closure arguments during macro expansion:
```swift
let arg0 = context.makeUniqueName("")
return """
{ \(arg0) in
...
}
"""
```
The compiler complains:
> 🛑 Inferred projection type 'Int' is not a property wrapper
> 🛑 Inferred projection type '() -> Int' is not a property wrapper
This means I can't reliably produce closure argument names, which is problematic if my macro expansion generates a closure and the macro is being used inside another closure:
```swift
@Test func foo() {
let x = [2, 4, 6]
x.forEach {
#expect($0 % 2 == 0) // 🛑 Anonymous closure arguments cannot be used inside
// a closure that has explicit arguments; did you mean '$0'?
}
}
```
### Steps to Reproduce
See above.
Contributor guide
Assessment
This issue has not been assessed yet.