Skip to content
← The design recordTooling and process

Diagnostics

Noisy by default, filtered by configuration, with a soundness floor that can't be turned off.

diagnostics.md on GitHub →

elp diagnostics

The principle

"I'd rather filter too much information than there not be enough."

The compiler is noisy by default and filtered by configuration, not quiet by default and opted into. A developer who never touches the settings sees everything the compiler noticed; a developer who has tuned them sees what they asked for.

This is the C++ -Wall / -Wextra lineage rather than the "errors only" one, and it inverts the usual default: the information exists either way, and the question is only who decides what to look at.

The soundness floor

A diagnostic that reports unsoundness is always an error and can never be configured down. Type errors, ownership violations, conformance failures, non-exhaustive matches with no fall-through, import cycles — none of these are tunable at any level.

This is the guard that makes the rest of the design safe. Without it, "configure how much the compiler tells you" quietly becomes "configure how much type safety you get", which is how -Wno-error ends up in a build script and stays there for four years.

So every diagnostic sits in one of two tiers:

tierwhat it coversconfigurable
errorsoundness: the program has no valid meaningno, ever
lintstyle, risk, redundancy, future breakageyes, allow → warn → deny

A lint may be raised to deny (fail the build). An error may not be lowered. There is no -Wno-type-error.

Every diagnostic has a stable name

Filtering requires something to name, so each lint carries a stable identifier — unreachable_pattern, foreign_enum_exhaustive, truncated_projection. Names are API: renaming one breaks every manifest that mentions it.

Lints are also grouped, so a developer can move a whole family at once rather than enumerating members.

Where the level is set

Three places, narrowest winning:

  1. The manifest, since it is already elp code:

    @Package(
    	name = "expenses",
    	lints = [
    		.deny(.unreachable_pattern),
    		.allow(.foreign_enum_exhaustive),
    	],
    )
  2. In source, on the declaration it concerns:

    @allow(unreachable_pattern)
    fn Category.label(&self) -> string { ... }
  3. The command line, overriding both, for a one-off build.

Lint configuration does not cross a package boundary. A dependency cannot silence a lint in your code, and you do not inherit its settings — you see diagnostics about your source under your rules. This follows from the manifest being per-package and is worth stating because the alternative (inherited lint config) is a common and miserable failure mode.

Compile time and run time are different things

reactivity.md commits to a dev-mode watchdog warning when a turn exceeds a frame budget, and notes it is "a runtime feature rather than a language one". That is a third category and it deserves its own vocabulary — a runtime diagnostic, present in dev builds and absent from release ones.

whenconfigured by
errorcompilenot at all
lintcompilemanifest / attribute / CLI
runtime diagnosticdev-build executionbuild profile

The exhaustiveness lints

error-handling.md settles the rule: a match with no catch-all must be exhaustive, and writing _ opts out. Two lints sit around that rule rather than inside it.

unreachable_pattern — warn by default

A catch-all on a match that is already exhaustive. The arm can never run, so it is either a mistake or a defence the author wanted; a lint says so without deciding which.

foreign_enum_exhaustive — warn by default

An exhaustive match, with no catch-all, over an enum declared in another package.

This is the forward-compatibility risk, and a lint is the right register for it: the match is correct today and will stop compiling if the upstream enum gains a variant. Saying so is informative. Making it an error would be a lie, because the code is fine.

It is also narrow by construction — it cannot fire on a match over your own enums, which is the overwhelming majority of them, so it stays quiet in the case where exhaustiveness is exactly what you want.

This is where the package boundary belongs. An earlier draft made a catch-all mandatory across package boundaries; that was too strong, because elp pins one version per package and makes conflicts a build error, so a new variant can only ever arrive through a deliberate upgrade. The break is visible and informative at the moment you choose it. A lint flags the exposure; it does not forbid it.

key_churn — a runtime diagnostic, not a lint

Every key in a markup for changed between two renders while the collection's length barely moved. That is what a position-dependent key looks like from inside the reconciler — by "{index}-{line}" and its relatives — and it is the one failure around reconciliation identity that nothing static can see, because the compiler cannot tell which of an iterator's fields is an index.

It is a heuristic, and it is in the register reactivity.md already uses for a turn exceeding the frame budget rather than the lint register, for the same reason: the condition is a fact about a run, not about a program.

What earns it a place is the failure it replaces. A position key is silent forever otherwise: the list renders correctly and the only symptoms are lost row state and animations re-firing, which is the hardest thing in this area to attribute to its cause. The reconciler already holds both key sets, so it costs a comparison.

identity_by_value — warn by default

A markup for whose by expression is the loop binding itself, with no projection: for line in lines by line.

by asserts that the key is unique within the list, and keying on the value asserts that no two elements are equal — which for a [string] is usually false and silently collapses two rows into one. A duplicate key traps at runtime (control-flow.md), and this is the compile-time half: the shape that is almost always a false claim is statically visible even though uniqueness is not.

The message is the point, and it is not about the key. What this lint has actually found is that the collection has no identity — a [string] document model cannot say which line is which, and no key expression can invent one. The fix is never at the loop, so the diagnostic should name the model rather than suggest a different by.

