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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .sampo/changesets/cbor-negative-bignum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cargo/nash-plutus: patch
---

Encode and decode negative Data integers below `-(2^64 - 1)` as the Haskell node does: CBOR tag 3 holds `-1 - n`, and `-2^64` is a plain negative integer.
5 changes: 5 additions & 0 deletions .sampo/changesets/cli-disable-unused-bzip2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cargo/nash-cli: patch
---

Disable unused Bzip2 ZIP support to avoid building bzip2-sys. Retain all other existing ZIP features and XZ compiler-release extraction.
5 changes: 5 additions & 0 deletions .sampo/changesets/codegen-traversal-recursion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cargo/nash-codegen: patch
---

Restore the recursive lowering, constant-sharing rewrite, and recursion rewrite.
6 changes: 6 additions & 0 deletions .sampo/changesets/compiler-maintenance-final-cleanup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
cargo/nash-constrain: patch
cargo/nash-codegen: patch
---

Traverse diagnostic alias chains with a loop, and remove duplicate internal superclass handling while retaining public input validation.
8 changes: 8 additions & 0 deletions .sampo/changesets/compiler-stack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
cargo/nash-driver: minor
cargo/nash-parse: minor
cargo/nash-report: patch
cargo/nash-cli: patch
---

Run compiler work on threads with a 128 MiB stack (`nash_driver::stack`) and remove the parser nesting limit of 64 with its `Space::TooDeep` error. Input that is too deep now ends the process with a stack overflow.
5 changes: 5 additions & 0 deletions .sampo/changesets/core-traversal-recursion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cargo/nash-ir: patch
---

Restore the recursive Core traversals: `walk`, `map`, occurrence and free-variable analysis, discard checks, hygiene, ANF, beta splicing, and Core printing.
7 changes: 7 additions & 0 deletions .sampo/changesets/flat-term-recursion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
cargo/nash-plutus: patch
cargo/nash-test: minor
cargo/nash-cli: patch
---

Restore the recursive Flat term encoder and decoder. `nash_test::Config` gains `worker_stack`, and `nash test` runs its workers on the compiler stack.
8 changes: 8 additions & 0 deletions .sampo/changesets/remove-unused-compiler-helpers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
cargo/nash-driver: minor
cargo/nash-constrain: minor
cargo/nash-report: minor
cargo/nash-test: minor
---

Remove unused dependency bookkeeping, report and type helpers, and the unused FailureKind alias. Compilation, diagnostics, and supported editor behavior are unchanged.
5 changes: 5 additions & 0 deletions .sampo/changesets/uplc-support-recursion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cargo/nash-plutus: patch
---

Restore the recursive UPLC term printer, De Bruijn conversion, and target validation.
20 changes: 0 additions & 20 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ tower-lsp-server = { version = "0.23.0", default-features = false, features = [
] }
url = "2"
xz2 = "0.1"
zip = "2"
# Keep zip 2 defaults except unused Bzip2 support.
zip = { version = "2", default-features = false, features = ["aes-crypto", "deflate64", "deflate", "lzma", "time", "zstd", "xz"] }

