all is working again

This commit is contained in:
Folkert 2021-03-13 22:36:44 +01:00
parent 022ed7b24c
commit c26fd45d54
6 changed files with 191 additions and 113 deletions

View file

@ -125,6 +125,22 @@ fn to_syntax_report<'a>(
report(doc)
}
NotEndOfFile(row, col) => {
let surroundings = Region::from_rows_cols(start_row, start_col, *row, *col);
let region = Region::from_row_col(*row, *col);
let doc = alloc.stack(vec![
alloc.reflow(r"I expected to reach the end of the file, but got stuck here:"),
alloc.region_with_subregion(surroundings, region),
alloc.concat(vec![alloc.reflow("no hints")]),
]);
Report {
filename,
doc,
title: "NOT END OF FILE".to_string(),
}
}
SyntaxError::Eof(region) => {
let doc = alloc.stack(vec![alloc.reflow("End of Field"), alloc.region(*region)]);

View file

@ -65,6 +65,7 @@ mod test_reporting {
problems: can_problems,
..
} = can_expr(arena, expr_src)?;
dbg!(&loc_expr);
let mut subs = Subs::new(var_store.into());
for (var, name) in output.introduced_variables.name_by_var {
@ -4205,12 +4206,12 @@ mod test_reporting {
indoc!(
r#"
TOO MANY ARGS
The `add` function expects 2 arguments, but it got 3 instead:
4 Num.add 1 2
^^^^^^^
This value is not a function, but it was given 3 arguments:
3 x == 5
^
Are there any missing commas? Or missing parentheses?
"#
),
@ -5727,22 +5728,24 @@ mod test_reporting {
indoc!(
r#"
main =
5 : I64
(\x -> x) : I64
3
"#
),
indoc!(
r#"
UNKNOWN OPERATOR
This looks like an operator, but it's not one I recognize!
1 main =
2 5 : I64
^
2 (\x -> x) : I64
^
The has-type operator : can only occur in a definition's type
signature, like
increment : I64 -> I64
increment = \x -> x + 1
"#