feat: plan 06 diagnostics - #18
Merged
Merged
Conversation
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
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
Implements plan 06 (plans/06-diagnostics.md): the new
nash-reportcrate ports Elm'sReporting/*(Doc,Report,Render,Suggest,Error/*) onto miette, and the driver, CLI and language server render owned diagnostics from it. Twelve commits: three compiler fixes that diagnostics depend on, sixnash-reportsteps, then driver/CLI/LSP wiring and final acceptance.Versioning: two changesets.
report-foundation.mdbumpsnash-reportminor andnash-parsepatch.report-wiring.mdbumpsnash-driver,nash-cli,nash-language-serverminor andnash-can,nash-constrain,nash-solvepatch. Internal path dependency versions match their crates; the publication graph including dev dependencies is acyclic.Compiler fixes
fix(parse): preserve nested diagnostic context— nested parser errors keep their inner variant instead of collapsing to the outer one.keyword::is_reservedandsymbol::is_binop_charare public for the report crate.fix(types): retain diagnostic context— trait-method call names survive into error context.fix(solve): recover independent errors— newnash-solve/src/recovery.rs. The solver no longer stops at the first error. Unrelated definitions and unrelated tuple/record children still check; a failure in one child keeps the known shape so siblings compare against their annotations. Changes to shared inference variables still invalidate every dependent computation. Kind and representation failures survive unrelated type errors. A failed solve returns errors and no solved output. Covered bynash-solve/tests/inference.rsandrepresentation_predicates.rs.nash-reportfeat(report): add documents and renderers—Docwith Elm's nestedfillSepsemantics, styled chunks and Unicode widths; ownedReportwith byte-safe source spans;Report::with_regionwidens source context while keeping the primary problem region; miette handler for terminal output;Suggestwith deterministic distance ordering.feat(report): render type names and differences—Localizer(actual source imports plus the compiler primitive inventory, qualification preserved when a primitive is shadowed),render_type, andtype_difffor focused differences.feat(report): explain syntax errors— module header, imports, exposing, whitespace, end of input, declarations, expressions, patterns and types. Covers all 369 parser variants.feat(report): explain canonicalization errors— including paired declaration locations.feat(report): explain type and trait errors— mismatches with expected/actual types and expression context, operators, records, missing impls (advises an explicit impl; states that@deriveis Plan 11), ambiguity, kind and representation errors. Pattern errors and warnings from nitpick.json.rs) with complete snippets. Byte regions convert to display-cell carets, including Unicode and tabs.Wiring (
feat(report): collect phase errors and warnings,feat(cli): …,feat(lsp): …)nash-driver/src/diagnostics.rs(string formatting) is deleted.compile.rscollects phase errors and warnings into owned reports. Independent modules continue after a failure; a failed dependency blocks its transitive users and exports no interface; unreadable files preserve independent diagnostics; shuffled discovery produces a stable compilation order. Warnings on a failed module sort together with its errors.nash checkgains--report human|jsonand--no-warnings. Global--color auto|always|never;autohonoursNO_COLORand a non-terminal stderr. Exit codes checked.nash-cli/tests/diagnostics.rsruns the three examples fromdocs/diagnostics.mdagainst the real core package and checks terminal, JSON and LSP agree on the problem set and source ranges.nash-language-server/src/workspace.rsanddiagnostics.rspublish live compiler diagnostics for unsaved buffers with UTF-16 ranges, paired related locations, version checks, close/repair clearing and nested workspace ownership.docs/diagnostics.mddescribes recovery rules, localizer scope and the checked examples. SPEC.md ticks plan 06.Deferred
@derive: Plan 11. Missing-impl reports mention it as unavailable.Test plan
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningscargo insta test --workspace --check --unreferenced reject— 2,950 passed, 0 failed, 3 ignored; no pending or unreferenced snapshotscargo run -p nash-cli -- check tests/core— 23 modules, 215 declarationsnash-solve/tests/inference.rs: mixed mismatches, missing impls, ambiguity and kind errors in both declaration orders; repeated and recursive uses; shared partial unification; independent tuple siblings; nested aggregates; generic record selection with failures in other fieldsnash-driver/src/compile/collection_tests.rsand graph tests: independent-module continuation, blocked dependents, unreadable files, no interfaces from failed modules, stable order under shuffled discoverynash-cli/tests/diagnostics.rs: identical ordering across repeated runs; terminal/JSON/LSP parity; color, warning controls and exit codes; docs examples against the shippingcore/https://claude.ai/code/session_01ScuAeUCfNGXAznfEEKDH1X