Open toxamin opened 4 months ago
Your example does error for me. Is this on master or on the current crate?
latest master, my code:
use full_moon::ast::AstResult;
use full_moon::{LuaVersion, parse_fallible};
fn main() {
let code = "
print(\"xd\")
continue
print(\"xd2\")
";
let raw_result: AstResult = parse_fallible(&code, LuaVersion::luau());
raw_result.errors().iter().for_each(|e| println!("{}", e));
println!("done");
}
I'm surprised we didn't have a regression test for this. Good find
Note this is specific to the top-level block parsing, and does not occur when parsing inside of nested blocks (e.g., loops)
Reopening as the error recovery part isn't completely solved yet, as we lose data
test case:
parsing this does not produce any errors (imo it should). however, even if this should be parsed, the location of the laststmt in question is ambiguous: if it's continue, then we keep parsing statements, so the continue statement "teleports" to the end if it's return, then the other statements get stripped (parser is no longer lossless) etc. etc.
of course it's possible to determine the position based on tokens, but it isn't very convenient