mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +00:00
fix expression indentation error
This commit is contained in:
parent
4f23bc39f0
commit
f323fe6534
2 changed files with 40 additions and 0 deletions
|
@ -529,6 +529,24 @@ fn to_expr_report<'a>(
|
||||||
|
|
||||||
EExpr::Ability(err, pos) => to_ability_def_report(alloc, lines, filename, err, *pos),
|
EExpr::Ability(err, pos) => to_ability_def_report(alloc, lines, filename, err, *pos),
|
||||||
|
|
||||||
|
EExpr::IndentEnd(pos) => {
|
||||||
|
let surroundings = Region::new(start, *pos);
|
||||||
|
let region = LineColumnRegion::from_pos(lines.convert_pos(*pos));
|
||||||
|
let doc = alloc.stack(vec![
|
||||||
|
alloc.reflow(r"I am partway through parsing an expression, but I got stuck here:"),
|
||||||
|
alloc.region_with_subregion(lines.convert_region(surroundings), region),
|
||||||
|
alloc.concat(vec![alloc.reflow(
|
||||||
|
"Looks like the indentation ends prematurely after an expression",
|
||||||
|
)]),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Report {
|
||||||
|
filename,
|
||||||
|
doc,
|
||||||
|
title: "INDENT ENDS AFTER EXPRESSION".to_string(),
|
||||||
|
severity: Severity::RuntimeError,
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => todo!("unhandled parse error: {:?}", parse_problem),
|
_ => todo!("unhandled parse error: {:?}", parse_problem),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4586,6 +4586,28 @@ mod test_reporting {
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test_report!(
|
||||||
|
expression_indentation_end,
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
f <- Foo.foo
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
@r###"
|
||||||
|
── INDENT ENDS AFTER EXPRESSION ────── tmp/expression_indentation_end/Test.roc ─
|
||||||
|
|
||||||
|
I am partway through parsing an expression, but I got stuck here:
|
||||||
|
|
||||||
|
1│ app "test" provides [main] to "./platform"
|
||||||
|
2│
|
||||||
|
3│ main =
|
||||||
|
4│ f <- Foo.foo
|
||||||
|
^
|
||||||
|
|
||||||
|
Looks like the indentation ends prematurely after an expression
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
|
||||||
test_report!(
|
test_report!(
|
||||||
type_inline_alias,
|
type_inline_alias,
|
||||||
indoc!(
|
indoc!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue