@@ -94,6 +94,34 @@ extension OperatorTable {
94
94
public static func makeBinaryOperationExpr(
95
95
lhs: ExprSyntax , op: ExprSyntax , rhs: ExprSyntax
96
96
) -> ExprSyntax {
97
+ // If the left-hand side is a "try" or "await", hoist it up to encompass
98
+ // the right-hand side as well.
99
+ if let tryExpr = lhs. as ( TryExprSyntax . self) {
100
+ return ExprSyntax (
101
+ TryExprSyntax (
102
+ tryExpr. unexpectedBeforeTryKeyword,
103
+ tryKeyword: tryExpr. tryKeyword,
104
+ tryExpr. unexpectedBetweenTryKeywordAndQuestionOrExclamationMark,
105
+ questionOrExclamationMark: tryExpr. questionOrExclamationMark,
106
+ tryExpr. unexpectedBetweenQuestionOrExclamationMarkAndExpression,
107
+ expression: makeBinaryOperationExpr (
108
+ lhs: tryExpr. expression, op: op, rhs: rhs)
109
+ )
110
+ )
111
+ }
112
+
113
+ if let awaitExpr = lhs. as ( AwaitExprSyntax . self) {
114
+ return ExprSyntax (
115
+ AwaitExprSyntax (
116
+ awaitExpr. unexpectedBeforeAwaitKeyword,
117
+ awaitKeyword: awaitExpr. awaitKeyword,
118
+ awaitExpr. unexpectedBetweenAwaitKeywordAndExpression,
119
+ expression: makeBinaryOperationExpr (
120
+ lhs: awaitExpr. expression, op: op, rhs: rhs)
121
+ )
122
+ )
123
+ }
124
+
97
125
// The form of the binary operation depends on the operator itself,
98
126
// which will be one of the unresolved infix operators.
99
127
0 commit comments