Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion parser/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,15 @@ func (p *Parser) parseNot() ast.Expression {
Op: "NOT",
}
p.nextToken()
expr.Operand = p.parseExpression(NOT_PREC)
// When NOT is followed by a parenthesized expression, use UNARY precedence
// so that binary operators after the group don't continue as part of the NOT operand.
// e.g., NOT (0) + 1 should parse as (NOT(0)) + 1, not NOT((0) + 1)
// But NOT 0 + 1 should parse as NOT(0 + 1)
if p.currentIs(token.LPAREN) {
expr.Operand = p.parseExpression(UNARY)
} else {
expr.Operand = p.parseExpression(NOT_PREC)
}
return expr
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"todo": true}
{}