Error codes

E0282: malformed format spec

In a terminal: auk explain E0282 prints this page.

On this page

The part after : in an interpolation isn't a valid format spec. Specs are an optional alignment <, > or ^ with a width, an optional 0 for zero-padding, an optional precision, and for an int an optional base x, X, o or b: {x:.2}, {n:>5}, {n:05}, {s:<10}, {n:08x}.

Wrong#

auk
fn sci(x: float): str = "{x:e}"

Fixed#

auk
fn sci(x: float): str = "{x:.3}"

Common causes#

  • Format types from Python or Rust other than x, X, o and b (:e, :?): not supported.
  • A : in the text right after an interpolation: write {x}{{ ... or separate it with a space.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page