Skip to content

Commit

Permalink
Add note about module names mis-compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
grynspan committed Dec 10, 2024
1 parent d4ff841 commit f23d8a3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/TestingMacros/Support/ConditionArgumentParsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ private final class _ContextInserter<C, M>: 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),
Expand Down

0 comments on commit f23d8a3

Please sign in to comment.