You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do not perform full expansion of #expect() when try or await is present.
For reasons that have been documented at length (see #162), we aren't able to
correctly expand conditions on `#expect()` or `#require()` that have effects
(`try` or `await`.) We aren't currently detecting all possible patterns that
expand incorrectly. This PR causes us to back out of the full expansion if the
`try` or `await` keyword is present _anywhere_ inside an expectation condition
expression.
Resolves#783.
Copy file name to clipboardExpand all lines: Sources/TestingMacros/Support/ConditionArgumentParsing.swift
+16-16
Original file line number
Diff line number
Diff line change
@@ -312,17 +312,6 @@ private func _exprFromOptionalChainedExpr(_ expr: some ExprSyntaxProtocol) -> (E
312
312
///
313
313
/// - Returns: An instance of ``Condition`` describing `expr`.
314
314
privatefunc _parseCondition(from expr:FunctionCallExprSyntax, for macro:someFreestandingMacroExpansionSyntax, in context:someMacroExpansionContext)->Condition{
315
-
// If the member function call involves the `try` or `await` keywords, assume
316
-
// we cannot expand it. This check cannot handle expressions like
317
-
// `try #expect(a.b(c))` where `b()` is throwing because the `try` keyword
318
-
// is outside the macro expansion. SEE: rdar://109470248
0 commit comments