summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/syntax/parser.rs19
-rw-r--r--tests/typ/compiler/ops-prec.typ4
2 files changed, 14 insertions, 9 deletions
diff --git a/src/syntax/parser.rs b/src/syntax/parser.rs
index 9f951389..8082fd64 100644
--- a/src/syntax/parser.rs
+++ b/src/syntax/parser.rs
@@ -562,16 +562,17 @@ fn code_expr_prec(p: &mut Parser, atomic: bool, min_prec: usize) {
continue;
}
- let binop = if p.eat_if(SyntaxKind::Not) {
- if p.at(SyntaxKind::In) {
- Some(ast::BinOp::NotIn)
+ let binop =
+ if ast::BinOp::NotIn.precedence() >= min_prec && p.eat_if(SyntaxKind::Not) {
+ if p.at(SyntaxKind::In) {
+ Some(ast::BinOp::NotIn)
+ } else {
+ p.expected("keyword `in`");
+ break;
+ }
} else {
- p.expected("keyword `in`");
- break;
- }
- } else {
- ast::BinOp::from_kind(p.current())
- };
+ ast::BinOp::from_kind(p.current())
+ };
if let Some(op) = binop {
let mut prec = op.precedence();
diff --git a/tests/typ/compiler/ops-prec.typ b/tests/typ/compiler/ops-prec.typ
index 2fa90382..e243a640 100644
--- a/tests/typ/compiler/ops-prec.typ
+++ b/tests/typ/compiler/ops-prec.typ
@@ -24,6 +24,10 @@
#{-not true}
---
+// Not in handles precedence.
+#test(-1 not in (1, 2, 3), true)
+
+---
// Parentheses override precedence.
#test((1), 1)
#test((1+2)*-3, -9)