LYR-SEM0164
a format spec in an f-string hole is malformed or does not apply
The spec after : in an f-string hole is not of the form [[fill]align][sign][#][0][width][grouping][.precision][type], or one of its parts does not apply to the value's type (a sign on a string, a precision on an integer …).
Explanation
A hole {value:spec} formats a scalar by the spec, or pads a Display value. The spec has one grammar, [[fill]align][sign][#][0][width][grouping][.precision][type], and each part applies to some types only: a precision and f or e to floats, x or b to integers, only fill, alignment and width to a type that renders through Display. A type that conforms to Format reads the spec itself and is not checked here.
Write the spec in that form — {avg:.2f}, not the .NET-style {avg:N2} — and use only the parts that apply to the value.
Wrong
fn main(): void {
let avg = 2.5;
assert(f"{avg:N2}" == "2.50");
}
Right
fn main(): void {
let avg = 2.5;
assert(f"{avg:.2f}" == "2.50");
}