# Optimize insta/similar in dev for faster diffs
[profile.dev.package]
Expand Down
2 changes: 1 addition & 1 deletion SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Implementation plans (Plans 08, 09 and 10 are complete):
- [x] 08 Optimizer: Single ANF normalization and optimization before recursion rewrite, inlining, builtin force caching, DCE, case-of-known-ctor/constant folding — [plans/08-optimizer.md](plans/08-optimizer.md) (Retained scope complete: recursive unused parameters, unbudgeted constant folding, joint lifting/cleanup fixed point, restricted pair cancellation, O0/O1 build/test/config integration, composition/convergence validation, adjacent application fusion, native value-call packing and late UPLC binding cleanup)
- [x] 09 Validators + `nash build` — [plans/09-validators-build.md](plans/09-validators-build.md)
- [x] 10 Testing: `tests` block, props, generators, shrinking, power-assert, `nash test` — [plans/10-testing.md](plans/10-testing.md)
- [ ] 11 Macros + comptime — [plans/11-macros-comptime.md](plans/11-macros-comptime.md); includes explicit integer-dispatch AST and positional library macro (chunk 13), reusable call/binding/case-shaped macro inputs required in chunk 14 (library semantics deferred)
- [ ] 11 Macros + comptime — [plans/11-macros-comptime.md](plans/11-macros-comptime.md); includes explicit integer-dispatch AST and positional library macro (chunk 13), reusable call/binding/case-shaped macro inputs required in chunk 14 (library semantics deferred); staged expression/binding foundation and property/assertion migration (chunk 15; public contracts pending)
- [ ] 12 Stdlib `nash/base` — [plans/12-stdlib.md](plans/12-stdlib.md) (chunks 1–9 and 11–13 complete; chunk 10 Ast/Derive deferred)
- [x] 13 `nash format` (`fmt`), `nash docs` — [plans/13-fmt-docs.md](plans/13-fmt-docs.md) (chunks 1–7 complete)
- [x] Representation-classed impl heads: `Big`/`Little` blankets and concrete little impls coexist — [plans/repr-classed-impl-heads.md](plans/repr-classed-impl-heads.md)
Expand Down
92 changes: 47 additions & 45 deletions crates/nash-cli/src/cmd/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,56 +39,58 @@ impl Args {
let success = docs.compiler.is_success();
// Render diagnostics off the executor just like documentation pages.
let (files, diagnostics) = spawn_blocking(move || {
let mut diagnostics = String::new();
for module in docs.compiler.ordered_reports() {
let source = nash_report::Source::new(&module.source);
for report in &module.reports {
nash_driver::stack::run(move || {
let mut diagnostics = String::new();
for module in docs.compiler.ordered_reports() {
let source = nash_report::Source::new(&module.source);
for report in &module.reports {
diagnostics.push_str(&format!(
"{:?}\n",
miette::Report::new(report.render(&source, &module.path, color))
));
}
}
for (uri, state) in &docs.compiler.modules {
if let nash_driver::ModuleResult::SourceUnavailable { message } = state {
diagnostics.push_str(&format!("Could not read {uri}: {message}\n"));
}
}
for warning in &docs.warnings {
let mut report = nash_report::Report::snippet(
"DOCUMENTATION WARNING",
nash_region::Region::zero(),
None,
nash_report::Doc::text(format!(
"{}.{}: {}",
warning.module, warning.name, warning.message
)),
nash_report::Doc::Empty,
)
.warning();
report.primary_label = None;
report.context = None;
diagnostics.push_str(&format!(
"{:?}\n",
miette::Report::new(report.render(&source, &module.path, color))
miette::Report::new(report.render(
&nash_report::Source::new(""),
&warning.module,
color
))
));
}
}
for (uri, state) in &docs.compiler.modules {
if let nash_driver::ModuleResult::SourceUnavailable { message } = state {
diagnostics.push_str(&format!("Could not read {uri}: {message}\n"));
}
}
for warning in &docs.warnings {
let mut report = nash_report::Report::snippet(
"DOCUMENTATION WARNING",
nash_region::Region::zero(),
None,
nash_report::Doc::text(format!(
"{}.{}: {}",
warning.module, warning.name, warning.message
)),
nash_report::Doc::Empty,
let format = match self.format {
Format::Html => nash_docs::Format::Html,
Format::Markdown => nash_docs::Format::Markdown,
};
(
if success {
nash_docs::render(&docs.modules, format)
} else {
Default::default()
},
diagnostics,
)
.warning();
report.primary_label = None;
report.context = None;
diagnostics.push_str(&format!(
"{:?}\n",
miette::Report::new(report.render(
&nash_report::Source::new(""),
&warning.module,
color
))
));
}
let format = match self.format {
Format::Html => nash_docs::Format::Html,
Format::Markdown => nash_docs::Format::Markdown,
};
(
if success {
nash_docs::render(&docs.modules, format)
} else {
Default::default()
},
diagnostics,
)
})
})
.await
.into_diagnostic()?;
Expand Down
34 changes: 19 additions & 15 deletions crates/nash-cli/src/cmd/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ impl Args {
.read_to_string(&mut source)
.await
.into_diagnostic()?;
let formatted = spawn_blocking(move || format_source(&source, "<stdin>", color))
.await
.into_diagnostic()??;
let formatted = spawn_blocking(move || {
nash_driver::stack::run(move || format_source(&source, "<stdin>", color))
})
.await
.into_diagnostic()??;
let mut stdout = tokio::io::stdout();
stdout
.write_all(formatted.as_bytes())
Expand Down Expand Up @@ -76,19 +78,21 @@ fn format_source(source: &str, name: &str, color: bool) -> Result<String> {
async fn format_file(path: PathBuf, name: String, check: bool, color: bool) -> Result<()> {
let source = tokio::fs::read_to_string(&path).await.into_diagnostic()?;
let formatted = spawn_blocking(move || {
let formatted = format_source(&source, &name, color)?;
if check {
if let Some(report) = nash_report::format::difference(&name, &source, &formatted) {
return Err(miette::Report::new(report.render(
&nash_report::Source::new(&source),
&name,
color,
)));
nash_driver::stack::run(move || {
let formatted = format_source(&source, &name, color)?;
if check {
if let Some(report) = nash_report::format::difference(&name, &source, &formatted) {
return Err(miette::Report::new(report.render(
&nash_report::Source::new(&source),
&name,
color,
)));
}
Ok(None)
} else {
Ok((source != formatted).then_some(formatted))
}
Ok(None)
} else {
Ok((source != formatted).then_some(formatted))
}
})
})
.await
.into_diagnostic()??;
Expand Down
1 change: 1 addition & 0 deletions crates/nash-cli/src/cmd/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl Args {
seed,
max_success: self.max_success,
jobs: self.jobs,
worker_stack: nash_driver::stack::COMPILER_STACK,
};
let outcomes = spawn_blocking(move || nash_test::run_all(programs, &config))
.await
Expand Down
23 changes: 13 additions & 10 deletions crates/nash-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ fn main() -> miette::Result<()> {
// process is single-threaded — so it runs before the runtime starts.
let proxied = nash_cli::proxy::proxy_guard()?;

tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.into_diagnostic()?
.block_on(async {
if !proxied {
nash_cli::proxy::maybe_proxy().await?;
}
// Commands render and drop compiler results on this thread.
nash_driver::stack::run(|| {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.into_diagnostic()?
.block_on(async {
if !proxied {
nash_cli::proxy::maybe_proxy().await?;
}

nash_cli::Cli::default().exec().await
})
nash_cli::Cli::default().exec().await
})
})
}
2 changes: 1 addition & 1 deletion crates/nash-codegen/src/can_to_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl<'a> Engine<'a, '_, '_> {
Binding::Template { id, projection } => {
let binder = self.use_template(id, node, ctx)?;
if let Some(name) = projection {
self.destruct_projection(id, name, binder, node, ctx)?
self.destruct_projection(id, name, binder)?
} else {
self.ir.var(binder.name, binder.ty)
}
Expand Down
2 changes: 0 additions & 2 deletions crates/nash-codegen/src/can_to_core/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ impl<'a> Engine<'a, '_, '_> {
id: usize,
name: &'a str,
binder: Binder<'a>,
_node: NodeId,
_ctx: &Context<'a>,
) -> Result<&'a Core<'a>, Error<'a>> {
let Source::Destruct { pattern, .. } = self.templates[id].source else {
return Err(Error::InvalidConstructor);
Expand Down
19 changes: 4 additions & 15 deletions crates/nash-codegen/src/evidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,19 +375,6 @@ impl<'a> Grounder<'a, '_> {
depth: usize,
) -> Result<Pred<'a>, Error<'a>> {
let (trait_, args) = match evidence {
Evidence::Repr { trait_, typ } => {
let super_ = trait_
.supers()
.get(usize::from(index))
.ok_or(Error::SuperIndex {
trait_: trait_.qualified(),
index,
})?;
return Ok(Pred::Implied {
trait_: super_.qualified(),
args: self.arena.alloc_slice_copy(&[*typ]),
});
}
Evidence::StructuralEq { typ } => (primitives::eq_trait(), vec![*typ]),
Evidence::ReflexiveLift { typ } => (primitives::lift_trait(), vec![*typ, *typ]),
Evidence::Impl {
Expand All @@ -401,8 +388,10 @@ impl<'a> Grounder<'a, '_> {
.collect::<Result<Vec<_>, _>>()?;
(impl_.key.trait_, args)
}
Evidence::Given { .. } | Evidence::Super { .. } => {
return Err(Error::UnresolvedEvidence);
// `one` has resolved givens/projections and handled representation
// superclasses directly before calling this private helper.
Evidence::Repr { .. } | Evidence::Given { .. } | Evidence::Super { .. } => {
unreachable!("superclass predicate requires resolved non-representation evidence")
}
};
let info = self
Expand Down
Loading
Loading