diagnostic: allocate stable error-code namespace ranges#405
Merged
Conversation
Document and enforce the ILO-<letter><digits> namespace layout in src/diagnostic/registry.rs. Each compiler phase has a reserved hundreds-block (L lexer, P parser, N names, I imports, T types, V verifier, R runtime, D deprecation, E engine-specific, S skill / spec) with generous spacing so future codes slot in without a renumber. Reserved namespaces (N, I, V, D, E, S) carry no codes today but are forward-declared. Historical codes (L001-L003, P001-P021, T001-T036, R001-R026, W001) stay valid forever - both the historical block and the canonical hundreds-block are in NAMESPACE_RANGES so existing identifiers keep working. New codes from now on go in the documented hundreds-block of their namespace. Backfill registry entries for codes that were emitted but missing from the explainer table: P019 (use-import name not found), T030 (circular type alias), T031 (alias shadows builtin), T036 (call register overflow), R014 (auto-unwrap propagation), R099 (internal runtime error). Without these, 'ilo --explain' on those codes returned 'unknown error code' even though the diagnostic was live in the codebase. Add parse_code and in_documented_range helpers plus three unit tests: parse_code_roundtrip, registry_codes_in_documented_ranges (every REGISTRY entry lives in a documented range), and reserved_namespaces_have_room (each forward-looking namespace has at least 100 codes reserved).
Cross-engine regression test. Runs a battery of snippets known to provoke diagnostics (one per active namespace plus a runtime example) under every available engine selector (default / --run-tree / --run-vm / --jit when cranelift is enabled), scrapes every ILO-XYZNN code from stderr, and asserts each one is in a NAMESPACE_RANGES entry. The second test asserts 'ilo explain CODE' succeeds for every REGISTRY entry. If a code emits and 'explain' can't find it, the agent loop breaks - this catches the case the previous commit fixed (R014, T030, T036, ... were emitted without registry entries) the next time it would regress.
Rewrite the 'Error codes' subsection of SPEC.md's Error Diagnostics chapter to spell out the full namespace table (active and reserved), the historical-codes-stay-valid contract, and the deprecation-warning policy for ILO-D7xx. ai.txt and skills/ilo/SKILL.md auto-regenerate from SPEC.md via build.rs.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adoption brief #2. Allocates stable
ILO-<letter><digits>namespace ranges by compiler phase so agents and tools can route on prefix and the namespace stays forward-compatible. Matches Zero's documented ranges (PAR100, NAM003, TYP010-26, IMP001-3, ...) - same discipline, ilo's letter scheme.ILO-L000-099ILO-P100-199ILO-N200-299ILO-I300-399ILO-T400-499ILO-V500-599ILO-R600-699ILO-D700-799ILO-E800-899ILO-S900-999No existing code changes identifier. The historical block (L001-L003, P001-P021, T001-T036, R001-R026, W001) and the canonical hundreds-block are both in
NAMESPACE_RANGES, so the existing prefixes keep working forever. New codes from now on land in the documented hundreds-block of their namespace, enforced by a cross-engine regression test.ILO-D700-799is reserved for deprecation warnings: when a feature is scheduled for removal it emits a compile-time warning without failing the build. The firstILO-D###ships with the first deprecation.What's in the diff
NAMESPACE_RANGES,parse_code,in_documented_range, and three unit tests (registry-in-range, parse roundtrip, reserved-room). Also backfills registry entries for codes that were emitted in the source but missing from the explainer table (P019, T030, T031, T036, R014, R099) -ilo --explainnow resolves every emitted code.ilo explain CODEsucceeds for every REGISTRY entry.Test plan
cargo test --release --features cranelift- all suites pass, including the two new testscargo fmt --checkcleancargo clippy --release --features cranelift --all-targets -- -D warningscleancargo build --releaseregenerates ai.txt + SKILL.md from SPEC.md cleanly (no drift)ilo --explain ILO-T030,ilo --explain ILO-R014,ilo --explain ILO-R099all resolve (previously surfaced as unknown error code)NAMESPACE_RANGES- asserted byregistry_codes_in_documented_rangesand the cross-engine regression testFollow-ups
ILO-D700and document the warning policy in SPEC.