Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .sampo/changesets/report-foundation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
cargo/nash-report: minor
cargo/nash-parse: patch
---

Add compiler report documents, source spans, terminal rendering and name suggestions. Expose parser token classifiers and preserve nested parse errors for diagnostics.
10 changes: 10 additions & 0 deletions .sampo/changesets/report-wiring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
cargo/nash-can: patch
cargo/nash-constrain: patch
cargo/nash-solve: patch
cargo/nash-driver: minor
cargo/nash-cli: minor
cargo/nash-language-server: minor
---

Collect independent compiler errors with dependency-aware recovery, retain failed module dependencies, and render owned diagnostics in the terminal, JSON, and language server. Preserve trait-method call names in error context. Add JSON and warning controls to `nash check`, and publish diagnostics for unsaved editor buffers with UTF-16 ranges.
32 changes: 32 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ octocrab = { version = "0.49.5", features = ["stream"] }
pretty_assertions = "1.4.0"
pubgrub = { version = "0.3", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tar = "0.4"
thiserror = "2"
tokio = { version = "1", features = ["fs", "macros", "rt-multi-thread", "sync"] }
Expand Down
8 changes: 4 additions & 4 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ produce UPLC programs; all dependencies inline into each program.
| `nash-constrain` | constraint generation, kinds | extend |
| `nash-solve` | solver, traits, defaulting | extend |
| `nash-nitpick` | exhaustiveness and redundancy | done ([plans/05](plans/05-nitpick.md)) |
| `nash-report` | diagnostics (Elm prose -> miette) | new ([plans/06](plans/06-diagnostics.md)) |
| `nash-report` | diagnostics (Elm prose -> miette) | done ([plans/06](plans/06-diagnostics.md)) |
| `nash-ir` | Core IR + passes | new ([plans/07](plans/07-codegen.md), [08](plans/08-optimizer.md)) |
| `nash-codegen` | Can -> Core -> UPLC | new ([plans/07](plans/07-codegen.md)) |
| `nash-test` | test runner, fuzzing, shrinking | new ([plans/10](plans/10-testing.md)) |
Expand All @@ -37,7 +37,7 @@ produce UPLC programs; all dependencies inline into each program.
| `nash-config` | `nash.jsonc` | done, extend |
| `nash-driver` | build graph, caching | done, extend |
| `nash-cli` | `nash` binary | `check`, `lsp`; add `build test fmt docs` |
| `nash-language-server` | LSP | stub |
| `nash-language-server` | LSP | live compiler diagnostics with UTF-16 ranges |
| `core/` | `nash/core` stdlib package (Nash source) | new ([plans/12](plans/12-stdlib.md)) |

## Progress
Expand All @@ -60,7 +60,7 @@ Planned, in execution order (each links to its plan):
- [x] 03 Traits: qualified types, resolution, superclasses, defaults, multi-param, orphan rules, literal traits + defaulting, evidence — [plans/03-traits.md](plans/03-traits.md) (default imports deferred to Plan 12)
- [x] 04 Representation: remove row polymorphism and Elm supertypes, builtin type inventory, record encoding — [plans/04-representation.md](plans/04-representation.md)
- [x] 05 Exhaustiveness (`Nitpick/PatternMatches` port) — [plans/05-nitpick.md](plans/05-nitpick.md)
- [ ] 06 Diagnostics (`nash-report`, Elm `Reporting/*` port onto miette) — [plans/06-diagnostics.md](plans/06-diagnostics.md)
- [x] 06 Diagnostics (`nash-report`, Elm `Reporting/*` port onto miette) — [plans/06-diagnostics.md](plans/06-diagnostics.md)
- [ ] 07 Codegen: Core IR, monomorphization, decision trees, recursion, Data casts, UPLC lowering — [plans/07-codegen.md](plans/07-codegen.md)
- [ ] 08 Optimizer: inlining, builtin force caching, DCE, case-of-known-ctor/constant folding — [plans/08-optimizer.md](plans/08-optimizer.md)
- [ ] 09 Validators + `nash build` — [plans/09-validators-build.md](plans/09-validators-build.md)
Expand All @@ -83,7 +83,7 @@ Later: LSP features, web playground, package registry (pubgrub), TypeScript code
| `Type/Type.hs`, `Type/Constrain/*` | `crates/nash-constrain/src/*` |
| `Type/{Solve,Unify,Occurs}.hs` | `crates/nash-solve/src/*` |
| `Nitpick/PatternMatches.hs` | `crates/nash-nitpick` |
| `Reporting/{Doc,Report,Render,Suggest}.hs`, `Reporting/Error/*` | `crates/nash-report` (planned) |
| `Reporting/{Doc,Report,Render,Suggest}.hs`, `Reporting/Error/*` | `crates/nash-report` |
| `builder/src/Elm/Outline.hs` | `crates/nash-config` |
| `builder/src/Build.hs` | `crates/nash-driver` |

Expand Down
2 changes: 1 addition & 1 deletion crates/nash-can/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub mod warning;

pub use crate::entailment::Failure as EntailmentFailure;
pub use crate::error::{
BadArityContext, DuplicatePatternContext, Error, KindContext, PossibleNames, VarKind,
BadArityContext, BadHead, DuplicatePatternContext, Error, KindContext, PossibleNames, VarKind,
};
pub use crate::interface::{
AliasVisibility, Annotations, Interface, InterfaceAlias, InterfaceBinop, InterfaceMethod,
Expand Down
5 changes: 5 additions & 0 deletions crates/nash-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ color-print.workspace = true
dirs.workspace = true
futures.workspace = true
miette.workspace = true
serde_json.workspace = true
nash-config = { path = "../nash-config", version = "0.3.0" }
nash-report = { path = "../nash-report", version = "0.1.0" }
nash-driver = { path = "../nash-driver", version = "0.4.0" }
nash-language-server = { path = "../nash-language-server", version = "0.2.0" }
octocrab.workspace = true
Expand All @@ -31,3 +33,6 @@ tokio-util = { version = "0.7.18", features = ["compat"] }
tower-lsp-server.workspace = true
xz2.workspace = true
zip.workspace = true

[dev-dependencies]
insta.workspace = true
21 changes: 20 additions & 1 deletion crates/nash-cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
use clap::Parser;
use std::io::IsTerminal;

use crate::cmd;

#[derive(Parser)]
#[command(name = "nash", version, about = "The Nash programming language compiler", long_about = Some(crate::BANNER))]
#[command(propagate_version = true)]
pub struct Cli {
/// Control diagnostic colors. NO_COLOR disables automatic colors.
#[arg(long, global = true, value_enum, default_value = "auto")]
pub color: Color,
#[command(subcommand)]
pub cmd: cmd::Cmd,
}

#[derive(Clone, Copy, clap::ValueEnum)]
pub enum Color {
Auto,
Always,
Never,
}

impl Default for Cli {
fn default() -> Self {
Self::parse()
Expand All @@ -18,6 +29,14 @@ impl Default for Cli {

impl Cli {
pub async fn exec(self) -> miette::Result<()> {
self.cmd.exec().await
let color = match self.color {
Color::Always => true,
Color::Never => false,
Color::Auto => {
std::io::stderr().is_terminal() && std::env::var_os("NO_COLOR").is_none()
}
};
miette::set_hook(Box::new(move |_| Box::new(nash_report::handler(color))))?;
self.cmd.exec(color).await
}
}
Loading
Loading