For an example script like this:
use rhai::Engine;
fn main() {
let engine = Engine::new();
let main_script = r#"
let x = 1+2
let y = x;
y
"#
.trim();
let err = engine.eval::<i32>(main_script);
println!("{err:?}");
}
The resulting error will be
Err(ErrorParsing(MissingToken(";", "to terminate this statement"), 3:1))
where 3:1 becomes "let y = x", that is, the statement after the missing statement.
I would assume this occurs because the parser will ignore whitespace until it scans a terminator, but
I think this makes the error message unclear, since it makes it look like the next statement is the one
that is missing the terminator.
If the parser doesn't keep track of spans, perhaps at least changing the message to be "expected terminator ; before this statement" or something of that nature.
For an example script like this:
The resulting error will be
Err(ErrorParsing(MissingToken(";", "to terminate this statement"), 3:1))where 3:1 becomes "let y = x", that is, the statement after the missing statement.
I would assume this occurs because the parser will ignore whitespace until it scans a terminator, but
I think this makes the error message unclear, since it makes it look like the next statement is the one
that is missing the terminator.
If the parser doesn't keep track of spans, perhaps at least changing the message to be "expected terminator ; before this statement" or something of that nature.