Skip to content

Fix peer macro expansion on multiple variables - #3501

Open
akasakariko wants to merge 1 commit into
swiftlang:mainfrom
akasakariko:fix/3320-peer-macro-multiple-variables
Open

akasakariko wants to merge 1 commit into
swiftlang:mainfrom
akasakariko:fix/3320-peer-macro-multiple-variables

Conversation

@akasakariko

Copy link
Copy Markdown
Contributor

Summary

  • Expand peer macros once for each named variable, keeping the complete declaration on every call
  • Handle tuple and wildcard patterns without altering accessor macro restrictions
  • Cover member, top-level and local declarations, unique generated peers, empty expansions and repeated diagnostics

Reproduction

  • Reproduced on unmodified main at 574f42037e7fa2bcc62bfc0188c585dd3c9e4b2a using the generic assertion core called by assertMacroExpansion
  • The empty peer macro produced an unexpected single-variable diagnostic while the native compiler accepted the same source
  • Compiler probes confirmed that every invocation receives the complete declaration, including all bindings

Validation

  • The four affected regression tests fail on the original implementation, all eight peer macro tests pass after the fix
  • Linux macro suite, SKIP_LONG_TESTS=1 swift test --jobs 1 -Xswiftc -disable-batch-mode --filter SwiftSyntaxMacroExpansionTest, 141 XCTest cases and 2 Swift Testing cases pass
  • Linux full quick suite, SKIP_LONG_TESTS=1 swift test --skip-build, 3538 XCTest cases with 9 skips and no failures, plus 2 passing Swift Testing cases
  • Native macOS compiler checks and the generic assertion reproduction pass
  • Strict Swift formatting lint and git diff --check pass

AI assistance

  • This change was implemented and checked with AI assistance

Fixes #3320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

assertMacroExpansion() gives different diagnostics than using a macro when attached to multiple variables

1 participant