From f23d8a389f4c5e6ff7000fca47e3b5ba4037192b Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Mon, 9 Dec 2024 16:20:33 -0500 Subject: [PATCH] Add note about module names mis-compiling --- .../TestingMacros/Support/ConditionArgumentParsing.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/TestingMacros/Support/ConditionArgumentParsing.swift b/Sources/TestingMacros/Support/ConditionArgumentParsing.swift index 95f4441fa..29acf0e38 100644 --- a/Sources/TestingMacros/Support/ConditionArgumentParsing.swift +++ b/Sources/TestingMacros/Support/ConditionArgumentParsing.swift @@ -248,6 +248,15 @@ private final class _ContextInserter: SyntaxRewriter where C: MacroExpansi // expression, and that member access expression is the called expression of // a function, it is generally safe to extract out (but may need `.self` // added to the end.) + // + // Module names are an exception to this rule as they cannot be referred to + // directly in source. So for instance, the following expression will be + // expanded incorrectly: + // + // #expect(Testing.foo(bar)) + // + // These sorts of expressions are relatively rare, so we'll allow the bug + // for the sake of better diagnostics in the common case. if let memberAccessExpr = node.parent?.as(MemberAccessExprSyntax.self), ExprSyntax(node) == memberAccessExpr.base, let functionCallExpr = memberAccessExpr.parent?.as(FunctionCallExprSyntax.self),