mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Fix "not in" precedence
This commit is contained in:
parent
ebe919220d
commit
03cbdea4b4
@ -562,16 +562,17 @@ 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 p.at(SyntaxKind::In) {
|
if ast::BinOp::NotIn.precedence() >= min_prec && p.eat_if(SyntaxKind::Not) {
|
||||||
Some(ast::BinOp::NotIn)
|
if p.at(SyntaxKind::In) {
|
||||||
|
Some(ast::BinOp::NotIn)
|
||||||
|
} else {
|
||||||
|
p.expected("keyword `in`");
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p.expected("keyword `in`");
|
ast::BinOp::from_kind(p.current())
|
||||||
break;
|
};
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast::BinOp::from_kind(p.current())
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(op) = binop {
|
if let Some(op) = binop {
|
||||||
let mut prec = op.precedence();
|
let mut prec = op.precedence();
|
||||||
|
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user