Description
This is reproduced with [email protected].
When testing macros attached to properties where there are multiple properties on the same var/let, assertMacroExpansion() gives an error before executing the macro. But when using the macro outside of assertMacroExpansion(), the macro is executed similarly to when there is only one property.
Testing macro

Using macro outside test

Steps to Reproduce
A minimal project showing the issue is here: https://github.com/fizker/swift-syntax-peer-macro-issue
To summarize:
We start with the following macro:
public struct MyMacro: PeerMacro {
public static func expansion(
of node: AttributeSyntax,
providingPeersOf declaration: some DeclSyntaxProtocol,
in context: some MacroExpansionContext,
) throws -> [DeclSyntax] {
return []
}
}
We then use the macro
struct Foo {
@MyMacro
var a: Int, b: Int
}
If this code is placed in regularly executing Swift, it runs without issues and the return-statement is hit twice, for both a and b. But if it executed through assertMacroExpansion(), a diagnostic is raised stating that peer macro can only be applied to a single variable, and the macro code is never executed.
Description
This is reproduced with [email protected].
When testing macros attached to properties where there are multiple properties on the same
var/let,assertMacroExpansion()gives an error before executing the macro. But when using the macro outside ofassertMacroExpansion(), the macro is executed similarly to when there is only one property.Testing macro

Using macro outside test

Steps to Reproduce
A minimal project showing the issue is here: https://github.com/fizker/swift-syntax-peer-macro-issue
To summarize:
We start with the following macro:
We then use the macro
If this code is placed in regularly executing Swift, it runs without issues and the return-statement is hit twice, for both
aandb. But if it executed throughassertMacroExpansion(), a diagnostic is raised stating thatpeer macro can only be applied to a single variable, and the macro code is never executed.