diff --git a/lib/src/compiler/tests/testdata/errors/143.out b/lib/src/compiler/tests/testdata/errors/143.out index 65874b531..6efca407e 100644 --- a/lib/src/compiler/tests/testdata/errors/143.out +++ b/lib/src/compiler/tests/testdata/errors/143.out @@ -1,5 +1,5 @@ error[E001]: syntax error - --> src/compiler/tests/testdata/includes/included_error.yar:1:15 + --> src/compiler/tests/testdata/includes/included_error.yar:1:16 | 1 | rule included { - | ^ expecting `condition`, found end of file \ No newline at end of file + | ^ expecting `condition`, found end of file \ No newline at end of file diff --git a/lib/src/compiler/tests/testdata/errors/153.in b/lib/src/compiler/tests/testdata/errors/153.in new file mode 100644 index 000000000..02174f9c8 --- /dev/null +++ b/lib/src/compiler/tests/testdata/errors/153.in @@ -0,0 +1,3 @@ +rule test { +strings: + $a = “foo” \ No newline at end of file diff --git a/lib/src/compiler/tests/testdata/errors/153.out b/lib/src/compiler/tests/testdata/errors/153.out new file mode 100644 index 000000000..03ed37195 --- /dev/null +++ b/lib/src/compiler/tests/testdata/errors/153.out @@ -0,0 +1,5 @@ +error[E001]: syntax error + --> line:3:10 + | +3 | $a = “foo” + | ^^^^^ expecting STRING, regexp or `{`, found `“foo”` \ No newline at end of file diff --git a/lib/src/compiler/tests/testdata/errors/64.out b/lib/src/compiler/tests/testdata/errors/64.out index e674f827c..5fdf034d0 100644 --- a/lib/src/compiler/tests/testdata/errors/64.out +++ b/lib/src/compiler/tests/testdata/errors/64.out @@ -1,5 +1,5 @@ error[E001]: syntax error - --> line:1:27 + --> line:1:28 | 1 | rule test { condition: true - | ^ expecting operator or `}`, found end of file \ No newline at end of file + | ^ expecting operator or `}`, found end of file \ No newline at end of file diff --git a/parser/src/parser/mod.rs b/parser/src/parser/mod.rs index b2f98b991..b9c4226e1 100644 --- a/parser/src/parser/mod.rs +++ b/parser/src/parser/mod.rs @@ -543,8 +543,8 @@ impl<'src> ParserImpl<'src> { None => { // Special case when the end of the source is reached. The span // used for error reporting is a zero-length span pointing to - // last byte in the source code. - let last = self.tokens.source().len().saturating_sub(1) as u32; + // the end of the code. + let last = self.tokens.source().len() as u32; (None, None, Span(last..last)) } Some(token) => ( diff --git a/parser/src/parser/tests/testdata/basic-error-3.ast b/parser/src/parser/tests/testdata/basic-error-3.ast index 8f0633670..b79a31ea4 100644 --- a/parser/src/parser/tests/testdata/basic-error-3.ast +++ b/parser/src/parser/tests/testdata/basic-error-3.ast @@ -1,2 +1,2 @@ ERRORS: -- SyntaxError { message: "expecting operator or `}`, found end of file", span: Span(26..26) } +- SyntaxError { message: "expecting operator or `}`, found end of file", span: Span(27..27) } diff --git a/parser/src/parser/tests/testdata/basic-error-3.cst b/parser/src/parser/tests/testdata/basic-error-3.cst index afbc4ee0f..1a35139e7 100644 --- a/parser/src/parser/tests/testdata/basic-error-3.cst +++ b/parser/src/parser/tests/testdata/basic-error-3.cst @@ -15,4 +15,4 @@ SOURCE_FILE@0..27 TRUE_KW@23..27 "true" ERRORS: -- [26..26]: expecting operator or `}`, found end of file +- [27..27]: expecting operator or `}`, found end of file diff --git a/parser/src/parser/tests/testdata/basic-error-3.cststream b/parser/src/parser/tests/testdata/basic-error-3.cststream index 3dc5cc769..b871c38fe 100644 --- a/parser/src/parser/tests/testdata/basic-error-3.cststream +++ b/parser/src/parser/tests/testdata/basic-error-3.cststream @@ -17,5 +17,5 @@ End { kind: BOOLEAN_TERM, span: Span(23..27) } End { kind: BOOLEAN_EXPR, span: Span(23..27) } End { kind: CONDITION_BLK, span: Span(12..27) } End { kind: ERROR, span: Span(0..27) } -Error { message: "expecting operator or `}`, found end of file", span: Span(26..26) } +Error { message: "expecting operator or `}`, found end of file", span: Span(27..27) } End { kind: SOURCE_FILE, span: Span(0..27) }