mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Merge pull request #3635 from rtfeldman/joshuawarner32/multiline
Strip indents and the first/last newline from multiline strings
This commit is contained in:
commit
fa5bd442f8
8 changed files with 284 additions and 44 deletions
|
@ -921,6 +921,27 @@ fn to_str_report<'a>(
|
|||
severity: Severity::RuntimeError,
|
||||
}
|
||||
}
|
||||
EString::MultilineInsufficientIndent(pos) => {
|
||||
let surroundings = Region::new(start, pos);
|
||||
let region = LineColumnRegion::from_pos(lines.convert_pos(pos));
|
||||
|
||||
let doc = alloc.stack([
|
||||
alloc.reflow(r"This multiline string is not sufficiently indented:"),
|
||||
alloc.region_with_subregion(lines.convert_region(surroundings), region),
|
||||
alloc.concat([
|
||||
alloc.reflow(r"Lines in a multi-line string must be indented at least as "),
|
||||
alloc.reflow("much as the beginning \"\"\". This extra indentation is automatically removed "),
|
||||
alloc.reflow("from the string during compilation."),
|
||||
]),
|
||||
]);
|
||||
|
||||
Report {
|
||||
filename,
|
||||
doc,
|
||||
title: "INSUFFICIENT INDENT IN MULTI-LINE STRING".to_string(),
|
||||
severity: Severity::RuntimeError,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fn to_expr_in_parens_report<'a>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue