Merge pull request #3635 from rtfeldman/joshuawarner32/multiline

Strip indents and the first/last newline from multiline strings
This commit is contained in:
Richard Feldman 2022-07-26 22:09:58 -04:00 committed by GitHub
commit fa5bd442f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 284 additions and 44 deletions

View file

@ -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>(