Narrow by construction — it cannot fire on by post.id or by row.category, which are projections and therefore real claims — and a lint rather than an error because the claim is occasionally true, as for a list of distinct tags keyed by the tag.

Two corpus sites make the false claim today (examples/Undo, examples/Buffer), and in both the real fix is a stable line identity rather than a different key, which is why the lint points at a representation problem rather than a typo.

Not a lint

An exhaustive match with no catch-all over your own enum is correct code and says nothing. Category.label and PatternError.toString are silent, and the day a sixth variant is added they are a hard error — which is the whole point.

unreleased_resource — proposed, warn by default

The lint the release decision makes load-bearing. memory-model.md deleted with ... as x { } in favour of defer x.release(), and with it the last candidate for a guaranteed release. Forgetting the defer leaks — exactly as a Scoped type never bound by a with was never released, so this is the same hole made visible rather than a new one.

It was considered and rejected in November as "@MustUse-style linting, which catches the common case and nothing else". It is now the only candidate, and the common case is the whole of what the corpus does:

warning: this `Connection` is never released
  --> db.elp:171
   |  const db = Connection.open(path)?
   |        ^^ `Connection` is `Scoped`, and nothing in this scope calls
   |           `db.release()`
   = help: add `defer db.release()` on the next line
   = note: a value moved out of this scope is not reported

What it keys on is the Scoped marker, which is what that interface is for now that nothing calls it. What it cannot see is a resource returned to a caller (VulkanTriangle's Renderer.new) or handed to a platform runtime (examples/Playhead), so both are the "moved out" note above rather than warnings — which is also why this is a lint and not a rule.

A second one is wanted by the same decision and is not proposed here because its shape is unclear: release taking &self makes double release spellable, and sqlite3_close twice is undefined behaviour. The two candidates are a lint for release called outside a defer, and the type guarding itself with one bool and &var self. The second is not a diagnostic at all, which is why this file does not claim the question.

existential_error — warn by default

An export fn whose error type is the interface Error rather than a concrete type. error-handling.md decides that the existential belongs where nobody branches, which is about one function per program, and the corpus survey that forced the decision found 51 of 59 fallible signatures returning it.

The message names the concrete type the body produces, because in every corpus instance the body knows it:

warning: this returns `Either<Link, Error>`, so a caller cannot tell its
         failures apart
  --> store.elp:80
   |  export fn Store.put(&self, link Link) -> Either<Link, Error> {
   |                                                        ^^^^^ the
   |                                                   interface, not a type
   = note: the body produces `StoreError`, which has 3 variants
   = help: return `Either<Link, StoreError>`; the existential belongs at the
           top of a program, where nobody branches

Warn, not deny: it is right at the top of a program and in a prototype, and @allow(existential_error) on main is the expected annotation.

Not a lint — the fallible transform

error-handling.md ratifies commit for the strong guarantee, and a transform whose R is an Either must use it rather than update. That is an error, not a lint, for the reason the soundness floor above gives: the program it rejects has no correct handler, so there is nothing for an author to weigh. The diagnostic is written out in that document.

Commitments already made elsewhere

Scattered through the other docs, collected here so they have a home:

diagnosticsourcetier
extra fields in a structural projection are truncatedgenerics.md, and a comment in ChatRoom/main.velplint — truncated_projection
a turn exceeds the frame budgetreactivity.mdruntime diagnostic
a duplicate by key in a markup forcontrol-flow.mdtrap — the same register as an out-of-bounds []
every by key changed at oncecontrol-flow.mdruntime diagnostic — key_churn

grammar-script-notes.md also contains a deliberate rejection of a lint: accessibility state is derived from props rather than passed separately, "making the drift unrepresentable rather than lintable". That is the preferred move whenever it is available — a lint is what you reach for when the design cannot make the mistake impossible.

Where the messages are

This document names lints and sets their register; it contains almost no messages. examples/Rejected does: sixteen wrong programs, each carrying what the compiler should print, written against the principle above that the diagnostic is the teaching.

It is worth reading before writing any diagnostic, and it produced one result that belongs here rather than there. A rule whose message cannot be written is a rule that is not finished. Five of its sixteen cases failed exactly that way — the message would have had to name a borrow duration, an allocates-or-not property, a body-position mechanism, a choice between three error kinds, or the outcome of a conformance the fields deny, and none of those is decided.

That is a mechanical test for an unfinished rule, available with no compiler, and it is cheaper than any amount of rereading.

Open

  • Default level of each lint, which can only really be set once there are lints and a corpus noisy enough to judge them against.
  • Lint groups: what the families are, and whether there is an all / extra pair in the C++ style or Rust's category names.
  • Whether deny in a manifest is honoured when the package is built as a dependency, or only when it is the root. Cargo's answer is "only the root", and it exists because the alternative makes other people's strictness your build failure.
  • Attribute spelling. @allow(name) reuses the macro-attribute syntax, which raises the same macro-vs-type namespace question already open in core-language-probes.md.