@@ -12400,11 +12400,22 @@ func (c *Checker) getSyntacticTruthySemantics(node *ast.Node) PredicateSemantics
12400
12400
}
12401
12401
12402
12402
func (c *Checker) checkNullishCoalesceOperands(left *ast.Node, right *ast.Node) {
12403
- if ast.IsBinaryExpression(left) && ast.IsLogicalBinaryOperator(left.AsBinaryExpression().OperatorToken.Kind) {
12404
- c.grammarErrorOnNode(left, diagnostics.X_0_and_1_operations_cannot_be_mixed_without_parentheses, scanner.TokenToString(left.AsBinaryExpression().OperatorToken.Kind), scanner.TokenToString(ast.KindQuestionQuestionToken))
12405
- }
12406
- if ast.IsBinaryExpression(right) && ast.IsLogicalBinaryOperator(right.AsBinaryExpression().OperatorToken.Kind) {
12407
- c.grammarErrorOnNode(right, diagnostics.X_0_and_1_operations_cannot_be_mixed_without_parentheses, scanner.TokenToString(right.AsBinaryExpression().OperatorToken.Kind), scanner.TokenToString(ast.KindQuestionQuestionToken))
12403
+ if ast.IsBinaryExpression(left.Parent.Parent) {
12404
+ operatorToken := left.Parent.Parent.AsBinaryExpression().OperatorToken
12405
+ left := left.Parent.Parent.AsBinaryExpression().Left
12406
+ if ast.IsBinaryExpression(left) && operatorToken.Kind == ast.KindBarBarToken {
12407
+ c.grammarErrorOnNode(left, diagnostics.X_0_and_1_operations_cannot_be_mixed_without_parentheses, scanner.TokenToString(ast.KindQuestionQuestionToken), scanner.TokenToString(operatorToken.Kind))
12408
+ }
12409
+ } else if ast.IsBinaryExpression(left) {
12410
+ operatorToken := left.AsBinaryExpression().OperatorToken
12411
+ if operatorToken.Kind == ast.KindBarBarToken || operatorToken.Kind == ast.KindAmpersandAmpersandToken {
12412
+ c.grammarErrorOnNode(left, diagnostics.X_0_and_1_operations_cannot_be_mixed_without_parentheses, scanner.TokenToString(operatorToken.Kind), scanner.TokenToString(ast.KindQuestionQuestionToken))
12413
+ }
12414
+ } else if ast.IsBinaryExpression(right) {
12415
+ operatorToken := right.AsBinaryExpression().OperatorToken
12416
+ if operatorToken.Kind == ast.KindAmpersandAmpersandToken {
12417
+ c.grammarErrorOnNode(right, diagnostics.X_0_and_1_operations_cannot_be_mixed_without_parentheses, scanner.TokenToString(ast.KindQuestionQuestionToken), scanner.TokenToString(operatorToken.Kind))
12418
+ }
12408
12419
}
12409
12420
leftTarget := ast.SkipOuterExpressions(left, ast.OEKAll)
12410
12421
nullishSemantics := c.getSyntacticNullishnessSemantics(leftTarget)
0 commit comments