No way to describe operator precedence to `assertMacroExpansion`
Closed this issue · 3 comments
stephencelis commented
Description
It doesn't seem possible to write tests for macros that visit InfixOperatorExprSyntax
. This includes the "add blocker" example from swift-macro-examples.
Steps to Reproduce
- Try to write a macro test for: https://github.com/DougGregor/swift-macro-examples/blob/66ded9b2774c06c5a51254b0640a456ef1055a68/MacroExamplesPlugin/AddBlocker.swift
- The
AddVisitor
never visits the node because the node doesn't exist in the test run.
ahoppen commented
Tracked in Apple’s issue tracker as rdar://114786803
stephencelis commented
My assumption is:
- The parsed source should be folded using the standard operators defined in the
SwiftOperators
module - There may need to be an option to provide custom operators
ahoppen commented
Thanks for the bug report. I’m fixing it in #2132.
We don’t need an option to provide custom operators in assertMacroExpansion
yet because the compiler also only folds operators using the standard operator table. Once the compiler gains support for folding of custom operators, we need to an option to specify a custom operator table in assertMacroExpansion
.