Handle import params indent error in reporting

This commit is contained in:
Agus Zubiaga 2024-05-09 07:49:21 -03:00
parent 9be3358355
commit b8280bf69a
No known key found for this signature in database
2 changed files with 37 additions and 26 deletions

View file

@ -4983,6 +4983,10 @@ mod test_reporting {
Or the `exposing` keyword, like: Or the `exposing` keyword, like:
import svg.Path exposing [arc, rx] import svg.Path exposing [arc, rx]
Or module params, like:
import Menu { echo, read }
"### "###
); );

View file

@ -1487,8 +1487,12 @@ fn to_import_report<'a>(
.indent(4), .indent(4),
]), ]),
), ),
IndentAs(pos) | As(pos) | IndentExposing(pos) | Exposing(pos) | EndNewline(pos) => { Params(EImportParams::Indent(pos), _)
to_unfinished_import_report( | IndentAs(pos)
| As(pos)
| IndentExposing(pos)
| Exposing(pos)
| EndNewline(pos) => to_unfinished_import_report(
alloc, alloc,
lines, lines,
filename, filename,
@ -1511,9 +1515,12 @@ fn to_import_report<'a>(
alloc alloc
.parser_suggestion("import svg.Path exposing [arc, rx]") .parser_suggestion("import svg.Path exposing [arc, rx]")
.indent(4), .indent(4),
alloc.reflow("Or module params, like:"),
alloc
.parser_suggestion("import Menu { echo, read }")
.indent(4),
]), ]),
) ),
}
Params(EImportParams::Record(problem, pos), _) => { Params(EImportParams::Record(problem, pos), _) => {
to_record_report(alloc, lines, filename, problem, *pos, start) to_record_report(alloc, lines, filename, problem, *pos, start)
} }