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:
parent
acab26e5c1
commit
09d67de989
11 changed files with 612 additions and 40 deletions
|
|
@ -1381,7 +1381,7 @@ pub mod tests {
|
|||
Equal(b, 5)
|
||||
)
|
||||
"#;
|
||||
let module = load_module(input, "test", ¶ms, vec![]).unwrap();
|
||||
let module = load_module(input, "test", ¶ms, &[]).unwrap();
|
||||
let batch = module.batch.clone();
|
||||
let pred_test = batch.predicate_ref_by_name("Test").unwrap();
|
||||
|
||||
|
|
@ -1430,7 +1430,7 @@ pub mod tests {
|
|||
c(6, 3)
|
||||
)
|
||||
"#;
|
||||
let module = load_module(input, "test", ¶ms, vec![]).unwrap();
|
||||
let module = load_module(input, "test", ¶ms, &[]).unwrap();
|
||||
let batch = module.batch.clone();
|
||||
let pred_test = batch.predicate_ref_by_name("Test").unwrap();
|
||||
|
||||
|
|
@ -1452,7 +1452,7 @@ pub mod tests {
|
|||
c(6, 3)
|
||||
)
|
||||
"#;
|
||||
let module = load_module(input, "test", ¶ms, vec![]).unwrap();
|
||||
let module = load_module(input, "test", ¶ms, &[]).unwrap();
|
||||
let batch = module.batch.clone();
|
||||
let pred_test = batch.predicate_ref_by_name("Test").unwrap();
|
||||
|
||||
|
|
@ -1491,7 +1491,7 @@ pub mod tests {
|
|||
"#;
|
||||
|
||||
// Parse and batch the predicate (this handles splitting internally)
|
||||
let module = load_module(input, "test", ¶ms, vec![])?;
|
||||
let module = load_module(input, "test", ¶ms, &[])?;
|
||||
|
||||
// Verify it was split
|
||||
assert!(module.split_chains.contains_key("large_pred"));
|
||||
|
|
|
|||
|
|
@ -763,7 +763,7 @@ mod tests {
|
|||
"#,
|
||||
"test",
|
||||
¶ms,
|
||||
vec![],
|
||||
&[],
|
||||
)
|
||||
.expect("load module");
|
||||
let batch = &module.batch;
|
||||
|
|
@ -1492,7 +1492,7 @@ mod tests {
|
|||
"#,
|
||||
"test",
|
||||
¶ms,
|
||||
vec![],
|
||||
&[],
|
||||
)
|
||||
.expect("load module");
|
||||
let batch = &module.batch;
|
||||
|
|
@ -1621,7 +1621,7 @@ mod tests {
|
|||
"#,
|
||||
"test",
|
||||
¶ms,
|
||||
vec![],
|
||||
&[],
|
||||
)
|
||||
.expect("load module");
|
||||
let batch = &module.batch;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue