Lyricdev
GitHub

LYR-LEX0011

an f-string that is not closed

error · spec 01-lexical

An f-string reaches the end of its line (or, for f""", of the file) without its closing quote — also when the line ends inside an interpolation or its format spec.

Explanation

An f"…" stands on one line, as a plain string does, and each { that opens an interpolation is closed by its } on that line. A multi-line f-string is written f"""…""".

Close the f-string, and every interpolation in it, on its line.

Wrong

fn main(): void {
    let n = 1;
    let s = f"n is {n}
    ;
    let _ = s;
}
fn main(): void {
    let n = 1;
    let s = f"n is {n}";
    let _ = s;
}