Lyricdev
GitHub

LYR-LEX0015

a line of a multi-line string indented less than its closing quotes

error ยท spec 01-lexical

A line of a multi-line string (or a multi-line f-string) does not begin with the indentation of the line that holds the closing """. A blank line may be indented less.

Explanation

The indentation of the closing """ is taken off every line, so the text can be indented with the code around it. A line indented less has no such indentation to give, and what it would mean is unclear.

Indent the line at least as far as the closing """, or move the closing """ to the left.

Wrong

fn main(): void {
    let text = """
      short
        """;
    let _ = text;
}
fn main(): void {
    let text = """
        short
        """;
    let _ = text;
}