File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
testdata/02920_unary_operators_functions Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -809,7 +809,15 @@ func (p *Parser) parseNot() ast.Expression {
809809 Op : "NOT" ,
810810 }
811811 p .nextToken ()
812- expr .Operand = p .parseExpression (NOT_PREC )
812+ // When NOT is followed by a parenthesized expression, use UNARY precedence
813+ // so that binary operators after the group don't continue as part of the NOT operand.
814+ // e.g., NOT (0) + 1 should parse as (NOT(0)) + 1, not NOT((0) + 1)
815+ // But NOT 0 + 1 should parse as NOT(0 + 1)
816+ if p .currentIs (token .LPAREN ) {
817+ expr .Operand = p .parseExpression (UNARY )
818+ } else {
819+ expr .Operand = p .parseExpression (NOT_PREC )
820+ }
813821 return expr
814822}
815823
Original file line number Diff line number Diff line change 1- {"todo" : true }
1+ {}
You can’t perform that action at this time.
0 commit comments