Skip to content

Diagnostics And Formatting

Chris Michael edited this page Sep 2, 2026 · 3 revisions

Pudu

Diagnostics And Formatting

E0xxx source and lexing
E1xxx parsing
E2xxx names
E3xxx types
E4xxx ownership
E5xxx exhaustiveness and effects
E6xxx lowering and backend
E7xxx runtime and toolchain

Status: structured diagnostics, source spans, plain/interactive rendering, summaries, stable code families, LSP conversion, and the canonical formatter are implemented. Not every reserved family has an implemented compiler phase yet.

Diagnostic contract

Errors use E codes and warnings use W codes. Each code is five ASCII characters and has one meaning. Diagnostics can carry help and related source context. Earlier phase failures suppress later cascades where the later message would only restate the same defect.

Warnings do not make pudu check fail. Error-severity diagnostics do. The repository CI verifies that a diagnostic code is not reused for unrelated meanings.

Common recent diagnostics

Code Meaning
E1056 if let pattern cannot fail.
E1057 let … else pattern cannot fail.
E1058 while let pattern cannot fail.
E3011 Propagation carrier does not match the enclosing function.
E3036 let … else fallback can continue.
W3003 A match only re-propagates the same carrier and can use ?.
W5001 A match arm is unreachable.

The complete registry lives in the compiler and grammar; this page is not an exhaustive code catalog.

Formatting

pudu fmt Source.pudu
pudu fmt --check Source.pudu
pudu fmt --stdout Source.pudu

Canonical style uses two-space indentation, braces on declaration/control lines, no semicolons, and lexical import ordering with the standard library first. Formatter output is idempotent.

The formatter works from the token stream and preserves the token sequence: it moves whitespace but does not rewrite program meaning. Lexically invalid input is returned unchanged.

Macro calls expose one current style defect: the grammar writes name!(argument), while the formatter inserts a space as name !(argument). Both forms check, but the documented compact form does not pass pudu fmt --check. The macro example is therefore checked for syntax and excluded from the formatter-clean example set until the formatter and grammar agree.

Related

Clone this wiki locally