Fix "not in" precedence

This commit is contained in:
Laurenz 2023-02-12 10:17:35 +01:00
parent ebe919220d
commit 03cbdea4b4
2 changed files with 14 additions and 9 deletions

View File

@ -562,7 +562,8 @@ fn code_expr_prec(p: &mut Parser, atomic: bool, min_prec: usize) {
continue; continue;
} }
let binop = if p.eat_if(SyntaxKind::Not) { let binop =
if ast::BinOp::NotIn.precedence() >= min_prec && p.eat_if(SyntaxKind::Not) {
if p.at(SyntaxKind::In) { if p.at(SyntaxKind::In) {
Some(ast::BinOp::NotIn) Some(ast::BinOp::NotIn)
} else { } else {

View File

@ -23,6 +23,10 @@
// Error: 3-12 cannot apply '-' to boolean // Error: 3-12 cannot apply '-' to boolean
#{-not true} #{-not true}
---
// Not in handles precedence.
#test(-1 not in (1, 2, 3), true)
--- ---
// Parentheses override precedence. // Parentheses override precedence.
#test((1), 1) #test((1), 1)