Diagnostics
The active compiler diagnostics surface is Vitte-owned.
Source of truth
- Structured diagnostics types and renderers live in
src/vitte/compiler/diagnostics/diagnostic.vit. - The seed path documented in
docs/seed_diagnostics.mdonly describes the bootstrap stage0 surface. - Ad-hoc diagnostics are rejected: public errors should be emitted through the shared
Diagnosticmodel. - Locale coverage starts from
tests/diag_snapshots/core_diagnostic_codes.txtand is expanded bytools/diagnostic_catalog_data.py. tools/check_diagnostics_locales.pyverifies every supported locale against the expanded public contract.- Each public code has Fluent keys for:
CODEmessage titleCODE.summaryCODE.causeCODE.step1CODE.fixCODE.example- The generated public catalog is intentionally broad enough for a large compiler error surface: syntax, lexer, parser, names/modules, type checking, generics, traits, ownership, lifetimes, constants, macros, HIR/MIR/IR, backend, linker, runtime, driver, bootstrap, and resource limits.
Public vs. Internal Codes
- Public codes are stable user-facing diagnostics that may appear in text, JSON, LSP, snapshots, and local catalogs.
- Internal codes are implementation/debugging details and should not be required in
locales/*/diagnostics.ftl. - Lexer input-hardening and source-shape failures such as
LEX_E_INVALID_UTF8,LEX_E_TOKEN_TOO_LARGE, and unterminated token codes are public because users can receive them directly from normal compiler commands. - ICE or maintainer-only failures such as
LEX_E_INTERNALremain internal unless they are intentionally promoted into the public diagnostics contract. - Reserved public diagnostics may appear in the Fluent catalog before every compiler path emits them. This keeps installers, completions, docs, LSP, and future compiler phases aligned before rollout.
Main commands
vitte check <file>vitte build <file> -o <out>vitte run <file>vitte parse <file>vitte explain <code>vitte check <file> --diagnostics-jsonvitte dump-ast <file>vitte dump-hir <file>vitte dump-mir <file>
Use tests/strict_ok.vit as the tracked smoke fixture when a page or diagnostic needs a small known-good source file.
Output formats
- Human text:
error[CODE] phase: message- labels, notes, helps, and suggestions are rendered below the primary header.
- JSON envelope:
schema = "vitte.compiler.surface"surface = "diagnostics"- top-level validity and pipeline summary fields
primary_report.diagnostics[]for the flattened reportphase_reports.<phase>for per-phase diagnostics
Contract suggestions
- Diagnostics carry a bounded suggestion list, ordered by applicability and confidence.
- The default public limit is 5 suggestions per diagnosis.
- Each suggestion has:
kind:insert,replace,remove, orhelpspan: the edit or explanation locationreplacement: concrete text for edit suggestions, empty for manual helpmachine_applicable: legacy boolean for safe automatic editsapplicability:machine,maybe_machine, ormanualconfidence:high,medium, orlowreason: why this suggestion is attached to the diagnosismachinesuggestions may be applied by tools without extra inference.maybe_machinesuggestions are useful as IDE quick fixes but should be reviewed.manualsuggestions are explanatory and should not be applied automatically.- Code-specific suggestions live behind
diagnostic_catalog_suggestions; phase defaults are only a fallback. - LSP integration exposes suggestions as code actions with the original diagnostic code, range, replacement text, and applicability.
Stable phases
lexerparserastast_validationmodule_resolutionsymbol_resolutionsemahirtypeckborrowcklifetimemirmir_loweringmir_verificationirbackendlinkerruntime_executiondriverinternal
Operational notes
pipeline_failed_atpoints to the first failing stage for the current request.- Input-hardening failures use explicit limit codes such as:
LIMIT_FILE_SIZE_MAXLIMIT_TOKEN_SIZE_MAXLIMIT_AST_DEPTH_MAXLIMIT_EXPR_DEPTH_MAXLIMIT_IMPORT_DEPTH_MAXLIMIT_MODULE_COUNT_MAXLIMIT_DIAGNOSTICS_MAXLIMIT_SYMBOL_COUNT_MAXLIMIT_PARSER_RECURSION_MAXLIMIT_MACRO_EXPANSION_MAXInvalidInputis reserved for hostile or malformed input; ICE/internal failures should remain compiler bugs only.