Skip to content

Commit 36fdfa5

Browse files
committed
Add note about module names mis-compiling
1 parent bde7848 commit 36fdfa5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/TestingMacros/Support/ConditionArgumentParsing.swift

+9
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,15 @@ private final class _ContextInserter<C, M>: SyntaxRewriter where C: MacroExpansi
248248
// expression, and that member access expression is the called expression of
249249
// a function, it is generally safe to extract out (but may need `.self`
250250
// added to the end.)
251+
//
252+
// Module names are an exception to this rule as they cannot be referred to
253+
// directly in source. So for instance, the following expression will be
254+
// expanded incorrectly:
255+
//
256+
// #expect(Testing.foo(bar))
257+
//
258+
// These sorts of expressions are relatively rare, so we'll allow the bug
259+
// for the sake of better diagnostics in the common case.
251260
if let memberAccessExpr = node.parent?.as(MemberAccessExprSyntax.self),
252261
ExprSyntax(node) == memberAccessExpr.base,
253262
let functionCallExpr = memberAccessExpr.parent?.as(FunctionCallExprSyntax.self),

0 commit comments

Comments
 (0)