diff --git a/lib/src/compiler/tests/testdata/errors/137.in b/lib/src/compiler/tests/testdata/errors/137.in new file mode 100644 index 00000000..5fa723c5 --- /dev/null +++ b/lib/src/compiler/tests/testdata/errors/137.in @@ -0,0 +1,4 @@ +rule test { + condition: + uint16(,0) == 0 +} \ No newline at end of file diff --git a/lib/src/compiler/tests/testdata/errors/137.out b/lib/src/compiler/tests/testdata/errors/137.out new file mode 100644 index 00000000..66ed65e4 --- /dev/null +++ b/lib/src/compiler/tests/testdata/errors/137.out @@ -0,0 +1,6 @@ +error[E001]: syntax error + --> line:3:13 + | +3 | uint16(,0) == 0 + | ^ expecting expression, `for`, `all`, `none`, `any`, `with` or `)`, found `,` + | \ No newline at end of file diff --git a/parser/src/ast/cst2ast.rs b/parser/src/ast/cst2ast.rs index d00aef31..2e3a321c 100644 --- a/parser/src/ast/cst2ast.rs +++ b/parser/src/ast/cst2ast.rs @@ -225,6 +225,10 @@ impl<'src> Builder<'src> { match self.next()? { Event::Token { kind, span } => { if expected_kind != kind { + // If this ever happens is because we are finding an + // unexpected syntax in the CST. Either the source -> CST + // phase is not strict enough, or the CST -> AST phase is + // overly strict. panic!("expected {:?}, got {:?}", expected_kind, kind); } Ok(span) diff --git a/parser/src/parser/mod.rs b/parser/src/parser/mod.rs index e3893f8d..b88a2205 100644 --- a/parser/src/parser/mod.rs +++ b/parser/src/parser/mod.rs @@ -1432,11 +1432,12 @@ impl<'src> ParserImpl<'src> { .then(|p| p.primary_expr()) .cond(t!(L_BRACKET), |p| p.expr().expect(t!(R_BRACKET))) .cond(t!(L_PAREN), |p| { - p.opt(|p| p.boolean_expr()) - .zero_or_more(|p| { + p.opt(|p| { + p.boolean_expr().zero_or_more(|p| { p.expect(t!(COMMA)).then(|p| p.boolean_expr()) }) - .expect(t!(R_PAREN)) + }) + .expect(t!(R_PAREN)) }) .end() }