Add annotate_snippets for better parsing errors (#477)

Adds nicer errors for Podlang code, using the `annotate_snippets` crate, the same crate used by the Rust compiler to generate contextual errors. This prints a short snippet of the code containing the error within the error message, highlighting the part that needs to be fixed.

It also includes a change to the `load_module` function, changing a `Vec` function argument to a slice.
This commit is contained in:
Rob Knight 2026-02-11 11:14:23 +01:00 committed by GitHub
parent acab26e5c1
commit 09d67de989
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 612 additions and 40 deletions

View file

@ -88,7 +88,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
game_pk = game_pk,
);
println!("# custom predicate batch:{}", input);
let module = load_module(&input, "points_module", &params, vec![])?;
let module = load_module(&input, "points_module", &params, &[])?;
let batch = module.batch.clone();
let points_pred = batch.predicate_ref_by_name("points").unwrap();
let over_9000_pred = batch.predicate_ref_by_name("over_9000").unwrap();