diff --git a/.sampo/changesets/constant-fold-fixed-point.md b/.sampo/changesets/constant-fold-fixed-point.md new file mode 100644 index 00000000..028023c4 --- /dev/null +++ b/.sampo/changesets/constant-fold-fixed-point.md @@ -0,0 +1,6 @@ +--- +cargo/nash-codegen: patch +cargo/nash-plutus: patch +--- + +Run constant folding, unused-parameter removal and cleanup until unchanged without optimizer resource or output-growth limits. Evaluate all pure representable builtin calls directly and return errors instead of panicking for out-of-range constant indices and constructor tags. Correct whole-byte left shifts and handle arbitrary-size shift, rotate and list-drop inputs. diff --git a/.sampo/changesets/o1-application-cleanup.md b/.sampo/changesets/o1-application-cleanup.md new file mode 100644 index 00000000..dab26ebf --- /dev/null +++ b/.sampo/changesets/o1-application-cleanup.md @@ -0,0 +1,8 @@ +--- +cargo/nash-ir: patch +cargo/nash-codegen: patch +--- + +Fuse adjacent application stages in O1, clean up generated UPLC bindings, and +pack value application spines with native Case/Constr while preserving traces, +failure and termination. diff --git a/.sampo/changesets/o1-constant-folding.md b/.sampo/changesets/o1-constant-folding.md new file mode 100644 index 00000000..515b183c --- /dev/null +++ b/.sampo/changesets/o1-constant-folding.md @@ -0,0 +1,6 @@ +--- +cargo/nash-ir: patch +cargo/nash-codegen: patch +--- + +Enable bounded constant builtin evaluation in O1. Fold saturated literal calls through ANF bindings and repeat cleanup, preserving traces and runtime failures. Keep O0 and explicit comptime policies unchanged. diff --git a/.sampo/changesets/optimizer-static-fixed-point.md b/.sampo/changesets/optimizer-static-fixed-point.md new file mode 100644 index 00000000..1fa89a32 --- /dev/null +++ b/.sampo/changesets/optimizer-static-fixed-point.md @@ -0,0 +1,6 @@ +--- +cargo/nash-codegen: patch +cargo/nash-ir: patch +--- + +Revisit static recursive parameter lifting after cleanup and recursive pruning so O1 reaches the same closed program in one invocation. Preserve atomic operands when lifting all-static oversaturated recursive calls and check optimizer idempotence across executable fixtures. diff --git a/.sampo/changesets/pair-access-and-cancellation.md b/.sampo/changesets/pair-access-and-cancellation.md new file mode 100644 index 00000000..62fc987f --- /dev/null +++ b/.sampo/changesets/pair-access-and-cancellation.md @@ -0,0 +1,8 @@ +--- +cargo/nash-solve: minor +cargo/nash-codegen: minor +cargo/nash-ir: patch +cargo/nash-report: patch +--- + +Support read-only `.fst` and `.snd` field access and accessor functions for known builtin pair types, including aliases. Lower access directly to the pair builtins. Enable the restricted O1 pair-case rewrite only when constructor inverse cleanup removes the introduced projection, preserving strict producer evaluation. diff --git a/.sampo/changesets/plutus-v3-only.md b/.sampo/changesets/plutus-v3-only.md new file mode 100644 index 00000000..555dc53a --- /dev/null +++ b/.sampo/changesets/plutus-v3-only.md @@ -0,0 +1,9 @@ +--- +cargo/nash-config: minor +cargo/nash-codegen: minor +cargo/nash-test: minor +cargo/nash-driver: minor +cargo/nash-cli: minor +--- + +Remove the Plutus V1 and V2 targets. Nash compiles validators against the V3 script context only, so a V1 or V2 language tag produced an invalid validator. The `plutusVersion` project setting, the `--plutus-version` option, `nash_config::PlutusVersion`, `assemble_core_for_version`, `TestProgram::plutus_version` and the version parameters of `assemble_core_with_options` and `compile_tests*` are gone. Script hashes always use the V3 language tag. diff --git a/.sampo/changesets/post-anf-folding.md b/.sampo/changesets/post-anf-folding.md new file mode 100644 index 00000000..fd2c3dc9 --- /dev/null +++ b/.sampo/changesets/post-anf-folding.md @@ -0,0 +1,5 @@ +--- +cargo/nash-codegen: patch +--- + +Run constructor folding and representation cancellation only in the post-ANF cleanup loops, following generated bindings and opportunities exposed by inlining. Remove the early direct-expression passes. diff --git a/.sampo/changesets/recursive-unused-parameters.md b/.sampo/changesets/recursive-unused-parameters.md new file mode 100644 index 00000000..9d8efd71 --- /dev/null +++ b/.sampo/changesets/recursive-unused-parameters.md @@ -0,0 +1,6 @@ +--- +cargo/nash-ir: patch +cargo/nash-codegen: patch +--- + +Remove unused self-recursive and mutual parameters in O1 while preserving strict argument order, forwarding dependencies, type views, and delayed worker execution. diff --git a/.sampo/changesets/silent-o2.md b/.sampo/changesets/silent-o2.md new file mode 100644 index 00000000..28bf90a4 --- /dev/null +++ b/.sampo/changesets/silent-o2.md @@ -0,0 +1,8 @@ +--- +cargo/nash-config: minor +cargo/nash-codegen: minor +cargo/nash-driver: minor +cargo/nash-cli: minor +--- + +Add explicit O2 compilation for build and test. O2 requires silent settings, removes user and compiler traces, and discards trace message computations even when they fail or diverge before applying the O1 optimizer. Reject compact, verbose and compiler tracing with O2. Keep O1 as the default. diff --git a/SPEC.md b/SPEC.md index 1eab386a..80e37e5e 100644 --- a/SPEC.md +++ b/SPEC.md @@ -52,7 +52,7 @@ Done: - [x] `nash check` - [x] UPLC runtime (`nash-plutus`): conformance suite passes -Implementation plans (Plan 08 is in progress; Plans 09 and 10 are complete): +Implementation plans (Plans 08, 09 and 10 are complete): - [x] 01 Syntax: `'a` type vars, little/Big names, `trait`/`impl`, `=>` contexts, representation annotations, `validator module`, `tests` block, `do`, attributes, `name!()`, `comptime`, `assert`/`fail`/`todo`/`trace`; drop `Float`/`Char`/record extension types — [plans/01-syntax.md](plans/01-syntax.md) - [x] 02 Kinds: original declaration checking and representation rules (engine replaced by the follow-up) — [plans/02-kinds.md](plans/02-kinds.md) @@ -63,7 +63,7 @@ Implementation plans (Plan 08 is in progress; Plans 09 and 10 are complete): - [x] 05 Exhaustiveness (`Nitpick/PatternMatches` port) — [plans/05-nitpick.md](plans/05-nitpick.md) - [x] 06 Diagnostics (`nash-report`, concise source labels, stable codes, JSON/LSP) — [plans/06-diagnostics.md](plans/06-diagnostics.md); [concise diagnostics refactor](plans/diagnostics-refactor.md) complete - [x] 07 Codegen: Core IR, monomorphization, decision trees, recursion, Data casts, UPLC lowering — [plans/07-codegen.md](plans/07-codegen.md) -- [ ] 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 of Chunks 1–8 accepted; representation cancellation and O0/O1 build/test/config integration available; recursive unused-parameter removal, Chunks 9–10 and final composition review open) +- [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) @@ -73,6 +73,8 @@ Implementation plans (Plan 08 is in progress; Plans 09 and 10 are complete): - [ ] 14 Explicit Big constructor tags: preserve declared Data tags; little tags remain consecutive from zero — [plans/14-explicit-big-constructor-tags.md](plans/14-explicit-big-constructor-tags.md) +- [ ] 15 Silent O2 and application regrouping: silent O2 implemented, including removal of failing/diverging trace messages; broader grouping/motion pending; trace-preserving candidates remain O1 — [plans/15-o2-optimizer.md](plans/15-o2-optimizer.md) (partial) + Later: LSP features, web playground, package registry (pubgrub), TypeScript codegen. ## Elm file mappings diff --git a/crates/nash-cli/src/cli.rs b/crates/nash-cli/src/cli.rs index d8433159..eb553c9d 100644 --- a/crates/nash-cli/src/cli.rs +++ b/crates/nash-cli/src/cli.rs @@ -49,7 +49,7 @@ mod tests { #[test] fn optimization_flags() { for command in ["build", "test"] { - for flag in ["-O0", "-O1"] { + for flag in ["-O0", "-O1", "-O2"] { let cli = Cli::try_parse_from(["nash", command, flag]).unwrap(); let level = match cli.cmd { crate::cmd::Cmd::Build(args) => args.optimize, @@ -59,10 +59,89 @@ mod tests { assert_eq!(u8::from(level.unwrap()), flag.as_bytes()[2] - b'0'); } assert!(Cli::try_parse_from(["nash", command, "--optimize", "1"]).is_ok()); - assert!(Cli::try_parse_from(["nash", command, "-O2"]).is_err()); + assert!(Cli::try_parse_from(["nash", command, "-O3"]).is_err()); } } + #[test] + fn o2_settings_merge_before_test_defaults() { + let mut rendered = Vec::new(); + for command in ["build", "test"] { + for args in [ + vec!["-O2"], + vec!["-O2", "--trace-level", "silent"], + vec!["-O2", "--trace-level", "compact"], + vec!["-O2", "--trace-level", "verbose"], + vec!["-O1"], + ] { + for (setting, trace_level, compiler_traces) in [ + ("default", nash_config::TraceLevel::Silent, false), + ("verbose project", nash_config::TraceLevel::Verbose, false), + ("compiler traces", nash_config::TraceLevel::Silent, true), + ] { + let cli = Cli::try_parse_from( + ["nash", command].into_iter().chain(args.iter().copied()), + ) + .unwrap(); + let build = nash_config::Build { + trace_level, + compiler_traces, + trace_level_explicit: setting != "default", + ..Default::default() + }; + let resolved = match cli.cmd { + crate::cmd::Cmd::Build(args) => args.resolve_config(build), + crate::cmd::Cmd::Test(args) => args + .resolve_config(build) + .map(nash_config::Build::for_tests), + _ => unreachable!(), + }; + rendered.push(format!( + "{command} {} ({setting}): {}", + args.join(" "), + match resolved { + Ok(config) => format!( + "O{} {:?}, compiler traces: {}", + u8::from(config.optimize), + config.trace_level, + config.compiler_traces + ), + Err(error) => error.to_string(), + } + )); + } + } + } + insta::with_settings!({omit_expression => true}, { insta::assert_snapshot!(rendered.join("\n")); }); + } + + #[test] + fn o2_compiler_trace_cli_overrides() { + let mut rows = Vec::new(); + for flag in ["--compiler-traces", "--compiler-traces=false"] { + let cli = Cli::try_parse_from(["nash", "build", "-O2", flag]).unwrap(); + let crate::cmd::Cmd::Build(args) = cli.cmd else { + unreachable!() + }; + let result = args.resolve_config(nash_config::Build { + compiler_traces: true, + ..Default::default() + }); + rows.push(format!( + "{flag}: {}", + match result { + Ok(config) => format!( + "O{}; compiler traces: {}", + u8::from(config.optimize), + config.compiler_traces + ), + Err(error) => error.to_string(), + } + )); + } + insta::with_settings!({omit_expression => true}, { insta::assert_snapshot!(rows.join("\n")); }); + } + #[test] fn command_schema_is_consistent() { Cli::command().debug_assert(); diff --git a/crates/nash-cli/src/cmd/build.rs b/crates/nash-cli/src/cmd/build.rs index 673a0e5b..66524ed1 100644 --- a/crates/nash-cli/src/cmd/build.rs +++ b/crates/nash-cli/src/cmd/build.rs @@ -5,7 +5,7 @@ use tokio::sync::Mutex; #[derive(clap::Args)] pub struct Args { - /// Optimization level: 0 (baseline) or 1 (preserves enabled traces). + /// Optimization level: 0 (baseline), 1 (preserves traces), or 2 (silent). #[arg(short = 'O', long)] pub optimize: Option, /// Path to the project. @@ -17,9 +17,6 @@ pub struct Args { /// Include user traces in the script. #[arg(long, value_enum)] pub trace_level: Option, - /// Ledger language target (protocol 11 compatibility). - #[arg(long, value_enum)] - pub plutus_version: Option, /// Include compiler traces for failed casts and pattern checks. #[arg(long, num_args = 0..=1, require_equals = true, default_missing_value = "true")] pub compiler_traces: Option, @@ -32,16 +29,38 @@ pub enum TraceLevelArg { Verbose, } -#[derive(Clone, Copy, clap::ValueEnum)] -pub enum PlutusVersionArg { - V1, - V2, - V3, -} - impl Args { + pub(crate) fn resolve_config( + &self, + mut config: nash_config::Build, + ) -> std::result::Result { + if let Some(level) = self.optimize { + config.optimize = level; + } + if let Some(level) = self.trace_level { + config.trace_level_explicit = true; + config.trace_level = match level { + TraceLevelArg::Silent => nash_config::TraceLevel::Silent, + TraceLevelArg::Compact => nash_config::TraceLevel::Compact, + TraceLevelArg::Verbose => nash_config::TraceLevel::Verbose, + }; + } + if let Some(enabled) = self.compiler_traces { + config.compiler_traces = enabled; + } + config.validate()?; + Ok(config) + } + pub async fn exec(self, color: bool) -> Result<()> { let project = Project::load(&self.path).await.into_diagnostic()?; + // Reject conflicts even when a project/member contains no source roots. + self.resolve_config(project.config.build()) + .into_diagnostic()?; + for member in &project.members { + self.resolve_config(member.config.build()) + .into_diagnostic()?; + } let db = Arc::new(Mutex::new(Database::new(FileSystemSource::new()))); let modules = project .discover_modules_production(&*db.lock().await) @@ -76,34 +95,15 @@ impl Args { .to_file_path() .expect("discovered source has a file URL"); let path = path.canonicalize().unwrap_or(path); - let mut config = member_settings + let config = member_settings .iter() .filter(|(directory, _)| path.starts_with(directory)) .max_by_key(|(directory, _)| directory.components().count()) .map_or_else(|| project.config.build(), |(_, config)| *config); - if let Some(version) = self.plutus_version { - config.plutus_version = match version { - PlutusVersionArg::V1 => nash_config::PlutusVersion::V1, - PlutusVersionArg::V2 => nash_config::PlutusVersion::V2, - PlutusVersionArg::V3 => nash_config::PlutusVersion::V3, - }; - } - if let Some(level) = self.optimize { - config.optimize = level; - } - if let Some(level) = self.trace_level { - config.trace_level = match level { - TraceLevelArg::Silent => nash_config::TraceLevel::Silent, - TraceLevelArg::Compact => nash_config::TraceLevel::Compact, - TraceLevelArg::Verbose => nash_config::TraceLevel::Verbose, - }; - } - if let Some(enabled) = self.compiler_traces { - config.compiler_traces = enabled; - } - (uri.clone(), config) + Ok((uri.clone(), self.resolve_config(config)?)) }) - .collect(); + .collect::>() + .into_diagnostic()?; let (report, output) = build_with(db, &graph, &modules, move |solved| { nash_driver::build::build_validators_matching_with(solved, |uri| { configs.get(uri).copied() diff --git a/crates/nash-cli/src/cmd/test.rs b/crates/nash-cli/src/cmd/test.rs index 65618747..74db9ce8 100644 --- a/crates/nash-cli/src/cmd/test.rs +++ b/crates/nash-cli/src/cmd/test.rs @@ -4,7 +4,7 @@ use miette::{IntoDiagnostic, Result}; use nash_driver::{Database, FileSystemSource, Project, build_graph_with_tests, test_with}; use tokio::{sync::Mutex, task::spawn_blocking}; -use super::build::{PlutusVersionArg, TraceLevelArg}; +use super::build::TraceLevelArg; #[derive(Clone, Copy, clap::ValueEnum)] pub enum Coverage { @@ -14,7 +14,7 @@ pub enum Coverage { #[derive(clap::Args)] pub struct Args { - /// Optimization level: 0 (baseline) or 1 (preserves enabled traces). + /// Optimization level: 0 (baseline), 1 (preserves traces), or 2 (silent). #[arg(short = 'O', long)] pub optimize: Option, #[arg(default_value = ".")] @@ -29,8 +29,6 @@ pub struct Args { pub exact: bool, #[arg(long, value_enum)] pub trace_level: Option, - #[arg(long, value_enum)] - pub plutus_version: Option, #[arg(long, default_value_t = default_jobs(), value_parser = positive)] pub jobs: usize, #[arg(long, value_enum, default_value = "labels")] @@ -51,6 +49,25 @@ fn default_jobs() -> usize { } impl Args { + pub(crate) fn resolve_config( + &self, + mut config: nash_config::Build, + ) -> std::result::Result { + if let Some(level) = self.optimize { + config.optimize = level; + } + if let Some(level) = self.trace_level { + config.trace_level_explicit = true; + config.trace_level = match level { + TraceLevelArg::Silent => nash_config::TraceLevel::Silent, + TraceLevelArg::Compact => nash_config::TraceLevel::Compact, + TraceLevelArg::Verbose => nash_config::TraceLevel::Verbose, + }; + } + config.validate()?; + Ok(config) + } + pub async fn exec(self, color: bool) -> Result<()> { let json = self.json; let path = self.path.clone(); @@ -68,6 +85,13 @@ impl Args { async fn exec_inner(self, color: bool) -> Result<()> { let project = Project::load(&self.path).await.into_diagnostic()?; + // Reject conflicts even when a project/member contains no source roots. + self.resolve_config(project.config.build()) + .into_diagnostic()?; + for member in &project.members { + self.resolve_config(member.config.build()) + .into_diagnostic()?; + } let db = Arc::new(Mutex::new(Database::new(FileSystemSource::new()))); let modules = project .discover_modules(&*db.lock().await) @@ -93,7 +117,7 @@ impl Args { directory .canonicalize() .unwrap_or_else(|_| directory.clone()), - member.config.build().for_tests(), + member.config.build(), ) }) }) @@ -103,32 +127,15 @@ impl Args { .map(|uri| { let path = uri.to_file_path().expect("discovered file URL"); let path = path.canonicalize().unwrap_or(path); - let mut config = member_settings + let config = member_settings .iter() .filter(|(directory, _)| path.starts_with(directory)) .max_by_key(|(directory, _)| directory.components().count()) - .map_or_else(|| project.config.build().for_tests(), |(_, config)| *config); - if let Some(level) = self.optimize { - config.optimize = level; - } - if let Some(level) = self.trace_level { - config.trace_level_explicit = true; - config.trace_level = match level { - TraceLevelArg::Silent => nash_config::TraceLevel::Silent, - TraceLevelArg::Compact => nash_config::TraceLevel::Compact, - TraceLevelArg::Verbose => nash_config::TraceLevel::Verbose, - }; - } - if let Some(version) = self.plutus_version { - config.plutus_version = match version { - PlutusVersionArg::V1 => nash_config::PlutusVersion::V1, - PlutusVersionArg::V2 => nash_config::PlutusVersion::V2, - PlutusVersionArg::V3 => nash_config::PlutusVersion::V3, - }; - } - (uri.clone(), config) + .map_or_else(|| project.config.build(), |(_, config)| *config); + Ok((uri.clone(), self.resolve_config(config)?)) }) - .collect(); + .collect::>() + .into_diagnostic()?; let patterns = self.matches.clone(); let exact = self.exact; let (report, programs) = test_with(db, &graph, &modules, move |solved| { diff --git a/crates/nash-cli/src/snapshots/nash_cli__cli__tests__o2_compiler_trace_cli_overrides.snap b/crates/nash-cli/src/snapshots/nash_cli__cli__tests__o2_compiler_trace_cli_overrides.snap new file mode 100644 index 00000000..f4699881 --- /dev/null +++ b/crates/nash-cli/src/snapshots/nash_cli__cli__tests__o2_compiler_trace_cli_overrides.snap @@ -0,0 +1,5 @@ +--- +source: crates/nash-cli/src/cli.rs +--- +--compiler-traces: O2 does not support compiler traces +--compiler-traces=false: O2; compiler traces: false diff --git a/crates/nash-cli/src/snapshots/nash_cli__cli__tests__o2_settings_merge_before_test_defaults.snap b/crates/nash-cli/src/snapshots/nash_cli__cli__tests__o2_settings_merge_before_test_defaults.snap new file mode 100644 index 00000000..2f6ad4a9 --- /dev/null +++ b/crates/nash-cli/src/snapshots/nash_cli__cli__tests__o2_settings_merge_before_test_defaults.snap @@ -0,0 +1,33 @@ +--- +source: crates/nash-cli/src/cli.rs +--- +build -O2 (default): O2 Silent, compiler traces: false +build -O2 (verbose project): O2 requires silent tracing; compact and verbose tracing are not supported +build -O2 (compiler traces): O2 does not support compiler traces +build -O2 --trace-level silent (default): O2 Silent, compiler traces: false +build -O2 --trace-level silent (verbose project): O2 Silent, compiler traces: false +build -O2 --trace-level silent (compiler traces): O2 does not support compiler traces +build -O2 --trace-level compact (default): O2 requires silent tracing; compact and verbose tracing are not supported +build -O2 --trace-level compact (verbose project): O2 requires silent tracing; compact and verbose tracing are not supported +build -O2 --trace-level compact (compiler traces): O2 requires silent tracing; compact and verbose tracing are not supported +build -O2 --trace-level verbose (default): O2 requires silent tracing; compact and verbose tracing are not supported +build -O2 --trace-level verbose (verbose project): O2 requires silent tracing; compact and verbose tracing are not supported +build -O2 --trace-level verbose (compiler traces): O2 requires silent tracing; compact and verbose tracing are not supported +build -O1 (default): O1 Silent, compiler traces: false +build -O1 (verbose project): O1 Verbose, compiler traces: false +build -O1 (compiler traces): O1 Silent, compiler traces: true +test -O2 (default): O2 Silent, compiler traces: false +test -O2 (verbose project): O2 requires silent tracing; compact and verbose tracing are not supported +test -O2 (compiler traces): O2 does not support compiler traces +test -O2 --trace-level silent (default): O2 Silent, compiler traces: false +test -O2 --trace-level silent (verbose project): O2 Silent, compiler traces: false +test -O2 --trace-level silent (compiler traces): O2 does not support compiler traces +test -O2 --trace-level compact (default): O2 requires silent tracing; compact and verbose tracing are not supported +test -O2 --trace-level compact (verbose project): O2 requires silent tracing; compact and verbose tracing are not supported +test -O2 --trace-level compact (compiler traces): O2 requires silent tracing; compact and verbose tracing are not supported +test -O2 --trace-level verbose (default): O2 requires silent tracing; compact and verbose tracing are not supported +test -O2 --trace-level verbose (verbose project): O2 requires silent tracing; compact and verbose tracing are not supported +test -O2 --trace-level verbose (compiler traces): O2 requires silent tracing; compact and verbose tracing are not supported +test -O1 (default): O1 Verbose, compiler traces: true +test -O1 (verbose project): O1 Verbose, compiler traces: true +test -O1 (compiler traces): O1 Silent, compiler traces: true diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_and_labeled_constructor_keep_distinct_layouts.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_and_labeled_constructor_keep_distinct_layouts.snap index 91ddc1f4..929bb8c4 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_and_labeled_constructor_keep_distinct_layouts.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_and_labeled_constructor_keep_distinct_layouts.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\ntype alias Record = { owner : Bytes, count : Int }\ntype Datum = Datum { owner : Bytes, count : Int }\nrecord : Record\nrecord = { owner = #\"aa\", count = 1 }\ndatum : Datum\ndatum = Datum { owner = #\"bb\", count = 2 }\nmain = neq record.count datum.count\n" --- --- unoptimized Core @@ -88,16 +87,13 @@ let projection#38 : list Data = unListData record#34 in case@List projection#38 of Cons head#39 tail#40 -> case@List tail#40 of Cons head#41 tail#42 -> let projection#43 : pair int (list Data) = unConstrData datum#37 in - case@Pair projection#43 of - Pair tag#44 fields#45 -> case@List fields#45 of - Cons head#46 tail#47 -> case@List tail#47 of - Cons head#48 tail#49 -> let anf#52 : bool = equalsData head#41 head#48 in - case@Bool anf#52 of - True -> false - False -> true + let anf#52 : bool = equalsData head#41 anf#61 in + case@Bool anf#52 of + True -> false + False -> true --- optimized UPLC (program 1.1.0 - [(lam builtin_26 + [(lam builtin_20 [(lam fromBytes_1 [(lam fromInt_2 [(lam anf_3 @@ -120,34 +116,20 @@ case@List projection#38 of (lam head_16 (lam tail_17 [(lam projection_18 - (case - projection_18 - (lam tag_19 - (lam fields_20 - (case - fields_20 - (lam head_21 - (lam tail_22 - (case - tail_22 - (lam head_23 - (lam tail_24 - [(lam anf_25 (case anf_25 (con bool True) (con bool False))) - [[(builtin equalsData) head_16] head_23]])) - (error)))) - (error)))))) + [(lam anf_19 (case anf_19 (con bool True) (con bool False))) + [[(builtin equalsData) head_16] anf_9]]) [(builtin unConstrData) datum_12]])) (error)))) (error))) [(builtin unListData) record_7]]) [[(builtin constrData) (con integer 0)] anf_11]]) - [[builtin_26 anf_8] anf_10]]) - [[builtin_26 anf_9] (con (list data) [])]]) + [[builtin_20 anf_8] anf_10]]) + [[builtin_20 anf_9] (con (list data) [])]]) [fromInt_2 (con integer 2)]]) [fromBytes_1 (con bytestring #bb)]]) [(builtin listData) anf_6]]) - [[builtin_26 anf_3] anf_5]]) - [[builtin_26 anf_4] (con (list data) [])]]) + [[builtin_20 anf_3] anf_5]]) + [[builtin_20 anf_4] (con (list data) [])]]) [fromInt_2 (con integer 1)]]) [fromBytes_1 (con bytestring #aa)]]) (builtin iData)]) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_does_not_validate_unchanged_suffix.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_does_not_validate_unchanged_suffix.snap index 48b9a8f2..362690e7 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_does_not_validate_unchanged_suffix.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_does_not_validate_unchanged_suffix.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 1688 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\ntype alias Record = { a : Int, b : Int }\noriginal : Record\noriginal = Primitive.coerce (Builtin.listData [Builtin.iData 1])\nmain = Builtin.equalsData\n (Primitive.coerce { original | a = 10 })\n (Primitive.coerce (Builtin.listData [Builtin.iData 10]))\n" --- --- unoptimized Core @@ -44,45 +43,19 @@ case@List projection#12 of (con (list data) [])]]]]) (lam value_11 value_11)]) --- optimized Core -let anf#28 : Int = iData 1 in -let anf#29 : list Int = mkCons anf#28 (con (list data) []) in -let anf#30 : List Int = listData anf#29 in let evaluated#20 : Int = iData 10 in -let projection#21 : list Data = unListData anf#30 in -case@List projection#21 of - Cons head#22 tail#23 -> let anf#31 : list Data = mkCons evaluated#20 tail#23 in - let anf#32 : { _0 : Int, _1 : Int } = listData anf#31 in - let anf#35 : Int = iData 10 in - let anf#36 : list Int = mkCons anf#35 (con (list data) []) in - let anf#37 : List Int = listData anf#36 in - equalsData anf#32 anf#37 +let anf#31 : list Data = mkCons evaluated#20 (con (list data) []) in +let anf#32 : { _0 : Int, _1 : Int } = listData anf#31 in +equalsData anf#32 (con data (List [I 10])) --- optimized UPLC (program 1.1.0 - [(lam builtin_13 - [(lam anf_1 + [(lam builtin_4 + [(lam evaluated_1 [(lam anf_2 - [(lam anf_3 - [(lam evaluated_4 - [(lam projection_5 - (case - projection_5 - (lam head_6 - (lam tail_7 - [(lam anf_8 - [(lam anf_9 - [(lam anf_10 - [(lam anf_11 - [(lam anf_12 [[(builtin equalsData) anf_9] anf_12]) [(builtin listData) anf_11]]) - [[builtin_13 anf_10] (con (list data) [])]]) - [(builtin iData) (con integer 10)]]) - [(builtin listData) anf_8]]) - [[builtin_13 evaluated_4] tail_7]])) - (error))) - [(builtin unListData) anf_3]]) - [(builtin iData) (con integer 10)]]) + [(lam anf_3 [[(builtin equalsData) anf_3] (con data (List [I 10]))]) [(builtin listData) anf_2]]) - [[builtin_13 anf_1] (con (list data) [])]]) - [(builtin iData) (con integer 1)]]) + [[builtin_4 evaluated_1] (con (list data) [])]]) + [(builtin iData) (con integer 10)]]) (force (builtin mkCons))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_preserves_opaque_suffix.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_preserves_opaque_suffix.snap index 8871405f..ba6fa2f6 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_preserves_opaque_suffix.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_preserves_opaque_suffix.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 1641 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\ntype alias Record = { a : Int, b : Int }\nreplace : Record -> Record\nreplace r = { r | a = (trace \"first\" 10) }\noriginal : Record\noriginal = Primitive.coerce (Builtin.listData [Builtin.iData 1, Builtin.iData 2, Builtin.iData 3])\nmain = Builtin.equalsData (Primitive.coerce (replace original))\n (Primitive.coerce (Builtin.listData [Builtin.iData 10, Builtin.iData 2, Builtin.iData 3]))\n" --- --- unoptimized Core @@ -58,70 +57,21 @@ main#1 (builtin iData)]) (con string "first")]) --- optimized Core -let anf#40 : Int = iData 1 in -let anf#42 : Int = iData 2 in -let anf#44 : Int = iData 3 in -let anf#45 : list Int = mkCons anf#44 (con (list data) []) in -let anf#46 : list Int = mkCons anf#42 anf#45 in -let anf#47 : list Int = mkCons anf#40 anf#46 in -let anf#48 : List Int = listData anf#47 in let evaluated#25 : Int = trace "first" in iData 10 in -let projection#26 : list Data = unListData anf#48 in -let anf#49 : { _0 : Int, _1 : Int } = case@List projection#26 of - Cons head#27 tail#28 -> let anf#38 : list Data = mkCons evaluated#25 tail#28 in - listData anf#38 in -let anf#52 : Int = iData 10 in -let anf#54 : Int = iData 2 in -let anf#56 : Int = iData 3 in -let anf#57 : list Int = mkCons anf#56 (con (list data) []) in -let anf#58 : list Int = mkCons anf#54 anf#57 in -let anf#59 : list Int = mkCons anf#52 anf#58 in -let anf#60 : List Int = listData anf#59 in -equalsData anf#49 anf#60 +let anf#38 : list Data = mkCons evaluated#25 (con (list data) [(I 2), (I 3)]) in +let anf#49 : { _0 : Int, _1 : Int } = listData anf#38 in +equalsData anf#49 (con data (List [I 10, I 2, I 3])) --- optimized UPLC (program 1.1.0 - [(lam builtin_21 - [(lam builtin_22 - [(lam anf_1 + [(lam builtin_4 + [(lam builtin_5 + [(lam evaluated_1 [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - [(lam anf_5 - [(lam anf_6 - [(lam anf_7 - [(lam evaluated_8 - [(lam projection_9 - [(lam anf_13 - [(lam anf_14 - [(lam anf_15 - [(lam anf_16 - [(lam anf_17 - [(lam anf_18 - [(lam anf_19 - [(lam anf_20 [[(builtin equalsData) anf_13] anf_20]) - [(builtin listData) anf_19]]) - [[builtin_21 anf_14] anf_18]]) - [[builtin_21 anf_15] anf_17]]) - [[builtin_21 anf_16] (con (list data) [])]]) - [(builtin iData) (con integer 3)]]) - [(builtin iData) (con integer 2)]]) - [(builtin iData) (con integer 10)]]) - (case - projection_9 - (lam head_10 - (lam tail_11 - [(lam anf_12 [(builtin listData) anf_12]) [[builtin_21 evaluated_8] tail_11]])) - (error))]) - [(builtin unListData) anf_7]]) - (force - [[builtin_22 (con string "first")] (delay [(builtin iData) (con integer 10)])])]) - [(builtin listData) anf_6]]) - [[builtin_21 anf_1] anf_5]]) - [[builtin_21 anf_2] anf_4]]) - [[builtin_21 anf_3] (con (list data) [])]]) - [(builtin iData) (con integer 3)]]) - [(builtin iData) (con integer 2)]]) - [(builtin iData) (con integer 1)]]) + [(lam anf_3 [[(builtin equalsData) anf_3] (con data (List [I 10, I 2, I 3]))]) + [(builtin listData) anf_2]]) + [[builtin_4 evaluated_1] (con (list data) [(I 2), (I 3)])]]) + (force + [[builtin_5 (con string "first")] (delay [(builtin iData) (con integer 10)])])]) (force (builtin trace))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_traces_before_missing_tail_failure.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_traces_before_missing_tail_failure.snap index 3ea428b0..430f0b51 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_traces_before_missing_tail_failure.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_record_update_traces_before_missing_tail_failure.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 1672 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\ntype alias Record = { a : Int, b : Int }\nempty : list Data\nempty = []\noriginal : Record\noriginal = Primitive.coerce (Builtin.listData empty)\nmain : Record\nmain = { original | a = (trace \"before tail\" 10) }\n" --- --- unoptimized Core @@ -43,32 +42,16 @@ case@List projection#11 of (con (list data) [])]) (con string "before tail")]) --- optimized Core -let anf#27 : List Data = listData (con (list data) []) in let evaluated#22 : Int = trace "before tail" in iData 10 in -let projection#23 : list Data = unListData anf#27 in -case@List projection#23 of - Cons head#24 tail#25 -> let anf#29 : list Data = mkCons evaluated#22 tail#25 in - listData anf#29 +error --- optimized UPLC (program 1.1.0 - [(lam builtin_7 - [(lam builtin_8 - [(lam anf_1 - [(lam evaluated_2 - [(lam projection_3 - (case - projection_3 - (lam head_4 - (lam tail_5 - [(lam anf_6 [(builtin listData) anf_6]) [[builtin_7 evaluated_2] tail_5]])) - (error))) - [(builtin unListData) anf_1]]) - (force - [[builtin_8 (con string "before tail")] - (delay [(builtin iData) (con integer 10)])])]) - [(builtin listData) (con (list data) [])]]) - (force (builtin trace))]) - (force (builtin mkCons))]) + [(lam builtin_2 + [(lam evaluated_1 (error)) + (force + [[builtin_2 (con string "before tail")] + (delay [(builtin iData) (con integer 10)])])]) + (force (builtin trace))]) --- result error: ExplicitErrorTerm --- logs diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_binds_whole_and_captures_outer.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_binds_whole_and_captures_outer.snap index a9153d41..1b026e54 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_binds_whole_and_captures_outer.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_binds_whole_and_captures_outer.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | Zero | One Int | Two Int Int\nread : Choice -> int\nread value =\n case value of\n Stop -> 0\n Zero -> 0\n One a -> unIData a\n Two a b -> addInteger (unIData a) (unIData b)\nchoose : int -> Choice -> int\nchoose outer subject =\n case trace \"subject\" subject of\n Stop -> 1\n whole -> trace \"fallback\" (addInteger outer (read whole))\nmain = (choose 10 Stop, choose 10 Zero, choose 10 (One 20), choose 10 (Two 30 40))\n" --- --- unoptimized Core @@ -147,11 +146,9 @@ case@Pair projection#62 of 3 -> leaf#61 match#59 in let fromInt#69 : int -> Int = iData in let anf#80 : Main.Choice -> int = choose#68 10 in -let anf#81 : Main.Choice = constrData 0 (con (list data) []) in -let anf#82 : int = anf#80 anf#81 in +let anf#82 : int = anf#80 (con data (Constr 0 [])) in let anf#84 : Main.Choice -> int = choose#68 10 in -let anf#85 : Main.Choice = constrData 1 (con (list data) []) in -let anf#86 : int = anf#84 anf#85 in +let anf#86 : int = anf#84 (con data (Constr 1 [])) in let anf#88 : Main.Choice -> int = choose#68 10 in let anf#90 : Int = fromInt#69 20 in let anf#89 : list Data = mkCons anf#90 (con (list data) []) in @@ -167,8 +164,8 @@ let anf#101 : int = anf#94 anf#100 in constr 0 anf#82 anf#86 anf#92 anf#101 --- optimized UPLC (program 1.1.0 - [(lam builtin_41 - [(lam builtin_42 + [(lam builtin_39 + [(lam builtin_40 [(lam choose_21 [(lam fromInt_22 [(lam anf_23 @@ -186,25 +183,21 @@ constr 0 anf#82 anf#86 anf#92 anf#101 [(lam anf_35 [(lam anf_36 [(lam anf_37 - [(lam anf_38 - [(lam anf_39 - [(lam anf_40 (constr 0 anf_25 anf_28 anf_33 anf_40)) [anf_34 anf_39]]) - [[(builtin constrData) (con integer 3)] anf_38]]) - [[builtin_41 anf_35] anf_37]]) - [[builtin_41 anf_36] (con (list data) [])]]) - [fromInt_22 (con integer 40)]]) - [fromInt_22 (con integer 30)]]) - [choose_21 (con integer 10)]]) - [anf_29 anf_32]]) - [[(builtin constrData) (con integer 2)] anf_31]]) - [[builtin_41 anf_30] (con (list data) [])]]) - [fromInt_22 (con integer 20)]]) - [choose_21 (con integer 10)]]) - [anf_26 anf_27]]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) - [choose_21 (con integer 10)]]) - [anf_23 anf_24]]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) + [(lam anf_38 (constr 0 anf_24 anf_26 anf_31 anf_38)) [anf_32 anf_37]]) + [[(builtin constrData) (con integer 3)] anf_36]]) + [[builtin_39 anf_33] anf_35]]) + [[builtin_39 anf_34] (con (list data) [])]]) + [fromInt_22 (con integer 40)]]) + [fromInt_22 (con integer 30)]]) + [choose_21 (con integer 10)]]) + [anf_27 anf_30]]) + [[(builtin constrData) (con integer 2)] anf_29]]) + [[builtin_39 anf_28] (con (list data) [])]]) + [fromInt_22 (con integer 20)]]) + [choose_21 (con integer 10)]]) + [anf_25 (con data (Constr 1 []))]]) + [choose_21 (con integer 10)]]) + [anf_23 (con data (Constr 0 []))]]) [choose_21 (con integer 10)]]) (builtin iData)]) (lam outer_1 @@ -225,7 +218,7 @@ constr 0 anf#82 anf#86 anf#92 anf#101 [(builtin unConstrData) match_3]]) (lam whole_4 (force - [[builtin_42 (con string "fallback")] + [[builtin_40 (con string "fallback")] (delay [(lam projection_5 [(lam anf_16 [[(builtin addInteger) outer_1] anf_16]) @@ -256,7 +249,7 @@ constr 0 anf#82 anf#86 anf#92 anf#101 (error)))) (error))))))]) [(builtin unConstrData) whole_4]])]))]) - (force [[builtin_42 (con string "subject")] (delay subject_2)])]))]) + (force [[builtin_40 (con string "subject")] (delay subject_2)])]))]) (force (builtin trace))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_calls_user_continuation_only_when_selected.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_calls_user_continuation_only_when_selected.snap index 61ddcab2..ff499686 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_calls_user_continuation_only_when_selected.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_calls_user_continuation_only_when_selected.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | Zero | One Int | Two Int Int\nchoose : Choice -> (int -> int) -> int\nchoose subject continue =\n case trace \"subject\" subject of\n Stop -> 0\n _ -> trace \"fallback\" (continue 9)\nfinish : int -> int\nfinish n = trace \"continue\" (addInteger n 100)\nmain = (choose Stop (\\_ -> trace \"wrong\" fail), choose Zero finish, choose (One 2) finish, choose (Two 3 4) finish)\n" --- --- unoptimized Core @@ -103,10 +102,8 @@ case@Pair projection#38 of 3 -> force leaf#37 in let finish#43 : int -> int = \n#42 : int -> trace "continue" in addInteger n#42 100 in let fromInt#44 : int -> Int = iData in -let anf#56 : Main.Choice = constrData 0 (con (list data) []) in -let anf#58 : int = choose#41 anf#56 (\arg#45 : int -> trace "wrong" in error) in -let anf#59 : Main.Choice = constrData 1 (con (list data) []) in -let anf#60 : int = choose#41 anf#59 finish#43 in +let anf#58 : int = choose#41 (con data (Constr 0 [])) (\arg#45 : int -> trace "wrong" in error) in +let anf#60 : int = choose#41 (con data (Constr 1 [])) finish#43 in let anf#62 : Int = fromInt#44 2 in let anf#61 : list Data = mkCons anf#62 (con (list data) []) in let anf#63 : Main.Choice = constrData 2 anf#61 in @@ -120,12 +117,12 @@ let anf#71 : int = choose#41 anf#70 finish#43 in constr 0 anf#58 anf#60 anf#64 anf#71 --- optimized UPLC (program 1.1.0 - [(lam builtin_27 - [(lam builtin_28 + [(lam builtin_25 + [(lam builtin_26 [(lam choose_8 [(lam finish_10 [(lam fromInt_11 - [(lam anf_12 + [(lam anf_13 [(lam anf_14 [(lam anf_15 [(lam anf_16 @@ -136,28 +133,24 @@ constr 0 anf#58 anf#60 anf#64 anf#71 [(lam anf_21 [(lam anf_22 [(lam anf_23 - [(lam anf_24 - [(lam anf_25 - [(lam anf_26 (constr 0 anf_14 anf_16 anf_20 anf_26)) - [[choose_8 anf_25] finish_10]]) - [[(builtin constrData) (con integer 3)] anf_24]]) - [[builtin_27 anf_21] anf_23]]) - [[builtin_27 anf_22] (con (list data) [])]]) - [fromInt_11 (con integer 4)]]) - [fromInt_11 (con integer 3)]]) - [[choose_8 anf_19] finish_10]]) - [[(builtin constrData) (con integer 2)] anf_18]]) - [[builtin_27 anf_17] (con (list data) [])]]) - [fromInt_11 (con integer 2)]]) - [[choose_8 anf_15] finish_10]]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) - [[choose_8 anf_12] - (lam arg_13 (force [[builtin_28 (con string "wrong")] (delay (error))]))]]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) + [(lam anf_24 (constr 0 anf_13 anf_14 anf_18 anf_24)) + [[choose_8 anf_23] finish_10]]) + [[(builtin constrData) (con integer 3)] anf_22]]) + [[builtin_25 anf_19] anf_21]]) + [[builtin_25 anf_20] (con (list data) [])]]) + [fromInt_11 (con integer 4)]]) + [fromInt_11 (con integer 3)]]) + [[choose_8 anf_17] finish_10]]) + [[(builtin constrData) (con integer 2)] anf_16]]) + [[builtin_25 anf_15] (con (list data) [])]]) + [fromInt_11 (con integer 2)]]) + [[choose_8 (con data (Constr 1 []))] finish_10]]) + [[choose_8 (con data (Constr 0 []))] + (lam arg_12 (force [[builtin_26 (con string "wrong")] (delay (error))]))]]) (builtin iData)]) (lam n_9 (force - [[builtin_28 (con string "continue")] + [[builtin_26 (con string "continue")] (delay [[(builtin addInteger) n_9] (con integer 100)])]))]) (lam subject_1 (lam continue_2 @@ -172,8 +165,8 @@ constr 0 anf#58 anf#60 anf#64 anf#71 [(builtin unConstrData) match_3]]) (delay (force - [[builtin_28 (con string "fallback")] (delay [continue_2 (con integer 9)])]))]) - (force [[builtin_28 (con string "subject")] (delay subject_1)])]))]) + [[builtin_26 (con string "fallback")] (delay [continue_2 (con integer 9)])]))]) + (force [[builtin_26 (con string "subject")] (delay subject_1)])]))]) (force (builtin trace))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_does_not_extract_missing_fields.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_does_not_extract_missing_fields.snap index b8ba564a..698d8a41 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_does_not_extract_missing_fields.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_does_not_extract_missing_fields.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | One Int | Two Int Int\nchoose : Choice -> int\nchoose subject =\n case subject of\n Stop -> 1\n _ -> trace \"fallback\" 9\nmain = (choose (coerce (constrData 1 [])), choose (coerce (constrData 2 [])))\n" --- --- unoptimized Core @@ -57,21 +56,16 @@ case@Pair projection#24 of 0 -> 1 1 -> force leaf#17 2 -> force leaf#17 in -let anf#33 : Data = constrData 1 (con (list data) []) in -let anf#35 : int = choose#27 anf#33 in -let anf#37 : Data = constrData 2 (con (list data) []) in -let anf#39 : int = choose#27 anf#37 in +let anf#35 : int = choose#27 (con data (Constr 1 [])) in +let anf#39 : int = choose#27 (con data (Constr 2 [])) in constr 0 anf#35 anf#39 --- optimized UPLC (program 1.1.0 - [(lam builtin_11 + [(lam builtin_9 [(lam choose_6 [(lam anf_7 - [(lam anf_8 - [(lam anf_9 [(lam anf_10 (constr 0 anf_8 anf_10)) [choose_6 anf_9]]) - [[(builtin constrData) (con integer 2)] (con (list data) [])]]) - [choose_6 anf_7]]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) + [(lam anf_8 (constr 0 anf_7 anf_8)) [choose_6 (con data (Constr 2 []))]]) + [choose_6 (con data (Constr 1 []))]]) (lam subject_1 [(lam leaf_2 [(lam projection_3 @@ -80,7 +74,7 @@ constr 0 anf#35 anf#39 (lam tag_4 (lam fields_5 (case tag_4 (con integer 1) (force leaf_2) (force leaf_2)))))) [(builtin unConstrData) subject_1]]) - (delay (force [[builtin_11 (con string "fallback")] (delay (con integer 9))]))])]) + (delay (force [[builtin_9 (con string "fallback")] (delay (con integer 9))]))])]) (force (builtin trace))]) --- result (constr 0 (con integer 9) (con integer 9)) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_inline_function_result_consumes_fields.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_inline_function_result_consumes_fields.snap index 1386afd4..52cf834c 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_inline_function_result_consumes_fields.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_inline_function_result_consumes_fields.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | Two Int Int\nchoose : Choice -> (int -> int)\nchoose subject =\n case trace \"subject\" subject of\n Stop -> \\n -> n\n _ -> trace \"fallback\" (\\n -> addInteger n 1)\nmain = (choose Stop 10, choose (Two 3 4) 20)\n" --- --- unoptimized Core @@ -66,8 +65,7 @@ case@Pair projection#27 of 0 -> \n#30 : int -> n#30 1 -> trace "fallback" in \n#31 : int -> addInteger n#31 1 in let fromInt#33 : int -> Int = iData in -let anf#40 : Main.Choice = constrData 0 (con (list data) []) in -let anf#41 : int -> int = choose#32 anf#40 in +let anf#41 : int -> int = choose#32 (con data (Constr 0 [])) in let anf#43 : int = anf#41 10 in let anf#46 : Int = fromInt#33 3 in let anf#48 : Int = fromInt#33 4 in @@ -79,8 +77,8 @@ let anf#52 : int = anf#50 20 in constr 0 anf#43 anf#52 --- optimized UPLC (program 1.1.0 - [(lam builtin_20 - [(lam builtin_21 + [(lam builtin_19 + [(lam builtin_20 [(lam choose_8 [(lam fromInt_9 [(lam anf_10 @@ -90,17 +88,15 @@ constr 0 anf#43 anf#52 [(lam anf_14 [(lam anf_15 [(lam anf_16 - [(lam anf_17 - [(lam anf_18 [(lam anf_19 (constr 0 anf_12 anf_19)) [anf_18 (con integer 20)]]) - [choose_8 anf_17]]) - [[(builtin constrData) (con integer 1)] anf_16]]) - [[builtin_20 anf_13] anf_15]]) - [[builtin_20 anf_14] (con (list data) [])]]) - [fromInt_9 (con integer 4)]]) - [fromInt_9 (con integer 3)]]) - [anf_11 (con integer 10)]]) - [choose_8 anf_10]]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) + [(lam anf_17 [(lam anf_18 (constr 0 anf_11 anf_18)) [anf_17 (con integer 20)]]) + [choose_8 anf_16]]) + [[(builtin constrData) (con integer 1)] anf_15]]) + [[builtin_19 anf_12] anf_14]]) + [[builtin_19 anf_13] (con (list data) [])]]) + [fromInt_9 (con integer 4)]]) + [fromInt_9 (con integer 3)]]) + [anf_10 (con integer 10)]]) + [choose_8 (con data (Constr 0 []))]]) (builtin iData)]) (lam subject_1 [(lam match_2 @@ -113,10 +109,10 @@ constr 0 anf#43 anf#52 tag_4 (lam n_6 n_6) (force - [[builtin_21 (con string "fallback")] + [[builtin_20 (con string "fallback")] (delay (lam n_7 [[(builtin addInteger) n_7] (con integer 1)]))])))))) [(builtin unConstrData) match_2]]) - (force [[builtin_21 (con string "subject")] (delay subject_1)])])]) + (force [[builtin_20 (con string "subject")] (delay subject_1)])])]) (force (builtin trace))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_mixed_arities_trace_order.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_mixed_arities_trace_order.snap index 0cc0bc57..56c24795 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_mixed_arities_trace_order.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_mixed_arities_trace_order.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | Zero | One Int | Two Int Int\nchoose : Choice -> int\nchoose subject =\n case trace \"subject\" subject of\n Stop -> trace \"explicit\" 1\n _ -> trace \"fallback\" 9\nmain = (choose Stop, choose Zero, choose (One 2), choose (Two 3 4))\n" --- --- unoptimized Core @@ -86,10 +85,8 @@ case@Pair projection#30 of 2 -> force leaf#29 3 -> force leaf#29 in let fromInt#34 : int -> Int = iData in -let anf#42 : Main.Choice = constrData 0 (con (list data) []) in -let anf#43 : int = choose#33 anf#42 in -let anf#44 : Main.Choice = constrData 1 (con (list data) []) in -let anf#45 : int = choose#33 anf#44 in +let anf#43 : int = choose#33 (con data (Constr 0 [])) in +let anf#45 : int = choose#33 (con data (Constr 1 [])) in let anf#47 : Int = fromInt#34 2 in let anf#46 : list Data = mkCons anf#47 (con (list data) []) in let anf#48 : Main.Choice = constrData 2 anf#46 in @@ -103,8 +100,8 @@ let anf#56 : int = choose#33 anf#55 in constr 0 anf#43 anf#45 anf#49 anf#56 --- optimized UPLC (program 1.1.0 - [(lam builtin_24 - [(lam builtin_25 + [(lam builtin_22 + [(lam builtin_23 [(lam choose_7 [(lam fromInt_8 [(lam anf_9 @@ -118,22 +115,18 @@ constr 0 anf#43 anf#45 anf#49 anf#56 [(lam anf_17 [(lam anf_18 [(lam anf_20 - [(lam anf_21 - [(lam anf_22 - [(lam anf_23 (constr 0 anf_10 anf_12 anf_16 anf_23)) [choose_7 anf_22]]) - [[(builtin constrData) (con integer 3)] anf_21]]) - [[builtin_24 anf_17] anf_20]]) - [[builtin_24 anf_18] (con (list data) [])]]) - [fromInt_8 (con integer 4)]]) - [fromInt_8 (con integer 3)]]) - [choose_7 anf_15]]) - [[(builtin constrData) (con integer 2)] anf_14]]) - [[builtin_24 anf_13] (con (list data) [])]]) - [fromInt_8 (con integer 2)]]) - [choose_7 anf_11]]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) - [choose_7 anf_9]]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) + [(lam anf_21 (constr 0 anf_9 anf_10 anf_14 anf_21)) [choose_7 anf_20]]) + [[(builtin constrData) (con integer 3)] anf_18]]) + [[builtin_22 anf_15] anf_17]]) + [[builtin_22 anf_16] (con (list data) [])]]) + [fromInt_8 (con integer 4)]]) + [fromInt_8 (con integer 3)]]) + [choose_7 anf_13]]) + [[(builtin constrData) (con integer 2)] anf_12]]) + [[builtin_22 anf_11] (con (list data) [])]]) + [fromInt_8 (con integer 2)]]) + [choose_7 (con data (Constr 1 []))]]) + [choose_7 (con data (Constr 0 []))]]) (builtin iData)]) (lam subject_1 [(lam match_2 @@ -145,13 +138,13 @@ constr 0 anf#43 anf#45 anf#49 anf#56 (lam fields_6 (case tag_5 - (force [[builtin_25 (con string "explicit")] (delay (con integer 1))]) + (force [[builtin_23 (con string "explicit")] (delay (con integer 1))]) (force leaf_3) (force leaf_3) (force leaf_3)))))) [(builtin unConstrData) match_2]]) - (delay (force [[builtin_25 (con string "fallback")] (delay (con integer 9))]))]) - (force [[builtin_25 (con string "subject")] (delay subject_1)])])]) + (delay (force [[builtin_23 (con string "fallback")] (delay (con integer 9))]))]) + (force [[builtin_23 (con string "subject")] (delay subject_1)])])]) (force (builtin trace))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_multiple_bindings_return_function.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_multiple_bindings_return_function.snap index 1568e8e6..b5762eb4 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_multiple_bindings_return_function.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_multiple_bindings_return_function.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | Zero | One Int | Two Int Int\nchoose : (Choice, int, int) -> (int -> int)\nchoose subject =\n case trace \"subject\" subject of\n (Stop, _, _) -> \\n -> n\n (_, z, a) -> trace \"shared\" (\\n -> subtractInteger (addInteger z n) a)\nmain = (choose (Stop, 90, 80) 1, choose (Zero, 21, 3) 1, choose (One 2, 31, 4) 1, choose (Two 3 4, 41, 5) 1)\n" --- --- unoptimized Core @@ -115,12 +114,10 @@ case@Tag match#20 of 2 -> leaf#28 field#38 field#37 3 -> leaf#28 field#38 field#37 in let fromInt#52 : int -> Int = iData in -let anf#60 : Main.Choice = constrData 0 (con (list data) []) in -let anf#63 : (Main.Choice, int, int) = constr 0 anf#60 90 80 in +let anf#63 : (Main.Choice, int, int) = constr 0 (con data (Constr 0 [])) 90 80 in let anf#64 : int -> int = choose#49 anf#63 in let anf#66 : int = anf#64 1 in -let anf#67 : Main.Choice = constrData 1 (con (list data) []) in -let anf#70 : (Main.Choice, int, int) = constr 0 anf#67 21 3 in +let anf#70 : (Main.Choice, int, int) = constr 0 (con data (Constr 1 [])) 21 3 in let anf#71 : int -> int = choose#49 anf#70 in let anf#73 : int = anf#71 1 in let anf#75 : Int = fromInt#52 2 in @@ -140,8 +137,8 @@ let anf#94 : int = anf#92 1 in constr 0 anf#66 anf#73 anf#82 anf#94 --- optimized UPLC (program 1.1.0 - [(lam builtin_54 - [(lam builtin_55 + [(lam builtin_51 + [(lam builtin_52 [(lam choose_15 [(lam fromInt_16 [(lam anf_17 @@ -163,30 +160,26 @@ constr 0 anf#66 anf#73 anf#82 anf#94 [(lam anf_46 [(lam anf_47 [(lam anf_48 - [(lam anf_50 - [(lam anf_51 - [(lam anf_53 (constr 0 anf_24 anf_31 anf_43 anf_53)) [anf_51 (con integer 1)]]) - [choose_15 anf_50]]) - (constr 0 anf_48 (con integer 41) (con integer 5))]) - [[(builtin constrData) (con integer 3)] anf_47]]) - [[builtin_54 anf_44] anf_46]]) - [[builtin_54 anf_45] (con (list data) [])]]) - [fromInt_16 (con integer 4)]]) - [fromInt_16 (con integer 3)]]) - [anf_36 (con integer 1)]]) - [choose_15 anf_35]]) - (constr 0 anf_34 (con integer 31) (con integer 4))]) - [[(builtin constrData) (con integer 2)] anf_33]]) - [[builtin_54 anf_32] (con (list data) [])]]) - [fromInt_16 (con integer 2)]]) - [anf_30 (con integer 1)]]) - [choose_15 anf_26]]) - (constr 0 anf_25 (con integer 21) (con integer 3))]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) - [anf_23 (con integer 1)]]) - [choose_15 anf_18]]) - (constr 0 anf_17 (con integer 90) (con integer 80))]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) + [(lam anf_50 (constr 0 anf_23 anf_26 anf_35 anf_50)) [anf_48 (con integer 1)]]) + [choose_15 anf_47]]) + (constr 0 anf_46 (con integer 41) (con integer 5))]) + [[(builtin constrData) (con integer 3)] anf_45]]) + [[builtin_51 anf_36] anf_44]]) + [[builtin_51 anf_43] (con (list data) [])]]) + [fromInt_16 (con integer 4)]]) + [fromInt_16 (con integer 3)]]) + [anf_34 (con integer 1)]]) + [choose_15 anf_33]]) + (constr 0 anf_32 (con integer 31) (con integer 4))]) + [[(builtin constrData) (con integer 2)] anf_31]]) + [[builtin_51 anf_30] (con (list data) [])]]) + [fromInt_16 (con integer 2)]]) + [anf_25 (con integer 1)]]) + [choose_15 anf_24]]) + (constr 0 (con data (Constr 1 [])) (con integer 21) (con integer 3))]) + [anf_18 (con integer 1)]]) + [choose_15 anf_17]]) + (constr 0 (con data (Constr 0 [])) (con integer 90) (con integer 80))]) (builtin iData)]) (lam subject_1 [(lam match_2 @@ -211,12 +204,12 @@ constr 0 anf#66 anf#73 anf#82 anf#94 (lam a_3 (lam z_4 (force - [[builtin_55 (con string "shared")] + [[builtin_52 (con string "shared")] (delay (lam n_5 [(lam anf_6 [[(builtin subtractInteger) anf_6] a_3]) [[(builtin addInteger) z_4] n_5]]))])))]) - (force [[builtin_55 (con string "subject")] (delay subject_1)])])]) + (force [[builtin_52 (con string "subject")] (delay subject_1)])])]) (force (builtin trace))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_only_does_not_inspect_unknown_tag.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_only_does_not_inspect_unknown_tag.snap index d16d6247..add64a7c 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_only_does_not_inspect_unknown_tag.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_only_does_not_inspect_unknown_tag.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | Zero | One Int | Two Int Int\nchoose : Choice -> int\nchoose subject =\n case trace \"subject\" subject of\n _ -> trace \"fallback\" 9\nmain = choose (coerce (constrData 59 []))\n" --- --- unoptimized Core @@ -34,17 +33,14 @@ main#1 (con string "fallback")]) (con string "subject")]) --- optimized Core -let anf#26 : Data = constrData 59 (con (list data) []) in -let match#19 : Main.Choice = trace "subject" in anf#26 in +let match#19 : Main.Choice = trace "subject" in (con data (Constr 59 [])) in trace "fallback" in 9 --- optimized UPLC (program 1.1.0 - [(lam builtin_3 - [(lam anf_1 - [(lam match_2 - (force [[builtin_3 (con string "fallback")] (delay (con integer 9))])) - (force [[builtin_3 (con string "subject")] (delay anf_1)])]) - [[(builtin constrData) (con integer 59)] (con (list data) [])]]) + [(lam builtin_2 + [(lam match_1 + (force [[builtin_2 (con string "fallback")] (delay (con integer 9))])) + (force [[builtin_2 (con string "subject")] (delay (con data (Constr 59 [])))])]) (force (builtin trace))]) --- result (con integer 9) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_returns_captured_function.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_returns_captured_function.snap index cede132a..988ddc6b 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_returns_captured_function.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_returns_captured_function.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | Zero | One Int | Two Int Int\nchoose : int -> Choice -> (int -> int)\nchoose outer subject =\n case trace \"subject\" subject of\n Stop -> trace \"explicit\" (\\n -> n)\n _ -> trace \"fallback\" (\\n -> addInteger outer n)\nmain = (choose 10 Stop 5, choose 10 Zero 5, choose 10 (One 2) 5, choose 10 (Two 3 4) 5)\n" --- --- unoptimized Core @@ -93,12 +92,10 @@ case@Pair projection#33 of 3 -> force leaf#32 in let fromInt#40 : int -> Int = iData in let anf#49 : Main.Choice -> int -> int = choose#37 10 in -let anf#50 : Main.Choice = constrData 0 (con (list data) []) in -let anf#51 : int -> int = anf#49 anf#50 in +let anf#51 : int -> int = anf#49 (con data (Constr 0 [])) in let anf#53 : int = anf#51 5 in let anf#55 : Main.Choice -> int -> int = choose#37 10 in -let anf#56 : Main.Choice = constrData 1 (con (list data) []) in -let anf#57 : int -> int = anf#55 anf#56 in +let anf#57 : int -> int = anf#55 (con data (Constr 1 [])) in let anf#59 : int = anf#57 5 in let anf#61 : Main.Choice -> int -> int = choose#37 10 in let anf#63 : Int = fromInt#40 2 in @@ -117,8 +114,8 @@ let anf#78 : int = anf#76 5 in constr 0 anf#53 anf#59 anf#67 anf#78 --- optimized UPLC (program 1.1.0 - [(lam builtin_45 - [(lam builtin_46 + [(lam builtin_43 + [(lam builtin_44 [(lam choose_10 [(lam fromInt_11 [(lam anf_12 @@ -140,29 +137,25 @@ constr 0 anf#53 anf#59 anf#67 anf#78 [(lam anf_38 [(lam anf_39 [(lam anf_41 - [(lam anf_42 - [(lam anf_43 - [(lam anf_44 (constr 0 anf_15 anf_19 anf_28 anf_44)) [anf_43 (con integer 5)]]) - [anf_29 anf_42]]) - [[(builtin constrData) (con integer 3)] anf_41]]) - [[builtin_45 anf_30] anf_39]]) - [[builtin_45 anf_38] (con (list data) [])]]) - [fromInt_11 (con integer 4)]]) - [fromInt_11 (con integer 3)]]) - [choose_10 (con integer 10)]]) - [anf_27 (con integer 5)]]) - [anf_23 anf_26]]) - [[(builtin constrData) (con integer 2)] anf_25]]) - [[builtin_45 anf_24] (con (list data) [])]]) - [fromInt_11 (con integer 2)]]) - [choose_10 (con integer 10)]]) - [anf_18 (con integer 5)]]) - [anf_16 anf_17]]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) - [choose_10 (con integer 10)]]) - [anf_14 (con integer 5)]]) - [anf_12 anf_13]]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) + [(lam anf_42 (constr 0 anf_14 anf_17 anf_26 anf_42)) [anf_41 (con integer 5)]]) + [anf_27 anf_39]]) + [[(builtin constrData) (con integer 3)] anf_38]]) + [[builtin_43 anf_28] anf_30]]) + [[builtin_43 anf_29] (con (list data) [])]]) + [fromInt_11 (con integer 4)]]) + [fromInt_11 (con integer 3)]]) + [choose_10 (con integer 10)]]) + [anf_25 (con integer 5)]]) + [anf_18 anf_24]]) + [[(builtin constrData) (con integer 2)] anf_23]]) + [[builtin_43 anf_19] (con (list data) [])]]) + [fromInt_11 (con integer 2)]]) + [choose_10 (con integer 10)]]) + [anf_16 (con integer 5)]]) + [anf_15 (con data (Constr 1 []))]]) + [choose_10 (con integer 10)]]) + [anf_13 (con integer 5)]]) + [anf_12 (con data (Constr 0 []))]]) [choose_10 (con integer 10)]]) (builtin iData)]) (lam outer_1 @@ -176,16 +169,16 @@ constr 0 anf#53 anf#59 anf#67 anf#78 (lam fields_8 (case tag_7 - (force [[builtin_46 (con string "explicit")] (delay (lam n_9 n_9))]) + (force [[builtin_44 (con string "explicit")] (delay (lam n_9 n_9))]) (force leaf_5) (force leaf_5) (force leaf_5)))))) [(builtin unConstrData) match_3]]) (delay (force - [[builtin_46 (con string "fallback")] + [[builtin_44 (con string "fallback")] (delay (lam n_4 [[(builtin addInteger) outer_1] n_4]))]))]) - (force [[builtin_46 (con string "subject")] (delay subject_2)])]))]) + (force [[builtin_44 (con string "subject")] (delay subject_2)])]))]) (force (builtin trace))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_failure_unselected.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_failure_unselected.snap index 0db45990..cca86b5b 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_failure_unselected.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_failure_unselected.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | Zero | One Int | Two Int Int\nchoose : Choice -> int\nchoose subject =\n case trace \"subject\" subject of\n Stop -> trace \"explicit\" 1\n _ -> trace \"fallback\" fail\nmain = choose Stop\n" --- --- unoptimized Core @@ -56,8 +55,7 @@ main#1 (con string "fallback")]) (con string "subject")]) --- optimized Core -let anf#34 : Main.Choice = constrData 0 (con (list data) []) in -let match#24 : Main.Choice = trace "subject" in anf#34 in +let match#24 : Main.Choice = trace "subject" in (con data (Constr 0 [])) in let leaf#25 : @delay int = delay (trace "fallback" in error) in let projection#26 : pair int (list Data) = unConstrData match#24 in case@Pair projection#26 of @@ -68,25 +66,23 @@ case@Pair projection#26 of 3 -> force leaf#25 --- optimized UPLC (program 1.1.0 - [(lam builtin_7 - [(lam anf_1 - [(lam match_2 - [(lam leaf_3 - [(lam projection_4 - (case - projection_4 - (lam tag_5 - (lam fields_6 - (case - tag_5 - (force [[builtin_7 (con string "explicit")] (delay (con integer 1))]) - (force leaf_3) - (force leaf_3) - (force leaf_3)))))) - [(builtin unConstrData) match_2]]) - (delay (force [[builtin_7 (con string "fallback")] (delay (error))]))]) - (force [[builtin_7 (con string "subject")] (delay anf_1)])]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) + [(lam builtin_6 + [(lam match_1 + [(lam leaf_2 + [(lam projection_3 + (case + projection_3 + (lam tag_4 + (lam fields_5 + (case + tag_4 + (force [[builtin_6 (con string "explicit")] (delay (con integer 1))]) + (force leaf_2) + (force leaf_2) + (force leaf_2)))))) + [(builtin unConstrData) match_1]]) + (delay (force [[builtin_6 (con string "fallback")] (delay (error))]))]) + (force [[builtin_6 (con string "subject")] (delay (con data (Constr 0 [])))])]) (force (builtin trace))]) --- result (con integer 1) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_failure_zero.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_failure_zero.snap index 3667fe35..bd11ed82 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_failure_zero.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_failure_zero.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | Zero | One Int | Two Int Int\nchoose : Choice -> int\nchoose subject =\n case trace \"subject\" subject of\n Stop -> 1\n _ -> trace \"fallback\" fail\nmain = choose Zero\n" --- --- unoptimized Core @@ -51,8 +50,7 @@ main#1 (con string "fallback")]) (con string "subject")]) --- optimized Core -let anf#31 : Main.Choice = constrData 1 (con (list data) []) in -let match#15 : Main.Choice = trace "subject" in anf#31 in +let match#15 : Main.Choice = trace "subject" in (con data (Constr 1 [])) in let leaf#23 : @delay int = delay (trace "fallback" in error) in let projection#24 : pair int (list Data) = unConstrData match#15 in case@Pair projection#24 of @@ -63,20 +61,18 @@ case@Pair projection#24 of 3 -> force leaf#23 --- optimized UPLC (program 1.1.0 - [(lam builtin_7 - [(lam anf_1 - [(lam match_2 - [(lam leaf_3 - [(lam projection_4 - (case - projection_4 - (lam tag_5 - (lam fields_6 - (case tag_5 (con integer 1) (force leaf_3) (force leaf_3) (force leaf_3)))))) - [(builtin unConstrData) match_2]]) - (delay (force [[builtin_7 (con string "fallback")] (delay (error))]))]) - (force [[builtin_7 (con string "subject")] (delay anf_1)])]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) + [(lam builtin_6 + [(lam match_1 + [(lam leaf_2 + [(lam projection_3 + (case + projection_3 + (lam tag_4 + (lam fields_5 + (case tag_4 (con integer 1) (force leaf_2) (force leaf_2) (force leaf_2)))))) + [(builtin unConstrData) match_1]]) + (delay (force [[builtin_6 (con string "fallback")] (delay (error))]))]) + (force [[builtin_6 (con string "subject")] (delay (con data (Constr 1 [])))])]) (force (builtin trace))]) --- result error: ExplicitErrorTerm diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_helper_receives_bound_values.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_helper_receives_bound_values.snap index b950b5fe..7b6c73ff 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_helper_receives_bound_values.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_shared_helper_receives_bound_values.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | Zero | One Int | Two Int Int\nchoose : (Choice, int) -> int\nchoose subject =\n case trace \"subject\" subject of\n (Stop, _) -> 0\n (_, value) -> trace \"shared\" value\nmain = (choose (Stop, 1), choose (Zero, 11), choose (One 2, 22), choose (Two 3 4, 33))\n" --- --- unoptimized Core @@ -98,11 +97,9 @@ case@Tag match#22 of 2 -> leaf#24 field#33 3 -> leaf#24 field#33 in let fromInt#41 : int -> Int = iData in -let anf#48 : Main.Choice = constrData 0 (con (list data) []) in -let anf#50 : (Main.Choice, int) = constr 0 anf#48 1 in +let anf#50 : (Main.Choice, int) = constr 0 (con data (Constr 0 [])) 1 in let anf#51 : int = choose#40 anf#50 in -let anf#52 : Main.Choice = constrData 1 (con (list data) []) in -let anf#54 : (Main.Choice, int) = constr 0 anf#52 11 in +let anf#54 : (Main.Choice, int) = constr 0 (con data (Constr 1 [])) 11 in let anf#55 : int = choose#40 anf#54 in let anf#57 : Int = fromInt#41 2 in let anf#56 : list Data = mkCons anf#57 (con (list data) []) in @@ -119,8 +116,8 @@ let anf#70 : int = choose#40 anf#69 in constr 0 anf#51 anf#55 anf#61 anf#70 --- optimized UPLC (program 1.1.0 - [(lam builtin_39 - [(lam builtin_40 + [(lam builtin_32 + [(lam builtin_33 [(lam choose_10 [(lam fromInt_11 [(lam anf_12 @@ -138,26 +135,22 @@ constr 0 anf#51 anf#55 anf#61 anf#70 [(lam anf_28 [(lam anf_29 [(lam anf_30 - [(lam anf_31 - [(lam anf_37 - [(lam anf_38 (constr 0 anf_14 anf_17 anf_26 anf_38)) [choose_10 anf_37]]) - (constr 0 anf_31 (con integer 33))]) - [[(builtin constrData) (con integer 3)] anf_30]]) - [[builtin_39 anf_27] anf_29]]) - [[builtin_39 anf_28] (con (list data) [])]]) - [fromInt_11 (con integer 4)]]) - [fromInt_11 (con integer 3)]]) - [choose_10 anf_25]]) - (constr 0 anf_21 (con integer 22))]) - [[(builtin constrData) (con integer 2)] anf_20]]) - [[builtin_39 anf_19] (con (list data) [])]]) - [fromInt_11 (con integer 2)]]) - [choose_10 anf_16]]) - (constr 0 anf_15 (con integer 11))]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) - [choose_10 anf_13]]) - (constr 0 anf_12 (con integer 1))]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) + [(lam anf_31 (constr 0 anf_13 anf_15 anf_21 anf_31)) [choose_10 anf_30]]) + (constr 0 anf_29 (con integer 33))]) + [[(builtin constrData) (con integer 3)] anf_28]]) + [[builtin_32 anf_25] anf_27]]) + [[builtin_32 anf_26] (con (list data) [])]]) + [fromInt_11 (con integer 4)]]) + [fromInt_11 (con integer 3)]]) + [choose_10 anf_20]]) + (constr 0 anf_19 (con integer 22))]) + [[(builtin constrData) (con integer 2)] anf_17]]) + [[builtin_32 anf_16] (con (list data) [])]]) + [fromInt_11 (con integer 2)]]) + [choose_10 anf_14]]) + (constr 0 (con data (Constr 1 [])) (con integer 11))]) + [choose_10 anf_12]]) + (constr 0 (con data (Constr 0 [])) (con integer 1))]) (builtin iData)]) (lam subject_1 [(lam match_2 @@ -173,8 +166,8 @@ constr 0 anf#51 anf#55 anf#61 anf#70 (lam fields_9 (case tag_8 (con integer 0) [leaf_4 field_6] [leaf_4 field_6] [leaf_4 field_6]))))) [(builtin unConstrData) field_5]])))) - (lam value_3 (force [[builtin_40 (con string "shared")] (delay value_3)]))]) - (force [[builtin_40 (con string "subject")] (delay subject_1)])])]) + (lam value_3 (force [[builtin_33 (con string "shared")] (delay value_3)]))]) + (force [[builtin_33 (con string "subject")] (delay subject_1)])])]) (force (builtin trace))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_unknown_tag_fails_dispatch.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_unknown_tag_fails_dispatch.snap index 26ced3e1..85146f6b 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_unknown_tag_fails_dispatch.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__big_wildcard_unknown_tag_fails_dispatch.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype Choice = Stop | Zero | One Int | Two Int Int\nchoose : Choice -> int\nchoose subject =\n case trace \"subject\" subject of\n Stop -> trace \"explicit\" 1\n _ -> trace \"fallback\" 9\nmain = choose (coerce (constrData 59 []))\n" --- --- unoptimized Core @@ -60,8 +59,7 @@ main#1 (con string "fallback")]) (con string "subject")]) --- optimized Core -let anf#37 : Data = constrData 59 (con (list data) []) in -let match#25 : Main.Choice = trace "subject" in anf#37 in +let match#25 : Main.Choice = trace "subject" in (con data (Constr 59 [])) in let leaf#26 : @delay int = delay (trace "fallback" in 9) in let projection#27 : pair int (list Data) = unConstrData match#25 in case@Pair projection#27 of @@ -72,25 +70,23 @@ case@Pair projection#27 of 3 -> force leaf#26 --- optimized UPLC (program 1.1.0 - [(lam builtin_7 - [(lam anf_1 - [(lam match_2 - [(lam leaf_3 - [(lam projection_4 - (case - projection_4 - (lam tag_5 - (lam fields_6 - (case - tag_5 - (force [[builtin_7 (con string "explicit")] (delay (con integer 1))]) - (force leaf_3) - (force leaf_3) - (force leaf_3)))))) - [(builtin unConstrData) match_2]]) - (delay (force [[builtin_7 (con string "fallback")] (delay (con integer 9))]))]) - (force [[builtin_7 (con string "subject")] (delay anf_1)])]) - [[(builtin constrData) (con integer 59)] (con (list data) [])]]) + [(lam builtin_6 + [(lam match_1 + [(lam leaf_2 + [(lam projection_3 + (case + projection_3 + (lam tag_4 + (lam fields_5 + (case + tag_4 + (force [[builtin_6 (con string "explicit")] (delay (con integer 1))]) + (force leaf_2) + (force leaf_2) + (force leaf_2)))))) + [(builtin unConstrData) match_1]]) + (delay (force [[builtin_6 (con string "fallback")] (delay (con integer 9))]))]) + (force [[builtin_6 (con string "subject")] (delay (con data (Constr 59 [])))])]) (force (builtin trace))]) --- result error: NonConstrScrutinized(Con(Integer(59))) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__cached_drop_does_not_suppress_tail_failure.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__cached_drop_does_not_suppress_tail_failure.snap index badbaf2f..dc62a70a 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__cached_drop_does_not_suppress_tail_failure.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__cached_drop_does_not_suppress_tail_failure.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 1525 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nselect : list int -> bool\nselect xs =\n let\n dropped = Builtin.dropList 1 xs\n in\n if Builtin.nullList dropped then\n Builtin.nullList (Builtin.tailList xs)\n else False\nmain = select []\n" --- --- unoptimized Core @@ -29,29 +28,14 @@ main#1 (lam value_8 value_8)]) (lam value_7 value_7)]) --- optimized Core -let xs#14 : list int = (con (list integer) []) in -let dropped#15 : list int = dropList 1 xs#14 in -let anf#20 : bool = nullList dropped#15 in -case@Bool anf#20 of - True -> let projection#16 : list int = tailList xs#14 in - nullList projection#16 - False -> false +let projection#16 : list int = tailList (con (list integer) []) in +nullList projection#16 --- optimized UPLC (program 1.1.0 - [(lam builtin_5 - [(lam builtin_6 - [(lam builtin_7 - [(lam xs_1 - [(lam dropped_2 - [(lam anf_3 - (case - anf_3 - (con bool False) - [(lam projection_4 [builtin_5 projection_4]) [builtin_6 xs_1]])) - [builtin_5 dropped_2]]) - [[builtin_7 (con integer 1)] xs_1]]) - (con (list integer) [])]) - (force (builtin dropList))]) + [(lam builtin_2 + [(lam builtin_3 + [(lam projection_1 [builtin_2 projection_1]) + [builtin_3 (con (list integer) [])]]) (force (builtin tailList))]) (force (builtin nullList))]) --- result diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__constructor_pattern_tail_reused_by_field_access.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__constructor_pattern_tail_reused_by_field_access.snap index dd12aa51..9ea3ed60 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__constructor_pattern_tail_reused_by_field_access.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__constructor_pattern_tail_reused_by_field_access.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 1493 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\ntype Record = Record { a : Int, b : Int, c : Int, d : Int }\nselect : Record -> int\nselect r =\n case r of\n Record { b } -> Builtin.addInteger (Builtin.unIData b) (Builtin.unIData r.c)\nmain = select (Record { a = 1, b = 2, c = 3, d = 4 })\n" --- --- unoptimized Core @@ -76,16 +75,12 @@ let anf#44 : list Data = mkCons anf#48 anf#43 in let anf#45 : list Data = mkCons anf#46 anf#44 in let anf#53 : Main.Record = constrData 0 anf#45 in let projection#15 : pair int (list Data) = unConstrData anf#53 in -case@Pair projection#15 of - Pair tag#17 fields#18 -> case@List fields#18 of - Cons ignored#26 fieldTail#27 -> case@List fieldTail#27 of - Cons field#28 fieldTail#29 -> let evaluated#31 : int = unIData field#28 in - case@List fieldTail#29 of - Cons head#32 tail#33 -> let anf#41 : int = unIData head#32 in - addInteger evaluated#31 anf#41 +let evaluated#31 : int = unIData anf#48 in +let anf#41 : int = unIData anf#50 in +addInteger evaluated#31 anf#41 --- optimized UPLC (program 1.1.0 - [(lam builtin_25 + [(lam builtin_14 [(lam fromInt_1 [(lam anf_2 [(lam anf_3 @@ -97,35 +92,16 @@ case@Pair projection#15 of [(lam anf_9 [(lam anf_10 [(lam projection_11 - (case - projection_11 - (lam tag_12 - (lam fields_13 - (case - fields_13 - (lam ignored_14 - (lam fieldTail_16 - (case - fieldTail_16 - (lam field_19 - (lam fieldTail_20 - [(lam evaluated_21 - (case - fieldTail_20 - (lam head_22 - (lam tail_23 - [(lam anf_24 [[(builtin addInteger) evaluated_21] anf_24]) - [(builtin unIData) head_22]])) - (error))) - [(builtin unIData) field_19]])) - (error)))) - (error)))))) + [(lam evaluated_12 + [(lam anf_13 [[(builtin addInteger) evaluated_12] anf_13]) + [(builtin unIData) anf_4]]) + [(builtin unIData) anf_3]]) [(builtin unConstrData) anf_10]]) [[(builtin constrData) (con integer 0)] anf_9]]) - [[builtin_25 anf_2] anf_8]]) - [[builtin_25 anf_3] anf_7]]) - [[builtin_25 anf_4] anf_6]]) - [[builtin_25 anf_5] (con (list data) [])]]) + [[builtin_14 anf_2] anf_8]]) + [[builtin_14 anf_3] anf_7]]) + [[builtin_14 anf_4] anf_6]]) + [[builtin_14 anf_5] (con (list data) [])]]) [fromInt_1 (con integer 4)]]) [fromInt_1 (con integer 3)]]) [fromInt_1 (con integer 2)]]) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__empty_lists_key_the_native_element_layout_and_erase_big_nominal_names.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__empty_lists_key_the_native_element_layout_and_erase_big_nominal_names.snap index ceea2e72..5a93302e 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__empty_lists_key_the_native_element_layout_and_erase_big_nominal_names.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__empty_lists_key_the_native_element_layout_and_erase_big_nominal_names.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 754 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nempty _ = []\nints : unit -> list int\nints = empty\nbigInts : unit -> list Int\nbigInts = empty\nbigBytes : unit -> list Bytes\nbigBytes = empty\nmain = (ints (), bigInts (), bigBytes ())\n" --- --- unoptimized Core @@ -34,15 +33,14 @@ main#1 empty_6]) (lam arg_9 [(lam match_10 (con (list integer) [])) arg_9])]) --- optimized Core -let empty#21 : 'erased -> list Data = \arg#19 : 'erased -> (con (list data) []) in -let anf#28 : list Int = empty#21 () in -let anf#30 : list Bytes = empty#21 () in +let empty#21 : @delay (list Data) = delay (con (list data) []) in +let anf#28 : list Int = force empty#21 in +let anf#30 : list Bytes = force empty#21 in constr 0 (con (list integer) []) anf#28 anf#30 --- optimized UPLC (program 1.1.0 - [(lam empty_2 - [(lam anf_3 - [(lam anf_4 (constr 0 (con (list integer) []) anf_3 anf_4)) - [empty_2 (con unit ())]]) - [empty_2 (con unit ())]]) - (lam arg_1 (con (list data) []))]) + [(lam empty_1 + [(lam anf_2 + [(lam anf_3 (constr 0 (con (list integer) []) anf_2 anf_3)) (force empty_1)]) + (force empty_1)]) + (delay (con (list data) []))]) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__explicit_drops_preserve_saturation_after_cached_tail.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__explicit_drops_preserve_saturation_after_cached_tail.snap index 1c009d45..3cf28596 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__explicit_drops_preserve_saturation_after_cached_tail.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__explicit_drops_preserve_saturation_after_cached_tail.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 1508 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nselect : list int -> bool\nselect xs =\n let\n first = Builtin.dropList 2 xs\n second = Builtin.dropList 3 xs\n in\n if Builtin.nullList first then Builtin.nullList second else False\nmain = select [1]\n" --- --- unoptimized Core @@ -33,29 +32,9 @@ main#1 (lam value_9 value_9)]) (lam value_8 value_8)]) --- optimized Core -let anf#23 : list int = mkCons 1 (con (list integer) []) in -let second#15 : list int = dropList 3 anf#23 in -let first#16 : list int = dropList 2 anf#23 in -let anf#21 : bool = nullList first#16 in -case@Bool anf#21 of - True -> nullList second#15 - False -> false +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_5 - [(lam builtin_6 - [(lam builtin_7 - [(lam anf_1 - [(lam second_2 - [(lam first_3 - [(lam anf_4 (case anf_4 (con bool False) [builtin_5 second_2])) - [builtin_5 first_3]]) - [[builtin_6 (con integer 2)] anf_1]]) - [[builtin_6 (con integer 3)] anf_1]]) - [[builtin_7 (con integer 1)] (con (list integer) [])]]) - (force (builtin mkCons))]) - (force (builtin dropList))]) - (force (builtin nullList))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__generic_impl_context_default_and_superclass_evidence_are_closed.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__generic_impl_context_default_and_superclass_evidence_are_closed.snap index bafa6d5f..44d9e996 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__generic_impl_context_default_and_superclass_evidence_are_closed.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__generic_impl_context_default_and_superclass_evidence_are_closed.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\ntrait Eq 'a => Same 'a where\n same : 'a -> 'a -> bool\n same x y = eq x y\nimpl Same int where\nimpl Eq (list 'a) => Same (list 'a) where\nuse : Same 'a => 'a -> 'a -> bool\nuse x y = if same x y then neq x y else True\nmain = use [1, 2] [1, 3]\n" --- --- unoptimized Core @@ -109,10 +108,8 @@ letrec True -> eq#38 field#46 field#51 False -> false in -let anf#75 : list int = mkCons 2 (con (list integer) []) in -let anf#76 : list int = mkCons 1 anf#75 in -let anf#80 : list int = mkCons 3 (con (list integer) []) in -let anf#81 : list int = mkCons 1 anf#80 in +let anf#76 : list int = (con (list integer) [1, 2]) in +let anf#81 : list int = (con (list integer) [1, 3]) in let anf#72 : bool = eq#38 anf#76 anf#81 in case@Bool anf#72 of True -> let anf#71 : bool = eq#38 anf#76 anf#81 in @@ -122,43 +119,35 @@ case@Bool anf#72 of False -> true --- optimized UPLC (program 1.1.0 - [(lam builtin_22 - [(lam partial_23 - [(lam eq_15 - [(lam anf_16 - [(lam anf_17 - [(lam anf_18 - [(lam anf_19 - [(lam anf_20 + [(lam eq_15 + [(lam anf_16 + [(lam anf_17 + [(lam anf_18 + (case + anf_18 + (con bool True) + [(lam anf_19 (case anf_19 (con bool True) (con bool False))) + [[eq_15 anf_16] anf_17]])) + [[eq_15 anf_16] anf_17]]) + (con (list integer) [1, 3])]) + (con (list integer) [1, 2])]) + [(lam self_4 [self_4 self_4]) + (lam self_5 + (lam xs_6 + (lam ys_7 + (case + xs_6 + (lam field_10 + (lam field_11 (case - anf_20 - (con bool True) - [(lam anf_21 (case anf_21 (con bool True) (con bool False))) - [[eq_15 anf_17] anf_19]])) - [[eq_15 anf_17] anf_19]]) - [partial_23 anf_18]]) - [[builtin_22 (con integer 3)] (con (list integer) [])]]) - [partial_23 anf_16]]) - [[builtin_22 (con integer 2)] (con (list integer) [])]]) - [(lam self_4 [self_4 self_4]) - (lam self_5 - (lam xs_6 - (lam ys_7 - (case - xs_6 - (lam field_10 - (lam field_11 - (case - ys_7 - (lam field_12 - (lam field_13 - [(lam anf_14 - (case anf_14 (con bool False) [[[self_5 self_5] field_11] field_13])) - [[(builtin equalsInteger) field_10] field_12]])) - (con bool False)))) - (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) - [builtin_22 (con integer 1)]]) - (force (builtin mkCons))]) + ys_7 + (lam field_12 + (lam field_13 + [(lam anf_14 + (case anf_14 (con bool False) (case (constr 0 self_5 field_11 field_13) self_5))) + [[(builtin equalsInteger) field_10] field_12]])) + (con bool False)))) + (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__implementation_method_only_type_variables_match_by_type.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__implementation_method_only_type_variables_match_by_type.snap index 021c3b0e..7e9b1bdc 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__implementation_method_only_type_variables_match_by_type.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__implementation_method_only_type_variables_match_by_type.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntrait Keep 'a where\n keep : 'a -> 'b -> 'b\nimpl Keep (list 'b) where\n keep _ value = value\nmain : bool\nmain = keep [()] True\n" --- --- unoptimized Core @@ -23,13 +22,9 @@ main#1 (lam value_8 value_8)]) (lam arg_5 (lam value_6 [(lam match_7 value_6) arg_5]))]) --- optimized Core -let anf#20 : list unit = mkCons () (con (list unit) []) in true --- optimized UPLC -(program 1.1.0 - [(lam builtin_2 - [(lam anf_1 (con bool True)) [[builtin_2 (con unit ())] (con (list unit) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__list_eq_generic_big_and_little.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__list_eq_generic_big_and_little.snap index a45a7dde..f3680e8e 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__list_eq_generic_big_and_little.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__list_eq_generic_big_and_little.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Eq exposing (..)\nsame : Eq (list 'a) => list 'a -> list 'a -> bool\nsame xs ys = eq xs ys\nbig : list Int\nbig = [1, 2]\nsmall : list int\nsmall = [1, 2]\nmain = if same big big then same small small else False\n" --- --- unoptimized Core @@ -119,8 +118,7 @@ letrec True -> eq#46 field#54 field#59 False -> false in -let anf#77 : list int = mkCons 2 (con (list integer) []) in -let small#67 : list int = mkCons 1 anf#77 in +let small#67 : list int = (con (list integer) [1, 2]) in let anf#69 : List 'erased = listData big#44 in let anf#70 : List 'erased = listData big#44 in let anf#78 : bool = equalsData anf#69 anf#70 in @@ -129,23 +127,21 @@ case@Bool anf#78 of False -> false --- optimized UPLC (program 1.1.0 - [(lam builtin_26 + [(lam builtin_25 [(lam fromInt_4 [(lam anf_5 [(lam anf_6 [(lam anf_7 [(lam big_8 [(lam eq_20 - [(lam anf_21 - [(lam small_22 + [(lam small_21 + [(lam anf_22 [(lam anf_23 - [(lam anf_24 - [(lam anf_25 (case anf_25 (con bool False) [[eq_20 small_22] small_22])) - [[(builtin equalsData) anf_23] anf_24]]) - [(builtin listData) big_8]]) + [(lam anf_24 (case anf_24 (con bool False) [[eq_20 small_21] small_21])) + [[(builtin equalsData) anf_22] anf_23]]) [(builtin listData) big_8]]) - [[builtin_26 (con integer 1)] anf_21]]) - [[builtin_26 (con integer 2)] (con (list integer) [])]]) + [(builtin listData) big_8]]) + (con (list integer) [1, 2])]) [(lam self_9 [self_9 self_9]) (lam self_10 (lam xs_11 @@ -159,12 +155,15 @@ case@Bool anf#78 of (lam field_17 (lam field_18 [(lam anf_19 - (case anf_19 (con bool False) [[[self_10 self_10] field_16] field_18])) + (case + anf_19 + (con bool False) + (case (constr 0 self_10 field_16 field_18) self_10))) [[(builtin equalsInteger) field_15] field_17]])) (con bool False)))) (case ys_12 (lam field_13 (lam field_14 (con bool False))) (con bool True))))))]]) - [[builtin_26 anf_5] anf_7]]) - [[builtin_26 anf_6] (con (list data) [])]]) + [[builtin_25 anf_5] anf_7]]) + [[builtin_25 anf_6] (con (list data) [])]]) [fromInt_4 (con integer 2)]]) [fromInt_4 (con integer 1)]]) (builtin iData)]) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__list_eq_little_preserves_custom_eq_and_short_circuit.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__list_eq_little_preserves_custom_eq_and_short_circuit.snap index 7de940a0..e5040859 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__list_eq_little_preserves_custom_eq_and_short_circuit.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__list_eq_little_preserves_custom_eq_and_short_circuit.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 1854 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Literal exposing (..)\nimport Eq exposing (..)\nvalues : list int\nvalues = [1, 2]\nmain = eq values values\n" --- --- unoptimized Core @@ -105,37 +104,31 @@ letrec True -> eq#41 field#49 field#54 False -> false in -let anf#65 : list int = mkCons 2 (con (list integer) []) in -let values#59 : list int = mkCons 1 anf#65 in +let values#59 : list int = (con (list integer) [1, 2]) in eq#41 values#59 values#59 --- optimized UPLC (program 1.1.0 - [(lam builtin_18 - [(lam builtin_19 - [(lam eq_15 - [(lam anf_16 - [(lam values_17 [[eq_15 values_17] values_17]) - [[builtin_18 (con integer 1)] anf_16]]) - [[builtin_18 (con integer 2)] (con (list integer) [])]]) - [(lam self_4 [self_4 self_4]) - (lam self_5 - (lam xs_6 - (lam ys_7 - (case - xs_6 - (lam field_10 - (lam field_11 - (case - ys_7 - (lam field_12 - (lam field_13 - [(lam anf_14 - (case anf_14 (con bool False) [[[self_5 self_5] field_11] field_13])) - (force [[builtin_19 (con string "custom")] (delay (con bool False))])])) - (con bool False)))) - (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) - (force (builtin trace))]) - (force (builtin mkCons))]) + [(lam builtin_17 + [(lam eq_15 + [(lam values_16 [[eq_15 values_16] values_16]) (con (list integer) [1, 2])]) + [(lam self_4 [self_4 self_4]) + (lam self_5 + (lam xs_6 + (lam ys_7 + (case + xs_6 + (lam field_10 + (lam field_11 + (case + ys_7 + (lam field_12 + (lam field_13 + [(lam anf_14 + (case anf_14 (con bool False) (case (constr 0 self_5 field_11 field_13) self_5))) + (force [[builtin_17 (con string "custom")] (delay (con bool False))])])) + (con bool False)))) + (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) + (force (builtin trace))]) --- result (con bool False) --- logs diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__little_constructor_record_accesses_each_field.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__little_constructor_record_accesses_each_field.snap index 4c900e8e..c5a6768d 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__little_constructor_record_accesses_each_field.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__little_constructor_record_accesses_each_field.snap @@ -46,12 +46,9 @@ main#1 (lam value_10 value_10)]) (lam value_9 value_9)]) --- optimized Core -let anf#34 : int = lengthOfByteString (con bytestring #aabb) in -addInteger 42 anf#34 +44 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [[(builtin addInteger) (con integer 42)] anf_1]) - [(builtin lengthOfByteString) (con bytestring #aabb)]]) +(program 1.1.0 (con integer 44)) --- result (con integer 44) --- logs diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__map_eq_big_and_native_preserve_entry_order.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__map_eq_big_and_native_preserve_entry_order.snap index 01c9eb0b..d558488f 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__map_eq_big_and_native_preserve_entry_order.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__map_eq_big_and_native_preserve_entry_order.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Eq exposing (..)\nentries : list (pair Int Int)\nentries = [Builtin.mkPairData 1 2, Builtin.mkPairData 1 3]\nreversed : list (pair Int Int)\nreversed = [Builtin.mkPairData 1 3, Builtin.mkPairData 1 2]\nmain =\n ( eq (Builtin.mapData entries) (Builtin.mapData entries)\n , eq (Builtin.mapData entries) (Builtin.mapData reversed)\n , eq entries entries\n , eq entries reversed\n )\n" --- --- unoptimized Core @@ -244,7 +243,10 @@ constr 0 anf#105 anf#108 anf#109 anf#110 (lam field_29 (lam field_30 [(lam anf_36 - (case anf_36 (con bool False) [[[self_22 self_22] field_28] field_30])) + (case + anf_36 + (con bool False) + (case (constr 0 self_22 field_28 field_30) self_22))) (case field_27 (lam field_31 diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__map_eq_little_preserves_custom_eq_and_short_circuit.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__map_eq_little_preserves_custom_eq_and_short_circuit.snap index f3f4683d..b609ccc9 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__map_eq_little_preserves_custom_eq_and_short_circuit.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__map_eq_little_preserves_custom_eq_and_short_circuit.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 2007 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Literal exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nvalues : map int (list Data)\nvalues = [Builtin.unConstrData (Builtin.constrData 1 []), Builtin.unConstrData (Builtin.constrData 2 [])]\nmain = eq values values\n" --- --- unoptimized Core @@ -194,65 +193,48 @@ letrec True -> eq#95 field#103 field#108 False -> false in -let evaluated#115 : Data = constrData 1 (con (list data) []) in -let projection#116 : pair int (list Data) = unConstrData evaluated#115 in -let evaluated#117 : Data = constrData 2 (con (list data) []) in -let projection#118 : pair int (list Data) = unConstrData evaluated#117 in -let anf#128 : list (pair int (list Data)) = mkCons projection#118 (con (list (pair integer (list data))) []) in -let values#119 : list (pair int (list Data)) = mkCons projection#116 anf#128 in +let values#119 : list (pair int (list Data)) = (con (list (pair integer (list data))) [(1, []), (2, [])]) in eq#95 values#119 values#119 --- optimized UPLC (program 1.1.0 - [(lam builtin_29 - [(lam builtin_30 - [(lam eq_22 - [(lam evaluated_23 - [(lam projection_24 - [(lam evaluated_25 - [(lam projection_26 - [(lam anf_27 - [(lam values_28 [[eq_22 values_28] values_28]) - [[builtin_29 projection_24] anf_27]]) - [[builtin_29 projection_26] (con (list (pair integer (list data))) [])]]) - [(builtin unConstrData) evaluated_25]]) - [[(builtin constrData) (con integer 2)] (con (list data) [])]]) - [(builtin unConstrData) evaluated_23]]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) - [(lam self_4 [self_4 self_4]) - (lam self_5 - (lam xs_6 - (lam ys_7 - (case - xs_6 - (lam field_10 - (lam field_11 - (case - ys_7 - (lam field_12 - (lam field_13 - [(lam anf_21 - (case anf_21 (con bool False) [[[self_5 self_5] field_11] field_13])) - (case - field_10 - (lam field_14 - (lam field_15 - (case - field_12 - (lam field_16 - (lam field_17 - [(lam anf_18 - (case - anf_18 - (con bool False) - [(lam anf_19 - [(lam anf_20 [[(builtin equalsData) anf_19] anf_20]) - [(builtin listData) field_17]]) - [(builtin listData) field_15]])) - (force [[builtin_30 (con string "custom")] (delay (con bool False))])]))))))])) - (con bool False)))) - (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) - (force (builtin trace))]) - (force (builtin mkCons))]) + [(lam builtin_24 + [(lam eq_22 + [(lam values_23 [[eq_22 values_23] values_23]) + (con (list (pair integer (list data))) [(1, []), (2, [])])]) + [(lam self_4 [self_4 self_4]) + (lam self_5 + (lam xs_6 + (lam ys_7 + (case + xs_6 + (lam field_10 + (lam field_11 + (case + ys_7 + (lam field_12 + (lam field_13 + [(lam anf_21 + (case anf_21 (con bool False) (case (constr 0 self_5 field_11 field_13) self_5))) + (case + field_10 + (lam field_14 + (lam field_15 + (case + field_12 + (lam field_16 + (lam field_17 + [(lam anf_18 + (case + anf_18 + (con bool False) + [(lam anf_19 + [(lam anf_20 [[(builtin equalsData) anf_19] anf_20]) + [(builtin listData) field_17]]) + [(builtin listData) field_15]])) + (force [[builtin_24 (con string "custom")] (delay (con bool False))])]))))))])) + (con bool False)))) + (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) + (force (builtin trace))]) --- result (con bool False) --- logs diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__method_context_follows_the_renamed_method_only_variable.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__method_context_follows_the_renamed_method_only_variable.snap index 575f606b..50a51e9b 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__method_context_follows_the_renamed_method_only_variable.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__method_context_follows_the_renamed_method_only_variable.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\ntrait Keep 'a where\n keep : Eq 'b => 'a -> 'b -> bool\nimpl Keep (list 'b) where\n keep _ x = eq x x\nmain = keep [()] 42\n" --- --- unoptimized Core @@ -26,14 +25,9 @@ main#1 (lam arg_5 (lam x_6 [(lam match_8 [[eq_7 x_6] x_6]) arg_5]))]) (builtin equalsInteger)]) --- optimized Core -let anf#22 : list unit = mkCons () (con (list unit) []) in equalsInteger 42 42 --- optimized UPLC -(program 1.1.0 - [(lam builtin_2 - [(lam anf_1 [[(builtin equalsInteger) (con integer 42)] (con integer 42)]) - [[builtin_2 (con unit ())] (con (list unit) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 [[(builtin equalsInteger) (con integer 42)] (con integer 42)]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__native_case_dispatches_lists_data_and_sparse_literals.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__native_case_dispatches_lists_data_and_sparse_literals.snap index be37b2ee..b361de98 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__native_case_dispatches_lists_data_and_sparse_literals.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__native_case_dispatches_lists_data_and_sparse_literals.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 1393 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nfirst : list int -> int\nfirst xs =\n case xs of\n [] -> Builtin.subtractInteger 0 1\n x :: _ -> x\ndecode : Data -> int\ndecode data =\n case data of\n I n -> n\n _ -> Builtin.subtractInteger 0 2\nselect : int -> int\nselect n =\n case n of\n 7 -> 10\n 100 -> 20\n _ -> 30\nmain = (first [], first [42], decode (I 9), decode (B #\"\"), select 7, select 100, select (Builtin.subtractInteger 0 7))\n" --- --- unoptimized Core @@ -90,9 +89,9 @@ main#1 (lam value_14 value_14)]) --- optimized Core let first#37 : list int -> int = \xs#20 : list int -> case@List xs#20 of - Nil -> subtractInteger 0 1 + Nil -> -1 Cons field#22 field#35 -> field#22 in -let decode#47 : Data -> int = \data#38 : Data -> let leaf#40 : @delay int = delay (subtractInteger 0 2) in +let decode#47 : Data -> int = \data#38 : Data -> let leaf#40 : @delay int = delay -2 in case@Data data#38 of DataConstr field#41 -> force leaf#40 DataMap field#42 -> force leaf#40 @@ -110,76 +109,64 @@ case@Bool anf#65 of True -> 20 False -> 30 in let anf#69 : int = first#37 (con (list integer) []) in -let anf#71 : list int = mkCons 42 (con (list integer) []) in -let anf#72 : int = first#37 anf#71 in -let anf#74 : Data = iData 9 in -let anf#75 : int = decode#47 anf#74 in -let anf#77 : Data = bData (con bytestring #) in -let anf#78 : int = decode#47 anf#77 in +let anf#72 : int = first#37 (con (list integer) [42]) in +let anf#75 : int = decode#47 (con data (I 9)) in +let anf#78 : int = decode#47 (con data (B #)) in let anf#80 : int = select#55 7 in let anf#82 : int = select#55 100 in -let anf#85 : int = subtractInteger 0 7 in -let anf#86 : int = select#55 anf#85 in +let anf#86 : int = select#55 -7 in constr 0 anf#69 anf#72 anf#75 anf#78 anf#80 anf#82 anf#86 --- optimized UPLC (program 1.1.0 - [(lam builtin_33 - [(lam builtin_35 - [(lam partial_36 - [(lam first_4 - [(lam decode_12 - [(lam eq_13 - [(lam select_19 - [(lam anf_21 - [(lam anf_23 - [(lam anf_24 - [(lam anf_25 - [(lam anf_26 - [(lam anf_27 - [(lam anf_28 - [(lam anf_29 - [(lam anf_30 - [(lam anf_31 - [(lam anf_32 (constr 0 anf_21 anf_24 anf_26 anf_28 anf_29 anf_30 anf_32)) - [select_19 anf_31]]) - [partial_36 (con integer 7)]]) - [select_19 (con integer 100)]]) - [select_19 (con integer 7)]]) - [decode_12 anf_27]]) - [(builtin bData) (con bytestring #)]]) - [decode_12 anf_25]]) - [(builtin iData) (con integer 9)]]) - [first_4 anf_23]]) - [[builtin_33 (con integer 42)] (con (list integer) [])]]) - [first_4 (con (list integer) [])]]) - (lam n_14 - [(lam anf_15 - [(lam anf_16 - (case - anf_16 - [(lam anf_17 - [(lam anf_18 (case anf_18 (con integer 30) (con integer 20))) - [anf_17 (con integer 100)]]) - [eq_13 n_14]] - (con integer 10))) - [anf_15 (con integer 7)]]) - [eq_13 n_14]])]) - (builtin equalsInteger)]) - (lam data_5 - [(lam leaf_6 - [(lam generated_34 - (force - [[[[[[builtin_35 generated_34] (delay (force leaf_6))] (delay (force leaf_6))] - (delay (force leaf_6))] - (delay [(lam field_10 field_10) [(builtin unIData) generated_34]])] - (delay (force leaf_6))])) - data_5]) - (delay [partial_36 (con integer 2)])])]) - (lam xs_1 - (case xs_1 (lam field_2 (lam field_3 field_2)) [partial_36 (con integer 1)]))]) - [(builtin subtractInteger) (con integer 0)]]) - (force (builtin chooseData))]) - (force (builtin mkCons))]) + [(lam builtin_30 + [(lam first_4 + [(lam decode_12 + [(lam eq_13 + [(lam select_19 + [(lam anf_21 + [(lam anf_23 + [(lam anf_24 + [(lam anf_25 + [(lam anf_26 + [(lam anf_27 + [(lam anf_28 (constr 0 anf_21 anf_23 anf_24 anf_25 anf_26 anf_27 anf_28)) + [select_19 (con integer -7)]]) + [select_19 (con integer 100)]]) + [select_19 (con integer 7)]]) + [decode_12 (con data (B #))]]) + [decode_12 (con data (I 9))]]) + [first_4 (con (list integer) [42])]]) + [first_4 (con (list integer) [])]]) + (lam n_14 + [(lam anf_15 + [(lam anf_16 + (case + anf_16 + [(lam anf_17 + [(lam anf_18 (case anf_18 (con integer 30) (con integer 20))) + [anf_17 (con integer 100)]]) + [eq_13 n_14]] + (con integer 10))) + [anf_15 (con integer 7)]]) + [eq_13 n_14]])]) + (builtin equalsInteger)]) + (lam data_5 + [(lam leaf_6 + [(lam generated_29 + (force + (case + (constr 0 + generated_29 + (delay (force leaf_6)) + (delay (force leaf_6)) + (delay (force leaf_6)) + (delay [(builtin unIData) generated_29]) + (delay (force leaf_6))) + builtin_30))) + data_5]) + (delay (con integer -2))])]) + (lam xs_1 (case xs_1 (lam field_2 (lam field_3 field_2)) (con integer -1)))]) + (force (builtin chooseData))]) --- result (constr 0 (con integer -1) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__native_literal_implementations_and_default_methods_execute.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__native_literal_implementations_and_default_methods_execute.snap index e3bd3787..db8b9f01 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__native_literal_implementations_and_default_methods_execute.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__native_literal_implementations_and_default_methods_execute.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nsame : int -> int -> bool\nsame = eq\nmain = if neq (Builtin.addInteger 20 21) 42 then same 42 42 else False\n" --- --- unoptimized Core @@ -41,28 +40,21 @@ main#1 (lam value_6 value_6)]) --- optimized Core let eq#19 : int -> int -> bool = equalsInteger in -let anf#31 : int = addInteger 20 21 in -let anf#28 : bool = eq#19 anf#31 42 in +let anf#28 : bool = eq#19 41 42 in let anf#34 : bool = case@Bool anf#28 of True -> false False -> true in case@Bool anf#34 of - True -> let anf#36 : int -> bool = eq#19 42 in - anf#36 42 + True -> eq#19 42 42 False -> false --- optimized UPLC (program 1.1.0 [(lam eq_1 [(lam anf_2 [(lam anf_3 - [(lam anf_4 - (case - anf_4 - (con bool False) - [(lam anf_5 [anf_5 (con integer 42)]) [eq_1 (con integer 42)]])) - (case anf_3 (con bool True) (con bool False))]) - [[eq_1 anf_2] (con integer 42)]]) - [[(builtin addInteger) (con integer 20)] (con integer 21)]]) + (case anf_3 (con bool False) [[eq_1 (con integer 42)] (con integer 42)])) + (case anf_2 (con bool True) (con bool False))]) + [[eq_1 (con integer 41)] (con integer 42)]]) (builtin equalsInteger)]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__primitive_map_eq_all_representation_classes.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__primitive_map_eq_all_representation_classes.snap index 5ae2f132..8b76cf82 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__primitive_map_eq_all_representation_classes.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__primitive_map_eq_all_representation_classes.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Eq exposing (..)\nbigBig : map Int Int\nbigBig = [Builtin.mkPairData 1 2]\nbigLittle : map Int int\nbigLittle = []\nlittleBig : map int Int\nlittleBig = []\nlittleLittle : map int (list Data)\nlittleLittle = [Builtin.unConstrData (Builtin.constrData 1 [])]\ndifferent : map int (list Data)\ndifferent = [Builtin.unConstrData (Builtin.constrData 2 [])]\nsame : Eq (map 'k 'v) => map 'k 'v -> map 'k 'v -> bool\nsame = eq\nmain =\n ( same bigBig bigBig\n , same bigLittle bigLittle\n , same littleBig littleBig\n , same littleLittle different\n )\n" --- --- unoptimized Core @@ -501,22 +500,16 @@ letrec True -> eq#259 field#267 field#272 False -> false in -let evaluated#280 : Data = constrData 1 (con (list data) []) in -let projection#281 : pair int (list Data) = unConstrData evaluated#280 in -let littleLittle#282 : list (pair int (list Data)) = mkCons projection#281 (con (list (pair integer (list data))) []) in -let evaluated#283 : Data = constrData 2 (con (list data) []) in -let projection#284 : pair int (list Data) = unConstrData evaluated#283 in -let different#285 : list (pair int (list Data)) = mkCons projection#284 (con (list (pair integer (list data))) []) in let anf#287 : Map 'erased 'erased = mapData bigBig#119 in let anf#288 : Map 'erased 'erased = mapData bigBig#119 in let anf#302 : bool = equalsData anf#287 anf#288 in let anf#303 : bool = eq#174 bigLittle#193 bigLittle#193 in let anf#304 : bool = eq#215 littleBig#234 littleBig#234 in -let anf#305 : bool = eq#259 littleLittle#282 different#285 in +let anf#305 : bool = eq#259 (con (list (pair integer (list data))) [(1, [])]) (con (list (pair integer (list data))) [(2, [])]) in constr 0 anf#302 anf#303 anf#304 anf#305 --- optimized UPLC (program 1.1.0 - [(lam builtin_83 + [(lam builtin_77 [(lam fromInt_10 [(lam anf_11 [(lam anf_12 @@ -528,30 +521,19 @@ constr 0 anf#302 anf#303 anf#304 anf#305 [(lam eq_50 [(lam littleBig_51 [(lam eq_70 - [(lam evaluated_71 - [(lam projection_72 - [(lam littleLittle_73 - [(lam evaluated_74 - [(lam projection_75 - [(lam different_76 - [(lam anf_77 - [(lam anf_78 - [(lam anf_79 - [(lam anf_80 - [(lam anf_81 - [(lam anf_82 (constr 0 anf_79 anf_80 anf_81 anf_82)) - [[eq_70 littleLittle_73] different_76]]) - [[eq_50 littleBig_51] littleBig_51]]) - [[eq_32 bigLittle_33] bigLittle_33]]) - [[(builtin equalsData) anf_77] anf_78]]) - [(builtin mapData) bigBig_14]]) - [(builtin mapData) bigBig_14]]) - [[builtin_83 projection_75] (con (list (pair integer (list data))) [])]]) - [(builtin unConstrData) evaluated_74]]) - [[(builtin constrData) (con integer 2)] (con (list data) [])]]) - [[builtin_83 projection_72] (con (list (pair integer (list data))) [])]]) - [(builtin unConstrData) evaluated_71]]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) + [(lam anf_71 + [(lam anf_72 + [(lam anf_73 + [(lam anf_74 + [(lam anf_75 + [(lam anf_76 (constr 0 anf_73 anf_74 anf_75 anf_76)) + [[eq_70 (con (list (pair integer (list data))) [(1, [])])] + (con (list (pair integer (list data))) [(2, [])])]]) + [[eq_50 littleBig_51] littleBig_51]]) + [[eq_32 bigLittle_33] bigLittle_33]]) + [[(builtin equalsData) anf_71] anf_72]]) + [(builtin mapData) bigBig_14]]) + [(builtin mapData) bigBig_14]]) [(lam self_52 [self_52 self_52]) (lam self_53 (lam xs_54 @@ -565,7 +547,10 @@ constr 0 anf#302 anf#303 anf#304 anf#305 (lam field_60 (lam field_61 [(lam anf_69 - (case anf_69 (con bool False) [[[self_53 self_53] field_59] field_61])) + (case + anf_69 + (con bool False) + (case (constr 0 self_53 field_59 field_61) self_53))) (case field_58 (lam field_62 @@ -599,7 +584,10 @@ constr 0 anf#302 anf#303 anf#304 anf#305 (lam field_42 (lam field_43 [(lam anf_49 - (case anf_49 (con bool False) [[[self_35 self_35] field_41] field_43])) + (case + anf_49 + (con bool False) + (case (constr 0 self_35 field_41 field_43) self_35))) (case field_40 (lam field_44 @@ -627,7 +615,10 @@ constr 0 anf#302 anf#303 anf#304 anf#305 (lam field_24 (lam field_25 [(lam anf_31 - (case anf_31 (con bool False) [[[self_17 self_17] field_23] field_25])) + (case + anf_31 + (con bool False) + (case (constr 0 self_17 field_23 field_25) self_17))) (case field_22 (lam field_26 @@ -641,7 +632,7 @@ constr 0 anf#302 anf#303 anf#304 anf#305 (con bool False)))) (case ys_19 (lam field_20 (lam field_21 (con bool False))) (con bool True))))))]]) (builtin equalsInteger)]) - [[builtin_83 anf_13] (con (list (pair data data)) [])]]) + [[builtin_77 anf_13] (con (list (pair data data)) [])]]) [[(builtin mkPairData) anf_11] anf_12]]) [fromInt_10 (con integer 2)]]) [fromInt_10 (con integer 1)]]) diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_data_encoding_preserves_nominal_constructors.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_data_encoding_preserves_nominal_constructors.snap index 963c8164..722f8839 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_data_encoding_preserves_nominal_constructors.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_data_encoding_preserves_nominal_constructors.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\ntype First = First\ntype Second = Second\nencodeFirst : First -> Data\nencodeFirst value =\n case value of\n First -> Builtin.constrData 0 []\nencodeSecond : Second -> Data\nencodeSecond value =\n case value of\n Second -> Builtin.constrData 1 []\nmain = Builtin.equalsData (encodeFirst First) (encodeSecond Second)\n" --- --- unoptimized Core @@ -30,23 +29,9 @@ main#1 value_4])]) (lam value_9 value_9)]) --- optimized Core -let anf#21 : Main.First = constrData 0 (con (list data) []) in -let anf#22 : Data = constrData 0 (con (list data) []) in -let anf#23 : Main.Second = constrData 0 (con (list data) []) in -let anf#24 : Data = constrData 1 (con (list data) []) in -equalsData anf#22 anf#24 +false --- optimized UPLC -(program 1.1.0 - [(lam partial_5 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 [[(builtin equalsData) anf_2] anf_4]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) - [partial_5 (con (list data) [])]]) - [partial_5 (con (list data) [])]]) - [partial_5 (con (list data) [])]]) - [(builtin constrData) (con integer 0)]]) +(program 1.1.0 (con bool False)) --- result (con bool False) --- logs diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_identity_accepts_a_function_and_overapplication.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_identity_accepts_a_function_and_overapplication.snap index b0482a7e..bbfdfd9e 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_identity_accepts_a_function_and_overapplication.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_identity_accepts_a_function_and_overapplication.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 239 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nidentity value = value\nmain : int\nmain = identity Builtin.addInteger 20 22\n" --- --- unoptimized Core @@ -18,11 +17,9 @@ main#1 (lam value_5 value_5)]) (lam value_4 value_4)]) --- optimized Core -let anf#13 : int -> int = addInteger 20 in -anf#13 22 +addInteger 20 22 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [anf_1 (con integer 22)]) [(builtin addInteger) (con integer 20)]]) +(program 1.1.0 [[(builtin addInteger) (con integer 20)] (con integer 22)]) --- result (con integer 42) --- logs diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_let_application.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_let_application.snap index c20fb079..b44c9a61 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_let_application.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_let_application.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 1223 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nmain : int\nmain =\n let\n x = 1\n in\n (\\y -> Builtin.addInteger x y) 2\n" --- --- unoptimized Core @@ -17,9 +16,9 @@ main#1 [fromInt_4 (con integer 1)]]) (lam value_5 value_5)]) --- optimized Core -addInteger 1 2 +3 --- optimized UPLC -(program 1.1.0 [[(builtin addInteger) (con integer 1)] (con integer 2)]) +(program 1.1.0 (con integer 3)) --- result (con integer 3) --- logs diff --git a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_reachable_binding_chain.snap b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_reachable_binding_chain.snap index 31a3465f..fd337a86 100644 --- a/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_reachable_binding_chain.snap +++ b/crates/nash-codegen/src/build/snapshots/nash_codegen__build__tests__source_reachable_binding_chain.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests.rs -assertion_line: 1249 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nx : int\nx = 40\ny : int\ny = Builtin.addInteger x 2\nunused : int\nunused = fail\nmain : int\nmain = y\n" --- --- unoptimized Core @@ -18,9 +17,9 @@ main#1 [fromInt_4 (con integer 40)]]) (lam value_5 value_5)]) --- optimized Core -addInteger 40 2 +42 --- optimized UPLC -(program 1.1.0 [[(builtin addInteger) (con integer 40)] (con integer 2)]) +(program 1.1.0 (con integer 42)) --- result (con integer 42) --- logs diff --git a/crates/nash-codegen/src/build/tests/optimizer.rs b/crates/nash-codegen/src/build/tests/optimizer.rs index 3c333cd1..5d57b145 100644 --- a/crates/nash-codegen/src/build/tests/optimizer.rs +++ b/crates/nash-codegen/src/build/tests/optimizer.rs @@ -1,6 +1,8 @@ //! Source-to-optimized snapshots reuse the normal Base fixture compiler. use super::*; +use nash_config::OptimizationLevel; use nash_ir::{anf, build::Builder, hygiene, pretty::pretty}; +use nash_plutus::{builtin::DefaultFunction as F, term::Term}; macro_rules! boolean_case_snapshot { ($name:ident, $source:literal) => { @@ -15,7 +17,7 @@ macro_rules! boolean_case_snapshot { let baseline_core = crate::recursion::rewrite(&b, compiled.core).unwrap(); let baseline = crate::harness::eval_core_raw(arena, baseline_core); let optimized_core = crate::recursion::rewrite(&b, after).unwrap(); - let term = crate::lower::lower_with_constant_sharing(arena, optimized_core).unwrap(); + let term = crate::lower::lower_optimized(arena, optimized_core).unwrap(); let optimized = crate::harness::eval_named(arena, term); assert!(!optimized.result.starts_with("error:"), "{}", optimized.result); @@ -67,3 +69,395 @@ boolean_case_snapshot!( if True then strict else True "# ); + +boolean_case_snapshot!( + builtin_pair_accessors, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + first : pair 'a 'b -> 'a + first = .fst + second : pair 'a 'b -> 'b + second p = p.snd + main : (Data, Data) + main = + let + p = Builtin.trace "pair" (Builtin.mkPairData (I 20) (I 22)) + in + (first p, second p) +"# +); +boolean_case_snapshot!( + builtin_pair_accessor_alias, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + type alias decoded = pair int (list Data) + fields : decoded -> list Data + fields = .snd + main : Data + main = Builtin.headList (fields (Builtin.unConstrData (Builtin.constrData 0 [I 42]))) +"# +); + +boolean_case_snapshot!( + recursive_forwarded_parameter, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + loop : int -> int -> int + loop unused n = + if Builtin.equalsInteger n 0 then + 42 + else + loop unused (Builtin.subtractInteger n 1) + main : int + main = loop (Builtin.trace "entry" 7) 3 +"# +); +boolean_case_snapshot!( + mutually_forwarded_parameter, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + first : int -> int -> int + first unused n = + if Builtin.equalsInteger n 0 then + 42 + else + second (Builtin.subtractInteger n 1) unused + second : int -> int -> int + second n unused = first unused n + main : int + main = first (Builtin.trace "entry" 7) 3 +"# +); + +boolean_case_snapshot!( + staged_application_packing, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin exposing (..) + choose : int -> int -> int -> int + choose n = + if Builtin.equalsInteger n 0 then + \x y -> Builtin.addInteger x y + else + choose (Builtin.subtractInteger n 1) + main : int + main = + let + p = choose 3 20 + in + p 22 +"# +); +boolean_case_snapshot!( + packed_application_trace_stages, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin exposing (..) + choose : int -> int -> int -> int + choose n = + if Builtin.equalsInteger n 0 then + \x -> trace "first" (\y -> trace "second" (Builtin.addInteger x y)) + else + choose (Builtin.subtractInteger n 1) + main : int + main = + let + p = choose 3 20 + in + p 22 +"# +); +boolean_case_snapshot!( + application_argument_trace_stays_after_first_stage, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin exposing (..) + choose : int -> int -> int -> int + choose n = + if Builtin.equalsInteger n 0 then + \x -> trace "first" (\y -> trace "second" (Builtin.addInteger x y)) + else + choose (Builtin.subtractInteger n 1) + main : int + main = + let + p = choose 3 20 + in + p (trace "argument" 22) +"# +); + +#[test] +fn application_failure_precedes_later_argument() { + let source = indoc::indoc!( + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin exposing (..) + choose : int -> int -> int -> int + choose n = + if Builtin.equalsInteger n 0 then + \x -> trace "first" fail + else + choose (Builtin.subtractInteger n 1) + main : int + main = + let + p = choose 3 20 + in + p (trace "must not run" 22) + "# + ); + with_base(source, |arena, build, root| { + let compiled = build + .compile(arena, root, None, TraceConfig::default()) + .expect("source compiles to Core"); + let fixture = crate::harness::prepare_fixture(arena, compiled.core); + assert!(fixture.evaluated.result.starts_with("error:")); + insta::with_settings!({description => source, omit_expression => true}, { + insta::assert_snapshot!(format!("{}\n--- result\n{}\n--- logs\n{:?}", + fixture.code_snapshot(), fixture.evaluated.result, fixture.evaluated.logs)); + }); + fixture.assert_equivalent(arena); + }); +} + +fn check_silent(arena: &Arena, name: &str, core: &Core<'_>, source: &str, fails: bool) { + let after = crate::optimizer::optimize_silent(arena, core).unwrap(); + let before_program = crate::program::assemble_core(arena, core).unwrap(); + let after_program = + crate::program::assemble_core_with_options(arena, core, OptimizationLevel::O2).unwrap(); + let baseline = crate::harness::eval_named(arena, before_program.named); + let optimized = crate::harness::eval_named(arena, after_program.named); + assert_eq!(optimized.result.starts_with("error:"), fails); + insta::with_settings!({description => source, omit_expression => true}, { + insta::assert_snapshot!(name, format!("--- unoptimized Core\n{}\n--- unoptimized UPLC\n{}\n--- optimized Core (O2)\n{}\n--- optimized UPLC (O2)\n{}\n--- O0 result\n{}\n--- O0 logs\n{:?}\n--- O2 result\n{}\n--- O2 logs\n{:?}", pretty(core), baseline.uplc, pretty(after), optimized.uplc, baseline.result, baseline.logs, optimized.result, optimized.logs)); + }); + // O2 intentionally drops failures in trace messages. Value failures remain + // covered by the success/error guard and the evaluated snapshot. + assert_eq!(core.ty, after.ty); + nash_ir::hygiene::validate(after, &[]).unwrap(); + nash_ir::anf::validate(after).unwrap(); + assert_silent(after_program.named); + let twice = + crate::program::assemble_core_with_options(arena, after, OptimizationLevel::O2).unwrap(); + assert_eq!( + nash_plutus::flat::encode(after_program.program).unwrap(), + nash_plutus::flat::encode(twice.program).unwrap() + ); +} +fn assert_silent(root: &Term<'_, nash_plutus::binder::Name<'_>>) { + let mut pending = vec![root]; + while let Some(term) = pending.pop() { + match term { + Term::Builtin(F::Trace) => panic!("O2 emitted a trace builtin"), + Term::Lambda { body, .. } | Term::Delay(body) | Term::Force(body) => pending.push(body), + Term::Apply { function, argument } => pending.extend([*function, *argument]), + Term::Constr { fields, .. } => pending.extend(fields.iter().copied()), + Term::Case { constr, branches } => { + pending.push(constr); + pending.extend(branches.iter().copied()); + } + _ => {} + } + } +} + +macro_rules! silent_case_snapshot { + ($name:ident, $fails:literal, $source:literal) => { + #[test] + fn $name() { + let source = indoc::indoc!($source); + with_base(source, |arena, build, root| { + let compiled = build + .compile( + arena, + root, + None, + TraceConfig { + user: TraceLevel::Silent, + compiler: false, + }, + ) + .unwrap(); + check_silent(arena, stringify!($name), compiled.core, source, $fails); + }); + } + }; +} +silent_case_snapshot!( + o2_source_and_builtin, + false, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + main : int + main = trace "source" (Builtin.trace "builtin" 42) +"# +); +silent_case_snapshot!( + o2_first_class_and_partial, + false, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + log : string -> int -> int + log = Builtin.trace + main : int + main = + let + partial = log "partial" + in + partial (log "inner" 42) +"# +); +silent_case_snapshot!( + o2_discards_message_failure, + false, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + main : int + main = Builtin.trace (fail) 42 +"# +); +silent_case_snapshot!( + o2_strict_value_failure, + true, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + main : int + main = Builtin.trace "failure" (fail) +"# +); +silent_case_snapshot!( + o2_discards_partial_message_failure, + false, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + partial : int -> int + partial = Builtin.trace (fail) + main : int + main = + let + unused = partial + in + 42 +"# +); +silent_case_snapshot!( + o2_source_message_is_omitted, + false, + r#" + module Main exposing (..) + import Primitive exposing (..) + main : int + main = trace (fail) 42 +"# +); + +silent_case_snapshot!( + o2_discards_aliased_message_failure, + false, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + log : string -> int -> int + log = Builtin.trace + main : int + main = log (fail) 42 +"# +); + +#[test] +fn o2_discards_diverging_message() { + let source = indoc::indoc!( + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + loop : unit -> string + loop _ = loop () + main : int + main = Builtin.trace (loop ()) 42 + "# + ); + with_base(source, |arena, build, root| { + let core = build + .compile( + arena, + root, + None, + TraceConfig { + user: TraceLevel::Silent, + compiler: false, + }, + ) + .unwrap() + .core; + let before = crate::program::assemble_core(arena, core).unwrap(); + let after = crate::optimizer::optimize_silent(arena, core).unwrap(); + let compiled = crate::program::assemble_core_with_options( + arena, + core, + nash_config::OptimizationLevel::O2, + ) + .unwrap(); + let evaluated = crate::harness::eval_named(arena, compiled.named); + assert!(!evaluated.result.starts_with("error:")); + insta::with_settings!({description => source, omit_expression => true}, { + insta::assert_snapshot!(format!("--- unoptimized Core\n{}\n--- unoptimized UPLC (not evaluated: diverging message)\n{}\n--- optimized Core (O2)\n{}\n--- optimized UPLC (O2)\n{}\n--- result\n{}\n--- logs\n{:?}", pretty(core), nash_plutus::pretty::term(before.named), pretty(after), evaluated.uplc, evaluated.result, evaluated.logs)); + }); + assert_eq!(core.ty, after.ty); + hygiene::validate(after, &[]).unwrap(); + anf::validate(after).unwrap(); + }); +} + +silent_case_snapshot!( + o2_retains_separate_message_binding, + true, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + main : int + main = + let + message = fail + in + Builtin.trace message 42 +"# +); +silent_case_snapshot!( + o2_retains_indirect_caller_work, + true, + r#" + module Main exposing (..) + import Primitive exposing (..) + import Builtin + call : (string -> int -> int) -> int + call logger = logger (fail) 42 + main : int + main = call Builtin.trace +"# +); diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__application_argument_trace_stays_after_first_stage.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__application_argument_trace_stays_after_first_stage.snap new file mode 100644 index 00000000..7c185204 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__application_argument_trace_stays_after_first_stage.snap @@ -0,0 +1,96 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nchoose : int -> int -> int -> int\nchoose n =\n if Builtin.equalsInteger n 0 then\n \\x -> trace \"first\" (\\y -> trace \"second\" (Builtin.addInteger x y))\n else\n choose (Builtin.subtractInteger n 1)\nmain : int\nmain =\n let\n p = choose 3 20\n in\n p (trace \"argument\" 22)\n" +--- +--- unoptimized Core +let message#11 : string = "first" in +let message#12 : string = "second" in +let message#13 : string = "argument" in +let fromInt#3 : int -> int = \value#6 : int -> value#6 in +let fromString#4 : string -> string = \value#7 : string -> value#7 in +letrec + choose#5 : int -> int -> int -> int [static []] = \n#8 : int -> case@Bool equalsInteger n#8 (fromInt#3 0) of + True -> \x#9 : int -> trace (fromString#4 message#11) in \y#10 : int -> trace (fromString#4 message#12) in addInteger x#9 y#10 + False -> choose#5 (subtractInteger n#8 (fromInt#3 1)) +in +let p#2 : int -> int = choose#5 (fromInt#3 3) (fromInt#3 20) in +let main#1 : int = p#2 (trace (fromString#4 message#13) in fromInt#3 22) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam message_11 + [(lam message_12 + [(lam message_13 + [(lam fromInt_3 + [(lam fromString_4 + [(lam choose_5 + [(lam p_2 + [(lam main_1 main_1) + [p_2 + (force + [[(force (builtin trace)) [fromString_4 message_13]] + (delay [fromInt_3 (con integer 22)])])]]) + [[choose_5 [fromInt_3 (con integer 3)]] [fromInt_3 (con integer 20)]]]) + [(lam self_14 [self_14 self_14]) + (lam self_14 + (lam n_8 + (case + [[(builtin equalsInteger) n_8] [fromInt_3 (con integer 0)]] + [[self_14 self_14] + [[(builtin subtractInteger) n_8] [fromInt_3 (con integer 1)]]] + (lam x_9 + (force + [[(force (builtin trace)) [fromString_4 message_11]] + (delay + (lam y_10 + (force + [[(force (builtin trace)) [fromString_4 message_12]] + (delay [[(builtin addInteger) x_9] y_10])])))])))))]]) + (lam value_7 value_7)]) + (lam value_6 value_6)]) + (con string "argument")]) + (con string "second")]) + (con string "first")]) +--- optimized Core +letrec + choose#21 : int -> int -> int -> int [static []] = \n#22 : int -> let anf#28 : bool = equalsInteger n#22 0 in + case@Bool anf#28 of + True -> \x#23 : int -> trace "first" in \y#24 : int -> trace "second" in addInteger x#23 y#24 + False -> let anf#32 : int = subtractInteger n#22 1 in + choose#21 anf#32 +in +let anf#34 : int -> int -> int = choose#21 3 in +let p#25 : int -> int = anf#34 20 in +let anf#37 : int = trace "argument" in 22 in +p#25 anf#37 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_38 + [(lam choose_21 + [(lam anf_34 + [(lam p_25 + [(lam anf_37 [p_25 anf_37]) + (force [[builtin_38 (con string "argument")] (delay (con integer 22))])]) + [anf_34 (con integer 20)]]) + [choose_21 (con integer 3)]]) + [(lam self_16 [self_16 self_16]) + (lam self_16 + (lam n_22 + [(lam anf_28 + (case + anf_28 + [(lam anf_32 [[self_16 self_16] anf_32]) + [[(builtin subtractInteger) n_22] (con integer 1)]] + (lam x_23 + (force + [[builtin_38 (con string "first")] + (delay + (lam y_24 + (force + [[builtin_38 (con string "second")] (delay [[(builtin addInteger) x_23] y_24])])))])))) + [[(builtin equalsInteger) n_22] (con integer 0)]]))]]) + (force (builtin trace))]) +--- result +(con integer 42) +--- logs +["first", "argument", "second"] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__application_failure_precedes_later_argument.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__application_failure_precedes_later_argument.snap new file mode 100644 index 00000000..b0e4ca15 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__application_failure_precedes_later_argument.snap @@ -0,0 +1,81 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nchoose : int -> int -> int -> int\nchoose n =\n if Builtin.equalsInteger n 0 then\n \\x -> trace \"first\" fail\n else\n choose (Builtin.subtractInteger n 1)\nmain : int\nmain =\n let\n p = choose 3 20\n in\n p (trace \"must not run\" 22)\n" +--- +--- unoptimized Core +let message#10 : string = "first" in +let message#11 : string = "must not run" in +let fromInt#3 : int -> int = \value#6 : int -> value#6 in +let fromString#4 : string -> string = \value#7 : string -> value#7 in +letrec + choose#5 : int -> int -> int -> int [static []] = \n#8 : int -> case@Bool equalsInteger n#8 (fromInt#3 0) of + True -> \x#9 : int -> trace (fromString#4 message#10) in error + False -> choose#5 (subtractInteger n#8 (fromInt#3 1)) +in +let p#2 : int -> int = choose#5 (fromInt#3 3) (fromInt#3 20) in +let main#1 : int = p#2 (trace (fromString#4 message#11) in fromInt#3 22) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam message_10 + [(lam message_11 + [(lam fromInt_3 + [(lam fromString_4 + [(lam choose_5 + [(lam p_2 + [(lam main_1 main_1) + [p_2 + (force + [[(force (builtin trace)) [fromString_4 message_11]] + (delay [fromInt_3 (con integer 22)])])]]) + [[choose_5 [fromInt_3 (con integer 3)]] [fromInt_3 (con integer 20)]]]) + [(lam self_12 [self_12 self_12]) + (lam self_12 + (lam n_8 + (case + [[(builtin equalsInteger) n_8] [fromInt_3 (con integer 0)]] + [[self_12 self_12] + [[(builtin subtractInteger) n_8] [fromInt_3 (con integer 1)]]] + (lam x_9 + (force [[(force (builtin trace)) [fromString_4 message_10]] (delay (error))])))))]]) + (lam value_7 value_7)]) + (lam value_6 value_6)]) + (con string "must not run")]) + (con string "first")]) +--- optimized Core +letrec + choose#18 : int -> int -> int -> int [static []] = \n#19 : int -> let anf#24 : bool = equalsInteger n#19 0 in + case@Bool anf#24 of + True -> \x#20 : int -> trace "first" in error + False -> let anf#27 : int = subtractInteger n#19 1 in + choose#18 anf#27 +in +let anf#29 : int -> int -> int = choose#18 3 in +let p#21 : int -> int = anf#29 20 in +let anf#32 : int = trace "must not run" in 22 in +p#21 anf#32 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_13 + [(lam choose_9 + [(lam anf_10 + [(lam p_11 + [(lam anf_12 [p_11 anf_12]) + (force [[builtin_13 (con string "must not run")] (delay (con integer 22))])]) + [anf_10 (con integer 20)]]) + [choose_9 (con integer 3)]]) + [(lam self_3 [self_3 self_3]) + (lam self_4 + (lam n_5 + [(lam anf_6 + (case + anf_6 + [(lam anf_8 [[self_4 self_4] anf_8]) + [[(builtin subtractInteger) n_5] (con integer 1)]] + (lam x_7 (force [[builtin_13 (con string "first")] (delay (error))])))) + [[(builtin equalsInteger) n_5] (con integer 0)]]))]]) + (force (builtin trace))]) +--- result +error: ExplicitErrorTerm +--- logs +["first"] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__builtin_pair_accessor_alias.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__builtin_pair_accessor_alias.snap new file mode 100644 index 00000000..2cceebb6 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__builtin_pair_accessor_alias.snap @@ -0,0 +1,40 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\ntype alias decoded = pair int (list Data)\nfields : decoded -> list Data\nfields = .snd\nmain : Data\nmain = Builtin.headList (fields (Builtin.unConstrData (Builtin.constrData 0 [I 42])))\n" +--- +--- unoptimized Core +let fields#2 : pair int (list Data) -> list Data = \record#5 : pair int (list Data) -> let projection#7 : list Data = sndPair record#5 in +projection#7 in +let fromInt#3 : int -> int = \value#6 : int -> value#6 in +let evaluated#8 : Data = constrData (fromInt#3 0) (mkCons ((\field#4 : int -> iData field#4) (fromInt#3 42)) (con (list data) [])) in +let projection#9 : pair int (list Data) = unConstrData evaluated#8 in +let evaluated#10 : list Data = fields#2 projection#9 in +let projection#11 : Data = headList evaluated#10 in +let main#1 : Data = projection#11 in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam fields_2 + [(lam fromInt_3 + [(lam evaluated_8 + [(lam projection_9 + [(lam evaluated_10 + [(lam projection_11 [(lam main_1 main_1) projection_11]) + [(force (builtin headList)) evaluated_10]]) + [fields_2 projection_9]]) + [(builtin unConstrData) evaluated_8]]) + [[(builtin constrData) [fromInt_3 (con integer 0)]] + [[(force (builtin mkCons)) + [(lam field_4 [(builtin iData) field_4]) [fromInt_3 (con integer 42)]]] + (con (list data) [])]]]) + (lam value_6 value_6)]) + (lam record_5 + [(lam projection_7 projection_7) [(force (force (builtin sndPair))) record_5]])]) +--- optimized Core +(con data (I 42)) +--- optimized UPLC +(program 1.1.0 (con data (I 42))) +--- result +(con data (I 42)) +--- logs +[] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__builtin_pair_accessors.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__builtin_pair_accessors.snap new file mode 100644 index 00000000..6fe0ae8b --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__builtin_pair_accessors.snap @@ -0,0 +1,55 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nfirst : pair 'a 'b -> 'a\nfirst = .fst\nsecond : pair 'a 'b -> 'b\nsecond p = p.snd\nmain : (Data, Data)\nmain =\n let\n p = Builtin.trace \"pair\" (Builtin.mkPairData (I 20) (I 22))\n in\n (first p, second p)\n" +--- +--- unoptimized Core +let message#15 : string = "pair" in +let first#3 : pair 'erased 'erased -> 'erased = \record#9 : pair 'erased 'erased -> let projection#13 : 'erased = fstPair record#9 in +projection#13 in +let second#4 : pair 'erased 'erased -> 'erased = \p#10 : pair 'erased 'erased -> let projection#14 : 'erased = sndPair p#10 in +projection#14 in +let fromString#5 : string -> string = \value#11 : string -> value#11 in +let fromInt#7 : int -> int = \value#12 : int -> value#12 in +let p#2 : pair Data Data = trace (fromString#5 message#15) (mkPairData ((\field#6 : int -> iData field#6) (fromInt#7 20)) ((\field#8 : int -> iData field#8) (fromInt#7 22))) in +let main#1 : (Data, Data) = constr 0 (first#3 p#2) (second#4 p#2) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam message_15 + [(lam first_3 + [(lam second_4 + [(lam fromString_5 + [(lam fromInt_7 + [(lam p_2 [(lam main_1 main_1) (constr 0 [first_3 p_2] [second_4 p_2])]) + [[(force (builtin trace)) [fromString_5 message_15]] + [[(builtin mkPairData) + [(lam field_6 [(builtin iData) field_6]) [fromInt_7 (con integer 20)]]] + [(lam field_8 [(builtin iData) field_8]) [fromInt_7 (con integer 22)]]]]]) + (lam value_12 value_12)]) + (lam value_11 value_11)]) + (lam p_10 + [(lam projection_14 projection_14) [(force (force (builtin sndPair))) p_10]])]) + (lam record_9 + [(lam projection_13 projection_13) [(force (force (builtin fstPair))) record_9]])]) + (con string "pair")]) +--- optimized Core +let p#29 : pair Data Data = trace "pair" (con (pair data data) ((I 20), (I 22))) in +let anf#37 : Data = fstPair p#29 in +let anf#38 : Data = sndPair p#29 in +constr 0 anf#37 anf#38 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_39 + [(lam builtin_40 + [(lam builtin_41 + [(lam p_29 + [(lam anf_37 [(lam anf_38 (constr 0 anf_37 anf_38)) [builtin_39 p_29]]) + [builtin_40 p_29]]) + [[builtin_41 (con string "pair")] (con (pair data data) ((I 20), (I 22)))]]) + (force (builtin trace))]) + (force (force (builtin fstPair)))]) + (force (force (builtin sndPair)))]) +--- result +(constr 0 (con data (I 20)) (con data (I 22))) +--- logs +["pair"] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__mutually_forwarded_parameter.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__mutually_forwarded_parameter.snap new file mode 100644 index 00000000..3e8129a8 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__mutually_forwarded_parameter.snap @@ -0,0 +1,85 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nfirst : int -> int -> int\nfirst unused n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n second (Builtin.subtractInteger n 1) unused\nsecond : int -> int -> int\nsecond n unused = first unused n\nmain : int\nmain = first (Builtin.trace \"entry\" 7) 3\n" +--- +--- unoptimized Core +let message#12 : string = "entry" in +let fromInt#4 : int -> int = \value#9 : int -> value#9 in +letrec + first#2 : int -> int -> int [static []] = \unused#5 : int n#6 : int -> case@Bool equalsInteger n#6 (fromInt#4 0) of + True -> fromInt#4 42 + False -> second#7 (subtractInteger n#6 (fromInt#4 1)) unused#5 + second#7 : int -> int -> int [static []] = \n#10 : int unused#11 : int -> first#2 unused#11 n#10 +in +let fromString#3 : string -> string = \value#8 : string -> value#8 in +let main#1 : int = first#2 (trace (fromString#3 message#12) (fromInt#4 7)) (fromInt#4 3) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam message_12 + [(lam fromInt_4 + [(lam dispatch_13 + [(lam first_2 + [(lam second_7 + [(lam fromString_3 + [(lam main_1 main_1) + [[first_2 + [[(force (builtin trace)) [fromString_3 message_12]] + [fromInt_4 (con integer 7)]]] + [fromInt_4 (con integer 3)]]]) + (lam value_8 value_8)]) + (lam n_25 (lam unused_26 [dispatch_13 (constr 1 dispatch_13 n_25 unused_26)]))]) + (lam unused_27 (lam n_28 [dispatch_13 (constr 0 dispatch_13 unused_27 n_28)]))]) + (lam request_14 + (case + request_14 + (lam self_15 + (lam unused_5 + (lam n_6 + (case + [[(builtin equalsInteger) n_6] [fromInt_4 (con integer 0)]] + [self_15 + (constr 1 + self_15 + [[(builtin subtractInteger) n_6] [fromInt_4 (con integer 1)]] + unused_5)] + [fromInt_4 (con integer 42)])))) + (lam self_20 + (lam n_10 (lam unused_11 [self_20 (constr 0 self_20 unused_11 n_10)])))))]) + (lam value_9 value_9)]) + (con string "entry")]) +--- optimized Core +letrec + first#16 : int -> int [static []] = \n#19 : int -> let anf#29 : bool = equalsInteger n#19 0 in + case@Bool anf#29 of + True -> 42 + False -> let arg#25 : int = subtractInteger n#19 1 in + second#17 arg#25 + second#17 : int -> int [static []] = \n#20 : int -> first#16 n#20 +in +let arg#26 : int = trace "entry" 7 in +first#16 3 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_40 + [(lam dispatch_30 + [(lam arg_26 [dispatch_30 (constr 0 dispatch_30 (con integer 3))]) + [[builtin_40 (con string "entry")] (con integer 7)]]) + (lam request_31 + (case + request_31 + (lam self_32 + (lam n_19 + [(lam anf_29 + (case + anf_29 + [(lam arg_25 [self_32 (constr 1 self_32 arg_25)]) + [[(builtin subtractInteger) n_19] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_19] (con integer 0)]])) + (lam self_35 (lam n_20 [self_35 (constr 0 self_35 n_20)]))))]) + (force (builtin trace))]) +--- result +(con integer 42) +--- logs +["entry"] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_aliased_message_failure.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_aliased_message_failure.snap new file mode 100644 index 00000000..d0b53681 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_aliased_message_failure.snap @@ -0,0 +1,28 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nlog : string -> int -> int\nlog = Builtin.trace\nmain : int\nmain = log (fail) 42\n" +--- +--- unoptimized Core +let log#2 : string -> int -> int = trace in +let fromInt#3 : int -> int = \value#4 : int -> value#4 in +let main#1 : int = log#2 error (fromInt#3 42) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam log_2 + [(lam fromInt_3 + [(lam main_1 main_1) [[log_2 (error)] [fromInt_3 (con integer 42)]]]) + (lam value_4 value_4)]) + (force (builtin trace))]) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +error: ExplicitErrorTerm +--- O0 logs +[] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_diverging_message.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_diverging_message.snap new file mode 100644 index 00000000..e7ead3bc --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_diverging_message.snap @@ -0,0 +1,33 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nloop : unit -> string\nloop _ = loop ()\nmain : int\nmain = Builtin.trace (loop ()) 42\n" +--- +--- unoptimized Core +let fromUnit#3 : unit -> unit = \value#7 : unit -> value#7 in +letrec + loop#2 : unit -> string [static []] = \arg#5 : unit -> let match#6 : unit = arg#5 in + loop#2 (fromUnit#3 ()) +in +let fromInt#4 : int -> int = \value#8 : int -> value#8 in +let main#1 : int = trace (loop#2 (fromUnit#3 ())) (fromInt#4 42) in +main#1 +--- unoptimized UPLC (not evaluated: diverging message) +[(lam fromUnit_3 + [(lam loop_2 + [(lam fromInt_4 + [(lam main_1 main_1) + [[(force (builtin trace)) [loop_2 [fromUnit_3 (con unit ())]]] + [fromInt_4 (con integer 42)]]]) + (lam value_8 value_8)]) + [(lam self_9 [self_9 self_9]) + (lam self_9 + (lam arg_5 (case arg_5 [[self_9 self_9] [fromUnit_3 (con unit ())]])))]]) + (lam value_7 value_7)] +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_message_failure.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_message_failure.snap new file mode 100644 index 00000000..e595c3a1 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_message_failure.snap @@ -0,0 +1,26 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nmain : int\nmain = Builtin.trace (fail) 42\n" +--- +--- unoptimized Core +let fromInt#2 : int -> int = \value#3 : int -> value#3 in +let main#1 : int = trace error (fromInt#2 42) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam fromInt_2 + [(lam main_1 main_1) + [[(force (builtin trace)) (error)] [fromInt_2 (con integer 42)]]]) + (lam value_3 value_3)]) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +error: ExplicitErrorTerm +--- O0 logs +[] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_partial_message_failure.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_partial_message_failure.snap new file mode 100644 index 00000000..8553e455 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_discards_partial_message_failure.snap @@ -0,0 +1,29 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\npartial : int -> int\npartial = Builtin.trace (fail)\nmain : int\nmain =\n let\n unused = partial\n in\n 42\n" +--- +--- unoptimized Core +let fromInt#3 : int -> int = \value#5 : int -> value#5 in +let partial#4 : int -> int = trace error in +let unused#2 : int -> int = partial#4 in +let main#1 : int = fromInt#3 42 in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam fromInt_3 + [(lam partial_4 + [(lam unused_2 [(lam main_1 main_1) [fromInt_3 (con integer 42)]]) partial_4]) + [(force (builtin trace)) (error)]]) + (lam value_5 value_5)]) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +error: ExplicitErrorTerm +--- O0 logs +[] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_first_class_and_partial.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_first_class_and_partial.snap new file mode 100644 index 00000000..77aecbdf --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_first_class_and_partial.snap @@ -0,0 +1,41 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nlog : string -> int -> int\nlog = Builtin.trace\nmain : int\nmain =\n let\n partial = log \"partial\"\n in\n partial (log \"inner\" 42)\n" +--- +--- unoptimized Core +let message#8 : string = "partial" in +let message#9 : string = "inner" in +let log#3 : string -> int -> int = trace in +let fromString#4 : string -> string = \value#6 : string -> value#6 in +let fromInt#5 : int -> int = \value#7 : int -> value#7 in +let partial#2 : int -> int = log#3 (fromString#4 message#8) in +let main#1 : int = partial#2 (log#3 (fromString#4 message#9) (fromInt#5 42)) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam message_8 + [(lam message_9 + [(lam log_3 + [(lam fromString_4 + [(lam fromInt_5 + [(lam partial_2 + [(lam main_1 main_1) + [partial_2 [[log_3 [fromString_4 message_9]] [fromInt_5 (con integer 42)]]]]) + [log_3 [fromString_4 message_8]]]) + (lam value_7 value_7)]) + (lam value_6 value_6)]) + (force (builtin trace))]) + (con string "inner")]) + (con string "partial")]) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +(con integer 42) +--- O0 logs +["inner", "partial"] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_retains_indirect_caller_work.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_retains_indirect_caller_work.snap new file mode 100644 index 00000000..c886e8c7 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_retains_indirect_caller_work.snap @@ -0,0 +1,28 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\ncall : (string -> int -> int) -> int\ncall logger = logger (fail) 42\nmain : int\nmain = call Builtin.trace\n" +--- +--- unoptimized Core +let fromInt#4 : int -> int = \value#5 : int -> value#5 in +let call#2 : (string -> int -> int) -> int = \(logger#3 : string -> int -> int) -> logger#3 error (fromInt#4 42) in +let main#1 : int = call#2 trace in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam fromInt_4 + [(lam call_2 [(lam main_1 main_1) [call_2 (force (builtin trace))]]) + (lam logger_3 [[logger_3 (error)] [fromInt_4 (con integer 42)]])]) + (lam value_5 value_5)]) +--- optimized Core (O2) +let anf#15 : string = error in +42 +--- optimized UPLC (O2) +(program 1.1.0 [(lam anf_1 (con integer 42)) (error)]) +--- O0 result +error: ExplicitErrorTerm +--- O0 logs +[] +--- O2 result +error: ExplicitErrorTerm +--- O2 logs +[] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_retains_separate_message_binding.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_retains_separate_message_binding.snap new file mode 100644 index 00000000..7e2f8e95 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_retains_separate_message_binding.snap @@ -0,0 +1,30 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nmain : int\nmain =\n let\n message = fail\n in\n Builtin.trace message 42\n" +--- +--- unoptimized Core +let fromInt#3 : int -> int = \value#4 : int -> value#4 in +let message#2 : 'erased = error in +let main#1 : int = trace message#2 (fromInt#3 42) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam fromInt_3 + [(lam message_2 + [(lam main_1 main_1) + [[(force (builtin trace)) message_2] [fromInt_3 (con integer 42)]]]) + (error)]) + (lam value_4 value_4)]) +--- optimized Core (O2) +let message#3 : 'erased = error in +42 +--- optimized UPLC (O2) +(program 1.1.0 [(lam message_1 (con integer 42)) (error)]) +--- O0 result +error: ExplicitErrorTerm +--- O0 logs +[] +--- O2 result +error: ExplicitErrorTerm +--- O2 logs +[] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_source_and_builtin.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_source_and_builtin.snap new file mode 100644 index 00000000..c5ee827d --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_source_and_builtin.snap @@ -0,0 +1,33 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nmain : int\nmain = trace \"source\" (Builtin.trace \"builtin\" 42)\n" +--- +--- unoptimized Core +let message#6 : string = "builtin" in +let fromString#2 : string -> string = \value#4 : string -> value#4 in +let fromInt#3 : int -> int = \value#5 : int -> value#5 in +let main#1 : int = trace (fromString#2 message#6) (fromInt#3 42) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam message_6 + [(lam fromString_2 + [(lam fromInt_3 + [(lam main_1 main_1) + [[(force (builtin trace)) [fromString_2 message_6]] + [fromInt_3 (con integer 42)]]]) + (lam value_5 value_5)]) + (lam value_4 value_4)]) + (con string "builtin")]) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +(con integer 42) +--- O0 logs +["builtin"] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_source_message_is_omitted.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_source_message_is_omitted.snap new file mode 100644 index 00000000..2d502807 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_source_message_is_omitted.snap @@ -0,0 +1,24 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nmain : int\nmain = trace (fail) 42\n" +--- +--- unoptimized Core +let fromInt#2 : int -> int = \value#3 : int -> value#3 in +let main#1 : int = fromInt#2 42 in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam fromInt_2 [(lam main_1 main_1) [fromInt_2 (con integer 42)]]) + (lam value_3 value_3)]) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +(con integer 42) +--- O0 logs +[] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_strict_value_failure.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_strict_value_failure.snap new file mode 100644 index 00000000..2a3a2484 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__o2_strict_value_failure.snap @@ -0,0 +1,29 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nmain : int\nmain = Builtin.trace \"failure\" (fail)\n" +--- +--- unoptimized Core +let message#4 : string = "failure" in +let fromString#2 : string -> string = \value#3 : string -> value#3 in +let main#1 : int = trace (fromString#2 message#4) error in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam message_4 + [(lam fromString_2 + [(lam main_1 main_1) + [[(force (builtin trace)) [fromString_2 message_4]] (error)]]) + (lam value_3 value_3)]) + (con string "failure")]) +--- optimized Core (O2) +error +--- optimized UPLC (O2) +(program 1.1.0 (error)) +--- O0 result +error: ExplicitErrorTerm +--- O0 logs +[] +--- O2 result +error: ExplicitErrorTerm +--- O2 logs +[] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__packed_application_trace_stages.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__packed_application_trace_stages.snap new file mode 100644 index 00000000..c2728e10 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__packed_application_trace_stages.snap @@ -0,0 +1,80 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nchoose : int -> int -> int -> int\nchoose n =\n if Builtin.equalsInteger n 0 then\n \\x -> trace \"first\" (\\y -> trace \"second\" (Builtin.addInteger x y))\n else\n choose (Builtin.subtractInteger n 1)\nmain : int\nmain =\n let\n p = choose 3 20\n in\n p 22\n" +--- +--- unoptimized Core +let message#11 : string = "first" in +let message#12 : string = "second" in +let fromInt#3 : int -> int = \value#5 : int -> value#5 in +let fromString#9 : string -> string = \value#10 : string -> value#10 in +letrec + choose#4 : int -> int -> int -> int [static []] = \n#6 : int -> case@Bool equalsInteger n#6 (fromInt#3 0) of + True -> \x#7 : int -> trace (fromString#9 message#11) in \y#8 : int -> trace (fromString#9 message#12) in addInteger x#7 y#8 + False -> choose#4 (subtractInteger n#6 (fromInt#3 1)) +in +let p#2 : int -> int = choose#4 (fromInt#3 3) (fromInt#3 20) in +let main#1 : int = p#2 (fromInt#3 22) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam message_11 + [(lam message_12 + [(lam fromInt_3 + [(lam fromString_9 + [(lam choose_4 + [(lam p_2 [(lam main_1 main_1) [p_2 [fromInt_3 (con integer 22)]]]) + [[choose_4 [fromInt_3 (con integer 3)]] [fromInt_3 (con integer 20)]]]) + [(lam self_13 [self_13 self_13]) + (lam self_13 + (lam n_6 + (case + [[(builtin equalsInteger) n_6] [fromInt_3 (con integer 0)]] + [[self_13 self_13] + [[(builtin subtractInteger) n_6] [fromInt_3 (con integer 1)]]] + (lam x_7 + (force + [[(force (builtin trace)) [fromString_9 message_11]] + (delay + (lam y_8 + (force + [[(force (builtin trace)) [fromString_9 message_12]] + (delay [[(builtin addInteger) x_7] y_8])])))])))))]]) + (lam value_10 value_10)]) + (lam value_5 value_5)]) + (con string "second")]) + (con string "first")]) +--- optimized Core +letrec + choose#19 : int -> int -> int -> int [static []] = \n#20 : int -> let anf#26 : bool = equalsInteger n#20 0 in + case@Bool anf#26 of + True -> \x#21 : int -> trace "first" in \y#22 : int -> trace "second" in addInteger x#21 y#22 + False -> let anf#30 : int = subtractInteger n#20 1 in + choose#19 anf#30 +in +choose#19 3 20 22 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_31 + [(lam choose_19 + (case (constr 0 (con integer 3) (con integer 20) (con integer 22)) choose_19)) + [(lam self_15 [self_15 self_15]) + (lam self_15 + (lam n_20 + [(lam anf_26 + (case + anf_26 + [(lam anf_30 [[self_15 self_15] anf_30]) + [[(builtin subtractInteger) n_20] (con integer 1)]] + (lam x_21 + (force + [[builtin_31 (con string "first")] + (delay + (lam y_22 + (force + [[builtin_31 (con string "second")] (delay [[(builtin addInteger) x_21] y_22])])))])))) + [[(builtin equalsInteger) n_20] (con integer 0)]]))]]) + (force (builtin trace))]) +--- result +(con integer 42) +--- logs +["first", "second"] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__recursive_forwarded_parameter.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__recursive_forwarded_parameter.snap new file mode 100644 index 00000000..ac3dba2c --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__recursive_forwarded_parameter.snap @@ -0,0 +1,70 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nloop : int -> int -> int\nloop unused n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n loop unused (Builtin.subtractInteger n 1)\nmain : int\nmain = loop (Builtin.trace \"entry\" 7) 3\n" +--- +--- unoptimized Core +let message#9 : string = "entry" in +let fromInt#4 : int -> int = \value#8 : int -> value#8 in +letrec + loop#2 : int -> int -> int [static [0]] = \unused#5 : int n#6 : int -> case@Bool equalsInteger n#6 (fromInt#4 0) of + True -> fromInt#4 42 + False -> loop#2 unused#5 (subtractInteger n#6 (fromInt#4 1)) +in +let fromString#3 : string -> string = \value#7 : string -> value#7 in +let main#1 : int = loop#2 (trace (fromString#3 message#9) (fromInt#4 7)) (fromInt#4 3) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam message_9 + [(lam fromInt_4 + [(lam loop_2 + [(lam fromString_3 + [(lam main_1 main_1) + [[loop_2 + [[(force (builtin trace)) [fromString_3 message_9]] [fromInt_4 (con integer 7)]]] + [fromInt_4 (con integer 3)]]]) + (lam value_7 value_7)]) + (lam unused_5 + (lam n_6 + [[(lam self_10 [self_10 self_10]) + (lam self_10 + (lam n_6 + (case + [[(builtin equalsInteger) n_6] [fromInt_4 (con integer 0)]] + [[self_10 self_10] + [[(builtin subtractInteger) n_6] [fromInt_4 (con integer 1)]]] + [fromInt_4 (con integer 42)])))] + n_6]))]) + (lam value_8 value_8)]) + (con string "entry")]) +--- optimized Core +let arg#21 : int = trace "entry" 7 in +letrec + worker#20 : int -> int [static []] = \n#19 : int -> let anf#24 : bool = equalsInteger n#19 0 in + case@Bool anf#24 of + True -> 42 + False -> let anf#26 : int = subtractInteger n#19 1 in + worker#20 anf#26 +in +worker#20 3 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_27 + [(lam arg_21 + [(lam worker_20 [worker_20 (con integer 3)]) + [(lam self_11 [self_11 self_11]) + (lam self_11 + (lam n_19 + [(lam anf_24 + (case + anf_24 + [(lam anf_26 [[self_11 self_11] anf_26]) + [[(builtin subtractInteger) n_19] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_19] (con integer 0)]]))]]) + [[builtin_27 (con string "entry")] (con integer 7)]]) + (force (builtin trace))]) +--- result +(con integer 42) +--- logs +["entry"] diff --git a/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__staged_application_packing.snap b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__staged_application_packing.snap new file mode 100644 index 00000000..b63b6cd9 --- /dev/null +++ b/crates/nash-codegen/src/build/tests/snapshots/nash_codegen__build__tests__optimizer__staged_application_packing.snap @@ -0,0 +1,55 @@ +--- +source: crates/nash-codegen/src/build/tests/optimizer.rs +description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nchoose : int -> int -> int -> int\nchoose n =\n if Builtin.equalsInteger n 0 then\n \\x y -> Builtin.addInteger x y\n else\n choose (Builtin.subtractInteger n 1)\nmain : int\nmain =\n let\n p = choose 3 20\n in\n p 22\n" +--- +--- unoptimized Core +let fromInt#3 : int -> int = \value#5 : int -> value#5 in +letrec + choose#4 : int -> int -> int -> int [static []] = \n#6 : int -> case@Bool equalsInteger n#6 (fromInt#3 0) of + True -> \x#7 : int y#8 : int -> addInteger x#7 y#8 + False -> choose#4 (subtractInteger n#6 (fromInt#3 1)) +in +let p#2 : int -> int = choose#4 (fromInt#3 3) (fromInt#3 20) in +let main#1 : int = p#2 (fromInt#3 22) in +main#1 +--- unoptimized UPLC +(program 1.1.0 + [(lam fromInt_3 + [(lam choose_4 + [(lam p_2 [(lam main_1 main_1) [p_2 [fromInt_3 (con integer 22)]]]) + [[choose_4 [fromInt_3 (con integer 3)]] [fromInt_3 (con integer 20)]]]) + [(lam self_9 [self_9 self_9]) + (lam self_9 + (lam n_6 + (case + [[(builtin equalsInteger) n_6] [fromInt_3 (con integer 0)]] + [[self_9 self_9] [[(builtin subtractInteger) n_6] [fromInt_3 (con integer 1)]]] + (lam x_7 (lam y_8 [[(builtin addInteger) x_7] y_8])))))]]) + (lam value_5 value_5)]) +--- optimized Core +letrec + choose#11 : int -> int -> int -> int [static []] = \n#12 : int -> let anf#18 : bool = equalsInteger n#12 0 in + case@Bool anf#18 of + True -> \x#13 : int y#14 : int -> addInteger x#13 y#14 + False -> let anf#20 : int = subtractInteger n#12 1 in + choose#11 anf#20 +in +choose#11 3 20 22 +--- optimized UPLC +(program 1.1.0 + [(lam choose_11 + (case (constr 0 (con integer 3) (con integer 20) (con integer 22)) choose_11)) + [(lam self_15 [self_15 self_15]) + (lam self_15 + (lam n_12 + [(lam anf_18 + (case + anf_18 + [(lam anf_20 [[self_15 self_15] anf_20]) + [[(builtin subtractInteger) n_12] (con integer 1)]] + (lam x_13 (lam y_14 [[(builtin addInteger) x_13] y_14])))) + [[(builtin equalsInteger) n_12] (con integer 0)]]))]]) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__bls12_381_elements_from_data_conversion.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__bls12_381_elements_from_data_conversion.snap index 7a1623ca..851ccfc1 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__bls12_381_elements_from_data_conversion.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__bls12_381_elements_from_data_conversion.snap @@ -183,22 +183,27 @@ case@Pair field#25 of (lam field_18 [(lam generated_33 (force - [[[[[[builtin_34 generated_33] (delay (force leaf_10))] (delay (force leaf_10))] - (delay (force leaf_10))] - (delay (force leaf_10))] - (delay - [(lam field_27 - (case - field_18 - (lam field_28 - (lam field_29 - (case - field_29 - (lam field_31 (lam field_32 (force leaf_10))) - [(lam evaluated_30 [[(builtin bls12_381_G1_equal) evaluated_30] anf_1]) - [(builtin bls12_381_G1_uncompress) field_27]]))) - (force leaf_10))) - [(builtin unBData) generated_33]])])) + (case + (constr 0 + generated_33 + (delay (force leaf_10)) + (delay (force leaf_10)) + (delay (force leaf_10)) + (delay (force leaf_10)) + (delay + [(lam field_27 + (case + field_18 + (lam field_28 + (lam field_29 + (case + field_29 + (lam field_31 (lam field_32 (force leaf_10))) + [(lam evaluated_30 [[(builtin bls12_381_G1_equal) evaluated_30] anf_1]) + [(builtin bls12_381_G1_uncompress) field_27]]))) + (force leaf_10))) + [(builtin unBData) generated_33]])) + builtin_34))) field_17])) (force leaf_10)))) [anf_14 (con integer 0)]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__cast_never.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__cast_never.snap index dfc8d9c5..f6fdda74 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__cast_never.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__cast_never.snap @@ -62,10 +62,8 @@ main#1 (builtin equalsInteger)]) (lam value_32 value_32)]) --- optimized Core -let anf#50 : Main.Option = constrData 1 (con (list data) []) in let leaf#16 : @delay Main.never = delay error in -let field#17 : pair int (list Data) = unConstrData anf#50 in -let match#45 : Main.never = case@Pair field#17 of +let match#45 : Main.never = case@Pair (con (pair integer (list data)) (1, [])) of Pair field#18 field#19 -> let anf#47 : int -> bool = equalsInteger field#18 in let anf#49 : bool = anf#47 1 in case@Bool anf#49 of @@ -76,25 +74,21 @@ let match#45 : Main.never = case@Pair field#17 of () --- optimized UPLC (program 1.1.0 - [(lam anf_1 - [(lam leaf_2 - [(lam field_3 - [(lam match_10 (con unit ())) - (case - field_3 - (lam field_4 - (lam field_5 - [(lam anf_6 - [(lam anf_7 - (case - anf_7 - (force leaf_2) - (case field_5 (lam field_8 (lam field_9 (force leaf_2))) (constr 0)))) - [anf_6 (con integer 1)]]) - [(builtin equalsInteger) field_4]])))]) - [(builtin unConstrData) anf_1]]) - (delay (error))]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) + [(lam leaf_1 + [(lam match_8 (con unit ())) + (case + (con (pair integer (list data)) (1, [])) + (lam field_2 + (lam field_3 + [(lam anf_4 + [(lam anf_5 + (case + anf_5 + (force leaf_1) + (case field_3 (lam field_6 (lam field_7 (force leaf_1))) (constr 0)))) + [anf_4 (con integer 1)]]) + [(builtin equalsInteger) field_2]])))]) + (delay (error))]) --- result (con unit ()) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__custom_validate_rejects_wrong_shape.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__custom_validate_rejects_wrong_shape.snap index 8b757e00..41994e10 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__custom_validate_rejects_wrong_shape.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__custom_validate_rejects_wrong_shape.snap @@ -104,12 +104,8 @@ case@Pair projection#53 of (builtin equalsInteger)]) (lam value_51 value_51)]) --- optimized Core -let anf#80 : Data = bData (con bytestring #aa) in -let anf#81 : list Data = mkCons anf#80 (con (list data) []) in -let anf#82 : Data = constrData 0 anf#81 in let leaf#23 : @delay Main.Datum = delay error in -let field#24 : pair int (list Data) = unConstrData anf#82 in -let decoded#66 : Main.Datum = case@Pair field#24 of +let decoded#66 : Main.Datum = case@Pair (con (pair integer (list data)) (0, [(B #aa)])) of Pair field#25 field#26 -> let anf#75 : int -> bool = equalsInteger field#25 in let anf#77 : bool = anf#75 0 in case@Bool anf#77 of @@ -120,7 +116,7 @@ let decoded#66 : Main.Datum = case@Pair field#24 of DataMap field#31 -> force leaf#23 DataList field#32 -> force leaf#23 DataI field#33 -> case@List field#29 of - Nil -> anf#82 + Nil -> (con data (Constr 0 [B #aa])) Cons field#55 field#56 -> force leaf#23 DataB field#57 -> force leaf#23 False -> force leaf#23 in @@ -130,53 +126,50 @@ case@Pair projection#68 of Cons field#71 fieldTail#72 -> unIData field#71 --- optimized UPLC (program 1.1.0 - [(lam builtin_36 - [(lam builtin_37 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam leaf_4 - [(lam field_5 - [(lam decoded_19 - [(lam projection_20 - (case - projection_20 - (lam tag_21 - (lam fields_22 - (case - fields_22 - (lam field_27 (lam fieldTail_34 [(builtin unIData) field_27])) - (error)))))) - [(builtin unConstrData) decoded_19]]) + [(lam builtin_22 + [(lam leaf_1 + [(lam decoded_15 + [(lam projection_16 + (case + projection_16 + (lam tag_17 + (lam fields_18 + (case + fields_18 + (lam field_19 (lam fieldTail_20 [(builtin unIData) field_19])) + (error)))))) + [(builtin unConstrData) decoded_15]]) + (case + (con (pair integer (list data)) (0, [(B #aa)])) + (lam field_2 + (lam field_3 + [(lam anf_4 + [(lam anf_5 (case - field_5 - (lam field_6 - (lam field_7 - [(lam anf_8 - [(lam anf_9 + anf_5 + (force leaf_1) + (case + field_3 + (lam field_6 + (lam field_7 + (force (case - anf_9 - (force leaf_4) - (case - field_7 - (lam field_10 - (lam field_11 - [(lam generated_35 - (force - [[[[[[builtin_36 generated_35] (delay (force leaf_4))] (delay (force leaf_4))] - (delay (force leaf_4))] - (delay (case field_11 (lam field_16 (lam field_17 (force leaf_4))) anf_3))] - (delay (force leaf_4))])) - field_10])) - (force leaf_4)))) - [anf_8 (con integer 0)]]) - [(builtin equalsInteger) field_6]])))]) - [(builtin unConstrData) anf_3]]) - (delay (error))]) - [[(builtin constrData) (con integer 0)] anf_2]]) - [[builtin_37 anf_1] (con (list data) [])]]) - [(builtin bData) (con bytestring #aa)]]) - (force (builtin mkCons))]) + (constr 0 + field_6 + (delay (force leaf_1)) + (delay (force leaf_1)) + (delay (force leaf_1)) + (delay + (case + field_7 + (lam field_12 (lam field_13 (force leaf_1))) + (con data (Constr 0 [B #aa])))) + (delay (force leaf_1))) + builtin_22)))) + (force leaf_1)))) + [anf_4 (con integer 0)]]) + [(builtin equalsInteger) field_2]])))]) + (delay (error))]) (force (builtin chooseData))]) --- result error: ExplicitErrorTerm diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_map_codec.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_map_codec.snap index a22e6e8f..5ee63826 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_map_codec.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_map_codec.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 332 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData, fromData)\ninput = Map [mkPairData (B #\"aa\") (List [I 42])]\ndecoded : Map Bytes (List Int)\ndecoded = fromData input\nmain = equalsData (toData decoded) input\n" --- --- unoptimized Core @@ -36,32 +35,9 @@ main#1 (lam value_14 value_14)]) (lam coerce_5 coerce_5)]) --- optimized Core -let anf#32 : Data = bData (con bytestring #aa) in -let anf#34 : Data = iData 42 in -let anf#35 : list Data = mkCons anf#34 (con (list data) []) in -let anf#36 : Data = listData anf#35 in -let anf#37 : pair Data Data = mkPairData anf#32 anf#36 in -let anf#38 : list (pair Data Data) = mkCons anf#37 (con (list (pair data data)) []) in -let input#26 : Data = mapData anf#38 in -equalsData input#26 input#26 +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_8 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - [(lam anf_5 - [(lam anf_6 - [(lam input_7 [[(builtin equalsData) input_7] input_7]) - [(builtin mapData) anf_6]]) - [[builtin_8 anf_5] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_1] anf_4]]) - [(builtin listData) anf_3]]) - [[builtin_8 anf_2] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - [(builtin bData) (con bytestring #aa)]]) - (force (builtin mkCons))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_map_rejects_malformed_value.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_map_rejects_malformed_value.snap index d3ecf0fd..2b0c37f9 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_map_rejects_malformed_value.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_map_rejects_malformed_value.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 359 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (validate)\ndecoded : Map Bytes (List Int)\ndecoded = validate (Map [mkPairData (B #\"aa\") (List [B #\"bb\"])])\nmain = nullList (unMapData decoded)\n" --- --- unoptimized Core @@ -138,14 +137,7 @@ main#1 (lam x_16 (lam f_17 [f_17 x_16]))]) --- optimized Core let applyForward#55 : 'erased -> ('erased -> 'erased) -> 'erased = \x#53 : 'erased (f#54 : 'erased -> 'erased) -> f#54 x#53 in -let anf#124 : Data = bData (con bytestring #aa) in -let anf#126 : Data = bData (con bytestring #bb) in -let anf#127 : list Data = mkCons anf#126 (con (list data) []) in -let anf#128 : Data = listData anf#127 in -let anf#129 : pair Data Data = mkPairData anf#124 anf#128 in -let anf#130 : list (pair Data Data) = mkCons anf#129 (con (list (pair data data)) []) in -let anf#131 : Data = mapData anf#130 in -let anf#119 : list (pair Data Data) = applyForward#55 anf#131 unMapData in +let anf#119 : list (pair Data Data) = applyForward#55 (con data (Map [(B #aa, List [B #bb])])) unMapData in let anf#120 : (list (pair Data Data) -> list (pair Data Data)) -> list (pair Data Data) = applyForward#55 anf#119 in let anf#122 : list (pair Data Data) = anf#120 (\values#58 : list 'erased -> letrec worker#108 : list 'erased -> list (pair Data Data) [static []] = \values#107 : list 'erased -> case@List values#107 of @@ -173,71 +165,57 @@ let anf#132 : list (pair Bytes (List Int)) = unMapData decoded#103 in nullList anf#132 --- optimized UPLC (program 1.1.0 - [(lam builtin_45 - [(lam builtin_46 + [(lam builtin_38 + [(lam builtin_39 [(lam applyForward_7 [(lam anf_8 [(lam anf_9 - [(lam anf_10 - [(lam anf_11 - [(lam anf_12 - [(lam anf_13 - [(lam anf_14 - [(lam anf_15 - [(lam anf_16 - [(lam anf_42 - [(lam decoded_43 - [(lam anf_44 [builtin_45 anf_44]) [(builtin unMapData) decoded_43]]) - [[applyForward_7 anf_42] (builtin mapData)]]) - [anf_16 - (lam values_17 - [(lam worker_41 [worker_41 values_17]) - [(lam self_18 [self_18 self_18]) - (lam self_19 - (lam values_20 - (case - values_20 - (lam field_21 - (lam field_22 - [(lam anf_39 - [(lam anf_40 [[builtin_46 anf_39] anf_40]) [[self_19 self_19] field_22]]) - (case - field_21 - (lam field_23 - (lam field_24 - [(lam destruct_25 - [(lam anf_26 - [(lam anf_27 - [(lam anf_37 - [(lam anf_38 [[(builtin mkPairData) field_23] anf_38]) - [[applyForward_7 anf_37] (builtin listData)]]) - [anf_27 - (lam values_28 - [(lam worker_36 [worker_36 values_28]) - [(lam self_29 [self_29 self_29]) - (lam self_30 - (lam values_31 - (case - values_31 - (lam field_32 - (lam field_33 - [(lam destruct_34 - [(lam anf_35 [[builtin_46 field_32] anf_35]) [[self_30 self_30] field_33]]) - [(builtin unIData) field_32]])) - (con (list data) []))))]])]]) - [applyForward_7 anf_26]]) - [[applyForward_7 field_24] (builtin unListData)]]) - [(builtin unBData) field_23]])))])) - (con (list (pair data data)) []))))]])]]) - [applyForward_7 anf_15]]) - [[applyForward_7 anf_14] (builtin unMapData)]]) - [(builtin mapData) anf_13]]) - [[builtin_46 anf_12] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_8] anf_11]]) - [(builtin listData) anf_10]]) - [[builtin_46 anf_9] (con (list data) [])]]) - [(builtin bData) (con bytestring #bb)]]) - [(builtin bData) (con bytestring #aa)]]) + [(lam anf_35 + [(lam decoded_36 + [(lam anf_37 [builtin_38 anf_37]) [(builtin unMapData) decoded_36]]) + [[applyForward_7 anf_35] (builtin mapData)]]) + [anf_9 + (lam values_10 + [(lam worker_34 [worker_34 values_10]) + [(lam self_11 [self_11 self_11]) + (lam self_12 + (lam values_13 + (case + values_13 + (lam field_14 + (lam field_15 + [(lam anf_32 + [(lam anf_33 [[builtin_39 anf_32] anf_33]) [[self_12 self_12] field_15]]) + (case + field_14 + (lam field_16 + (lam field_17 + [(lam destruct_18 + [(lam anf_19 + [(lam anf_20 + [(lam anf_30 + [(lam anf_31 [[(builtin mkPairData) field_16] anf_31]) + [[applyForward_7 anf_30] (builtin listData)]]) + [anf_20 + (lam values_21 + [(lam worker_29 [worker_29 values_21]) + [(lam self_22 [self_22 self_22]) + (lam self_23 + (lam values_24 + (case + values_24 + (lam field_25 + (lam field_26 + [(lam destruct_27 + [(lam anf_28 [[builtin_39 field_25] anf_28]) [[self_23 self_23] field_26]]) + [(builtin unIData) field_25]])) + (con (list data) []))))]])]]) + [applyForward_7 anf_19]]) + [[applyForward_7 field_17] (builtin unListData)]]) + [(builtin unBData) field_16]])))])) + (con (list (pair data data)) []))))]])]]) + [applyForward_7 anf_8]]) + [[applyForward_7 (con data (Map [(B #aa, List [B #bb])]))] (builtin unMapData)]]) (lam x_5 (lam f_6 [f_6 x_5]))]) (force (builtin mkCons))]) (force (builtin nullList))]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_nested_list_codec.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_nested_list_codec.snap index 3c107d58..6af2d193 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_nested_list_codec.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_nested_list_codec.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 318 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData, fromData)\ninput = List [List [I 1, I 2], List []]\ndecoded : List (List Int)\ndecoded = fromData input\nmain = equalsData (toData decoded) input\n" --- --- unoptimized Core @@ -35,38 +34,9 @@ main#1 (lam value_14 value_14)]) (lam coerce_5 coerce_5)]) --- optimized Core -let anf#30 : Data = iData 1 in -let anf#32 : Data = iData 2 in -let anf#33 : list Data = mkCons anf#32 (con (list data) []) in -let anf#34 : list Data = mkCons anf#30 anf#33 in -let anf#35 : Data = listData anf#34 in -let anf#36 : Data = listData (con (list data) []) in -let anf#37 : list Data = mkCons anf#36 (con (list data) []) in -let anf#38 : list Data = mkCons anf#35 anf#37 in -let input#24 : Data = listData anf#38 in -equalsData input#24 input#24 +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_10 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - [(lam anf_5 - [(lam anf_6 - [(lam anf_7 - [(lam anf_8 - [(lam input_9 [[(builtin equalsData) input_9] input_9]) - [(builtin listData) anf_8]]) - [[builtin_10 anf_5] anf_7]]) - [[builtin_10 anf_6] (con (list data) [])]]) - [(builtin listData) (con (list data) [])]]) - [(builtin listData) anf_4]]) - [[builtin_10 anf_1] anf_3]]) - [[builtin_10 anf_2] (con (list data) [])]]) - [(builtin iData) (con integer 2)]]) - [(builtin iData) (con integer 1)]]) - (force (builtin mkCons))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_nested_list_rejects_malformed_element.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_nested_list_rejects_malformed_element.snap index fd90799f..c5317bfd 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_nested_list_rejects_malformed_element.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_nested_list_rejects_malformed_element.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 346 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (validate)\ndecoded : List (List Int)\ndecoded = validate (List [List [I 1, B #\"aa\"]])\nmain = nullList (unListData decoded)\n" --- --- unoptimized Core @@ -98,14 +97,7 @@ let mapList#39 : ('erased -> Data) -> list 'erased -> list Data = \(f#40 : 'eras mkCons anf#73 anf#74 in worker#72 values#41 in -let anf#84 : Data = iData 1 in -let anf#86 : Data = bData (con bytestring #aa) in -let anf#87 : list Data = mkCons anf#86 (con (list data) []) in -let anf#88 : list Data = mkCons anf#84 anf#87 in -let anf#89 : Data = listData anf#88 in -let anf#90 : list Data = mkCons anf#89 (con (list data) []) in -let anf#91 : Data = listData anf#90 in -let anf#79 : list Data = applyForward#38 anf#91 unListData in +let anf#79 : list Data = applyForward#38 (con data (List [List [I 1, B #aa]])) unListData in let anf#80 : (list Data -> list Data) -> list Data = applyForward#38 anf#79 in let anf#81 : list Data -> list Data = mapList#39 (\value#52 : Data -> let anf#75 : list Data = applyForward#38 value#52 unListData in let anf#76 : (list Data -> list Data) -> list Data = applyForward#38 anf#75 in @@ -119,45 +111,31 @@ let projection#69 : list (List Int) = unListData decoded#68 in nullList projection#69 --- optimized UPLC (program 1.1.0 - [(lam builtin_43 - [(lam builtin_44 + [(lam builtin_30 + [(lam builtin_31 [(lam applyForward_5 [(lam mapList_16 [(lam anf_17 [(lam anf_18 - [(lam anf_19 - [(lam anf_20 - [(lam anf_21 - [(lam anf_22 - [(lam anf_23 + [(lam anf_26 + [(lam anf_27 + [(lam decoded_28 + [(lam projection_29 [builtin_30 projection_29]) + [(builtin unListData) decoded_28]]) + [[applyForward_5 anf_27] (builtin listData)]]) + [anf_18 anf_26]]) + [mapList_16 + (lam value_19 + [(lam anf_20 + [(lam anf_21 [(lam anf_24 - [(lam anf_25 - [(lam anf_33 - [(lam anf_34 - [(lam decoded_35 - [(lam projection_42 [builtin_43 projection_42]) - [(builtin unListData) decoded_35]]) - [[applyForward_5 anf_34] (builtin listData)]]) - [anf_25 anf_33]]) - [mapList_16 - (lam value_26 - [(lam anf_27 - [(lam anf_28 - [(lam anf_31 - [(lam anf_32 [[applyForward_5 anf_32] (builtin listData)]) [anf_28 anf_31]]) - [mapList_16 - (lam value_29 [(lam destruct_30 value_29) [(builtin unIData) value_29]])]]) - [applyForward_5 anf_27]]) - [[applyForward_5 value_26] (builtin unListData)]])]]) - [applyForward_5 anf_24]]) - [[applyForward_5 anf_23] (builtin unListData)]]) - [(builtin listData) anf_22]]) - [[builtin_44 anf_21] (con (list data) [])]]) - [(builtin listData) anf_20]]) - [[builtin_44 anf_17] anf_19]]) - [[builtin_44 anf_18] (con (list data) [])]]) - [(builtin bData) (con bytestring #aa)]]) - [(builtin iData) (con integer 1)]]) + [(lam anf_25 [[applyForward_5 anf_25] (builtin listData)]) [anf_21 anf_24]]) + [mapList_16 + (lam value_22 [(lam destruct_23 value_22) [(builtin unIData) value_22]])]]) + [applyForward_5 anf_20]]) + [[applyForward_5 value_19] (builtin unListData)]])]]) + [applyForward_5 anf_17]]) + [[applyForward_5 (con data (List [List [I 1, B #aa]]))] (builtin unListData)]]) (lam f_6 (lam values_7 [(lam worker_15 [worker_15 values_7]) @@ -169,7 +147,7 @@ nullList projection#69 (lam field_11 (lam field_12 [(lam anf_13 - [(lam anf_14 [[builtin_44 anf_13] anf_14]) [[self_9 self_9] field_12]]) + [(lam anf_14 [[builtin_31 anf_13] anf_14]) [[self_9 self_9] field_12]]) [f_6 field_11]])) (con (list data) []))))]]))]) (lam x_3 (lam f_4 [f_4 x_3]))]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_scalar_codecs.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_scalar_codecs.snap index 97b848ed..ec2d1356 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_scalar_codecs.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__data_scalar_codecs.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 298 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData, fromData)\ndecodedInt : Int\ndecodedInt = fromData (I 42)\ndecodedBytes : Bytes\ndecodedBytes = fromData (B #\"abcd\")\nmain =\n if equalsInteger (unIData decodedInt) 42 then\n if equalsByteString (unBData decodedBytes) #\"abcd\" then\n equalsData (toData decodedInt) (I 42)\n else False\n else False\n" --- --- unoptimized Core @@ -47,40 +46,9 @@ main#1 (lam value_12 value_12)]) (lam value_9 value_9)]) --- optimized Core -let anf#34 : Data = iData 42 in -let anf#36 : Data = bData (con bytestring #abcd) in -let anf#37 : int = unIData anf#34 in -let anf#39 : bool = equalsInteger anf#37 42 in -case@Bool anf#39 of - True -> let anf#40 : bytes = unBData anf#36 in - let anf#42 : bool = equalsByteString anf#40 (con bytestring #abcd) in - case@Bool anf#42 of - True -> let anf#45 : Data = iData 42 in - equalsData anf#34 anf#45 - False -> false - False -> false +true --- optimized UPLC -(program 1.1.0 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - (case - anf_4 - (con bool False) - [(lam anf_5 - [(lam anf_6 - (case - anf_6 - (con bool False) - [(lam anf_7 [[(builtin equalsData) anf_1] anf_7]) - [(builtin iData) (con integer 42)]])) - [[(builtin equalsByteString) anf_5] (con bytestring #abcd)]]) - [(builtin unBData) anf_2]])) - [[(builtin equalsInteger) anf_3] (con integer 42)]]) - [(builtin unIData) anf_1]]) - [(builtin bData) (con bytestring #abcd)]]) - [(builtin iData) (con integer 42)]]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__expect_non_empty_list_with_as_binding_fails_in_silent_and_verbose.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__expect_non_empty_list_with_as_binding_fails_in_silent_and_verbose.snap index 8053a5a1..1879f8df 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__expect_non_empty_list_with_as_binding_fails_in_silent_and_verbose.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__expect_non_empty_list_with_as_binding_fails_in_silent_and_verbose.snap @@ -111,7 +111,7 @@ eq#31 x#53 x#53 (lam field_12 (lam field_13 [(lam anf_14 - (case anf_14 (con bool False) [[[self_5 self_5] field_11] field_13])) + (case anf_14 (con bool False) (case (constr 0 self_5 field_11 field_13) self_5))) [[(builtin equalsInteger) field_10] field_12]])) (con bool False)))) (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__expect_non_empty_list_with_as_binding_fails_silent.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__expect_non_empty_list_with_as_binding_fails_silent.snap index 8053a5a1..1879f8df 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__expect_non_empty_list_with_as_binding_fails_silent.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__expect_non_empty_list_with_as_binding_fails_silent.snap @@ -111,7 +111,7 @@ eq#31 x#53 x#53 (lam field_12 (lam field_13 [(lam anf_14 - (case anf_14 (con bool False) [[[self_5 self_5] field_11] field_13])) + (case anf_14 (con bool False) (case (constr 0 self_5 field_11 field_13) self_5))) [[(builtin equalsInteger) field_10] field_12]])) (con bool False)))) (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_blanket_without_validation_instances.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_blanket_without_validation_instances.snap index 14cb37cd..177047b3 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_blanket_without_validation_instances.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_blanket_without_validation_instances.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 526 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (fromData, toData)\ntype Token = Token Int\ntype alias Wrapped = { item : Token }\nunchecked : Big 'a => Data -> 'a\nunchecked = fromData\nwrapped : Wrapped\nwrapped = unchecked (List [Builtin.constrData 0 [I 42]])\ntokens : List Token\ntokens = unchecked (List [B #\"aa\"])\nmapping : Map Token Token\nmapping = fromData (Map [mkPairData (B #\"aa\") (I 7)])\nmain =\n if equalsData (toData wrapped) (List [Builtin.constrData 0 [I 42]]) then\n if equalsData (toData tokens) (List [B #\"aa\"]) then\n equalsData (toData mapping) (Map [mkPairData (B #\"aa\") (I 7)])\n else False\n else False\n" --- --- unoptimized Core @@ -82,106 +81,9 @@ main#1 (lam coerce_17 coerce_17)]) (lam value_16 value_16)]) --- optimized Core -let anf#61 : Data = iData 42 in -let anf#62 : list Data = mkCons anf#61 (con (list data) []) in -let anf#63 : Data = constrData 0 anf#62 in -let anf#64 : list Data = mkCons anf#63 (con (list data) []) in -let anf#65 : Data = listData anf#64 in -let anf#67 : Data = bData (con bytestring #aa) in -let anf#68 : list Data = mkCons anf#67 (con (list data) []) in -let anf#69 : Data = listData anf#68 in -let anf#71 : Data = bData (con bytestring #aa) in -let anf#73 : Data = iData 7 in -let anf#74 : pair Data Data = mkPairData anf#71 anf#73 in -let anf#75 : list (pair Data Data) = mkCons anf#74 (con (list (pair data data)) []) in -let anf#76 : Data = mapData anf#75 in -let anf#80 : Data = iData 42 in -let anf#81 : list Data = mkCons anf#80 (con (list data) []) in -let anf#82 : Data = constrData 0 anf#81 in -let anf#83 : list Data = mkCons anf#82 (con (list data) []) in -let anf#84 : Data = listData anf#83 in -let anf#85 : bool = equalsData anf#65 anf#84 in -case@Bool anf#85 of - True -> let anf#88 : Data = bData (con bytestring #aa) in - let anf#89 : list Data = mkCons anf#88 (con (list data) []) in - let anf#90 : Data = listData anf#89 in - let anf#91 : bool = equalsData anf#69 anf#90 in - case@Bool anf#91 of - True -> let anf#94 : Data = bData (con bytestring #aa) in - let anf#96 : Data = iData 7 in - let anf#97 : pair Data Data = mkPairData anf#94 anf#96 in - let anf#98 : list (pair Data Data) = mkCons anf#97 (con (list (pair data data)) []) in - let anf#99 : Data = mapData anf#98 in - equalsData anf#76 anf#99 - False -> false - False -> false +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_29 - [(lam partial_30 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - [(lam anf_5 - [(lam anf_6 - [(lam anf_7 - [(lam anf_8 - [(lam anf_9 - [(lam anf_10 - [(lam anf_11 - [(lam anf_12 - [(lam anf_13 - [(lam anf_14 - [(lam anf_15 - [(lam anf_16 - [(lam anf_17 - [(lam anf_18 - [(lam anf_19 - (case - anf_19 - (con bool False) - [(lam anf_20 - [(lam anf_21 - [(lam anf_22 - [(lam anf_23 - (case - anf_23 - (con bool False) - [(lam anf_24 - [(lam anf_25 - [(lam anf_26 - [(lam anf_27 - [(lam anf_28 [[(builtin equalsData) anf_13] anf_28]) [(builtin mapData) anf_27]]) - [[builtin_29 anf_26] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_24] anf_25]]) - [(builtin iData) (con integer 7)]]) - [(builtin bData) (con bytestring #aa)]])) - [[(builtin equalsData) anf_8] anf_22]]) - [(builtin listData) anf_21]]) - [[builtin_29 anf_20] (con (list data) [])]]) - [(builtin bData) (con bytestring #aa)]])) - [[(builtin equalsData) anf_5] anf_18]]) - [(builtin listData) anf_17]]) - [[builtin_29 anf_16] (con (list data) [])]]) - [partial_30 anf_15]]) - [[builtin_29 anf_14] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - [(builtin mapData) anf_12]]) - [[builtin_29 anf_11] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_9] anf_10]]) - [(builtin iData) (con integer 7)]]) - [(builtin bData) (con bytestring #aa)]]) - [(builtin listData) anf_7]]) - [[builtin_29 anf_6] (con (list data) [])]]) - [(builtin bData) (con bytestring #aa)]]) - [(builtin listData) anf_4]]) - [[builtin_29 anf_3] (con (list data) [])]]) - [partial_30 anf_2]]) - [[builtin_29 anf_1] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - [(builtin constrData) (con integer 0)]]) - (force (builtin mkCons))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_default_for_user_type.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_default_for_user_type.snap index 55fc2463..e7f61970 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_default_for_user_type.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_default_for_user_type.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 470 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (FromData)\ntype Datum = Datum Int\ndecoded : Datum\ndecoded = fromData (Builtin.constrData 0 [I 42])\nmain =\n case decoded of\n Datum number -> unIData number\n" --- --- unoptimized Core @@ -41,33 +40,9 @@ case@Pair projection#14 of (lam value_13 value_13)]) (lam coerce_12 coerce_12)]) --- optimized Core -let anf#31 : Data = iData 42 in -let anf#32 : list Data = mkCons anf#31 (con (list data) []) in -let anf#33 : Data = constrData 0 anf#32 in -let projection#22 : pair int (list Data) = unConstrData anf#33 in -case@Pair projection#22 of - Pair tag#23 fields#24 -> case@List fields#24 of - Cons field#25 fieldTail#26 -> unIData field#25 +42 --- optimized UPLC -(program 1.1.0 - [(lam builtin_9 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam projection_4 - (case - projection_4 - (lam tag_5 - (lam fields_6 - (case - fields_6 - (lam field_7 (lam fieldTail_8 [(builtin unIData) field_7])) - (error)))))) - [(builtin unConstrData) anf_3]]) - [[(builtin constrData) (con integer 0)] anf_2]]) - [[builtin_9 anf_1] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - (force (builtin mkCons))]) +(program 1.1.0 (con integer 42)) --- result (con integer 42) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_leaves_nested_data_unchecked.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_leaves_nested_data_unchecked.snap index fe864649..97ee5f7b 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_leaves_nested_data_unchecked.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_leaves_nested_data_unchecked.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 417 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (fromData)\ndecoded : List (List Int)\ndecoded = fromData (List [List [B #\"aa\"]])\nmain = nullList (unListData decoded)\n" --- --- unoptimized Core @@ -29,30 +28,9 @@ main#1 (lam value_9 value_9)]) (lam coerce_8 coerce_8)]) --- optimized Core -let anf#22 : Data = bData (con bytestring #aa) in -let anf#23 : list Data = mkCons anf#22 (con (list data) []) in -let anf#24 : Data = listData anf#23 in -let anf#25 : list Data = mkCons anf#24 (con (list data) []) in -let anf#26 : Data = listData anf#25 in -let projection#19 : list (List Int) = unListData anf#26 in -nullList projection#19 +false --- optimized UPLC -(program 1.1.0 - [(lam builtin_7 - [(lam builtin_8 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - [(lam anf_5 - [(lam projection_6 [builtin_7 projection_6]) [(builtin unListData) anf_5]]) - [(builtin listData) anf_4]]) - [[builtin_8 anf_3] (con (list data) [])]]) - [(builtin listData) anf_2]]) - [[builtin_8 anf_1] (con (list data) [])]]) - [(builtin bData) (con bytestring #aa)]]) - (force (builtin mkCons))]) - (force (builtin nullList))]) +(program 1.1.0 (con bool False)) --- result (con bool False) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_leaves_outer_shape_unchecked.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_leaves_outer_shape_unchecked.snap index c353cc7e..6b0ceea5 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_leaves_outer_shape_unchecked.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_leaves_outer_shape_unchecked.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 430 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (fromData)\ndecoded : Int\ndecoded = fromData (B #\"aa\")\nmain = equalsData (coerce decoded) (B #\"aa\")\n" --- --- unoptimized Core @@ -22,15 +21,9 @@ main#1 (lam coerce_9 coerce_9)]) (lam value_8 value_8)]) --- optimized Core -let anf#20 : Data = bData (con bytestring #aa) in -let anf#23 : Data = bData (con bytestring #aa) in -equalsData anf#20 anf#23 +true --- optimized UPLC -(program 1.1.0 - [(lam anf_1 - [(lam anf_2 [[(builtin equalsData) anf_1] anf_2]) - [(builtin bData) (con bytestring #aa)]]) - [(builtin bData) (con bytestring #aa)]]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_malformed_value_fails_on_use.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_malformed_value_fails_on_use.snap index 4cb53335..86832925 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_malformed_value_fails_on_use.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__from_data_malformed_value_fails_on_use.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 486 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (fromData)\ndecoded : Int\ndecoded = fromData (B #\"aa\")\nmain = unIData decoded\n" --- --- unoptimized Core @@ -19,11 +18,9 @@ main#1 (lam value_7 value_7)]) (lam coerce_6 coerce_6)]) --- optimized Core -let anf#16 : Data = bData (con bytestring #aa) in -unIData anf#16 +unIData (con data (B #aa)) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unIData) anf_1]) [(builtin bData) (con bytestring #aa)]]) +(program 1.1.0 [(builtin unIData) (con data (B #aa))]) --- result error: Runtime(MalFormedData(ByteString([170]))) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__hard_soft_cast.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__hard_soft_cast.snap index 460834da..ce1f2ec6 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__hard_soft_cast.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__hard_soft_cast.snap @@ -152,7 +152,7 @@ case@Data value#22 of DataList field#63 -> force leaf#24 DataI field#64 -> force leaf#24 DataB field#65 -> force leaf#24 in -let x#84 : Data = constrData 0 (con (list data) []) in +let x#84 : Data = (con data (Constr 0 [])) in let match#85 : nash/base:Option.option Main.foo = decode#66 x#84 in case@Tag match#85 of 0 field#86 -> true @@ -189,44 +189,47 @@ case@Tag match#85 of (case match_31 (lam field_32 field_32) (error))]) [decode_23 x_28]])) [decode_23 x_28]]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) + (con data (Constr 0 []))]) (lam value_2 [(lam leaf_3 [(lam generated_35 (force - [[[[[[builtin_36 generated_35] - (delay - [(lam field_4 - (case - field_4 - (lam field_5 - (lam field_6 - [(lam anf_7 - [(lam anf_8 - (case - anf_8 - [(lam anf_12 - [(lam anf_13 - (case - anf_13 - (force leaf_3) - (case - field_6 - (lam field_15 (lam field_16 (force leaf_3))) - [(lam anf_14 (constr 0 anf_14)) (constr 1)]))) - [anf_12 (con integer 1)]]) - [eq_1 field_5]] + (case + (constr 0 + generated_35 + (delay + [(lam field_4 + (case + field_4 + (lam field_5 + (lam field_6 + [(lam anf_7 + [(lam anf_8 (case - field_6 - (lam field_10 (lam field_11 (force leaf_3))) - [(lam anf_9 (constr 0 anf_9)) (constr 0)]))) - [anf_7 (con integer 0)]]) - [eq_1 field_5]])))) - [(builtin unConstrData) generated_35]])] - (delay (force leaf_3))] - (delay (force leaf_3))] - (delay (force leaf_3))] - (delay (force leaf_3))])) + anf_8 + [(lam anf_12 + [(lam anf_13 + (case + anf_13 + (force leaf_3) + (case + field_6 + (lam field_15 (lam field_16 (force leaf_3))) + [(lam anf_14 (constr 0 anf_14)) (constr 1)]))) + [anf_12 (con integer 1)]]) + [eq_1 field_5]] + (case + field_6 + (lam field_10 (lam field_11 (force leaf_3))) + [(lam anf_9 (constr 0 anf_9)) (constr 0)]))) + [anf_7 (con integer 0)]]) + [eq_1 field_5]])))) + [(builtin unConstrData) generated_35]]) + (delay (force leaf_3)) + (delay (force leaf_3)) + (delay (force leaf_3)) + (delay (force leaf_3))) + builtin_36))) value_2]) (delay (constr 1))])]) (builtin equalsInteger)]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__hard_soft_cast_silent.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__hard_soft_cast_silent.snap index 460834da..ce1f2ec6 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__hard_soft_cast_silent.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__hard_soft_cast_silent.snap @@ -152,7 +152,7 @@ case@Data value#22 of DataList field#63 -> force leaf#24 DataI field#64 -> force leaf#24 DataB field#65 -> force leaf#24 in -let x#84 : Data = constrData 0 (con (list data) []) in +let x#84 : Data = (con data (Constr 0 [])) in let match#85 : nash/base:Option.option Main.foo = decode#66 x#84 in case@Tag match#85 of 0 field#86 -> true @@ -189,44 +189,47 @@ case@Tag match#85 of (case match_31 (lam field_32 field_32) (error))]) [decode_23 x_28]])) [decode_23 x_28]]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) + (con data (Constr 0 []))]) (lam value_2 [(lam leaf_3 [(lam generated_35 (force - [[[[[[builtin_36 generated_35] - (delay - [(lam field_4 - (case - field_4 - (lam field_5 - (lam field_6 - [(lam anf_7 - [(lam anf_8 - (case - anf_8 - [(lam anf_12 - [(lam anf_13 - (case - anf_13 - (force leaf_3) - (case - field_6 - (lam field_15 (lam field_16 (force leaf_3))) - [(lam anf_14 (constr 0 anf_14)) (constr 1)]))) - [anf_12 (con integer 1)]]) - [eq_1 field_5]] + (case + (constr 0 + generated_35 + (delay + [(lam field_4 + (case + field_4 + (lam field_5 + (lam field_6 + [(lam anf_7 + [(lam anf_8 (case - field_6 - (lam field_10 (lam field_11 (force leaf_3))) - [(lam anf_9 (constr 0 anf_9)) (constr 0)]))) - [anf_7 (con integer 0)]]) - [eq_1 field_5]])))) - [(builtin unConstrData) generated_35]])] - (delay (force leaf_3))] - (delay (force leaf_3))] - (delay (force leaf_3))] - (delay (force leaf_3))])) + anf_8 + [(lam anf_12 + [(lam anf_13 + (case + anf_13 + (force leaf_3) + (case + field_6 + (lam field_15 (lam field_16 (force leaf_3))) + [(lam anf_14 (constr 0 anf_14)) (constr 1)]))) + [anf_12 (con integer 1)]]) + [eq_1 field_5]] + (case + field_6 + (lam field_10 (lam field_11 (force leaf_3))) + [(lam anf_9 (constr 0 anf_9)) (constr 0)]))) + [anf_7 (con integer 0)]]) + [eq_1 field_5]])))) + [(builtin unConstrData) generated_35]]) + (delay (force leaf_3)) + (delay (force leaf_3)) + (delay (force leaf_3)) + (delay (force leaf_3))) + builtin_36))) value_2]) (delay (constr 1))])]) (builtin equalsInteger)]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__map_lift_preserves_big_components.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__map_lift_preserves_big_components.snap index 514e06ac..16002f84 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__map_lift_preserves_big_components.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__map_lift_preserves_big_components.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 573 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Lift exposing (Lift)\nentries : map Int (List Data)\nentries = [Builtin.mkPairData (Builtin.iData 7) (Builtin.listData [I 42])]\nwrapped : Map Int (List Data)\nwrapped = lift entries\ndecoded : map Int (List Data)\ndecoded = lower wrapped\nmain : int\nmain =\n case decoded of\n [pair(key, values)] ->\n case Builtin.unListData values of\n [I number] -> Builtin.addInteger (Builtin.unIData key) number\n _ -> fail\n _ -> fail\n" --- --- unoptimized Core @@ -102,13 +101,7 @@ main#1 (builtin mapData)]) (builtin unMapData)]) --- optimized Core -let anf#66 : Int = iData 7 in -let anf#68 : Data = iData 42 in -let anf#69 : list Data = mkCons anf#68 (con (list data) []) in -let anf#70 : List Data = listData anf#69 in -let anf#71 : pair Int (List Data) = mkPairData anf#66 anf#70 in -let entries#12 : list (pair Int (List Data)) = mkCons anf#71 (con (list (pair data data)) []) in -let wrapped#13 : Map Int (List Data) = mapData entries#12 in +let wrapped#13 : Map Int (List Data) = mapData (con (list (pair data data)) [((I 7), (List [I 42]))]) in let decoded#14 : list (pair Int (List Data)) = unMapData wrapped#13 in let leaf#27 : @delay int = delay error in case@List decoded#14 of @@ -131,62 +124,53 @@ case@List decoded#14 of Cons field#62 field#63 -> force leaf#27 --- optimized UPLC (program 1.1.0 - [(lam builtin_37 - [(lam builtin_38 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - [(lam anf_5 - [(lam entries_6 - [(lam wrapped_7 - [(lam decoded_8 - [(lam leaf_9 - (case - decoded_8 - (lam field_10 - (lam field_11 - (case - field_10 - (lam field_15 - (lam field_16 - (case - field_11 - (lam field_34 (lam field_35 (force leaf_9))) - [(lam projection_17 - [(lam leaf_18 - (case - projection_17 - (lam field_19 - (lam field_20 - [(lam generated_36 - (force - [[[[[[builtin_37 generated_36] (delay (force leaf_18))] (delay (force leaf_18))] - (delay (force leaf_18))] - (delay - [(lam field_24 - (case - field_20 - (lam field_26 (lam field_32 (force leaf_18))) - [(lam anf_25 [[(builtin addInteger) anf_25] field_24]) - [(builtin unIData) field_15]])) - [(builtin unIData) generated_36]])] - (delay (force leaf_18))])) - field_19])) - (force leaf_18))) - (delay (error))]) - [(builtin unListData) field_16]])))))) - (force leaf_9))) - (delay (error))]) - [(builtin unMapData) wrapped_7]]) - [(builtin mapData) entries_6]]) - [[builtin_38 anf_5] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_1] anf_4]]) - [(builtin listData) anf_3]]) - [[builtin_38 anf_2] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - [(builtin iData) (con integer 7)]]) - (force (builtin mkCons))]) + [(lam builtin_25 + [(lam wrapped_1 + [(lam decoded_2 + [(lam leaf_3 + (case + decoded_2 + (lam field_4 + (lam field_5 + (case + field_4 + (lam field_6 + (lam field_7 + (case + field_5 + (lam field_22 (lam field_23 (force leaf_3))) + [(lam projection_8 + [(lam leaf_9 + (case + projection_8 + (lam field_10 + (lam field_11 + [(lam generated_24 + (force + (case + (constr 0 + generated_24 + (delay (force leaf_9)) + (delay (force leaf_9)) + (delay (force leaf_9)) + (delay + [(lam field_17 + (case + field_11 + (lam field_19 (lam field_20 (force leaf_9))) + [(lam anf_18 [[(builtin addInteger) anf_18] field_17]) + [(builtin unIData) field_6]])) + [(builtin unIData) generated_24]]) + (delay (force leaf_9))) + builtin_25))) + field_10])) + (force leaf_9))) + (delay (error))]) + [(builtin unListData) field_7]])))))) + (force leaf_3))) + (delay (error))]) + [(builtin unMapData) wrapped_1]]) + [(builtin mapData) (con (list (pair data data)) [((I 7), (List [I 42]))])]]) (force (builtin chooseData))]) --- result (con integer 49) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_1.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_1.snap index 96e8370a..9616c968 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_1.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_1.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 119 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nexpected : list int\nexpected = [1]\nmain : bool\nmain = eq (Builtin.mkCons 1 []) expected\n" --- --- unoptimized Core @@ -91,36 +90,27 @@ letrec True -> eq#27 field#35 field#40 False -> false in -let expected#45 : list int = mkCons 1 (con (list integer) []) in -let anf#50 : list int = mkCons 1 (con (list integer) []) in -eq#27 anf#50 expected#45 +eq#27 (con (list integer) [1]) (con (list integer) [1]) --- optimized UPLC (program 1.1.0 - [(lam builtin_18 - [(lam partial_19 - [(lam eq_15 - [(lam expected_16 - [(lam anf_17 [[eq_15 anf_17] expected_16]) [partial_19 (con (list integer) [])]]) - [partial_19 (con (list integer) [])]]) - [(lam self_4 [self_4 self_4]) - (lam self_5 - (lam xs_6 - (lam ys_7 - (case - xs_6 - (lam field_10 - (lam field_11 - (case - ys_7 - (lam field_12 - (lam field_13 - [(lam anf_14 - (case anf_14 (con bool False) [[[self_5 self_5] field_11] field_13])) - [[(builtin equalsInteger) field_10] field_12]])) - (con bool False)))) - (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) - [builtin_18 (con integer 1)]]) - (force (builtin mkCons))]) + [(lam eq_15 [[eq_15 (con (list integer) [1])] (con (list integer) [1])]) + [(lam self_4 [self_4 self_4]) + (lam self_5 + (lam xs_6 + (lam ys_7 + (case + xs_6 + (lam field_10 + (lam field_11 + (case + ys_7 + (lam field_12 + (lam field_13 + [(lam anf_14 + (case anf_14 (con bool False) (case (constr 0 self_5 field_11 field_13) self_5))) + [[(builtin equalsInteger) field_10] field_12]])) + (con bool False)))) + (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_2.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_2.snap index 89e74206..0ceb82fe 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_2.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_2.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 133 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (ToData)\ntype Option = Some Int | None\nmain : bool\nmain = equalsData\n (toData (Builtin.listData (Builtin.mkCons (Some 42) [None])))\n (toData (Builtin.listData [Some 42, None]))\n" --- --- unoptimized Core @@ -41,54 +40,40 @@ let fromInt#9 : int -> Int = iData in let anf#14 : Int = fromInt#9 42 in let anf#13 : list Data = mkCons anf#14 (con (list data) []) in let anf#15 : Main.Option = constrData 0 anf#13 in -let anf#16 : Main.Option = constrData 1 (con (list data) []) in -let anf#17 : list Main.Option = mkCons anf#16 (con (list data) []) in -let anf#18 : list Main.Option = mkCons anf#15 anf#17 in +let anf#18 : list Main.Option = mkCons anf#15 (con (list data) [(Constr 1 [])]) in let anf#19 : List Main.Option = listData anf#18 in let anf#22 : Int = fromInt#9 42 in let anf#21 : list Data = mkCons anf#22 (con (list data) []) in let anf#23 : Main.Option = constrData 0 anf#21 in -let anf#24 : Main.Option = constrData 1 (con (list data) []) in -let anf#25 : list Main.Option = mkCons anf#24 (con (list data) []) in -let anf#26 : list Main.Option = mkCons anf#23 anf#25 in +let anf#26 : list Main.Option = mkCons anf#23 (con (list data) [(Constr 1 [])]) in let anf#27 : List Main.Option = listData anf#26 in equalsData anf#19 anf#27 --- optimized UPLC (program 1.1.0 - [(lam builtin_31 - [(lam partial_32 - [(lam partial_33 - [(lam fromInt_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - [(lam anf_5 - [(lam anf_6 - [(lam anf_7 - [(lam anf_8 - [(lam anf_10 - [(lam anf_11 - [(lam anf_12 - [(lam anf_20 - [(lam anf_28 - [(lam anf_29 - [(lam anf_30 [[(builtin equalsData) anf_8] anf_30]) [(builtin listData) anf_29]]) - [[builtin_31 anf_12] anf_28]]) - [[builtin_31 anf_20] (con (list data) [])]]) - [partial_32 (con (list data) [])]]) - [partial_33 anf_11]]) - [[builtin_31 anf_10] (con (list data) [])]]) - [fromInt_1 (con integer 42)]]) - [(builtin listData) anf_7]]) - [[builtin_31 anf_4] anf_6]]) - [[builtin_31 anf_5] (con (list data) [])]]) - [partial_32 (con (list data) [])]]) - [partial_33 anf_3]]) - [[builtin_31 anf_2] (con (list data) [])]]) - [fromInt_1 (con integer 42)]]) - (builtin iData)]) - [(builtin constrData) (con integer 0)]]) - [(builtin constrData) (con integer 1)]]) + [(lam builtin_13 + [(lam partial_14 + [(lam fromInt_1 + [(lam anf_2 + [(lam anf_3 + [(lam anf_4 + [(lam anf_5 + [(lam anf_6 + [(lam anf_7 + [(lam anf_8 + [(lam anf_10 + [(lam anf_11 + [(lam anf_12 [[(builtin equalsData) anf_6] anf_12]) [(builtin listData) anf_11]]) + [[builtin_13 anf_10] (con (list data) [(Constr 1 [])])]]) + [partial_14 anf_8]]) + [[builtin_13 anf_7] (con (list data) [])]]) + [fromInt_1 (con integer 42)]]) + [(builtin listData) anf_5]]) + [[builtin_13 anf_4] (con (list data) [(Constr 1 [])])]]) + [partial_14 anf_3]]) + [[builtin_13 anf_2] (con (list data) [])]]) + [fromInt_1 (con integer 42)]]) + (builtin iData)]) + [(builtin constrData) (con integer 0)]]) (force (builtin mkCons))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_3.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_3.snap index 97e2cc42..0614c171 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_3.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_cons_direct_invoke_3.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 148 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData)\nmain : bool\nmain = equalsData\n (toData (Builtin.mapData (Builtin.mkCons (Builtin.mkPairData (I 1) (I 1)) (Builtin.mkNilPairData ()))))\n (toData (Builtin.mapData [Builtin.mkPairData (I 1) (I 1)]))\n" --- --- unoptimized Core @@ -34,43 +33,9 @@ main#1 (lam value_10 value_10)]) (lam coerce_9 coerce_9)]) --- optimized Core -let anf#24 : Data = iData 1 in -let anf#26 : Data = iData 1 in -let anf#27 : pair Data Data = mkPairData anf#24 anf#26 in -let anf#29 : list (pair Data Data) = mkNilPairData () in -let anf#30 : list (pair Data Data) = mkCons anf#27 anf#29 in -let anf#31 : Map Data Data = mapData anf#30 in -let anf#34 : Data = iData 1 in -let anf#36 : Data = iData 1 in -let anf#37 : pair Data Data = mkPairData anf#34 anf#36 in -let anf#38 : list (pair Data Data) = mkCons anf#37 (con (list (pair data data)) []) in -let anf#39 : Map Data Data = mapData anf#38 in -equalsData anf#31 anf#39 +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_12 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - [(lam anf_5 - [(lam anf_6 - [(lam anf_7 - [(lam anf_8 - [(lam anf_9 - [(lam anf_10 - [(lam anf_11 [[(builtin equalsData) anf_6] anf_11]) [(builtin mapData) anf_10]]) - [[builtin_12 anf_9] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_7] anf_8]]) - [(builtin iData) (con integer 1)]]) - [(builtin iData) (con integer 1)]]) - [(builtin mapData) anf_5]]) - [[builtin_12 anf_3] anf_4]]) - [(builtin mkNilPairData) (con unit ())]]) - [[(builtin mkPairData) anf_1] anf_2]]) - [(builtin iData) (con integer 1)]]) - [(builtin iData) (con integer 1)]]) - (force (builtin mkCons))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_nil_list_data.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_nil_list_data.snap index 9081fce1..94b1f0a5 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_nil_list_data.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_nil_list_data.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 176 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData)\nmain : bool\nmain = equalsData\n (toData (Builtin.listData (Builtin.mkNilData ())))\n (toData (Builtin.listData (Builtin.mkNilData ())))\n" --- --- unoptimized Core @@ -19,20 +18,9 @@ main#1 (lam value_5 value_5)]) (lam coerce_4 coerce_4)]) --- optimized Core -let anf#12 : list Data = mkNilData () in -let anf#13 : List Data = listData anf#12 in -let anf#16 : list Data = mkNilData () in -let anf#17 : List Data = listData anf#16 in -equalsData anf#13 anf#17 +true --- optimized UPLC -(program 1.1.0 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 [[(builtin equalsData) anf_2] anf_4]) [(builtin listData) anf_3]]) - [(builtin mkNilData) (con unit ())]]) - [(builtin listData) anf_1]]) - [(builtin mkNilData) (con unit ())]]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_nil_pair_data.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_nil_pair_data.snap index b40e4869..215c75ec 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_nil_pair_data.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_nil_pair_data.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 162 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData)\nmain : bool\nmain = equalsData\n (toData (Builtin.mapData (Builtin.mkNilPairData ())))\n (toData (Builtin.mapData (Builtin.mkNilPairData ())))\n" --- --- unoptimized Core @@ -21,20 +20,9 @@ main#1 (lam value_5 value_5)]) (lam coerce_4 coerce_4)]) --- optimized Core -let anf#12 : list (pair Data Data) = mkNilPairData () in -let anf#13 : Map Data Data = mapData anf#12 in -let anf#16 : list (pair Data Data) = mkNilPairData () in -let anf#17 : Map Data Data = mapData anf#16 in -equalsData anf#13 anf#17 +true --- optimized UPLC -(program 1.1.0 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 [[(builtin equalsData) anf_2] anf_4]) [(builtin mapData) anf_3]]) - [(builtin mkNilPairData) (con unit ())]]) - [(builtin mapData) anf_1]]) - [(builtin mkNilPairData) (con unit ())]]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_pair_data.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_pair_data.snap index 3717f450..6c648725 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_pair_data.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__mk_pair_data.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 190 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData)\nmain : bool\nmain = equalsData\n (toData (Builtin.fstPair (Builtin.mkPairData (Builtin.iData 1) (Builtin.iData 2))))\n (toData (Builtin.iData 1))\n" --- --- unoptimized Core @@ -25,26 +24,9 @@ main#1 (lam value_5 value_5)]) (lam coerce_4 coerce_4)]) --- optimized Core -let anf#16 : Int = iData 1 in -let anf#18 : Int = iData 2 in -let evaluated#12 : pair Int Int = mkPairData anf#16 anf#18 in -let projection#13 : Int = fstPair evaluated#12 in -let anf#21 : Int = iData 1 in -equalsData projection#13 anf#21 +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_6 - [(lam anf_1 - [(lam anf_2 - [(lam evaluated_3 - [(lam projection_4 - [(lam anf_5 [[(builtin equalsData) projection_4] anf_5]) - [(builtin iData) (con integer 1)]]) - [builtin_6 evaluated_3]]) - [[(builtin mkPairData) anf_1] anf_2]]) - [(builtin iData) (con integer 2)]]) - [(builtin iData) (con integer 1)]]) - (force (force (builtin fstPair)))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__to_data_blanket_user_types_and_collections.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__to_data_blanket_user_types_and_collections.snap index 6d805f82..3c232412 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__to_data_blanket_user_types_and_collections.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__to_data_blanket_user_types_and_collections.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 499 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData)\ntype Token = Token Int\ntype alias Wrapped = { item : Token }\nwrapped : Wrapped\nwrapped = { item = (Token 42) }\nidentityData : Big 'a => 'a -> Data\nidentityData = toData\nmain =\n if equalsData (toData wrapped) (List [Builtin.constrData 0 [I 42]]) then\n check\n else False\ncheck =\n if equalsData (identityData (Token 42)) (Builtin.constrData 0 [I 42]) then\n if equalsData (toData (listData [Token 42])) (List [Builtin.constrData 0 [I 42]]) then\n equalsData (toData (mapData [mkPairData (Token 1) (Token 2)]))\n (Map [mkPairData (Builtin.constrData 0 [I 1]) (Builtin.constrData 0 [I 2])])\n else False\n else False\n" --- --- unoptimized Core @@ -118,22 +117,14 @@ let wrapped#31 : { _0 : Main.Token } = listData anf#52 in let anf#54 : Int = fromInt#29 42 in let anf#53 : list Data = mkCons anf#54 (con (list data) []) in let anf#55 : Main.Token = constrData 0 anf#53 in -let anf#59 : Data = iData 42 in -let anf#60 : list Data = mkCons anf#59 (con (list data) []) in -let anf#61 : Data = constrData 0 anf#60 in -let anf#62 : bool = equalsData anf#55 anf#61 in +let anf#62 : bool = equalsData anf#55 (con data (Constr 0 [I 42])) in let check#45 : bool = case@Bool anf#62 of True -> let anf#64 : Int = fromInt#29 42 in let anf#63 : list Data = mkCons anf#64 (con (list data) []) in let anf#65 : Main.Token = constrData 0 anf#63 in let anf#66 : list Main.Token = mkCons anf#65 (con (list data) []) in let anf#67 : List Main.Token = listData anf#66 in - let anf#71 : Data = iData 42 in - let anf#72 : list Data = mkCons anf#71 (con (list data) []) in - let anf#73 : Data = constrData 0 anf#72 in - let anf#74 : list Data = mkCons anf#73 (con (list data) []) in - let anf#75 : Data = listData anf#74 in - let anf#76 : bool = equalsData anf#67 anf#75 in + let anf#76 : bool = equalsData anf#67 (con data (List [Constr 0 [I 42]])) in case@Bool anf#76 of True -> let anf#78 : Int = fromInt#29 1 in let anf#77 : list Data = mkCons anf#78 (con (list data) []) in @@ -144,31 +135,17 @@ let check#45 : bool = case@Bool anf#62 of let anf#83 : pair Main.Token Main.Token = mkPairData anf#79 anf#82 in let anf#84 : list (pair Main.Token Main.Token) = mkCons anf#83 (con (list (pair data data)) []) in let anf#85 : Map Main.Token Main.Token = mapData anf#84 in - let anf#89 : Data = iData 1 in - let anf#90 : list Data = mkCons anf#89 (con (list data) []) in - let anf#91 : Data = constrData 0 anf#90 in - let anf#94 : Data = iData 2 in - let anf#95 : list Data = mkCons anf#94 (con (list data) []) in - let anf#96 : Data = constrData 0 anf#95 in - let anf#97 : pair Data Data = mkPairData anf#91 anf#96 in - let anf#98 : list (pair Data Data) = mkCons anf#97 (con (list (pair data data)) []) in - let anf#99 : Data = mapData anf#98 in - equalsData anf#85 anf#99 + equalsData anf#85 (con data (Map [(Constr 0 [I 1], Constr 0 [I 2])])) False -> false False -> false in -let anf#103 : Data = iData 42 in -let anf#104 : list Data = mkCons anf#103 (con (list data) []) in -let anf#105 : Data = constrData 0 anf#104 in -let anf#106 : list Data = mkCons anf#105 (con (list data) []) in -let anf#107 : Data = listData anf#106 in -let anf#108 : bool = equalsData wrapped#31 anf#107 in +let anf#108 : bool = equalsData wrapped#31 (con data (List [Constr 0 [I 42]])) in case@Bool anf#108 of True -> check#45 False -> false --- optimized UPLC (program 1.1.0 - [(lam builtin_69 - [(lam partial_70 + [(lam builtin_28 + [(lam partial_29 [(lam fromInt_1 [(lam anf_2 [(lam anf_3 @@ -179,96 +156,55 @@ case@Bool anf#108 of [(lam anf_8 [(lam anf_9 [(lam anf_10 - [(lam anf_11 - [(lam anf_12 - [(lam anf_13 - [(lam check_46 - [(lam anf_47 - [(lam anf_48 - [(lam anf_56 - [(lam anf_57 - [(lam anf_58 - [(lam anf_68 (case anf_68 (con bool False) check_46)) - [[(builtin equalsData) wrapped_6] anf_58]]) - [(builtin listData) anf_57]]) - [[builtin_69 anf_56] (con (list data) [])]]) - [partial_70 anf_48]]) - [[builtin_69 anf_47] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - (case - anf_13 - (con bool False) + [(lam check_26 + [(lam anf_27 (case anf_27 (con bool False) check_26)) + [[(builtin equalsData) wrapped_6] (con data (List [Constr 0 [I 42]]))]]) + (case + anf_10 + (con bool False) + [(lam anf_11 + [(lam anf_12 + [(lam anf_13 [(lam anf_14 [(lam anf_15 [(lam anf_16 - [(lam anf_17 - [(lam anf_18 - [(lam anf_19 - [(lam anf_20 - [(lam anf_21 - [(lam anf_22 - [(lam anf_23 - [(lam anf_24 - (case - anf_24 - (con bool False) + (case + anf_16 + (con bool False) + [(lam anf_17 + [(lam anf_18 + [(lam anf_19 + [(lam anf_20 + [(lam anf_21 + [(lam anf_22 + [(lam anf_23 + [(lam anf_24 [(lam anf_25 - [(lam anf_26 - [(lam anf_27 - [(lam anf_28 - [(lam anf_30 - [(lam anf_32 - [(lam anf_33 - [(lam anf_34 - [(lam anf_35 - [(lam anf_36 - [(lam anf_37 - [(lam anf_38 - [(lam anf_39 - [(lam anf_40 - [(lam anf_41 - [(lam anf_42 - [(lam anf_43 - [(lam anf_44 [[(builtin equalsData) anf_35] anf_44]) [(builtin mapData) anf_43]]) - [[builtin_69 anf_42] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_38] anf_41]]) - [partial_70 anf_40]]) - [[builtin_69 anf_39] (con (list data) [])]]) - [(builtin iData) (con integer 2)]]) - [partial_70 anf_37]]) - [[builtin_69 anf_36] (con (list data) [])]]) - [(builtin iData) (con integer 1)]]) - [(builtin mapData) anf_34]]) - [[builtin_69 anf_33] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_27] anf_32]]) - [partial_70 anf_30]]) - [[builtin_69 anf_28] (con (list data) [])]]) - [fromInt_1 (con integer 2)]]) - [partial_70 anf_26]]) - [[builtin_69 anf_25] (con (list data) [])]]) - [fromInt_1 (con integer 1)]])) - [[(builtin equalsData) anf_18] anf_23]]) - [(builtin listData) anf_22]]) - [[builtin_69 anf_21] (con (list data) [])]]) - [partial_70 anf_20]]) - [[builtin_69 anf_19] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - [(builtin listData) anf_17]]) - [[builtin_69 anf_16] (con (list data) [])]]) - [partial_70 anf_15]]) - [[builtin_69 anf_14] (con (list data) [])]]) - [fromInt_1 (con integer 42)]])]) - [[(builtin equalsData) anf_9] anf_12]]) - [partial_70 anf_11]]) - [[builtin_69 anf_10] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - [partial_70 anf_8]]) - [[builtin_69 anf_7] (con (list data) [])]]) + [[(builtin equalsData) anf_25] + (con data (Map [(Constr 0 [I 1], Constr 0 [I 2])]))]) + [(builtin mapData) anf_24]]) + [[builtin_28 anf_23] (con (list (pair data data)) [])]]) + [[(builtin mkPairData) anf_19] anf_22]]) + [partial_29 anf_21]]) + [[builtin_28 anf_20] (con (list data) [])]]) + [fromInt_1 (con integer 2)]]) + [partial_29 anf_18]]) + [[builtin_28 anf_17] (con (list data) [])]]) + [fromInt_1 (con integer 1)]])) + [[(builtin equalsData) anf_15] (con data (List [Constr 0 [I 42]]))]]) + [(builtin listData) anf_14]]) + [[builtin_28 anf_13] (con (list data) [])]]) + [partial_29 anf_12]]) + [[builtin_28 anf_11] (con (list data) [])]]) + [fromInt_1 (con integer 42)]])]) + [[(builtin equalsData) anf_9] (con data (Constr 0 [I 42]))]]) + [partial_29 anf_8]]) + [[builtin_28 anf_7] (con (list data) [])]]) [fromInt_1 (con integer 42)]]) [(builtin listData) anf_5]]) - [[builtin_69 anf_4] (con (list data) [])]]) - [partial_70 anf_3]]) - [[builtin_69 anf_2] (con (list data) [])]]) + [[builtin_28 anf_4] (con (list data) [])]]) + [partial_29 anf_3]]) + [[builtin_28 anf_2] (con (list data) [])]]) [fromInt_1 (con integer 42)]]) (builtin iData)]) [(builtin constrData) (con integer 0)]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__validate_data_accepts_nested_map.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__validate_data_accepts_nested_map.snap index 31be3e9c..0f51e0a0 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__validate_data_accepts_nested_map.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__validate_data_accepts_nested_map.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 456 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (validate, toData)\ninput = Map [mkPairData (B #\"aa\") (List [I 42])]\ndecoded : Map Bytes (List Int)\ndecoded = validate input\nmain = equalsData (toData decoded) input\n" --- --- unoptimized Core @@ -144,13 +143,7 @@ main#1 (lam value_19 value_19)]) (lam coerce_5 coerce_5)]) --- optimized Core -let anf#120 : Data = bData (con bytestring #aa) in -let anf#122 : Data = iData 42 in -let anf#123 : list Data = mkCons anf#122 (con (list data) []) in -let anf#124 : Data = listData anf#123 in -let anf#125 : pair Data Data = mkPairData anf#120 anf#124 in -let anf#126 : list (pair Data Data) = mkCons anf#125 (con (list (pair data data)) []) in -let input#68 : Data = mapData anf#126 in +let input#68 : Data = (con data (Map [(B #aa, List [I 42])])) in let applyForward#71 : 'erased -> ('erased -> 'erased) -> 'erased = \x#69 : 'erased (f#70 : 'erased -> 'erased) -> f#70 x#69 in let anf#137 : list (pair Data Data) = applyForward#71 input#68 unMapData in let anf#138 : (list (pair Data Data) -> list (pair Data Data)) -> list (pair Data Data) = applyForward#71 anf#137 in @@ -179,70 +172,58 @@ let decoded#113 : Map Bytes (List Int) = applyForward#71 anf#140 mapData in equalsData decoded#113 input#68 --- optimized UPLC (program 1.1.0 - [(lam builtin_44 - [(lam anf_5 - [(lam anf_6 - [(lam anf_7 - [(lam anf_8 - [(lam anf_9 - [(lam anf_10 - [(lam input_11 - [(lam applyForward_14 - [(lam anf_15 - [(lam anf_16 - [(lam anf_42 - [(lam decoded_43 [[(builtin equalsData) decoded_43] input_11]) - [[applyForward_14 anf_42] (builtin mapData)]]) - [anf_16 - (lam values_17 - [(lam worker_41 [worker_41 values_17]) - [(lam self_18 [self_18 self_18]) - (lam self_19 - (lam values_20 - (case - values_20 - (lam field_21 - (lam field_22 - [(lam anf_39 - [(lam anf_40 [[builtin_44 anf_39] anf_40]) [[self_19 self_19] field_22]]) - (case - field_21 - (lam field_23 - (lam field_24 - [(lam destruct_25 - [(lam anf_26 - [(lam anf_27 - [(lam anf_37 - [(lam anf_38 [[(builtin mkPairData) field_23] anf_38]) - [[applyForward_14 anf_37] (builtin listData)]]) - [anf_27 - (lam values_28 - [(lam worker_36 [worker_36 values_28]) - [(lam self_29 [self_29 self_29]) - (lam self_30 - (lam values_31 - (case - values_31 - (lam field_32 - (lam field_33 - [(lam destruct_34 - [(lam anf_35 [[builtin_44 field_32] anf_35]) [[self_30 self_30] field_33]]) - [(builtin unIData) field_32]])) - (con (list data) []))))]])]]) - [applyForward_14 anf_26]]) - [[applyForward_14 field_24] (builtin unListData)]]) - [(builtin unBData) field_23]])))])) - (con (list (pair data data)) []))))]])]]) - [applyForward_14 anf_15]]) - [[applyForward_14 input_11] (builtin unMapData)]]) - (lam x_12 (lam f_13 [f_13 x_12]))]) - [(builtin mapData) anf_10]]) - [[builtin_44 anf_9] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_5] anf_8]]) - [(builtin listData) anf_7]]) - [[builtin_44 anf_6] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - [(builtin bData) (con bytestring #aa)]]) + [(lam builtin_38 + [(lam input_5 + [(lam applyForward_8 + [(lam anf_9 + [(lam anf_10 + [(lam anf_36 + [(lam decoded_37 [[(builtin equalsData) decoded_37] input_5]) + [[applyForward_8 anf_36] (builtin mapData)]]) + [anf_10 + (lam values_11 + [(lam worker_35 [worker_35 values_11]) + [(lam self_12 [self_12 self_12]) + (lam self_13 + (lam values_14 + (case + values_14 + (lam field_15 + (lam field_16 + [(lam anf_33 + [(lam anf_34 [[builtin_38 anf_33] anf_34]) [[self_13 self_13] field_16]]) + (case + field_15 + (lam field_17 + (lam field_18 + [(lam destruct_19 + [(lam anf_20 + [(lam anf_21 + [(lam anf_31 + [(lam anf_32 [[(builtin mkPairData) field_17] anf_32]) + [[applyForward_8 anf_31] (builtin listData)]]) + [anf_21 + (lam values_22 + [(lam worker_30 [worker_30 values_22]) + [(lam self_23 [self_23 self_23]) + (lam self_24 + (lam values_25 + (case + values_25 + (lam field_26 + (lam field_27 + [(lam destruct_28 + [(lam anf_29 [[builtin_38 field_26] anf_29]) [[self_24 self_24] field_27]]) + [(builtin unIData) field_26]])) + (con (list data) []))))]])]]) + [applyForward_8 anf_20]]) + [[applyForward_8 field_18] (builtin unListData)]]) + [(builtin unBData) field_17]])))])) + (con (list (pair data data)) []))))]])]]) + [applyForward_8 anf_9]]) + [[applyForward_8 input_5] (builtin unMapData)]]) + (lam x_6 (lam f_7 [f_7 x_6]))]) + (con data (Map [(B #aa, List [I 42])]))]) (force (builtin mkCons))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__validate_data_rejects_wrong_scalar_shape.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__validate_data_rejects_wrong_scalar_shape.snap index 622e84be..71ff9de7 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__validate_data_rejects_wrong_scalar_shape.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__builtins__validate_data_rejects_wrong_scalar_shape.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/builtins.rs -assertion_line: 443 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (validate)\ndecoded : Int\ndecoded = validate (B #\"aa\")\nmain = unIData decoded\n" --- --- unoptimized Core @@ -23,14 +22,14 @@ main#1 [(lam candidate_7 [(lam destruct_8 candidate_7) [(builtin unIData) candidate_7]]) [(lam coerce_9 coerce_9) value_6]])]) --- optimized Core -let anf#22 : Data = bData (con bytestring #aa) in +let anf#22 : Data = (con data (B #aa)) in let destruct#14 : int = unIData anf#22 in unIData anf#22 --- optimized UPLC (program 1.1.0 [(lam anf_1 [(lam destruct_2 [(builtin unIData) anf_1]) [(builtin unIData) anf_1]]) - [(builtin bData) (con bytestring #aa)]]) + (con data (B #aa))]) --- result error: Runtime(MalFormedData(ByteString([170]))) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_20_map_some.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_20_map_some.snap index 47aec8fa..626e46f8 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_20_map_some.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_20_map_some.snap @@ -68,12 +68,9 @@ main#1 (builtin equalsInteger)]) (lam value_33 value_33)]) --- optimized Core -let anf#57 : 'erased = addInteger 14 1 in -equalsInteger anf#57 15 +equalsInteger 15 15 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [[(builtin equalsInteger) anf_1] (con integer 15)]) - [[(builtin addInteger) (con integer 14)] (con integer 1)]]) +(program 1.1.0 [[(builtin equalsInteger) (con integer 15)] (con integer 15)]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_22_filter_map.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_22_filter_map.snap index 12b2af79..dc480a34 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_22_filter_map.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_22_filter_map.snap @@ -175,7 +175,7 @@ eq#47 anf#93 (con (list integer) []) (lam field_14 (lam field_15 [(lam anf_16 - (case anf_16 (con bool False) [[[self_7 self_7] field_13] field_15])) + (case anf_16 (con bool False) (case (constr 0 self_7 field_13 field_15) self_7))) [[(builtin equalsInteger) field_12] field_14]])) (con bool False)))) (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_23_to_list.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_23_to_list.snap index fdf98222..f075579b 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_23_to_list.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_23_to_list.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/collections.rs -assertion_line: 237 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData)\nimport Literal exposing (..)\nimport Eq exposing (..)\ntype assocList = AssocList { inner : list (pair Bytes Int) }\nimpl Eq assocList where\n eq left right = equalsData (toData (mapData left.inner)) (toData (mapData right.inner))\nnew = AssocList { inner = [] }\ntoList : assocList -> list (pair Bytes Int)\ntoList m = m.inner\ninsert : assocList -> bytes -> int -> assocList\ninsert m k v = AssocList { inner = (doInsert m.inner k v) }\ndoInsert elems k v =\n case elems of\n [] -> [mkPairData (bData k) (iData v)]\n entry :: rest ->\n let\n k2 = unBData (fstPair entry)\n v2 = unIData (sndPair entry)\n in\n if eq k k2 then mkCons (mkPairData (bData k) (iData v)) rest\n else mkCons (mkPairData (bData k2) (iData v2)) (doInsert rest k v)\nfixture1 = insert (insert new \"foo\" 42) \"bar\" 14\nmain = equalsData (toData (mapData (toList fixture1))) (toData (mapData [mkPairData (bData \"foo\") (iData 42), mkPairData (bData \"bar\") (iData 14)]))\n" --- --- unoptimized Core @@ -153,21 +152,19 @@ let anf#92 : list (pair Bytes Int) = field@0/1 fixture1#67 in let anf#93 : Map Bytes Int = mapData anf#92 in let anf#95 : bytes = fromString#42 message#35 in let anf#96 : Bytes = bData anf#95 in -let anf#98 : Int = iData 42 in -let anf#99 : pair Bytes Int = mkPairData anf#96 anf#98 in +let anf#99 : pair Bytes Int = mkPairData anf#96 (con data (I 42)) in let anf#100 : bytes = fromString#42 message#36 in let anf#101 : Bytes = bData anf#100 in -let anf#103 : Int = iData 14 in -let anf#104 : pair Bytes Int = mkPairData anf#101 anf#103 in +let anf#104 : pair Bytes Int = mkPairData anf#101 (con data (I 14)) in let anf#105 : list (pair Bytes Int) = mkCons anf#104 (con (list (pair data data)) []) in let anf#106 : list (pair Bytes Int) = mkCons anf#99 anf#105 in let anf#107 : Map Bytes Int = mapData anf#106 in equalsData anf#93 anf#107 --- optimized UPLC (program 1.1.0 - [(lam builtin_92 - [(lam builtin_94 - [(lam builtin_95 + [(lam builtin_69 + [(lam builtin_71 + [(lam builtin_72 [(lam message_3 [(lam message_4 [(lam fromString_5 @@ -191,21 +188,17 @@ equalsData anf#93 anf#107 [(lam anf_54 [(lam anf_63 [(lam anf_65 - [(lam anf_68 - [(lam anf_86 - [(lam anf_91 [[(builtin equalsData) anf_46] anf_91]) [(builtin mapData) anf_86]]) - [[builtin_92 anf_50] anf_68]]) - [[builtin_92 anf_65] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_54] anf_63]]) - [(builtin iData) (con integer 14)]]) - [(builtin bData) anf_53]]) - [fromString_5 message_4]]) - [[(builtin mkPairData) anf_48] anf_49]]) - [(builtin iData) (con integer 42)]]) + [(lam anf_68 [[(builtin equalsData) anf_46] anf_68]) [(builtin mapData) anf_65]]) + [[builtin_69 anf_49] anf_63]]) + [[builtin_69 anf_54] (con (list (pair data data)) [])]]) + [[(builtin mkPairData) anf_53] (con data (I 14))]]) + [(builtin bData) anf_50]]) + [fromString_5 message_4]]) + [[(builtin mkPairData) anf_48] (con data (I 42))]]) [(builtin bData) anf_47]]) [fromString_5 message_3]]) [(builtin mapData) anf_45]]) - (case fixture1_44 (lam generated_93 generated_93))]) + (case fixture1_44 (lam generated_70 generated_70))]) [anf_43 (con integer 14)]]) [anf_40 anf_41]]) [fromString_5 message_4]]) @@ -237,28 +230,28 @@ equalsData anf#93 anf#107 [(lam anf_26 [(lam anf_27 [(lam anf_28 - [(lam anf_29 [[builtin_92 anf_28] anf_29]) [[self_11 self_11] field_17]]) + [(lam anf_29 [[builtin_69 anf_28] anf_29]) [[self_11 self_11] field_17]]) [[(builtin mkPairData) anf_26] anf_27]]) [(builtin iData) v2_19]]) [(builtin bData) k2_21]] [(lam anf_23 [(lam anf_24 - [(lam anf_25 [[builtin_92 anf_25] field_17]) + [(lam anf_25 [[builtin_69 anf_25] field_17]) [[(builtin mkPairData) anf_23] anf_24]]) [(builtin iData) v_8]]) [(builtin bData) k_7]])) [[(builtin equalsByteString) k_7] k2_21]]) [(builtin unBData) projection_20]]) - [builtin_94 field_16]]) + [builtin_71 field_16]]) [(builtin unIData) projection_18]]) - [builtin_95 field_16]])) + [builtin_72 field_16]])) [(lam anf_13 [(lam anf_14 - [(lam anf_15 [[builtin_92 anf_15] (con (list (pair data data)) [])]) + [(lam anf_15 [[builtin_69 anf_15] (con (list (pair data data)) [])]) [[(builtin mkPairData) anf_13] anf_14]]) [(builtin iData) v_8]]) [(builtin bData) k_7]])))]]) - (case m_6 (lam generated_96 generated_96))])))]) + (case m_6 (lam generated_73 generated_73))])))]) (builtin encodeUtf8)]) (con string "bar")]) (con string "foo")]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_24_map_pair.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_24_map_pair.snap index 238c47bd..fe3a04f9 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_24_map_pair.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_24_map_pair.snap @@ -114,51 +114,9 @@ main#1 (constr 0 a_12 b_13)])))]) (lam value_43 value_43)]) --- optimized Core -let anf#101 : Int = iData 14 in -let anf#102 : Int = iData 42 in -let anf#94 : 'erased = mkPairData anf#101 anf#102 in -let anf#106 : Int = iData 14 in -let anf#108 : Int = iData 42 in -let anf#109 : pair Int Int = mkPairData anf#106 anf#108 in -let projection#65 : 'erased = fstPair anf#94 in -let projection#67 : 'erased = fstPair anf#109 in -let anf#92 : bool = equalsData projection#65 projection#67 in -case@Bool anf#92 of - True -> let projection#68 : 'erased = sndPair anf#94 in - let projection#70 : 'erased = sndPair anf#109 in - equalsData projection#68 projection#70 - False -> false +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_12 - [(lam builtin_13 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - [(lam anf_5 - [(lam anf_6 - [(lam projection_7 - [(lam projection_8 - [(lam anf_9 - (case - anf_9 - (con bool False) - [(lam projection_10 - [(lam projection_11 [[(builtin equalsData) projection_10] projection_11]) - [builtin_12 anf_6]]) - [builtin_12 anf_3]])) - [[(builtin equalsData) projection_7] projection_8]]) - [builtin_13 anf_6]]) - [builtin_13 anf_3]]) - [[(builtin mkPairData) anf_4] anf_5]]) - [(builtin iData) (con integer 42)]]) - [(builtin iData) (con integer 14)]]) - [[(builtin mkPairData) anf_1] anf_2]]) - [(builtin iData) (con integer 42)]]) - [(builtin iData) (con integer 14)]]) - (force (force (builtin fstPair)))]) - (force (force (builtin sndPair)))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_27_flat_map.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_27_flat_map.snap index f7365e28..124b4157 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_27_flat_map.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_27_flat_map.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/collections.rs -assertion_line: 170 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Eq exposing (..)\nfoldr xs f zero =\n case xs of\n [] -> zero\n x :: rest -> f x (foldr rest f zero)\nconcat left right = foldr left (\\x xs -> mkCons x xs) right\nflatMap xs f =\n case xs of\n [] -> []\n x :: rest -> concat (f x) (flatMap rest f)\nmain = eq (flatMap [1, 2, 3] (\\a -> [a, a])) [1, 1, 2, 2, 3, 3]\n" --- --- unoptimized Core @@ -156,9 +155,6 @@ letrec True -> eq#49 field#57 field#62 False -> false in -let anf#104 : list int = mkCons 3 (con (list integer) []) in -let anf#105 : list int = mkCons 2 anf#104 in -let anf#106 : list int = mkCons 1 anf#105 in letrec worker#92 : list 'erased -> list int [static []] = \xs#91 : list 'erased -> case@List xs#91 of Nil -> (con (list integer) []) @@ -173,87 +169,56 @@ letrec in worker#94 anf#98 in -let anf#108 : list int = worker#92 anf#106 in -let anf#109 : list int -> bool = eq#49 anf#108 in -let anf#116 : list int = mkCons 3 (con (list integer) []) in -let anf#117 : list int = mkCons 3 anf#116 in -let anf#118 : list int = mkCons 2 anf#117 in -let anf#119 : list int = mkCons 2 anf#118 in -let anf#120 : list int = mkCons 1 anf#119 in -let anf#121 : list int = mkCons 1 anf#120 in -anf#109 anf#121 +let anf#108 : list int = worker#92 (con (list integer) [1, 2, 3]) in +eq#49 anf#108 (con (list integer) [1, 1, 2, 2, 3, 3]) --- optimized UPLC (program 1.1.0 - [(lam builtin_47 - [(lam partial_48 - [(lam partial_49 - [(lam partial_50 - [(lam eq_19 - [(lam anf_20 - [(lam anf_21 - [(lam anf_22 - [(lam worker_38 - [(lam anf_39 - [(lam anf_40 - [(lam anf_41 - [(lam anf_42 - [(lam anf_43 - [(lam anf_44 - [(lam anf_45 [(lam anf_46 [anf_40 anf_46]) [partial_48 anf_45]]) - [partial_48 anf_44]]) - [partial_49 anf_43]]) - [partial_49 anf_42]]) - [partial_50 anf_41]]) - [partial_50 (con (list integer) [])]]) - [eq_19 anf_39]]) - [worker_38 anf_22]]) - [(lam self_23 [self_23 self_23]) - (lam self_24 - (lam xs_25 - (case - xs_25 - (lam field_26 - (lam field_27 - [(lam anf_28 - [(lam anf_29 - [(lam anf_30 - [(lam worker_37 [worker_37 anf_29]) - [(lam self_31 [self_31 self_31]) - (lam self_32 - (lam xs_33 - (case - xs_33 - (lam field_34 - (lam field_35 - [(lam anf_36 [[builtin_47 field_34] anf_36]) [[self_32 self_32] field_35]])) - anf_30)))]]) - [[self_24 self_24] field_27]]) - [[builtin_47 field_26] anf_28]]) - [[builtin_47 field_26] (con (list integer) [])]])) - (con (list integer) []))))]]) - [partial_48 anf_21]]) - [partial_49 anf_20]]) - [partial_50 (con (list integer) [])]]) - [(lam self_8 [self_8 self_8]) - (lam self_9 - (lam xs_10 - (lam ys_11 + [(lam builtin_37 + [(lam eq_19 + [(lam worker_35 + [(lam anf_36 [[eq_19 anf_36] (con (list integer) [1, 1, 2, 2, 3, 3])]) + [worker_35 (con (list integer) [1, 2, 3])]]) + [(lam self_20 [self_20 self_20]) + (lam self_21 + (lam xs_22 + (case + xs_22 + (lam field_23 + (lam field_24 + [(lam anf_25 + [(lam anf_26 + [(lam anf_27 + [(lam worker_34 [worker_34 anf_26]) + [(lam self_28 [self_28 self_28]) + (lam self_29 + (lam xs_30 + (case + xs_30 + (lam field_31 + (lam field_32 + [(lam anf_33 [[builtin_37 field_31] anf_33]) [[self_29 self_29] field_32]])) + anf_27)))]]) + [[self_21 self_21] field_24]]) + [[builtin_37 field_23] anf_25]]) + [[builtin_37 field_23] (con (list integer) [])]])) + (con (list integer) []))))]]) + [(lam self_8 [self_8 self_8]) + (lam self_9 + (lam xs_10 + (lam ys_11 + (case + xs_10 + (lam field_14 + (lam field_15 (case - xs_10 - (lam field_14 - (lam field_15 - (case - ys_11 - (lam field_16 - (lam field_17 - [(lam anf_18 - (case anf_18 (con bool False) [[[self_9 self_9] field_15] field_17])) - [[(builtin equalsInteger) field_14] field_16]])) - (con bool False)))) - (case ys_11 (lam field_12 (lam field_13 (con bool False))) (con bool True))))))]]) - [builtin_47 (con integer 3)]]) - [builtin_47 (con integer 2)]]) - [builtin_47 (con integer 1)]]) + ys_11 + (lam field_16 + (lam field_17 + [(lam anf_18 + (case anf_18 (con bool False) (case (constr 0 self_9 field_15 field_17) self_9))) + [[(builtin equalsInteger) field_14] field_16]])) + (con bool False)))) + (case ys_11 (lam field_12 (lam field_13 (con bool False))) (con bool True))))))]]) (force (builtin mkCons))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_28_unique_empty_list.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_28_unique_empty_list.snap index 27c7a56a..57558a28 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_28_unique_empty_list.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_28_unique_empty_list.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/collections.rs -assertion_line: 191 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Eq exposing (..)\nfilter xs f =\n case xs of\n [] -> []\n x :: rest ->\n if f x then mkCons x (filter rest f)\n else filter rest f\nunique xs =\n case xs of\n [] -> []\n x :: rest -> mkCons x (unique (filter rest (\\y -> neq y x)))\nempty : list int\nempty = []\nmain = eq (unique empty) []\n" --- --- unoptimized Core @@ -222,7 +221,10 @@ eq#47 anf#96 (con (list integer) []) (lam field_17 (lam field_18 [(lam anf_19 - (case anf_19 (con bool False) [[[self_10 self_10] field_16] field_18])) + (case + anf_19 + (con bool False) + (case (constr 0 self_10 field_16 field_18) self_10))) [[eq_8 field_15] field_17]])) (con bool False)))) (case ys_12 (lam field_13 (lam field_14 (con bool False))) (con bool True))))))]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_28_unique_list.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_28_unique_list.snap index f2df9a2c..e17f84b6 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_28_unique_list.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_28_unique_list.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/collections.rs -assertion_line: 215 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Eq exposing (..)\nfilter xs f =\n case xs of\n [] -> []\n x :: rest ->\n if f x then mkCons x (filter rest f)\n else filter rest f\nunique xs =\n case xs of\n [] -> []\n x :: rest -> mkCons x (unique (filter rest (\\y -> neq y x)))\nmain = eq (unique [1, 2, 3, 1]) [1, 2, 3]\n" --- --- unoptimized Core @@ -180,90 +179,65 @@ letrec let anf#97 : list int = unique#78 anf#96 in mkCons field#81 anf#97 in -let anf#102 : list int = mkCons 1 (con (list integer) []) in -let anf#103 : list int = mkCons 3 anf#102 in -let anf#104 : list int = mkCons 2 anf#103 in -let anf#105 : list int = mkCons 1 anf#104 in -let anf#106 : list int = unique#78 anf#105 in -let anf#107 : list int -> bool = eq#48 anf#106 in -let anf#111 : list int = mkCons 3 (con (list integer) []) in -let anf#112 : list int = mkCons 2 anf#111 in -let anf#113 : list int = mkCons 1 anf#112 in -anf#107 anf#113 +let anf#106 : list int = unique#78 (con (list integer) [1, 2, 3, 1]) in +eq#48 anf#106 (con (list integer) [1, 2, 3]) --- optimized UPLC (program 1.1.0 - [(lam builtin_47 - [(lam partial_48 - [(lam partial_49 - [(lam partial_50 - [(lam eq_8 - [(lam eq_20 - [(lam unique_37 - [(lam anf_38 - [(lam anf_39 - [(lam anf_40 - [(lam anf_41 - [(lam anf_42 - [(lam anf_43 - [(lam anf_44 - [(lam anf_45 [(lam anf_46 [anf_43 anf_46]) [partial_48 anf_45]]) - [partial_49 anf_44]]) - [partial_50 (con (list integer) [])]]) - [eq_20 anf_42]]) - [unique_37 anf_41]]) - [partial_48 anf_40]]) - [partial_49 anf_39]]) - [partial_50 anf_38]]) - [partial_48 (con (list integer) [])]]) - [(lam self_21 [self_21 self_21]) - (lam self_22 - (lam xs_23 - (case - xs_23 - (lam field_24 - (lam field_25 - [(lam worker_34 - [(lam anf_35 - [(lam anf_36 [[builtin_47 field_24] anf_36]) [[self_22 self_22] anf_35]]) - [worker_34 field_25]]) - [(lam self_26 [self_26 self_26]) - (lam self_27 - (lam xs_28 - (case - xs_28 - (lam field_29 - (lam field_30 - [(lam anf_31 - [(lam anf_32 - (case - anf_32 - [[self_27 self_27] field_30] - [(lam anf_33 [[builtin_47 field_29] anf_33]) [[self_27 self_27] field_30]])) - (case anf_31 (con bool True) (con bool False))]) - [[eq_8 field_29] field_24]])) - (con (list integer) []))))]])) - (con (list integer) []))))]]) - [(lam self_9 [self_9 self_9]) - (lam self_10 - (lam xs_11 - (lam ys_12 + [(lam builtin_39 + [(lam eq_8 + [(lam eq_20 + [(lam unique_37 + [(lam anf_38 [[eq_20 anf_38] (con (list integer) [1, 2, 3])]) + [unique_37 (con (list integer) [1, 2, 3, 1])]]) + [(lam self_21 [self_21 self_21]) + (lam self_22 + (lam xs_23 + (case + xs_23 + (lam field_24 + (lam field_25 + [(lam worker_34 + [(lam anf_35 + [(lam anf_36 [[builtin_39 field_24] anf_36]) [[self_22 self_22] anf_35]]) + [worker_34 field_25]]) + [(lam self_26 [self_26 self_26]) + (lam self_27 + (lam xs_28 + (case + xs_28 + (lam field_29 + (lam field_30 + [(lam anf_31 + [(lam anf_32 + (case + anf_32 + [[self_27 self_27] field_30] + [(lam anf_33 [[builtin_39 field_29] anf_33]) [[self_27 self_27] field_30]])) + (case anf_31 (con bool True) (con bool False))]) + [[eq_8 field_29] field_24]])) + (con (list integer) []))))]])) + (con (list integer) []))))]]) + [(lam self_9 [self_9 self_9]) + (lam self_10 + (lam xs_11 + (lam ys_12 + (case + xs_11 + (lam field_15 + (lam field_16 (case - xs_11 - (lam field_15 - (lam field_16 - (case - ys_12 - (lam field_17 - (lam field_18 - [(lam anf_19 - (case anf_19 (con bool False) [[[self_10 self_10] field_16] field_18])) - [[eq_8 field_15] field_17]])) - (con bool False)))) - (case ys_12 (lam field_13 (lam field_14 (con bool False))) (con bool True))))))]]) - (builtin equalsInteger)]) - [builtin_47 (con integer 3)]]) - [builtin_47 (con integer 2)]]) - [builtin_47 (con integer 1)]]) + ys_12 + (lam field_17 + (lam field_18 + [(lam anf_19 + (case + anf_19 + (con bool False) + (case (constr 0 self_10 field_16 field_18) self_10))) + [[eq_8 field_15] field_17]])) + (con bool False)))) + (case ys_12 (lam field_13 (lam field_14 (con bool False))) (con bool True))))))]]) + (builtin equalsInteger)]) (force (builtin mkCons))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_29_union_pair.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_29_union_pair.snap index 0a71f6dc..cd1209a4 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_29_union_pair.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_29_union_pair.snap @@ -254,7 +254,8 @@ equalsData anf#111 anf#112 (lam k_48 (lam v_49 [(lam projection_50 - [(lam anf_51 (constr 0 anf_51)) [[[doInsert_30 projection_50] k_48] v_49]]) + [(lam anf_51 (constr 0 anf_51)) + (case (constr 0 projection_50 k_48 v_49) doInsert_30)]) (case m_47 (lam generated_76 generated_76))])))]) (constr 0 field_45)]) (con (list (pair data data)) [])]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_29_union_tuple.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_29_union_tuple.snap index b9f8aa3e..a43fae34 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_29_union_tuple.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_29_union_tuple.snap @@ -342,7 +342,10 @@ worker#185 anf#198 projection#131 (lam field_68 (lam field_69 [(lam anf_75 - (case anf_75 (con bool False) [[[self_60 self_60] field_67] field_69])) + (case + anf_75 + (con bool False) + (case (constr 0 self_60 field_67 field_69) self_60))) (case field_66 (lam field_70 @@ -371,7 +374,8 @@ worker#185 anf#198 projection#131 (lam k_42 (lam v_43 [(lam projection_44 - [(lam anf_45 (constr 0 anf_45)) [[[doInsert_27 projection_44] k_42] v_43]]) + [(lam anf_45 (constr 0 anf_45)) + (case (constr 0 projection_44 k_42 v_43) doInsert_27)]) (case m_41 (lam generated_79 generated_79))])))]) (constr 0 anf_39)]) (constr 0)]) @@ -389,7 +393,8 @@ worker#185 anf#198 projection#131 (lam field_34 (lam field_35 [(lam anf_36 - [(lam anf_37 [anf_36 anf_37]) [[[doInsert_27 right_31] field_34] field_35]]) + [(lam anf_37 [anf_36 anf_37]) + (case (constr 0 right_31 field_34 field_35) doInsert_27)]) [[self_29 self_29] field_33]])))))))))]]) (lam elems_10 (lam k_11 diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_30_abs.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_30_abs.snap index 915e05d2..82060b8b 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_30_abs.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__collections__acceptance_test_30_abs.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/collections.rs -assertion_line: 358 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Eq exposing (..)\nabs a = if lessThanInteger a 0 then subtractInteger 0 a else a\nmain = eq (abs (subtractInteger 0 14)) 14\n" --- --- unoptimized Core @@ -30,24 +29,9 @@ main#1 (lam value_6 value_6)]) (builtin equalsInteger)]) --- optimized Core -let anf#18 : int = subtractInteger 0 14 in -let anf#14 : bool = lessThanInteger anf#18 0 in -let anf#19 : int = case@Bool anf#14 of - True -> subtractInteger 0 anf#18 - False -> anf#18 in -let anf#20 : int -> bool = equalsInteger anf#19 in -anf#20 14 +equalsInteger 14 14 --- optimized UPLC -(program 1.1.0 - [(lam partial_5 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 [anf_4 (con integer 14)]) [(builtin equalsInteger) anf_3]]) - (case anf_2 anf_1 [partial_5 anf_1])]) - [[(builtin lessThanInteger) anf_1] (con integer 0)]]) - [partial_5 (con integer 14)]]) - [(builtin subtractInteger) (con integer 0)]]) +(program 1.1.0 [[(builtin equalsInteger) (con integer 14)] (con integer 14)]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_10_map_some.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_10_map_some.snap index 63095153..5d3b3ca9 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_10_map_some.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_10_map_some.snap @@ -71,12 +71,9 @@ main#1 (builtin equalsInteger)]) (lam value_34 value_34)]) --- optimized Core -let anf#59 : 'erased = addInteger 1 1 in -equalsInteger anf#59 2 +equalsInteger 2 2 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [[(builtin equalsInteger) anf_1] (con integer 2)]) - [[(builtin addInteger) (con integer 1)] (con integer 1)]]) +(program 1.1.0 [[(builtin equalsInteger) (con integer 2)] (con integer 2)]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_11_map_empty.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_11_map_empty.snap index 642e82a7..6ffa448f 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_11_map_empty.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_11_map_empty.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 342 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nmap xs f =\n case xs of\n [] -> []\n x :: rest -> mkCons (f x) (map rest f)\nmain = eq (map [] (\\n -> addInteger n 1)) []\n" --- --- unoptimized Core @@ -156,7 +155,7 @@ eq#35 anf#69 (con (list integer) []) (lam field_14 (lam field_15 [(lam anf_16 - (case anf_16 (con bool False) [[[self_7 self_7] field_13] field_15])) + (case anf_16 (con bool False) (case (constr 0 self_7 field_13 field_15) self_7))) [[(builtin equalsInteger) field_12] field_14]])) (con bool False)))) (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_11_map_filled.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_11_map_filled.snap index 9caed0ea..beef445c 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_11_map_filled.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_11_map_filled.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 357 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nmap xs f =\n case xs of\n [] -> []\n x :: rest -> mkCons (f x) (map rest f)\nmain = eq (map [6, 7, 8] (\\n -> addInteger n 1)) [7, 8, 9]\n" --- --- unoptimized Core @@ -121,9 +120,6 @@ letrec True -> eq#35 field#43 field#48 False -> false in -let anf#71 : list int = mkCons 8 (con (list integer) []) in -let anf#72 : list int = mkCons 7 anf#71 in -let anf#73 : list int = mkCons 6 anf#72 in letrec worker#64 : list 'erased -> list int [static []] = \xs#63 : list 'erased -> case@List xs#63 of Nil -> (con (list integer) []) @@ -131,63 +127,43 @@ letrec let anf#67 : list int = worker#64 field#56 in mkCons anf#66 anf#67 in -let anf#75 : list int = worker#64 anf#73 in -let anf#76 : list int -> bool = eq#35 anf#75 in -let anf#80 : list int = mkCons 9 (con (list integer) []) in -let anf#81 : list int = mkCons 8 anf#80 in -let anf#82 : list int = mkCons 7 anf#81 in -anf#76 anf#82 +let anf#75 : list int = worker#64 (con (list integer) [6, 7, 8]) in +eq#35 anf#75 (con (list integer) [7, 8, 9]) --- optimized UPLC (program 1.1.0 - [(lam builtin_34 - [(lam partial_35 - [(lam partial_36 - [(lam eq_17 - [(lam anf_18 - [(lam anf_19 - [(lam anf_20 - [(lam worker_28 - [(lam anf_29 - [(lam anf_30 - [(lam anf_31 - [(lam anf_32 [(lam anf_33 [anf_30 anf_33]) [partial_35 anf_32]]) - [partial_36 anf_31]]) - [[builtin_34 (con integer 9)] (con (list integer) [])]]) - [eq_17 anf_29]]) - [worker_28 anf_20]]) - [(lam self_21 [self_21 self_21]) - (lam self_22 - (lam xs_23 - (case - xs_23 - (lam field_24 - (lam field_25 - [(lam anf_26 - [(lam anf_27 [[builtin_34 anf_26] anf_27]) [[self_22 self_22] field_25]]) - [[(builtin addInteger) field_24] (con integer 1)]])) - (con (list integer) []))))]]) - [[builtin_34 (con integer 6)] anf_19]]) - [partial_35 anf_18]]) - [partial_36 (con (list integer) [])]]) - [(lam self_6 [self_6 self_6]) - (lam self_7 - (lam xs_8 - (lam ys_9 - (case - xs_8 - (lam field_12 - (lam field_13 - (case - ys_9 - (lam field_14 - (lam field_15 - [(lam anf_16 - (case anf_16 (con bool False) [[[self_7 self_7] field_13] field_15])) - [[(builtin equalsInteger) field_12] field_14]])) - (con bool False)))) - (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) - [builtin_34 (con integer 8)]]) - [builtin_34 (con integer 7)]]) + [(lam builtin_27 + [(lam eq_17 + [(lam worker_25 + [(lam anf_26 [[eq_17 anf_26] (con (list integer) [7, 8, 9])]) + [worker_25 (con (list integer) [6, 7, 8])]]) + [(lam self_18 [self_18 self_18]) + (lam self_19 + (lam xs_20 + (case + xs_20 + (lam field_21 + (lam field_22 + [(lam anf_23 + [(lam anf_24 [[builtin_27 anf_23] anf_24]) [[self_19 self_19] field_22]]) + [[(builtin addInteger) field_21] (con integer 1)]])) + (con (list integer) []))))]]) + [(lam self_6 [self_6 self_6]) + (lam self_7 + (lam xs_8 + (lam ys_9 + (case + xs_8 + (lam field_12 + (lam field_13 + (case + ys_9 + (lam field_14 + (lam field_15 + [(lam anf_16 + (case anf_16 (con bool False) (case (constr 0 self_7 field_13 field_15) self_7))) + [[(builtin equalsInteger) field_12] field_14]])) + (con bool False)))) + (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) (force (builtin mkCons))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_12_filter_even.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_12_filter_even.snap index b92baf9d..79250db3 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_12_filter_even.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_12_filter_even.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 372 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nfilter xs f =\n case xs of\n [] -> []\n x :: rest ->\n if f x then mkCons x (filter rest f)\n else filter rest f\nmain = eq (filter [1, 2, 3, 4, 5, 6] (\\x -> equalsInteger (modInteger x 2) 0)) [2, 4, 6]\n" --- --- unoptimized Core @@ -132,12 +131,6 @@ letrec True -> eq#35 field#43 field#48 False -> false in -let anf#74 : list int = mkCons 6 (con (list integer) []) in -let anf#75 : list int = mkCons 5 anf#74 in -let anf#76 : list int = mkCons 4 anf#75 in -let anf#77 : list int = mkCons 3 anf#76 in -let anf#78 : list int = mkCons 2 anf#77 in -let anf#79 : list int = mkCons 1 anf#78 in letrec worker#64 : list int -> list int [static []] = \xs#63 : list int -> case@List xs#63 of Nil -> (con (list integer) []) @@ -148,76 +141,48 @@ letrec mkCons field#55 anf#67 False -> worker#64 field#56 in -let anf#83 : list int = worker#64 anf#79 in -let anf#84 : list int -> bool = eq#35 anf#83 in -let anf#88 : list int = mkCons 6 (con (list integer) []) in -let anf#89 : list int = mkCons 4 anf#88 in -let anf#90 : list int = mkCons 2 anf#89 in -anf#84 anf#90 +let anf#83 : list int = worker#64 (con (list integer) [1, 2, 3, 4, 5, 6]) in +eq#35 anf#83 (con (list integer) [2, 4, 6]) --- optimized UPLC (program 1.1.0 - [(lam builtin_45 - [(lam partial_46 - [(lam partial_47 - [(lam partial_48 - [(lam eq_17 - [(lam anf_18 - [(lam anf_19 - [(lam anf_20 - [(lam anf_21 - [(lam anf_22 - [(lam anf_23 - [(lam worker_32 - [(lam anf_33 - [(lam anf_34 - [(lam anf_38 - [(lam anf_39 [(lam anf_44 [anf_34 anf_44]) [partial_46 anf_39]]) - [partial_47 anf_38]]) - [partial_48 (con (list integer) [])]]) - [eq_17 anf_33]]) - [worker_32 anf_23]]) - [(lam self_24 [self_24 self_24]) - (lam self_25 - (lam xs_26 - (case - xs_26 - (lam field_27 - (lam field_28 - [(lam anf_29 - [(lam anf_30 - (case - anf_30 - [[self_25 self_25] field_28] - [(lam anf_31 [[builtin_45 field_27] anf_31]) [[self_25 self_25] field_28]])) - [[(builtin equalsInteger) anf_29] (con integer 0)]]) - [[(builtin modInteger) field_27] (con integer 2)]])) - (con (list integer) []))))]]) - [[builtin_45 (con integer 1)] anf_22]]) - [partial_46 anf_21]]) - [[builtin_45 (con integer 3)] anf_20]]) - [partial_47 anf_19]]) - [[builtin_45 (con integer 5)] anf_18]]) - [partial_48 (con (list integer) [])]]) - [(lam self_6 [self_6 self_6]) - (lam self_7 - (lam xs_8 - (lam ys_9 + [(lam builtin_28 + [(lam eq_17 + [(lam worker_26 + [(lam anf_27 [[eq_17 anf_27] (con (list integer) [2, 4, 6])]) + [worker_26 (con (list integer) [1, 2, 3, 4, 5, 6])]]) + [(lam self_18 [self_18 self_18]) + (lam self_19 + (lam xs_20 + (case + xs_20 + (lam field_21 + (lam field_22 + [(lam anf_23 + [(lam anf_24 + (case + anf_24 + [[self_19 self_19] field_22] + [(lam anf_25 [[builtin_28 field_21] anf_25]) [[self_19 self_19] field_22]])) + [[(builtin equalsInteger) anf_23] (con integer 0)]]) + [[(builtin modInteger) field_21] (con integer 2)]])) + (con (list integer) []))))]]) + [(lam self_6 [self_6 self_6]) + (lam self_7 + (lam xs_8 + (lam ys_9 + (case + xs_8 + (lam field_12 + (lam field_13 (case - xs_8 - (lam field_12 - (lam field_13 - (case - ys_9 - (lam field_14 - (lam field_15 - [(lam anf_16 - (case anf_16 (con bool False) [[[self_7 self_7] field_13] field_15])) - [[(builtin equalsInteger) field_12] field_14]])) - (con bool False)))) - (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) - [builtin_45 (con integer 6)]]) - [builtin_45 (con integer 4)]]) - [builtin_45 (con integer 2)]]) + ys_9 + (lam field_14 + (lam field_15 + [(lam anf_16 + (case anf_16 (con bool False) (case (constr 0 self_7 field_13 field_15) self_7))) + [[(builtin equalsInteger) field_12] field_14]])) + (con bool False)))) + (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) (force (builtin mkCons))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_14_list_creation.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_14_list_creation.snap index 6787bfa8..36274f43 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_14_list_creation.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_14_list_creation.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 389 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nmain = [subtractInteger 0 2, subtractInteger 0 1, 0]\n" --- --- unoptimized Core @@ -20,23 +19,9 @@ main#1 [[(force (builtin mkCons)) [fromInt_2 (con integer 0)]] (con (list integer) [])]]]]) (lam value_3 value_3)]) --- optimized Core -let anf#9 : int = subtractInteger 0 2 in -let anf#12 : int = subtractInteger 0 1 in -let anf#14 : list int = mkCons 0 (con (list integer) []) in -let anf#15 : list int = mkCons anf#12 anf#14 in -mkCons anf#9 anf#15 +(con (list integer) [-2, -1, 0]) --- optimized UPLC -(program 1.1.0 - [(lam builtin_5 - [(lam partial_6 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 [(lam anf_4 [[builtin_5 anf_1] anf_4]) [[builtin_5 anf_2] anf_3]]) - [[builtin_5 (con integer 0)] (con (list integer) [])]]) - [partial_6 (con integer 1)]]) - [partial_6 (con integer 2)]]) - [(builtin subtractInteger) (con integer 0)]]) - (force (builtin mkCons))]) +(program 1.1.0 (con (list integer) [-2, -1, 0])) --- result (con (list integer) [-2, -1, 0]) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_15_zero_arg.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_15_zero_arg.snap index 3c62077d..1f662ca8 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_15_zero_arg.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_15_zero_arg.snap @@ -50,15 +50,9 @@ main#1 arg_6]))]) (lam coerce_19 coerce_19)]) --- optimized Core -let anf#39 : Map Data Data = mapData (con (list (pair data data)) []) in -let anf#41 : Map Data Data = mapData (con (list (pair data data)) []) in -equalsData anf#39 anf#41 +true --- optimized UPLC -(program 1.1.0 - [(lam anf_1 - [(lam anf_2 [[(builtin equalsData) anf_1] anf_2]) - [(builtin mapData) (con (list (pair data data)) [])]]) - [(builtin mapData) (con (list (pair data data)) [])]]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_16_drop.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_16_drop.snap index 82ee607a..88ed98cd 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_16_drop.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_16_drop.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 414 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nslice bytes start end = sliceByteString start end bytes\nlength bytes = lengthOfByteString bytes\ndrop bytes n = slice bytes n (subtractInteger (length bytes) n)\nmain =\n let\n x = #\"01020304050607\"\n in\n eq (drop x 2) #\"0304050607\"\n" --- --- unoptimized Core @@ -37,22 +36,11 @@ main#1 (lam end_15 [[[(builtin sliceByteString) start_14] end_15] bytes_13])))]) (builtin equalsByteString)]) --- optimized Core -let anf#34 : int = lengthOfByteString (con bytestring #01020304050607) in -let anf#35 : int = subtractInteger anf#34 2 in -let anf#38 : bytes = sliceByteString 2 anf#35 (con bytestring #01020304050607) in -let anf#39 : bytes -> bool = equalsByteString anf#38 in -anf#39 (con bytestring #0304050607) +equalsByteString (con bytestring #0304050607) (con bytestring #0304050607) --- optimized UPLC (program 1.1.0 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 [anf_4 (con bytestring #0304050607)]) - [(builtin equalsByteString) anf_3]]) - [[[(builtin sliceByteString) (con integer 2)] anf_2] - (con bytestring #01020304050607)]]) - [[(builtin subtractInteger) anf_1] (con integer 2)]]) - [(builtin lengthOfByteString) (con bytestring #01020304050607)]]) + [[(builtin equalsByteString) (con bytestring #0304050607)] + (con bytestring #0304050607)]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_17_take.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_17_take.snap index c719960d..29a87ef0 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_17_take.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_17_take.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 432 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nslice bytes start end = sliceByteString start end bytes\ntake bytes n = slice bytes 0 n\nmain = eq (take #\"010203\" 2) #\"0102\"\n" --- --- unoptimized Core @@ -30,15 +29,10 @@ main#1 (lam value_10 value_10)]) (builtin equalsByteString)]) --- optimized Core -let anf#32 : bytes = sliceByteString 0 2 (con bytestring #010203) in -let anf#33 : bytes -> bool = equalsByteString anf#32 in -anf#33 (con bytestring #0102) +equalsByteString (con bytestring #0102) (con bytestring #0102) --- optimized UPLC (program 1.1.0 - [(lam anf_1 - [(lam anf_2 [anf_2 (con bytestring #0102)]) [(builtin equalsByteString) anf_1]]) - [[[(builtin sliceByteString) (con integer 0)] (con integer 2)] - (con bytestring #010203)]]) + [[(builtin equalsByteString) (con bytestring #0102)] (con bytestring #0102)]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_18_or_else.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_18_or_else.snap index b0ae1f8a..c6542026 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_18_or_else.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_18_or_else.snap @@ -26,9 +26,9 @@ main#1 [(lam match_8 (case match_8 default_6 (lam field_9 [(lam a_7 a_7) field_9]))) opt_5]))]) --- optimized Core -equalsInteger 42 42 +true --- optimized UPLC -(program 1.1.0 [[(builtin equalsInteger) (con integer 42)] (con integer 42)]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_1_length.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_1_length.snap index 3828b286..00cc19e8 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_1_length.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_1_length.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 1 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nlength xs =\n case xs of\n [] -> 0\n _ :: rest -> addInteger 1 (length rest)\nmain = equalsInteger (length [1, 2, 3]) 3\n" --- --- unoptimized Core @@ -46,34 +45,23 @@ letrec Cons field#15 field#16 -> let anf#20 : int = length#12 field#16 in addInteger 1 anf#20 in -let anf#24 : list int = mkCons 3 (con (list integer) []) in -let anf#25 : list int = mkCons 2 anf#24 in -let anf#26 : list int = mkCons 1 anf#25 in -let anf#27 : int = length#12 anf#26 in +let anf#27 : int = length#12 (con (list integer) [1, 2, 3]) in equalsInteger anf#27 3 --- optimized UPLC (program 1.1.0 - [(lam builtin_18 - [(lam length_9 - [(lam anf_10 - [(lam anf_11 - [(lam anf_14 - [(lam anf_17 [[(builtin equalsInteger) anf_17] (con integer 3)]) - [length_9 anf_14]]) - [[builtin_18 (con integer 1)] anf_11]]) - [[builtin_18 (con integer 2)] anf_10]]) - [[builtin_18 (con integer 3)] (con (list integer) [])]]) - [(lam self_3 [self_3 self_3]) - (lam self_4 - (lam xs_5 - (case - xs_5 - (lam field_6 - (lam field_7 - [(lam anf_8 [[(builtin addInteger) (con integer 1)] anf_8]) - [[self_4 self_4] field_7]])) - (con integer 0))))]]) - (force (builtin mkCons))]) + [(lam length_9 + [(lam anf_10 [[(builtin equalsInteger) anf_10] (con integer 3)]) + [length_9 (con (list integer) [1, 2, 3])]]) + [(lam self_3 [self_3 self_3]) + (lam self_4 + (lam xs_5 + (case + xs_5 + (lam field_6 + (lam field_7 + [(lam anf_8 [[(builtin addInteger) (con integer 1)] anf_8]) + [[self_4 self_4] field_7]])) + (con integer 0))))]]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_2_repeat.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_2_repeat.snap index c2dfefd7..ddea4d4f 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_2_repeat.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_2_repeat.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 16 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nrepeat x n =\n if lessThanEqualsInteger n 0 then []\n else mkCons x (repeat x (subtractInteger n 1))\nmain = eq (repeat #\"61696b656e\" 2) [#\"61696b656e\", #\"61696b656e\"]\n" --- --- unoptimized Core @@ -121,50 +120,43 @@ letrec mkCons (con bytestring #61696b656e) anf#62 in let anf#66 : list bytes = worker#56 2 in -let anf#67 : list bytes -> bool = eq#31 anf#66 in -let anf#70 : list bytes = mkCons (con bytestring #61696b656e) (con (list bytestring) []) in -let anf#71 : list bytes = mkCons (con bytestring #61696b656e) anf#70 in -anf#67 anf#71 +eq#31 anf#66 (con (list bytestring) [#61696b656e, #61696b656e]) --- optimized UPLC (program 1.1.0 - [(lam builtin_29 - [(lam partial_30 - [(lam eq_17 - [(lam worker_24 - [(lam anf_25 - [(lam anf_26 - [(lam anf_27 [(lam anf_28 [anf_26 anf_28]) [partial_30 anf_27]]) - [partial_30 (con (list bytestring) [])]]) - [eq_17 anf_25]]) - [worker_24 (con integer 2)]]) - [(lam self_18 [self_18 self_18]) - (lam self_19 - (lam n_20 - [(lam anf_21 - (case - anf_21 - [(lam anf_22 [(lam anf_23 [partial_30 anf_23]) [[self_19 self_19] anf_22]]) - [[(builtin subtractInteger) n_20] (con integer 1)]] - (con (list bytestring) []))) - [[(builtin lessThanEqualsInteger) n_20] (con integer 0)]]))]]) - [(lam self_6 [self_6 self_6]) - (lam self_7 - (lam xs_8 - (lam ys_9 + [(lam builtin_26 + [(lam eq_17 + [(lam worker_24 + [(lam anf_25 [[eq_17 anf_25] (con (list bytestring) [#61696b656e, #61696b656e])]) + [worker_24 (con integer 2)]]) + [(lam self_18 [self_18 self_18]) + (lam self_19 + (lam n_20 + [(lam anf_21 (case - xs_8 - (lam field_12 - (lam field_13 - (case - ys_9 - (lam field_14 - (lam field_15 - [(lam anf_16 - (case anf_16 (con bool False) [[[self_7 self_7] field_13] field_15])) - [[(builtin equalsByteString) field_12] field_14]])) - (con bool False)))) - (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) - [builtin_29 (con bytestring #61696b656e)]]) + anf_21 + [(lam anf_22 + [(lam anf_23 [[builtin_26 (con bytestring #61696b656e)] anf_23]) + [[self_19 self_19] anf_22]]) + [[(builtin subtractInteger) n_20] (con integer 1)]] + (con (list bytestring) []))) + [[(builtin lessThanEqualsInteger) n_20] (con integer 0)]]))]]) + [(lam self_6 [self_6 self_6]) + (lam self_7 + (lam xs_8 + (lam ys_9 + (case + xs_8 + (lam field_12 + (lam field_13 + (case + ys_9 + (lam field_14 + (lam field_15 + [(lam anf_16 + (case anf_16 (con bool False) (case (constr 0 self_7 field_13 field_15) self_7))) + [[(builtin equalsByteString) field_12] field_14]])) + (con bool False)))) + (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) (force (builtin mkCons))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_3_concat.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_3_concat.snap index 220027b0..7b5b3426 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_3_concat.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_3_concat.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 30 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nfoldr xs f zero =\n case xs of\n [] -> zero\n x :: rest -> f x (foldr rest f zero)\nconcat left right = foldr left (\\x xs -> mkCons x xs) right\nmain = eq (concat [1, 2, 3] [4, 5, 6]) [1, 2, 3, 4, 5, 6]\n" --- --- unoptimized Core @@ -131,96 +130,47 @@ letrec True -> eq#40 field#48 field#53 False -> false in -let anf#81 : list int = mkCons 3 (con (list integer) []) in -let anf#82 : list int = mkCons 2 anf#81 in -let anf#83 : list int = mkCons 1 anf#82 in -let anf#88 : list int = mkCons 6 (con (list integer) []) in -let anf#89 : list int = mkCons 5 anf#88 in -let anf#90 : list int = mkCons 4 anf#89 in letrec worker#74 : list 'erased -> 'erased [static []] = \xs#73 : list 'erased -> case@List xs#73 of - Nil -> anf#90 + Nil -> (con (list integer) [4, 5, 6]) Cons field#61 field#62 -> let anf#77 : 'erased = worker#74 field#62 in mkCons field#61 anf#77 in -let anf#91 : list int = worker#74 anf#83 in -let anf#92 : list int -> bool = eq#40 anf#91 in -let anf#99 : list int = mkCons 6 (con (list integer) []) in -let anf#100 : list int = mkCons 5 anf#99 in -let anf#101 : list int = mkCons 4 anf#100 in -let anf#102 : list int = mkCons 3 anf#101 in -let anf#103 : list int = mkCons 2 anf#102 in -let anf#104 : list int = mkCons 1 anf#103 in -anf#92 anf#104 +let anf#91 : list int = worker#74 (con (list integer) [1, 2, 3]) in +eq#40 anf#91 (con (list integer) [1, 2, 3, 4, 5, 6]) --- optimized UPLC (program 1.1.0 - [(lam builtin_39 - [(lam partial_40 - [(lam partial_41 - [(lam partial_42 - [(lam partial_43 - [(lam partial_44 - [(lam partial_45 - [(lam eq_17 - [(lam anf_18 - [(lam anf_19 - [(lam anf_20 - [(lam anf_21 - [(lam anf_22 - [(lam anf_23 - [(lam worker_30 - [(lam anf_31 - [(lam anf_32 - [(lam anf_33 - [(lam anf_34 - [(lam anf_35 - [(lam anf_36 - [(lam anf_37 [(lam anf_38 [anf_32 anf_38]) [partial_40 anf_37]]) - [partial_41 anf_36]]) - [partial_42 anf_35]]) - [partial_43 anf_34]]) - [partial_44 anf_33]]) - [partial_45 (con (list integer) [])]]) - [eq_17 anf_31]]) - [worker_30 anf_20]]) - [(lam self_24 [self_24 self_24]) - (lam self_25 - (lam xs_26 - (case - xs_26 - (lam field_27 - (lam field_28 - [(lam anf_29 [[builtin_39 field_27] anf_29]) [[self_25 self_25] field_28]])) - anf_23)))]]) - [partial_43 anf_22]]) - [partial_44 anf_21]]) - [partial_45 (con (list integer) [])]]) - [partial_40 anf_19]]) - [partial_41 anf_18]]) - [partial_42 (con (list integer) [])]]) - [(lam self_6 [self_6 self_6]) - (lam self_7 - (lam xs_8 - (lam ys_9 - (case - xs_8 - (lam field_12 - (lam field_13 - (case - ys_9 - (lam field_14 - (lam field_15 - [(lam anf_16 - (case anf_16 (con bool False) [[[self_7 self_7] field_13] field_15])) - [[(builtin equalsInteger) field_12] field_14]])) - (con bool False)))) - (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) - [builtin_39 (con integer 6)]]) - [builtin_39 (con integer 5)]]) - [builtin_39 (con integer 4)]]) - [builtin_39 (con integer 3)]]) - [builtin_39 (con integer 2)]]) - [builtin_39 (con integer 1)]]) + [(lam builtin_26 + [(lam eq_17 + [(lam worker_24 + [(lam anf_25 [[eq_17 anf_25] (con (list integer) [1, 2, 3, 4, 5, 6])]) + [worker_24 (con (list integer) [1, 2, 3])]]) + [(lam self_18 [self_18 self_18]) + (lam self_19 + (lam xs_20 + (case + xs_20 + (lam field_21 + (lam field_22 + [(lam anf_23 [[builtin_26 field_21] anf_23]) [[self_19 self_19] field_22]])) + (con (list integer) [4, 5, 6]))))]]) + [(lam self_6 [self_6 self_6]) + (lam self_7 + (lam xs_8 + (lam ys_9 + (case + xs_8 + (lam field_12 + (lam field_13 + (case + ys_9 + (lam field_14 + (lam field_15 + [(lam anf_16 + (case anf_16 (con bool False) (case (constr 0 self_7 field_13 field_15) self_7))) + [[(builtin equalsInteger) field_12] field_14]])) + (con bool False)))) + (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) (force (builtin mkCons))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_4_concat_no_anon_func.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_4_concat_no_anon_func.snap index 0453ea2c..d64711b3 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_4_concat_no_anon_func.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_4_concat_no_anon_func.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 46 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nfoldr xs f zero =\n case xs of\n [] -> zero\n x :: rest -> f x (foldr rest f zero)\nprepend x xs = mkCons x xs\nconcat left right = foldr left prepend right\nmain = eq (concat [1, 2, 3] [4, 5, 6]) [1, 2, 3, 4, 5, 6]\n" --- --- unoptimized Core @@ -130,96 +129,47 @@ letrec True -> eq#41 field#49 field#54 False -> false in -let anf#83 : list int = mkCons 3 (con (list integer) []) in -let anf#84 : list int = mkCons 2 anf#83 in -let anf#85 : list int = mkCons 1 anf#84 in -let anf#90 : list int = mkCons 6 (con (list integer) []) in -let anf#91 : list int = mkCons 5 anf#90 in -let anf#92 : list int = mkCons 4 anf#91 in letrec worker#76 : list 'erased -> 'erased [static []] = \xs#75 : list 'erased -> case@List xs#75 of - Nil -> anf#92 + Nil -> (con (list integer) [4, 5, 6]) Cons field#62 field#63 -> let anf#79 : 'erased = worker#76 field#63 in mkCons field#62 anf#79 in -let anf#93 : list int = worker#76 anf#85 in -let anf#94 : list int -> bool = eq#41 anf#93 in -let anf#101 : list int = mkCons 6 (con (list integer) []) in -let anf#102 : list int = mkCons 5 anf#101 in -let anf#103 : list int = mkCons 4 anf#102 in -let anf#104 : list int = mkCons 3 anf#103 in -let anf#105 : list int = mkCons 2 anf#104 in -let anf#106 : list int = mkCons 1 anf#105 in -anf#94 anf#106 +let anf#93 : list int = worker#76 (con (list integer) [1, 2, 3]) in +eq#41 anf#93 (con (list integer) [1, 2, 3, 4, 5, 6]) --- optimized UPLC (program 1.1.0 - [(lam builtin_39 - [(lam partial_40 - [(lam partial_41 - [(lam partial_42 - [(lam partial_43 - [(lam partial_44 - [(lam partial_45 - [(lam eq_17 - [(lam anf_18 - [(lam anf_19 - [(lam anf_20 - [(lam anf_21 - [(lam anf_22 - [(lam anf_23 - [(lam worker_30 - [(lam anf_31 - [(lam anf_32 - [(lam anf_33 - [(lam anf_34 - [(lam anf_35 - [(lam anf_36 - [(lam anf_37 [(lam anf_38 [anf_32 anf_38]) [partial_40 anf_37]]) - [partial_41 anf_36]]) - [partial_42 anf_35]]) - [partial_43 anf_34]]) - [partial_44 anf_33]]) - [partial_45 (con (list integer) [])]]) - [eq_17 anf_31]]) - [worker_30 anf_20]]) - [(lam self_24 [self_24 self_24]) - (lam self_25 - (lam xs_26 - (case - xs_26 - (lam field_27 - (lam field_28 - [(lam anf_29 [[builtin_39 field_27] anf_29]) [[self_25 self_25] field_28]])) - anf_23)))]]) - [partial_43 anf_22]]) - [partial_44 anf_21]]) - [partial_45 (con (list integer) [])]]) - [partial_40 anf_19]]) - [partial_41 anf_18]]) - [partial_42 (con (list integer) [])]]) - [(lam self_6 [self_6 self_6]) - (lam self_7 - (lam xs_8 - (lam ys_9 - (case - xs_8 - (lam field_12 - (lam field_13 - (case - ys_9 - (lam field_14 - (lam field_15 - [(lam anf_16 - (case anf_16 (con bool False) [[[self_7 self_7] field_13] field_15])) - [[(builtin equalsInteger) field_12] field_14]])) - (con bool False)))) - (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) - [builtin_39 (con integer 6)]]) - [builtin_39 (con integer 5)]]) - [builtin_39 (con integer 4)]]) - [builtin_39 (con integer 3)]]) - [builtin_39 (con integer 2)]]) - [builtin_39 (con integer 1)]]) + [(lam builtin_26 + [(lam eq_17 + [(lam worker_24 + [(lam anf_25 [[eq_17 anf_25] (con (list integer) [1, 2, 3, 4, 5, 6])]) + [worker_24 (con (list integer) [1, 2, 3])]]) + [(lam self_18 [self_18 self_18]) + (lam self_19 + (lam xs_20 + (case + xs_20 + (lam field_21 + (lam field_22 + [(lam anf_23 [[builtin_26 field_21] anf_23]) [[self_19 self_19] field_22]])) + (con (list integer) [4, 5, 6]))))]]) + [(lam self_6 [self_6 self_6]) + (lam self_7 + (lam xs_8 + (lam ys_9 + (case + xs_8 + (lam field_12 + (lam field_13 + (case + ys_9 + (lam field_14 + (lam field_15 + [(lam anf_16 + (case anf_16 (con bool False) (case (constr 0 self_7 field_13 field_15) self_7))) + [[(builtin equalsInteger) field_12] field_14]])) + (con bool False)))) + (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) (force (builtin mkCons))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_direct_2_heads.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_direct_2_heads.snap index ec9c72a1..f687f854 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_direct_2_heads.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_direct_2_heads.snap @@ -156,52 +156,27 @@ letrec True -> eq#28 field#60 field#65 False -> false in -let anf#103 : list int = mkCons 3 (con (list integer) []) in -let anf#104 : list int = mkCons 2 anf#103 in -let anf#105 : list int = mkCons 1 anf#104 in -let anf#98 : list int = mkCons 2 (con (list integer) []) in -let anf#99 : list int = mkCons 1 anf#98 in -let anf#110 : list int = mkCons 2 (con (list integer) []) in -let anf#111 : list int = mkCons 1 anf#110 in -eq#28 anf#99 anf#111 +eq#28 (con (list integer) [1, 2]) (con (list integer) [1, 2]) --- optimized UPLC (program 1.1.0 - [(lam builtin_23 - [(lam partial_24 - [(lam partial_25 - [(lam eq_15 - [(lam anf_16 - [(lam anf_17 - [(lam anf_18 - [(lam anf_19 - [(lam anf_20 - [(lam anf_21 [(lam anf_22 [[eq_15 anf_20] anf_22]) [partial_24 anf_21]]) - [partial_25 (con (list integer) [])]]) - [partial_24 anf_19]]) - [partial_25 (con (list integer) [])]]) - [partial_24 anf_17]]) - [partial_25 anf_16]]) - [[builtin_23 (con integer 3)] (con (list integer) [])]]) - [(lam self_4 [self_4 self_4]) - (lam self_5 - (lam xs_6 - (lam ys_7 + [(lam eq_15 [[eq_15 (con (list integer) [1, 2])] (con (list integer) [1, 2])]) + [(lam self_4 [self_4 self_4]) + (lam self_5 + (lam xs_6 + (lam ys_7 + (case + xs_6 + (lam field_10 + (lam field_11 (case - xs_6 - (lam field_10 - (lam field_11 - (case - ys_7 - (lam field_12 - (lam field_13 - [(lam anf_14 - (case anf_14 (con bool False) [[[self_5 self_5] field_11] field_13])) - [[(builtin equalsInteger) field_10] field_12]])) - (con bool False)))) - (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) - [builtin_23 (con integer 2)]]) - [builtin_23 (con integer 1)]]) - (force (builtin mkCons))]) + ys_7 + (lam field_12 + (lam field_13 + [(lam anf_14 + (case anf_14 (con bool False) (case (constr 0 self_5 field_11 field_13) self_5))) + [[(builtin equalsInteger) field_10] field_12]])) + (con bool False)))) + (case ys_7 (lam field_8 (lam field_9 (con bool False))) (con bool True))))))]]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_direct_head.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_direct_head.snap index 6a450439..4a6ee8fc 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_direct_head.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_direct_head.snap @@ -67,20 +67,9 @@ main#1 (builtin equalsInteger)]) (lam value_30 value_30)]) --- optimized Core -let anf#54 : list int = mkCons 3 (con (list integer) []) in -let anf#55 : list int = mkCons 2 anf#54 in -let anf#56 : list int = mkCons 1 anf#55 in equalsInteger 1 1 --- optimized UPLC -(program 1.1.0 - [(lam builtin_4 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 [[(builtin equalsInteger) (con integer 1)] (con integer 1)]) - [[builtin_4 (con integer 1)] anf_2]]) - [[builtin_4 (con integer 2)] anf_1]]) - [[builtin_4 (con integer 3)] (con (list integer) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 [[(builtin equalsInteger) (con integer 1)] (con integer 1)]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_head_not_empty.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_head_not_empty.snap index 3d9b45e7..70b59ee3 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_head_not_empty.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_5_head_not_empty.snap @@ -67,20 +67,9 @@ main#1 (builtin equalsInteger)]) (lam value_30 value_30)]) --- optimized Core -let anf#54 : list int = mkCons 3 (con (list integer) []) in -let anf#55 : list int = mkCons 2 anf#54 in -let anf#56 : list int = mkCons 1 anf#55 in equalsInteger 1 1 --- optimized UPLC -(program 1.1.0 - [(lam builtin_4 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 [[(builtin equalsInteger) (con integer 1)] (con integer 1)]) - [[builtin_4 (con integer 1)] anf_2]]) - [[builtin_4 (con integer 2)] anf_1]]) - [[builtin_4 (con integer 3)] (con (list integer) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 [[(builtin equalsInteger) (con integer 1)] (con integer 1)]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_equals_pair.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_equals_pair.snap index 98961ae9..701192b9 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_equals_pair.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_equals_pair.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 176 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData)\nempty : list Data\nempty = []\nsame a b = if equalsData (toData (fstPair a)) (toData (fstPair b)) then equalsData (toData (sndPair a)) (toData (sndPair b)) else False\nmain = same (mkPairData (iData 1) (listData empty)) (mkPairData (iData 1) (listData empty))\n" --- --- unoptimized Core @@ -55,54 +54,9 @@ main#1 (lam coerce_11 coerce_11)]) (lam value_10 value_10)]) --- optimized Core -let empty#33 : list Data = (con (list data) []) in -let anf#39 : Int = iData 1 in -let anf#40 : List Data = listData empty#33 in -let anf#41 : pair Int (List Data) = mkPairData anf#39 anf#40 in -let anf#44 : Int = iData 1 in -let anf#45 : List Data = listData empty#33 in -let anf#46 : pair Int (List Data) = mkPairData anf#44 anf#45 in -let projection#24 : 'erased = fstPair anf#41 in -let projection#26 : 'erased = fstPair anf#46 in -let anf#36 : bool = equalsData projection#24 projection#26 in -case@Bool anf#36 of - True -> let projection#27 : 'erased = sndPair anf#41 in - let projection#29 : 'erased = sndPair anf#46 in - equalsData projection#27 projection#29 - False -> false +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_13 - [(lam builtin_14 - [(lam empty_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - [(lam anf_5 - [(lam anf_6 - [(lam anf_7 - [(lam projection_8 - [(lam projection_9 - [(lam anf_10 - (case - anf_10 - (con bool False) - [(lam projection_11 - [(lam projection_12 [[(builtin equalsData) projection_11] projection_12]) - [builtin_13 anf_7]]) - [builtin_13 anf_4]])) - [[(builtin equalsData) projection_8] projection_9]]) - [builtin_14 anf_7]]) - [builtin_14 anf_4]]) - [[(builtin mkPairData) anf_5] anf_6]]) - [(builtin listData) empty_1]]) - [(builtin iData) (con integer 1)]]) - [[(builtin mkPairData) anf_2] anf_3]]) - [(builtin listData) empty_1]]) - [(builtin iData) (con integer 1)]]) - (con (list data) [])]) - (force (force (builtin fstPair)))]) - (force (force (builtin sndPair)))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_equals_tuple.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_equals_tuple.snap index bfcc4b80..0fdb1b20 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_equals_tuple.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_equals_tuple.snap @@ -149,7 +149,7 @@ case@Bool anf#72 of (lam field_13 (lam field_14 [(lam anf_15 - (case anf_15 (con bool False) [[[self_6 self_6] field_12] field_14])) + (case anf_15 (con bool False) (case (constr 0 self_6 field_12 field_14) self_6))) [[eq_4 field_11] field_13]])) (con bool False)))) (case ys_8 (lam field_9 (lam field_10 (con bool False))) (con bool True))))))]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_if_else.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_if_else.snap index d614cb6f..00f56ef6 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_if_else.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_6_if_else.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 160 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nmain : bool\nmain =\n let\n x = 1\n in\n if equalsInteger x 1 then True else False\n" --- --- unoptimized Core @@ -25,14 +24,9 @@ main#1 (lam value_6 value_6)]) (lam value_5 value_5)]) --- optimized Core -let anf#14 : bool = equalsInteger 1 1 in -case@Bool anf#14 of - True -> true - False -> false +true --- optimized UPLC -(program 1.1.0 - [(lam anf_1 (case anf_1 (con bool False) (con bool True))) - [[(builtin equalsInteger) (con integer 1)] (con integer 1)]]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_7_unzip_pair.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_7_unzip_pair.snap index a40cafe8..fb42d4dd 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_7_unzip_pair.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_7_unzip_pair.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 228 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData)\nunzip : list (pair Int Bytes) -> pair (List Int) (List Bytes)\nunzip xs =\n case xs of\n [] -> mkPairData (listData []) (listData [])\n entry :: rest ->\n let\n tails = unzip rest\n in\n mkPairData\n (listData (mkCons (fstPair entry) (unListData (fstPair tails))))\n (listData (mkCons (sndPair entry) (unListData (sndPair tails))))\nsame : pair (List Int) (List Bytes) -> pair (List Int) (List Bytes) -> bool\nsame a b =\n if equalsData (toData (fstPair a)) (toData (fstPair b)) then\n equalsData (toData (sndPair a)) (toData (sndPair b))\n else False\nmain =\n let\n x = [mkPairData (iData 3) (bData #\"55\"), mkPairData (iData 4) (bData #\"7799\")]\n in\n same (unzip x)\n (mkPairData (listData [iData 3, iData 4]) (listData [bData #\"55\", bData #\"7799\"]))\n" --- --- unoptimized Core @@ -122,9 +121,7 @@ main#1 --- optimized Core letrec unzip#48 : list (pair Int Bytes) -> pair (List Int) (List Bytes) [static []] = \xs#49 : list (pair Int Bytes) -> case@List xs#49 of - Nil -> let anf#72 : List Int = listData (con (list data) []) in - let anf#73 : List Bytes = listData (con (list data) []) in - mkPairData anf#72 anf#73 + Nil -> (con (pair data data) ((List []), (List []))) Cons field#51 field#52 -> let tails#55 : pair (List Int) (List Bytes) = unzip#48 field#52 in let projection#56 : Int = fstPair field#51 in let projection#57 : List Int = fstPair tails#55 in @@ -138,126 +135,61 @@ letrec let anf#76 : List Bytes = listData anf#75 in mkPairData evaluated#59 anf#76 in -let anf#78 : Int = iData 3 in -let anf#80 : Bytes = bData (con bytestring #55) in -let anf#81 : pair Int Bytes = mkPairData anf#78 anf#80 in -let anf#83 : Int = iData 4 in -let anf#85 : Bytes = bData (con bytestring #7799) in -let anf#86 : pair Int Bytes = mkPairData anf#83 anf#85 in -let anf#87 : list (pair Int Bytes) = mkCons anf#86 (con (list (pair data data)) []) in -let x#67 : list (pair Int Bytes) = mkCons anf#81 anf#87 in -let anf#88 : pair (List Int) (List Bytes) = unzip#48 x#67 in -let anf#91 : Int = iData 3 in -let anf#93 : Int = iData 4 in -let anf#94 : list Int = mkCons anf#93 (con (list data) []) in -let anf#95 : list Int = mkCons anf#91 anf#94 in -let anf#96 : List Int = listData anf#95 in -let anf#98 : Bytes = bData (con bytestring #55) in -let anf#100 : Bytes = bData (con bytestring #7799) in -let anf#101 : list Bytes = mkCons anf#100 (con (list data) []) in -let anf#102 : list Bytes = mkCons anf#98 anf#101 in -let anf#103 : List Bytes = listData anf#102 in -let anf#104 : pair (List Int) (List Bytes) = mkPairData anf#96 anf#103 in +let anf#88 : pair (List Int) (List Bytes) = unzip#48 (con (list (pair data data)) [((I 3), (B #55)), ((I 4), (B #7799))]) in let projection#41 : List Int = fstPair anf#88 in -let projection#43 : List Int = fstPair anf#104 in -let anf#70 : bool = equalsData projection#41 projection#43 in +let anf#70 : bool = equalsData projection#41 (con data (List [I 3, I 4])) in case@Bool anf#70 of True -> let projection#44 : List Bytes = sndPair anf#88 in - let projection#46 : List Bytes = sndPair anf#104 in - equalsData projection#44 projection#46 + equalsData projection#44 (con data (List [B #55, B #7799])) False -> false --- optimized UPLC (program 1.1.0 - [(lam builtin_55 - [(lam builtin_56 - [(lam builtin_57 - [(lam unzip_21 - [(lam anf_22 - [(lam anf_23 - [(lam anf_24 - [(lam anf_25 - [(lam anf_26 - [(lam anf_27 - [(lam anf_28 - [(lam x_29 - [(lam anf_30 - [(lam anf_31 - [(lam anf_32 - [(lam anf_33 - [(lam anf_34 - [(lam anf_35 - [(lam anf_36 - [(lam anf_37 - [(lam anf_38 - [(lam anf_39 - [(lam anf_40 - [(lam anf_42 - [(lam projection_45 - [(lam projection_47 - [(lam anf_50 - (case - anf_50 - (con bool False) - [(lam projection_53 - [(lam projection_54 [[(builtin equalsData) projection_53] projection_54]) - [builtin_55 anf_42]]) - [builtin_55 anf_30]])) - [[(builtin equalsData) projection_45] projection_47]]) - [builtin_56 anf_42]]) - [builtin_56 anf_30]]) - [[(builtin mkPairData) anf_35] anf_40]]) - [(builtin listData) anf_39]]) - [[builtin_57 anf_36] anf_38]]) - [[builtin_57 anf_37] (con (list data) [])]]) - [(builtin bData) (con bytestring #7799)]]) - [(builtin bData) (con bytestring #55)]]) - [(builtin listData) anf_34]]) - [[builtin_57 anf_31] anf_33]]) - [[builtin_57 anf_32] (con (list data) [])]]) - [(builtin iData) (con integer 4)]]) - [(builtin iData) (con integer 3)]]) - [unzip_21 x_29]]) - [[builtin_57 anf_24] anf_28]]) - [[builtin_57 anf_27] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_25] anf_26]]) - [(builtin bData) (con bytestring #7799)]]) - [(builtin iData) (con integer 4)]]) - [[(builtin mkPairData) anf_22] anf_23]]) - [(builtin bData) (con bytestring #55)]]) - [(builtin iData) (con integer 3)]]) + [(lam builtin_24 + [(lam builtin_25 + [(lam builtin_26 + [(lam unzip_19 + [(lam anf_20 + [(lam projection_21 + [(lam anf_22 + (case + anf_22 + (con bool False) + [(lam projection_23 + [[(builtin equalsData) projection_23] (con data (List [B #55, B #7799]))]) + [builtin_24 anf_20]])) + [[(builtin equalsData) projection_21] (con data (List [I 3, I 4]))]]) + [builtin_25 anf_20]]) + [unzip_19 (con (list (pair data data)) [((I 3), (B #55)), ((I 4), (B #7799))])]]) [(lam self_3 [self_3 self_3]) (lam self_4 (lam xs_5 (case xs_5 - (lam field_8 - (lam field_9 - [(lam tails_10 - [(lam projection_11 - [(lam projection_12 - [(lam projection_13 - [(lam anf_14 - [(lam evaluated_15 - [(lam projection_16 - [(lam projection_17 - [(lam projection_18 - [(lam anf_19 - [(lam anf_20 [[(builtin mkPairData) evaluated_15] anf_20]) - [(builtin listData) anf_19]]) - [[builtin_57 projection_16] projection_18]]) - [(builtin unListData) projection_17]]) - [builtin_55 tails_10]]) - [builtin_55 field_8]]) - [(builtin listData) anf_14]]) - [[builtin_57 projection_11] projection_13]]) - [(builtin unListData) projection_12]]) - [builtin_56 tails_10]]) - [builtin_56 field_8]]) - [[self_4 self_4] field_9]])) - [(lam anf_6 - [(lam anf_7 [[(builtin mkPairData) anf_6] anf_7]) - [(builtin listData) (con (list data) [])]]) - [(builtin listData) (con (list data) [])]])))]]) + (lam field_6 + (lam field_7 + [(lam tails_8 + [(lam projection_9 + [(lam projection_10 + [(lam projection_11 + [(lam anf_12 + [(lam evaluated_13 + [(lam projection_14 + [(lam projection_15 + [(lam projection_16 + [(lam anf_17 + [(lam anf_18 [[(builtin mkPairData) evaluated_13] anf_18]) + [(builtin listData) anf_17]]) + [[builtin_26 projection_14] projection_16]]) + [(builtin unListData) projection_15]]) + [builtin_24 tails_8]]) + [builtin_24 field_6]]) + [(builtin listData) anf_12]]) + [[builtin_26 projection_9] projection_11]]) + [(builtin unListData) projection_10]]) + [builtin_25 tails_8]]) + [builtin_25 field_6]]) + [[self_4 self_4] field_7]])) + (con (pair data data) ((List []), (List []))))))]]) (force (builtin mkCons))]) (force (force (builtin fstPair)))]) (force (force (builtin sndPair)))]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_7_unzip_tuple.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_7_unzip_tuple.snap index 0de102b9..2529845b 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_7_unzip_tuple.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_7_unzip_tuple.snap @@ -284,18 +284,14 @@ let anf#177 : Main.sequence ('erased, 'erased) = constr 0 in let anf#178 : Main.sequence ('erased, 'erased) = constr 1 anf#175 anf#177 in let x#161 : Main.sequence ('erased, 'erased) = constr 1 anf#171 anf#178 in let anf#179 : (list int, list bytes) = unzip#131 x#161 in -let anf#183 : list int = mkCons 4 (con (list integer) []) in -let anf#184 : list int = mkCons 3 anf#183 in -let anf#187 : list bytes = mkCons (con bytestring #7799) (con (list bytestring) []) in -let anf#188 : list bytes = mkCons (con bytestring #55) anf#187 in case@Tag anf#179 of - 0 field#121 field#122 -> let anf#165 : bool = eq#85 field#121 anf#184 in + 0 field#121 field#122 -> let anf#165 : bool = eq#85 field#121 (con (list integer) [3, 4]) in case@Bool anf#165 of - True -> eq#102 field#122 anf#188 + True -> eq#102 field#122 (con (list bytestring) [#55, #7799]) False -> false --- optimized UPLC (program 1.1.0 - [(lam builtin_63 + [(lam builtin_59 [(lam eq_20 [(lam eq_32 [(lam unzip_49 @@ -305,20 +301,16 @@ case@Tag anf#179 of [(lam anf_53 [(lam x_54 [(lam anf_55 - [(lam anf_56 - [(lam anf_57 - [(lam anf_58 - [(lam anf_59 + (case + anf_55 + (lam field_56 + (lam field_57 + [(lam anf_58 (case - anf_55 - (lam field_60 - (lam field_61 - [(lam anf_62 (case anf_62 (con bool False) [[eq_32 field_61] anf_59])) - [[eq_20 field_60] anf_57]])))) - [[builtin_63 (con bytestring #55)] anf_58]]) - [[builtin_63 (con bytestring #7799)] (con (list bytestring) [])]]) - [[builtin_63 (con integer 3)] anf_56]]) - [[builtin_63 (con integer 4)] (con (list integer) [])]]) + anf_58 + (con bool False) + [[eq_32 field_57] (con (list bytestring) [#55, #7799])])) + [[eq_20 field_56] (con (list integer) [3, 4])]])))) [unzip_49 x_54]]) (constr 1 anf_50 anf_53)]) (constr 1 anf_51 anf_52)]) @@ -341,9 +333,9 @@ case@Tag anf#179 of [(lam anf_43 [(lam evaluated_44 [(lam anf_47 - [(lam anf_48 (constr 0 evaluated_44 anf_48)) [[builtin_63 field_39] anf_47]]) + [(lam anf_48 (constr 0 evaluated_44 anf_48)) [[builtin_59 field_39] anf_47]]) (case destruct_40 (lam field_45 (lam field_46 field_46)))]) - [[builtin_63 field_38] anf_43]]) + [[builtin_59 field_38] anf_43]]) (case destruct_40 (lam field_41 (lam field_42 field_41)))]) [[self_34 self_34] field_37]]))))))))]]) [(lam self_21 [self_21 self_21]) @@ -359,7 +351,10 @@ case@Tag anf#179 of (lam field_29 (lam field_30 [(lam anf_31 - (case anf_31 (con bool False) [[[self_22 self_22] field_28] field_30])) + (case + anf_31 + (con bool False) + (case (constr 0 self_22 field_28 field_30) self_22))) [[(builtin equalsByteString) field_27] field_29]])) (con bool False)))) (case ys_24 (lam field_25 (lam field_26 (con bool False))) (con bool True))))))]]) @@ -376,7 +371,10 @@ case@Tag anf#179 of (lam field_17 (lam field_18 [(lam anf_19 - (case anf_19 (con bool False) [[[self_10 self_10] field_16] field_18])) + (case + anf_19 + (con bool False) + (case (constr 0 self_10 field_16 field_18) self_10))) [[(builtin equalsInteger) field_15] field_17]])) (con bool False)))) (case ys_12 (lam field_13 (lam field_14 (con bool False))) (con bool True))))))]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_8_is_empty.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_8_is_empty.snap index 0c937ae6..2cd8b623 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_8_is_empty.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_8_is_empty.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 260 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nisEmpty bytes = equalsInteger (Builtin.lengthOfByteString bytes) 0\nmain = eq (isEmpty #\"\") True\n" --- --- unoptimized Core @@ -48,22 +47,11 @@ main#1 let not#23 : 'erased -> bool = \value#21 : 'erased -> case@Bool value#21 of True -> false False -> true in -let anf#44 : int = lengthOfByteString (con bytestring #) in -let anf#47 : bool = equalsInteger anf#44 0 in -let b#30 : bool = true in -let anf#43 : bool = case@Bool anf#47 of - True -> not#23 b#30 - False -> b#30 in +let anf#43 : bool = not#23 true in not#23 anf#43 --- optimized UPLC (program 1.1.0 - [(lam not_2 - [(lam anf_3 - [(lam anf_4 - [(lam b_5 [(lam anf_6 [not_2 anf_6]) (case anf_4 b_5 [not_2 b_5])]) - (con bool True)]) - [[(builtin equalsInteger) anf_3] (con integer 0)]]) - [(builtin lengthOfByteString) (con bytestring #)]]) + [(lam not_2 [(lam anf_3 [not_2 anf_3]) [not_2 (con bool True)]]) (lam value_1 (case value_1 (con bool True) (con bool False)))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_8_is_not_empty.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_8_is_not_empty.snap index a35307b2..d0b188fc 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_8_is_not_empty.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_8_is_not_empty.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 272 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nisEmpty bytes = equalsInteger (Builtin.lengthOfByteString bytes) 0\nmain = eq (isEmpty #\"01\") False\n" --- --- unoptimized Core @@ -45,26 +44,9 @@ main#1 (lam value_14 (case [(lam identity_15 identity_15) value_14] (con bool True) (con bool False)))]) --- optimized Core -let not#23 : 'erased -> bool = \value#21 : 'erased -> case@Bool value#21 of - True -> false - False -> true in -let anf#44 : int = lengthOfByteString (con bytestring #01) in -let anf#47 : bool = equalsInteger anf#44 0 in -let b#30 : bool = false in -let anf#43 : bool = case@Bool anf#47 of - True -> not#23 b#30 - False -> b#30 in -not#23 anf#43 +true --- optimized UPLC -(program 1.1.0 - [(lam not_2 - [(lam anf_3 - [(lam anf_4 - [(lam b_5 [(lam anf_6 [not_2 anf_6]) (case anf_4 b_5 [not_2 b_5])]) - (con bool False)]) - [[(builtin equalsInteger) anf_3] (con integer 0)]]) - [(builtin lengthOfByteString) (con bytestring #01)]]) - (lam value_1 (case value_1 (con bool True) (con bool False)))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_9_is_empty.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_9_is_empty.snap index 23359f2c..e7462bef 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_9_is_empty.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__lists__acceptance_test_9_is_empty.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/lists.rs -assertion_line: 284 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nisEmpty bytes = equalsInteger (lengthOfByteString bytes) 0\nmain = eq (isEmpty #\"\") True\n" --- --- unoptimized Core @@ -48,22 +47,11 @@ main#1 let not#23 : 'erased -> bool = \value#21 : 'erased -> case@Bool value#21 of True -> false False -> true in -let anf#44 : int = lengthOfByteString (con bytestring #) in -let anf#47 : bool = equalsInteger anf#44 0 in -let b#30 : bool = true in -let anf#43 : bool = case@Bool anf#47 of - True -> not#23 b#30 - False -> b#30 in +let anf#43 : bool = not#23 true in not#23 anf#43 --- optimized UPLC (program 1.1.0 - [(lam not_2 - [(lam anf_3 - [(lam anf_4 - [(lam b_5 [(lam anf_6 [not_2 anf_6]) (case anf_4 b_5 [not_2 b_5])]) - (con bool True)]) - [[(builtin equalsInteger) anf_3] (con integer 0)]]) - [(builtin lengthOfByteString) (con bytestring #)]]) + [(lam not_2 [(lam anf_3 [not_2 anf_3]) [not_2 (con bool True)]]) (lam value_1 (case value_1 (con bool True) (con bool False)))]) --- result (con bool True) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_boolean_lift_and_lower.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_boolean_lift_and_lower.snap index dcb8e3ff..3dd36807 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_boolean_lift_and_lower.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_boolean_lift_and_lower.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 851 description: "module Main exposing (..)\nimport Bool\nimport Logic\nimport Lift exposing (Lift)\nmake : bool -> Bool.Bool\nmake = lift\nmain : (bool, bool)\nmain = (lower (make Primitive.False), lower (make Primitive.True))\n" --- --- unoptimized Core @@ -46,8 +45,8 @@ case@Pair projection#13 of 0 -> false 1 -> true in let lift#18 : bool -> nash/base:Bool.Bool = \value#17 : bool -> case@Bool value#17 of - True -> constrData 1 (con (list data) []) - False -> constrData 0 (con (list data) []) in + True -> (con data (Constr 1 [])) + False -> (con data (Constr 0 [])) in let anf#21 : nash/base:Bool.Bool = lift#18 false in let anf#22 : bool = lower#16 anf#21 in let anf#23 : nash/base:Bool.Bool = lift#18 true in @@ -63,11 +62,7 @@ constr 0 anf#22 anf#24 [lift_7 (con bool True)]]) [lower_5 anf_8]]) [lift_7 (con bool False)]]) - (lam value_6 - (case - value_6 - [[(builtin constrData) (con integer 0)] (con (list data) [])] - [[(builtin constrData) (con integer 1)] (con (list data) [])]))]) + (lam value_6 (case value_6 (con data (Constr 0 [])) (con data (Constr 1 []))))]) (lam value_1 [(lam projection_2 (case diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_constructor_field_skip.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_constructor_field_skip.snap index 0971d96a..95c942b4 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_constructor_field_skip.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_constructor_field_skip.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 715 description: "module Main exposing (..)\nimport Primitive exposing (..)\ntype Datum = Datum { a : Int, b : Int, c : Int, d : Int }\nmain : int\nmain = Builtin.unIData ((Datum { a = 10, b = 20, c = 30, d = 40 }).d)\n" --- --- unoptimized Core @@ -54,14 +53,13 @@ let anf#29 : list Data = mkCons anf#33 anf#28 in let anf#30 : list Data = mkCons anf#31 anf#29 in let evaluated#19 : Main.Datum = constrData 0 anf#30 in let projection#20 : pair int (list Data) = unConstrData evaluated#19 in -case@Pair projection#20 of - Pair tag#21 fields#22 -> let projection#23 : list Data = dropList 3 fields#22 in - case@List projection#23 of - Cons head#24 tail#25 -> unIData head#24 +let projection#23 : list Data = dropList 3 anf#30 in +case@List projection#23 of + Cons head#24 tail#25 -> unIData head#24 --- optimized UPLC (program 1.1.0 - [(lam builtin_18 - [(lam builtin_19 + [(lam builtin_16 + [(lam builtin_17 [(lam fromInt_1 [(lam anf_2 [(lam anf_3 @@ -73,22 +71,18 @@ case@Pair projection#20 of [(lam anf_9 [(lam evaluated_10 [(lam projection_11 - (case - projection_11 - (lam tag_12 - (lam fields_13 - [(lam projection_15 - (case - projection_15 - (lam head_16 (lam tail_17 [(builtin unIData) head_16])) - (error))) - [[builtin_18 (con integer 3)] fields_13]])))) + [(lam projection_12 + (case + projection_12 + (lam head_13 (lam tail_15 [(builtin unIData) head_13])) + (error))) + [[builtin_16 (con integer 3)] anf_9]]) [(builtin unConstrData) evaluated_10]]) [[(builtin constrData) (con integer 0)] anf_9]]) - [[builtin_19 anf_2] anf_8]]) - [[builtin_19 anf_3] anf_7]]) - [[builtin_19 anf_4] anf_6]]) - [[builtin_19 anf_5] (con (list data) [])]]) + [[builtin_17 anf_2] anf_8]]) + [[builtin_17 anf_3] anf_7]]) + [[builtin_17 anf_4] anf_6]]) + [[builtin_17 anf_5] (con (list data) [])]]) [fromInt_1 (con integer 40)]]) [fromInt_1 (con integer 30)]]) [fromInt_1 (con integer 20)]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_field_skip_rejects_short_payload.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_field_skip_rejects_short_payload.snap index 40e829a2..e290cff0 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_field_skip_rejects_short_payload.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_field_skip_rejects_short_payload.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 726 description: "module Main exposing (..)\nimport Primitive exposing (..)\ntype alias Record = { a : Int, b : Int, c : Int }\nmalformed : Record\nmalformed = coerce (List [I 1])\nmain = malformed.c\n" --- --- unoptimized Core @@ -30,29 +29,9 @@ case@List projection#11 of (con (list data) [])]]]]) (lam value_9 value_9)]) --- optimized Core -let anf#24 : Data = iData 1 in -let anf#25 : list Data = mkCons anf#24 (con (list data) []) in -let anf#26 : Data = listData anf#25 in -let projection#18 : list Data = unListData anf#26 in -let projection#19 : list Data = dropList 2 projection#18 in -case@List projection#19 of - Cons head#20 tail#21 -> head#20 +error --- optimized UPLC -(program 1.1.0 - [(lam builtin_8 - [(lam builtin_9 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam projection_4 - [(lam projection_5 (case projection_5 (lam head_6 (lam tail_7 head_6)) (error))) - [[builtin_8 (con integer 2)] projection_4]]) - [(builtin unListData) anf_3]]) - [(builtin listData) anf_2]]) - [[builtin_9 anf_1] (con (list data) [])]]) - [(builtin iData) (con integer 1)]]) - (force (builtin mkCons))]) - (force (builtin dropList))]) +(program 1.1.0 (error)) --- result error: ExplicitErrorTerm --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_single_constructor_nested_fields.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_single_constructor_nested_fields.snap index 79447e04..43cb963a 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_single_constructor_nested_fields.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_single_constructor_nested_fields.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 878 description: "module Main exposing (..)\ntype Box = Box Int Int\ntype Choice = First Box | Second Int | Third\nselect : Choice -> int\nselect value = case value of\n First (Box first second) -> Builtin.addInteger (Builtin.unIData first) (Builtin.unIData second)\n Second number -> Builtin.unIData number\n Third -> 0\nmain : (int, int, int)\nmain = (select (First (Box 20 22)), select (Second 7), select Third)\n" --- --- unoptimized Core @@ -122,13 +121,12 @@ let anf#69 : Int = fromInt#51 7 in let anf#68 : list Data = mkCons anf#69 (con (list data) []) in let anf#70 : Main.Choice = constrData 1 anf#68 in let anf#71 : int = select#50 anf#70 in -let anf#72 : Main.Choice = constrData 2 (con (list data) []) in -let anf#73 : int = select#50 anf#72 in +let anf#73 : int = select#50 (con data (Constr 2 [])) in constr 0 anf#67 anf#71 anf#73 --- optimized UPLC (program 1.1.0 - [(lam builtin_47 - [(lam partial_48 + [(lam builtin_46 + [(lam partial_47 [(lam select_18 [(lam fromInt_19 [(lam anf_20 @@ -143,18 +141,18 @@ constr 0 anf#67 anf#71 anf#73 [(lam anf_29 [(lam anf_30 [(lam anf_32 - [(lam anf_45 [(lam anf_46 (constr 0 anf_27 anf_32 anf_46)) [select_18 anf_45]]) - [[(builtin constrData) (con integer 2)] (con (list data) [])]]) + [(lam anf_45 (constr 0 anf_27 anf_32 anf_45)) + [select_18 (con data (Constr 2 []))]]) [select_18 anf_30]]) [[(builtin constrData) (con integer 1)] anf_29]]) - [[builtin_47 anf_28] (con (list data) [])]]) + [[builtin_46 anf_28] (con (list data) [])]]) [fromInt_19 (con integer 7)]]) [select_18 anf_26]]) - [partial_48 anf_25]]) - [[builtin_47 anf_24] (con (list data) [])]]) - [partial_48 anf_23]]) - [[builtin_47 anf_20] anf_22]]) - [[builtin_47 anf_21] (con (list data) [])]]) + [partial_47 anf_25]]) + [[builtin_46 anf_24] (con (list data) [])]]) + [partial_47 anf_23]]) + [[builtin_46 anf_20] anf_22]]) + [[builtin_46 anf_21] (con (list data) [])]]) [fromInt_19 (con integer 22)]]) [fromInt_19 (con integer 20)]]) (builtin iData)]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_unit_pattern_keeps_scrutinee_effects.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_unit_pattern_keeps_scrutinee_effects.snap index 47147121..09d43561 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_unit_pattern_keeps_scrutinee_effects.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__big_unit_pattern_keeps_scrutinee_effects.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 865 description: "module Main exposing (..)\nimport Unit\nconsume : Unit.Unit -> unit\nconsume value = case value of\n Unit.Unit -> ()\nmain : unit\nmain = consume (trace \"unit input\" Unit.Unit)\n" --- --- unoptimized Core @@ -27,15 +26,13 @@ main#1 (lam value_8 value_8)]) (con string "unit input")]) --- optimized Core -let anf#20 : nash/base:Unit.Unit = trace "unit input" in constrData 0 (con (list data) []) in +let anf#20 : nash/base:Unit.Unit = trace "unit input" in (con data (Constr 0 [])) in () --- optimized UPLC (program 1.1.0 [(lam builtin_2 [(lam anf_1 (con unit ())) - (force - [[builtin_2 (con string "unit input")] - (delay [[(builtin constrData) (con integer 0)] (con (list data) [])])])]) + (force [[builtin_2 (con string "unit input")] (delay (con data (Constr 0 [])))])]) (force (builtin trace))]) --- result (con unit ()) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_arguments_and_lambda.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_arguments_and_lambda.snap index 526e2f8c..24664349 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_arguments_and_lambda.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_arguments_and_lambda.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 633 description: "module Main exposing (..)\nimport Primitive exposing (..)\nfirst pair(a, _) = a\nmain : int\nmain =\n let\n value = Builtin.unConstrData (Builtin.constrData 7 [])\n pair = first value\n in\n (\\pair(a, _) -> Builtin.addInteger pair a) value\n" --- --- unoptimized Core @@ -45,23 +44,20 @@ main#1 (case match_13 (lam field_14 (lam field_15 [(lam a_12 a_12) field_14])))) arg_11])]) --- optimized Core -let evaluated#27 : Data = constrData 7 (con (list data) []) in -let projection#28 : pair int (list Data) = unConstrData evaluated#27 in +let projection#28 : pair int (list Data) = (con (pair integer (list data)) (7, [])) in let pair#30 : int = case@Pair projection#28 of Pair field#21 field#22 -> field#21 in case@Pair projection#28 of Pair field#33 field#34 -> addInteger pair#30 field#33 --- optimized UPLC (program 1.1.0 - [(lam evaluated_1 - [(lam projection_2 - [(lam pair_5 - (case - projection_2 - (lam field_6 (lam field_7 [[(builtin addInteger) pair_5] field_6])))) - (case projection_2 (lam field_3 (lam field_4 field_3)))]) - [(builtin unConstrData) evaluated_1]]) - [[(builtin constrData) (con integer 7)] (con (list data) [])]]) + [(lam projection_1 + [(lam pair_4 + (case + projection_1 + (lam field_5 (lam field_6 [[(builtin addInteger) pair_4] field_5])))) + (case projection_1 (lam field_2 (lam field_3 field_2)))]) + (con (pair integer (list data)) (7, []))]) --- result (con integer 14) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_do_binding.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_do_binding.snap index 9935d77d..87448eac 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_do_binding.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_do_binding.snap @@ -53,21 +53,17 @@ main#1 (constr 1))) value_15]))]) --- optimized Core -let evaluated#31 : Data = constrData 42 (con (list data) []) in -let projection#32 : pair int (list Data) = unConstrData evaluated#31 in -let result#40 : nash/base:Option.option int = case@Pair projection#32 of +let result#40 : nash/base:Option.option int = case@Pair (con (pair integer (list data)) (42, [])) of Pair field#36 field#37 -> constr 0 field#36 in case@Tag result#40 of 0 field#42 -> field#42 1 -> error --- optimized UPLC (program 1.1.0 - [(lam evaluated_1 - [(lam projection_2 - [(lam result_5 (case result_5 (lam field_6 field_6) (error))) - (case projection_2 (lam field_3 (lam field_4 (constr 0 field_3))))]) - [(builtin unConstrData) evaluated_1]]) - [[(builtin constrData) (con integer 42)] (con (list data) [])]]) + [(lam result_3 (case result_3 (lam field_4 field_4) (error))) + (case + (con (pair integer (list data)) (42, [])) + (lam field_1 (lam field_2 (constr 0 field_1))))]) --- result (con integer 42) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_let.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_let.snap index d2f00cda..39facabf 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_let.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_let.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 617 description: "module Main exposing (..)\nimport Primitive exposing (..)\nmain : int\nmain =\n let\n pair(tag, fields) = Builtin.unConstrData (Builtin.constrData 7 [I 42])\n in\n case fields of\n [I number] -> Builtin.addInteger tag number\n _ -> fail\n" --- --- unoptimized Core @@ -82,11 +81,7 @@ case@Pair match#5 of (con (list data) [])]]]) (lam value_36 value_36)]) --- optimized Core -let anf#57 : Data = iData 42 in -let anf#58 : list Data = mkCons anf#57 (con (list data) []) in -let evaluated#16 : Data = constrData 7 anf#58 in -let projection#17 : pair int (list Data) = unConstrData evaluated#16 in -case@Pair projection#17 of +case@Pair (con (pair integer (list data)) (7, [(I 42)])) of Pair field#20 field#21 -> let leaf#40 : @delay int = delay error in case@List field#21 of Nil -> force leaf#40 @@ -100,41 +95,36 @@ case@Pair projection#17 of DataB field#53 -> force leaf#40 --- optimized UPLC (program 1.1.0 - [(lam builtin_20 - [(lam builtin_21 - [(lam anf_1 - [(lam anf_2 - [(lam evaluated_3 - [(lam projection_4 - (case - projection_4 + [(lam builtin_14 + (case + (con (pair integer (list data)) (7, [(I 42)])) + (lam field_1 + (lam field_2 + [(lam leaf_3 + (case + field_2 + (lam field_4 (lam field_5 - (lam field_6 - [(lam leaf_7 + [(lam generated_13 + (force (case - field_6 - (lam field_8 - (lam field_9 - [(lam generated_19 - (force - [[[[[[builtin_20 generated_19] (delay (force leaf_7))] (delay (force leaf_7))] - (delay (force leaf_7))] - (delay - [(lam field_13 - (case - field_9 - (lam field_14 (lam field_15 (force leaf_7))) - [[(builtin addInteger) field_5] field_13])) - [(builtin unIData) generated_19]])] - (delay (force leaf_7))])) - field_8])) - (force leaf_7))) - (delay (error))])))) - [(builtin unConstrData) evaluated_3]]) - [[(builtin constrData) (con integer 7)] anf_2]]) - [[builtin_21 anf_1] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - (force (builtin mkCons))]) + (constr 0 + generated_13 + (delay (force leaf_3)) + (delay (force leaf_3)) + (delay (force leaf_3)) + (delay + [(lam field_9 + (case + field_5 + (lam field_10 (lam field_11 (force leaf_3))) + [[(builtin addInteger) field_1] field_9])) + [(builtin unIData) generated_13]]) + (delay (force leaf_3))) + builtin_14))) + field_4])) + (force leaf_3))) + (delay (error))])))) (force (builtin chooseData))]) --- result (con integer 49) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_nested_patterns.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_nested_patterns.snap index 260d4b24..3af5d2fb 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_nested_patterns.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__builtin_pair_nested_patterns.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 649 description: "module Main exposing (..)\nimport Primitive exposing (..)\ninspect value =\n case value of\n pair(I a, B bytes) -> Builtin.addInteger a (Builtin.lengthOfByteString bytes)\n _ -> 0\nmain : int\nmain = Builtin.addInteger (inspect (Builtin.mkPairData (I 40) (B #\"aabb\"))) (inspect (Builtin.mkPairData (B #\"\") (I 2)))\n" --- --- unoptimized Core @@ -90,59 +89,52 @@ case@Pair value#15 of DataB field#43 -> let anf#55 : int = lengthOfByteString field#43 in addInteger field#23 anf#55 DataB field#46 -> force leaf#17 in -let anf#57 : Data = iData 40 in -let anf#59 : Data = bData (con bytestring #aabb) in -let anf#60 : pair Data Data = mkPairData anf#57 anf#59 in -let anf#61 : int = inspect#47 anf#60 in -let anf#63 : Data = bData (con bytestring #) in -let anf#65 : Data = iData 2 in -let anf#66 : pair Data Data = mkPairData anf#63 anf#65 in -let anf#67 : int = inspect#47 anf#66 in +let anf#61 : int = inspect#47 (con (pair data data) ((I 40), (B #aabb))) in +let anf#67 : int = inspect#47 (con (pair data data) ((B #), (I 2))) in addInteger anf#61 anf#67 --- optimized UPLC (program 1.1.0 - [(lam builtin_36 + [(lam builtin_30 [(lam inspect_25 [(lam anf_26 - [(lam anf_27 - [(lam anf_28 - [(lam anf_29 - [(lam anf_30 - [(lam anf_31 - [(lam anf_32 - [(lam anf_33 [[(builtin addInteger) anf_29] anf_33]) [inspect_25 anf_32]]) - [[(builtin mkPairData) anf_30] anf_31]]) - [(builtin iData) (con integer 2)]]) - [(builtin bData) (con bytestring #)]]) - [inspect_25 anf_28]]) - [[(builtin mkPairData) anf_26] anf_27]]) - [(builtin bData) (con bytestring #aabb)]]) - [(builtin iData) (con integer 40)]]) + [(lam anf_27 [[(builtin addInteger) anf_26] anf_27]) + [inspect_25 (con (pair data data) ((B #), (I 2)))]]) + [inspect_25 (con (pair data data) ((I 40), (B #aabb)))]]) (lam value_1 [(lam leaf_2 (case value_1 (lam field_3 (lam field_4 - [(lam generated_34 + [(lam generated_28 (force - [[[[[[builtin_36 generated_34] (delay (force leaf_2))] (delay (force leaf_2))] - (delay (force leaf_2))] - (delay - [(lam field_8 - [(lam generated_35 - (force - [[[[[[builtin_36 generated_35] (delay (force leaf_2))] (delay (force leaf_2))] - (delay (force leaf_2))] - (delay (force leaf_2))] - (delay - [(lam field_13 - [(lam anf_14 [[(builtin addInteger) field_8] anf_14]) - [(builtin lengthOfByteString) field_13]]) - [(builtin unBData) generated_35]])])) - field_4]) - [(builtin unIData) generated_34]])] - (delay (force leaf_2))])) + (case + (constr 0 + generated_28 + (delay (force leaf_2)) + (delay (force leaf_2)) + (delay (force leaf_2)) + (delay + [(lam field_8 + [(lam generated_29 + (force + (case + (constr 0 + generated_29 + (delay (force leaf_2)) + (delay (force leaf_2)) + (delay (force leaf_2)) + (delay (force leaf_2)) + (delay + [(lam field_13 + [(lam anf_14 [[(builtin addInteger) field_8] anf_14]) + [(builtin lengthOfByteString) field_13]]) + [(builtin unBData) generated_29]])) + builtin_30))) + field_4]) + [(builtin unIData) generated_28]]) + (delay (force leaf_2))) + builtin_30))) field_3])))) (delay (con integer 0))])]) (force (builtin chooseData))]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_constr_pair_base_helpers.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_constr_pair_base_helpers.snap index 55c96b0d..3c4bc073 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_constr_pair_base_helpers.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_constr_pair_base_helpers.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 699 description: "module Main exposing (..)\nimport Data\nimport Primitive exposing (..)\nimport Option exposing (type option(..))\nmain : int\nmain =\n let index = Data.tag (Builtin.constrData 7 [I 42]) in\n case Data.fields (Builtin.constrData 7 [I 42]) of\n [I number] -> Builtin.addInteger index number\n _ -> fail\n" --- --- unoptimized Core @@ -89,77 +88,15 @@ main#1 projection_42]) [(builtin unConstrData) value_29]])]) --- optimized Core -let anf#71 : Data = iData 42 in -let anf#72 : list Data = mkCons anf#71 (con (list data) []) in -let anf#73 : Data = constrData 7 anf#72 in -let projection#46 : pair int (list Data) = unConstrData anf#73 in -let index#54 : int = case@Pair projection#46 of +let index#54 : int = case@Pair (con (pair integer (list data)) (7, [(I 42)])) of Pair field#49 field#50 -> field#49 in -let anf#76 : Data = iData 42 in -let anf#77 : list Data = mkCons anf#76 (con (list data) []) in -let anf#78 : Data = constrData 7 anf#77 in -let projection#9 : pair int (list Data) = unConstrData anf#78 in -let match#56 : list Data = case@Pair projection#9 of - Pair field#12 field#13 -> field#13 in -let leaf#57 : @delay int = delay error in -case@List match#56 of - Nil -> force leaf#57 - Cons field#58 field#59 -> case@Data field#58 of - DataConstr field#60 -> force leaf#57 - DataMap field#61 -> force leaf#57 - DataList field#62 -> force leaf#57 - DataI field#63 -> case@List field#59 of - Nil -> addInteger index#54 field#63 - Cons field#65 field#66 -> force leaf#57 - DataB field#67 -> force leaf#57 +addInteger index#54 42 --- optimized UPLC (program 1.1.0 - [(lam builtin_29 - [(lam builtin_30 - [(lam partial_31 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam projection_4 - [(lam index_7 - [(lam anf_8 - [(lam anf_10 - [(lam anf_11 - [(lam projection_14 - [(lam match_17 - [(lam leaf_18 - (case - match_17 - (lam field_19 - (lam field_20 - [(lam generated_28 - (force - [[[[[[builtin_29 generated_28] (delay (force leaf_18))] (delay (force leaf_18))] - (delay (force leaf_18))] - (delay - [(lam field_24 - (case - field_20 - (lam field_25 (lam field_26 (force leaf_18))) - [[(builtin addInteger) index_7] field_24])) - [(builtin unIData) generated_28]])] - (delay (force leaf_18))])) - field_19])) - (force leaf_18))) - (delay (error))]) - (case projection_14 (lam field_15 (lam field_16 field_16)))]) - [(builtin unConstrData) anf_11]]) - [partial_31 anf_10]]) - [[builtin_30 anf_8] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - (case projection_4 (lam field_5 (lam field_6 field_5)))]) - [(builtin unConstrData) anf_3]]) - [partial_31 anf_2]]) - [[builtin_30 anf_1] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - [(builtin constrData) (con integer 7)]]) - (force (builtin mkCons))]) - (force (builtin chooseData))]) + [(lam index_3 [[(builtin addInteger) index_3] (con integer 42)]) + (case + (con (pair integer (list data)) (7, [(I 42)])) + (lam field_1 (lam field_2 field_1)))]) --- result (con integer 49) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_constr_pair_payload.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_constr_pair_payload.snap index 0f5614ed..6c6679ad 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_constr_pair_payload.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_constr_pair_payload.snap @@ -109,11 +109,7 @@ main#1 (delay (error))]) value_41])]) --- optimized Core -let anf#77 : Data = iData 42 in -let anf#78 : list Data = mkCons anf#77 (con (list data) []) in -let anf#79 : Data = constrData 7 anf#78 in -let field#11 : pair int (list Data) = unConstrData anf#79 in -let match#47 : Data = case@Pair field#11 of +let match#47 : Data = case@Pair (con (pair integer (list data)) (7, [(I 42)])) of Pair tag#14 fields#15 -> constrData tag#14 fields#15 in let leaf#48 : @delay int = delay error in case@Data match#47 of @@ -134,56 +130,54 @@ case@Data match#47 of DataB field#73 -> force leaf#48 --- optimized UPLC (program 1.1.0 - [(lam builtin_30 - [(lam builtin_31 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam field_4 - [(lam match_7 - [(lam leaf_8 - [(lam generated_28 - (force - [[[[[[builtin_30 generated_28] - (delay - [(lam field_9 - (case - field_9 - (lam field_10 - (lam field_12 - (case - field_12 - (lam field_13 - (lam field_16 - [(lam generated_29 - (force - [[[[[[builtin_30 generated_29] (delay (force leaf_8))] (delay (force leaf_8))] - (delay (force leaf_8))] - (delay - [(lam field_20 - (case - field_16 - (lam field_21 (lam field_22 (force leaf_8))) - [[(builtin addInteger) field_10] field_20])) - [(builtin unIData) generated_29]])] - (delay (force leaf_8))])) - field_13])) - (force leaf_8)))))) - [(builtin unConstrData) generated_28]])] - (delay (force leaf_8))] - (delay (force leaf_8))] - (delay (force leaf_8))] - (delay (force leaf_8))])) - match_7]) - (delay (error))]) - (case - field_4 - (lam tag_5 (lam fields_6 [[(builtin constrData) tag_5] fields_6])))]) - [(builtin unConstrData) anf_3]]) - [[(builtin constrData) (con integer 7)] anf_2]]) - [[builtin_31 anf_1] (con (list data) [])]]) - [(builtin iData) (con integer 42)]]) - (force (builtin mkCons))]) + [(lam builtin_25 + [(lam match_3 + [(lam leaf_4 + [(lam generated_23 + (force + (case + (constr 0 + generated_23 + (delay + [(lam field_5 + (case + field_5 + (lam field_6 + (lam field_7 + (case + field_7 + (lam field_8 + (lam field_9 + [(lam generated_24 + (force + (case + (constr 0 + generated_24 + (delay (force leaf_4)) + (delay (force leaf_4)) + (delay (force leaf_4)) + (delay + [(lam field_13 + (case + field_9 + (lam field_16 (lam field_17 (force leaf_4))) + [[(builtin addInteger) field_6] field_13])) + [(builtin unIData) generated_24]]) + (delay (force leaf_4))) + builtin_25))) + field_8])) + (force leaf_4)))))) + [(builtin unConstrData) generated_23]]) + (delay (force leaf_4)) + (delay (force leaf_4)) + (delay (force leaf_4)) + (delay (force leaf_4))) + builtin_25))) + match_3]) + (delay (error))]) + (case + (con (pair integer (list data)) (7, [(I 42)])) + (lam tag_1 (lam fields_2 [[(builtin constrData) tag_1] fields_2])))]) (force (builtin chooseData))]) --- result (con integer 49) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_ignored_payload_keeps_scrutinee_effects.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_ignored_payload_keeps_scrutinee_effects.snap index a0b24285..74ba3d66 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_ignored_payload_keeps_scrutinee_effects.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__data_ignored_payload_keeps_scrutinee_effects.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 1031 description: "module Main exposing (..)\nimport Data exposing (ToData)\nimport Primitive exposing (Data(..))\nmain : int\nmain = case trace \"data input\" (toData (Builtin.iData 42)) of\n I _ -> 7\n _ -> fail\n" --- --- unoptimized Core @@ -43,7 +42,7 @@ main#1 (lam coerce_17 coerce_17)]) (con string "data input")]) --- optimized Core -let match#23 : Data = trace "data input" in iData 42 in +let match#23 : Data = trace "data input" in (con data (I 42)) in let leaf#24 : @delay int = delay error in case@Data match#23 of DataConstr field#25 -> force leaf#24 @@ -57,17 +56,18 @@ case@Data match#23 of [(lam builtin_10 [(lam match_1 [(lam leaf_2 - [(lam generated_8 - (force - [[[[[[builtin_9 generated_8] (delay (force leaf_2))] (delay (force leaf_2))] - (delay (force leaf_2))] - (delay (con integer 7))] - (delay (force leaf_2))])) - match_1]) + (force + (case + (constr 0 + match_1 + (delay (force leaf_2)) + (delay (force leaf_2)) + (delay (force leaf_2)) + (delay (con integer 7)) + (delay (force leaf_2))) + builtin_9))) (delay (error))]) - (force - [[builtin_10 (con string "data input")] - (delay [(builtin iData) (con integer 42)])])]) + (force [[builtin_10 (con string "data input")] (delay (con data (I 42)))])]) (force (builtin trace))]) (force (builtin chooseData))]) --- result diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_empty_list_on_filled_list.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_empty_list_on_filled_list.snap index 4f5782c4..6e5a4232 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_empty_list_on_filled_list.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_empty_list_on_filled_list.snap @@ -25,15 +25,9 @@ main#1 (lam value_9 value_9)]) (lam value_8 value_8)]) --- optimized Core -let anf#21 : list int = mkCons 2 (con (list integer) []) in -let x#14 : list int = mkCons 1 anf#21 in error --- optimized UPLC -(program 1.1.0 - [(lam builtin_3 - [(lam anf_1 [(lam x_2 (error)) [[builtin_3 (con integer 1)] anf_1]]) - [[builtin_3 (con integer 2)] (con (list integer) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 (error)) --- result error: ExplicitErrorTerm --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head3_cast_data_no_tail.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head3_cast_data_no_tail.snap index 7124c685..b5ec5ddf 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head3_cast_data_no_tail.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head3_cast_data_no_tail.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 473 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (validate)\nimport Lift exposing (lower)\nimport Functor\nmain =\n let\n a : Data\n a = List [I 1, I 2, I 3]\n checked : List Int\n checked = validate a\n values : list int\n values = Functor.map Builtin.unIData (Builtin.unListData checked)\n in\n case values of\n [h, i, j] -> if equalsInteger h h then\n if equalsInteger i i then equalsInteger j j else False\n else False\n _ -> fail\n" --- --- unoptimized Core @@ -165,14 +164,7 @@ main#1 (lam value_34 value_34)]) --- optimized Core let applyForward#69 : 'erased -> ('erased -> 'erased) -> 'erased = \x#67 : 'erased (f#68 : 'erased -> 'erased) -> f#68 x#67 in -let anf#124 : Data = iData 1 in -let anf#126 : Data = iData 2 in -let anf#128 : Data = iData 3 in -let anf#129 : list Data = mkCons anf#128 (con (list data) []) in -let anf#130 : list Data = mkCons anf#126 anf#129 in -let anf#131 : list Data = mkCons anf#124 anf#130 in -let a#93 : Data = listData anf#131 in -let anf#119 : list Data = applyForward#69 a#93 unListData in +let anf#119 : list Data = applyForward#69 (con data (List [I 1, I 2, I 3])) unListData in let anf#120 : (list Data -> list Data) -> list Data = applyForward#69 anf#119 in let anf#122 : list Data = anf#120 (\values#72 : list 'erased -> letrec worker#112 : list 'erased -> list Data [static []] = \values#111 : list 'erased -> case@List values#111 of @@ -210,87 +202,73 @@ case@List values#96 of Cons field#108 field#109 -> force leaf#98 --- optimized UPLC (program 1.1.0 - [(lam builtin_51 + [(lam builtin_44 [(lam applyForward_7 [(lam anf_8 [(lam anf_9 - [(lam anf_10 - [(lam anf_11 - [(lam anf_12 - [(lam anf_13 - [(lam a_14 - [(lam anf_15 - [(lam anf_18 - [(lam anf_28 - [(lam checked_29 - [(lam projection_30 - [(lam worker_38 - [(lam values_39 - [(lam leaf_40 - (case - values_39 - (lam field_41 - (lam field_42 - (case - field_42 - (lam field_43 - (lam field_44 - (case - field_44 - (lam field_45 - (lam field_46 - (case - field_46 - (lam field_49 (lam field_50 (force leaf_40))) - [(lam anf_47 - (case - anf_47 - (con bool False) - [(lam anf_48 - (case anf_48 (con bool False) [[(builtin equalsInteger) field_45] field_45])) - [[(builtin equalsInteger) field_43] field_43]])) - [[(builtin equalsInteger) field_41] field_41]]))) - (force leaf_40)))) - (force leaf_40)))) - (force leaf_40))) - (delay (error))]) - [worker_38 projection_30]]) - [(lam self_31 [self_31 self_31]) - (lam self_32 - (lam values_33 - (case - values_33 - (lam field_34 - (lam field_35 - [(lam anf_36 - [(lam anf_37 [[builtin_51 anf_36] anf_37]) [[self_32 self_32] field_35]]) - [(builtin unIData) field_34]])) - (con (list integer) []))))]]) - [(builtin unListData) checked_29]]) - [[applyForward_7 anf_28] (builtin listData)]]) - [anf_18 - (lam values_19 - [(lam worker_27 [worker_27 values_19]) - [(lam self_20 [self_20 self_20]) - (lam self_21 - (lam values_22 - (case - values_22 - (lam field_23 - (lam field_24 - [(lam destruct_25 - [(lam anf_26 [[builtin_51 field_23] anf_26]) [[self_21 self_21] field_24]]) - [(builtin unIData) field_23]])) - (con (list data) []))))]])]]) - [applyForward_7 anf_15]]) - [[applyForward_7 a_14] (builtin unListData)]]) - [(builtin listData) anf_13]]) - [[builtin_51 anf_8] anf_12]]) - [[builtin_51 anf_9] anf_11]]) - [[builtin_51 anf_10] (con (list data) [])]]) - [(builtin iData) (con integer 3)]]) - [(builtin iData) (con integer 2)]]) - [(builtin iData) (con integer 1)]]) + [(lam anf_21 + [(lam checked_22 + [(lam projection_23 + [(lam worker_31 + [(lam values_32 + [(lam leaf_33 + (case + values_32 + (lam field_34 + (lam field_35 + (case + field_35 + (lam field_36 + (lam field_37 + (case + field_37 + (lam field_38 + (lam field_39 + (case + field_39 + (lam field_42 (lam field_43 (force leaf_33))) + [(lam anf_40 + (case + anf_40 + (con bool False) + [(lam anf_41 + (case anf_41 (con bool False) [[(builtin equalsInteger) field_38] field_38])) + [[(builtin equalsInteger) field_36] field_36]])) + [[(builtin equalsInteger) field_34] field_34]]))) + (force leaf_33)))) + (force leaf_33)))) + (force leaf_33))) + (delay (error))]) + [worker_31 projection_23]]) + [(lam self_24 [self_24 self_24]) + (lam self_25 + (lam values_26 + (case + values_26 + (lam field_27 + (lam field_28 + [(lam anf_29 + [(lam anf_30 [[builtin_44 anf_29] anf_30]) [[self_25 self_25] field_28]]) + [(builtin unIData) field_27]])) + (con (list integer) []))))]]) + [(builtin unListData) checked_22]]) + [[applyForward_7 anf_21] (builtin listData)]]) + [anf_9 + (lam values_10 + [(lam worker_20 [worker_20 values_10]) + [(lam self_11 [self_11 self_11]) + (lam self_12 + (lam values_13 + (case + values_13 + (lam field_14 + (lam field_15 + [(lam destruct_18 + [(lam anf_19 [[builtin_44 field_14] anf_19]) [[self_12 self_12] field_15]]) + [(builtin unIData) field_14]])) + (con (list data) []))))]])]]) + [applyForward_7 anf_8]]) + [[applyForward_7 (con data (List [I 1, I 2, I 3]))] (builtin unListData)]]) (lam x_5 (lam f_6 [f_6 x_5]))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head3_no_tail.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head3_no_tail.snap index ae395e2c..f3333c7e 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head3_no_tail.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head3_no_tail.snap @@ -73,37 +73,9 @@ main#1 (lam value_27 value_27)]) (lam value_26 value_26)]) --- optimized Core -let anf#42 : list int = mkCons 3 (con (list integer) []) in -let anf#43 : list int = mkCons 2 anf#42 in -let a#12 : list int = mkCons 1 anf#43 in -let anf#44 : bool = equalsInteger 1 1 in -case@Bool anf#44 of - True -> let anf#45 : bool = equalsInteger 2 2 in - case@Bool anf#45 of - True -> equalsInteger 3 3 - False -> false - False -> false +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_6 - [(lam anf_1 - [(lam anf_2 - [(lam a_3 - [(lam anf_4 - (case - anf_4 - (con bool False) - [(lam anf_5 - (case - anf_5 - (con bool False) - [[(builtin equalsInteger) (con integer 3)] (con integer 3)])) - [[(builtin equalsInteger) (con integer 2)] (con integer 2)]])) - [[(builtin equalsInteger) (con integer 1)] (con integer 1)]]) - [[builtin_6 (con integer 1)] anf_2]]) - [[builtin_6 (con integer 2)] anf_1]]) - [[builtin_6 (con integer 3)] (con (list integer) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_cast_data_no_tail.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_cast_data_no_tail.snap index 7c4de1c2..f9694da8 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_cast_data_no_tail.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_cast_data_no_tail.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 499 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (validate)\nimport Lift exposing (lower)\nimport Functor\nmain =\n let\n a : Data\n a = List [I 1, I 2, I 3]\n checked : List Int\n checked = validate a\n values : list int\n values = Functor.map Builtin.unIData (Builtin.unListData checked)\n in\n case values of\n [h] -> equalsInteger h h\n _ -> fail\n" --- --- unoptimized Core @@ -130,14 +129,7 @@ main#1 values_32]))]) --- optimized Core let applyForward#59 : 'erased -> ('erased -> 'erased) -> 'erased = \x#57 : 'erased (f#58 : 'erased -> 'erased) -> f#58 x#57 in -let anf#108 : Data = iData 1 in -let anf#110 : Data = iData 2 in -let anf#112 : Data = iData 3 in -let anf#113 : list Data = mkCons anf#112 (con (list data) []) in -let anf#114 : list Data = mkCons anf#110 anf#113 in -let anf#115 : list Data = mkCons anf#108 anf#114 in -let a#83 : Data = listData anf#115 in -let anf#103 : list Data = applyForward#59 a#83 unListData in +let anf#103 : list Data = applyForward#59 (con data (List [I 1, I 2, I 3])) unListData in let anf#104 : (list Data -> list Data) -> list Data = applyForward#59 anf#103 in let anf#106 : list Data = anf#104 (\values#62 : list 'erased -> letrec worker#96 : list 'erased -> list Data [static []] = \values#95 : list 'erased -> case@List values#95 of @@ -165,70 +157,56 @@ case@List values#86 of Cons field#92 field#93 -> force leaf#88 --- optimized UPLC (program 1.1.0 - [(lam builtin_43 + [(lam builtin_36 [(lam applyForward_7 [(lam anf_8 [(lam anf_9 - [(lam anf_10 - [(lam anf_11 - [(lam anf_12 - [(lam anf_13 - [(lam a_14 - [(lam anf_15 - [(lam anf_16 - [(lam anf_26 - [(lam checked_27 - [(lam projection_28 - [(lam worker_36 - [(lam values_37 - [(lam leaf_38 - (case - values_37 - (lam field_39 - (lam field_40 - (case - field_40 - (lam field_41 (lam field_42 (force leaf_38))) - [[(builtin equalsInteger) field_39] field_39]))) - (force leaf_38))) - (delay (error))]) - [worker_36 projection_28]]) - [(lam self_29 [self_29 self_29]) - (lam self_30 - (lam values_31 - (case - values_31 - (lam field_32 - (lam field_33 - [(lam anf_34 - [(lam anf_35 [[builtin_43 anf_34] anf_35]) [[self_30 self_30] field_33]]) - [(builtin unIData) field_32]])) - (con (list integer) []))))]]) - [(builtin unListData) checked_27]]) - [[applyForward_7 anf_26] (builtin listData)]]) - [anf_16 - (lam values_17 - [(lam worker_25 [worker_25 values_17]) - [(lam self_18 [self_18 self_18]) - (lam self_19 - (lam values_20 - (case - values_20 - (lam field_21 - (lam field_22 - [(lam destruct_23 - [(lam anf_24 [[builtin_43 field_21] anf_24]) [[self_19 self_19] field_22]]) - [(builtin unIData) field_21]])) - (con (list data) []))))]])]]) - [applyForward_7 anf_15]]) - [[applyForward_7 a_14] (builtin unListData)]]) - [(builtin listData) anf_13]]) - [[builtin_43 anf_8] anf_12]]) - [[builtin_43 anf_9] anf_11]]) - [[builtin_43 anf_10] (con (list data) [])]]) - [(builtin iData) (con integer 3)]]) - [(builtin iData) (con integer 2)]]) - [(builtin iData) (con integer 1)]]) + [(lam anf_19 + [(lam checked_20 + [(lam projection_21 + [(lam worker_29 + [(lam values_30 + [(lam leaf_31 + (case + values_30 + (lam field_32 + (lam field_33 + (case + field_33 + (lam field_34 (lam field_35 (force leaf_31))) + [[(builtin equalsInteger) field_32] field_32]))) + (force leaf_31))) + (delay (error))]) + [worker_29 projection_21]]) + [(lam self_22 [self_22 self_22]) + (lam self_23 + (lam values_24 + (case + values_24 + (lam field_25 + (lam field_26 + [(lam anf_27 + [(lam anf_28 [[builtin_36 anf_27] anf_28]) [[self_23 self_23] field_26]]) + [(builtin unIData) field_25]])) + (con (list integer) []))))]]) + [(builtin unListData) checked_20]]) + [[applyForward_7 anf_19] (builtin listData)]]) + [anf_9 + (lam values_10 + [(lam worker_18 [worker_18 values_10]) + [(lam self_11 [self_11 self_11]) + (lam self_12 + (lam values_13 + (case + values_13 + (lam field_14 + (lam field_15 + [(lam destruct_16 + [(lam anf_17 [[builtin_36 field_14] anf_17]) [[self_12 self_12] field_15]]) + [(builtin unIData) field_14]])) + (con (list data) []))))]])]]) + [applyForward_7 anf_8]]) + [[applyForward_7 (con data (List [I 1, I 2, I 3]))] (builtin unListData)]]) (lam x_5 (lam f_6 [f_6 x_5]))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_cast_data_with_tail.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_cast_data_with_tail.snap index 78d36183..ccc4a720 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_cast_data_with_tail.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_cast_data_with_tail.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 523 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (validate)\nimport Lift exposing (lower)\nimport Functor\nmain =\n let\n a : Data\n a = List [I 1, I 2, I 3]\n checked : List Int\n checked = validate a\n values : list int\n values = Functor.map Builtin.unIData (Builtin.unListData checked)\n in\n case values of\n h :: j :: _ -> if equalsInteger h h then equalsInteger j j else False\n _ -> fail\n" --- --- unoptimized Core @@ -145,14 +144,7 @@ main#1 (lam value_25 value_25)]) --- optimized Core let applyForward#64 : 'erased -> ('erased -> 'erased) -> 'erased = \x#62 : 'erased (f#63 : 'erased -> 'erased) -> f#63 x#62 in -let anf#114 : Data = iData 1 in -let anf#116 : Data = iData 2 in -let anf#118 : Data = iData 3 in -let anf#119 : list Data = mkCons anf#118 (con (list data) []) in -let anf#120 : list Data = mkCons anf#116 anf#119 in -let anf#121 : list Data = mkCons anf#114 anf#120 in -let a#88 : Data = listData anf#121 in -let anf#109 : list Data = applyForward#64 a#88 unListData in +let anf#109 : list Data = applyForward#64 (con data (List [I 1, I 2, I 3])) unListData in let anf#110 : (list Data -> list Data) -> list Data = applyForward#64 anf#109 in let anf#112 : list Data = anf#110 (\values#67 : list 'erased -> letrec worker#102 : list 'erased -> list Data [static []] = \values#101 : list 'erased -> case@List values#101 of @@ -183,74 +175,60 @@ case@List values#91 of False -> false --- optimized UPLC (program 1.1.0 - [(lam builtin_44 + [(lam builtin_37 [(lam applyForward_7 [(lam anf_8 [(lam anf_9 - [(lam anf_10 - [(lam anf_11 - [(lam anf_12 - [(lam anf_13 - [(lam a_14 - [(lam anf_15 - [(lam anf_16 - [(lam anf_26 - [(lam checked_27 - [(lam projection_28 - [(lam worker_36 - [(lam values_37 - [(lam leaf_38 - (case - values_37 - (lam field_39 - (lam field_40 - (case - field_40 - (lam field_41 - (lam field_42 - [(lam anf_43 - (case anf_43 (con bool False) [[(builtin equalsInteger) field_41] field_41])) - [[(builtin equalsInteger) field_39] field_39]])) - (force leaf_38)))) - (force leaf_38))) - (delay (error))]) - [worker_36 projection_28]]) - [(lam self_29 [self_29 self_29]) - (lam self_30 - (lam values_31 - (case - values_31 - (lam field_32 - (lam field_33 - [(lam anf_34 - [(lam anf_35 [[builtin_44 anf_34] anf_35]) [[self_30 self_30] field_33]]) - [(builtin unIData) field_32]])) - (con (list integer) []))))]]) - [(builtin unListData) checked_27]]) - [[applyForward_7 anf_26] (builtin listData)]]) - [anf_16 - (lam values_17 - [(lam worker_25 [worker_25 values_17]) - [(lam self_18 [self_18 self_18]) - (lam self_19 - (lam values_20 - (case - values_20 - (lam field_21 - (lam field_22 - [(lam destruct_23 - [(lam anf_24 [[builtin_44 field_21] anf_24]) [[self_19 self_19] field_22]]) - [(builtin unIData) field_21]])) - (con (list data) []))))]])]]) - [applyForward_7 anf_15]]) - [[applyForward_7 a_14] (builtin unListData)]]) - [(builtin listData) anf_13]]) - [[builtin_44 anf_8] anf_12]]) - [[builtin_44 anf_9] anf_11]]) - [[builtin_44 anf_10] (con (list data) [])]]) - [(builtin iData) (con integer 3)]]) - [(builtin iData) (con integer 2)]]) - [(builtin iData) (con integer 1)]]) + [(lam anf_19 + [(lam checked_20 + [(lam projection_21 + [(lam worker_29 + [(lam values_30 + [(lam leaf_31 + (case + values_30 + (lam field_32 + (lam field_33 + (case + field_33 + (lam field_34 + (lam field_35 + [(lam anf_36 + (case anf_36 (con bool False) [[(builtin equalsInteger) field_34] field_34])) + [[(builtin equalsInteger) field_32] field_32]])) + (force leaf_31)))) + (force leaf_31))) + (delay (error))]) + [worker_29 projection_21]]) + [(lam self_22 [self_22 self_22]) + (lam self_23 + (lam values_24 + (case + values_24 + (lam field_25 + (lam field_26 + [(lam anf_27 + [(lam anf_28 [[builtin_37 anf_27] anf_28]) [[self_23 self_23] field_26]]) + [(builtin unIData) field_25]])) + (con (list integer) []))))]]) + [(builtin unListData) checked_20]]) + [[applyForward_7 anf_19] (builtin listData)]]) + [anf_9 + (lam values_10 + [(lam worker_18 [worker_18 values_10]) + [(lam self_11 [self_11 self_11]) + (lam self_12 + (lam values_13 + (case + values_13 + (lam field_14 + (lam field_15 + [(lam destruct_16 + [(lam anf_17 [[builtin_37 field_14] anf_17]) [[self_12 self_12] field_15]]) + [(builtin unIData) field_14]])) + (con (list data) []))))]])]]) + [applyForward_7 anf_8]]) + [[applyForward_7 (con data (List [I 1, I 2, I 3]))] (builtin unListData)]]) (lam x_5 (lam f_6 [f_6 x_5]))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_discard_tail.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_discard_tail.snap index d4cad589..a3dd0155 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_discard_tail.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_discard_tail.snap @@ -28,20 +28,9 @@ main#1 [[(force (builtin mkCons)) [fromInt_7 (con integer 3)]] (con (list integer) [])]]]]) (lam value_8 value_8)]) --- optimized Core -let anf#20 : list int = mkCons 3 (con (list integer) []) in -let anf#21 : list int = mkCons 2 anf#20 in -let a#11 : list int = mkCons 1 anf#21 in -equalsInteger 1 1 +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_4 - [(lam anf_1 - [(lam anf_2 - [(lam a_3 [[(builtin equalsInteger) (con integer 1)] (con integer 1)]) - [[builtin_4 (con integer 1)] anf_2]]) - [[builtin_4 (con integer 2)] anf_1]]) - [[builtin_4 (con integer 3)] (con (list integer) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_no_tail.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_no_tail.snap index a63e9755..323206a0 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_no_tail.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__expect_head_no_tail.snap @@ -38,18 +38,9 @@ main#1 (con (list integer) [])]]]]) (lam value_15 value_15)]) --- optimized Core -let anf#26 : list int = mkCons 3 (con (list integer) []) in -let anf#27 : list int = mkCons 2 anf#26 in -let a#7 : list int = mkCons 1 anf#27 in error --- optimized UPLC -(program 1.1.0 - [(lam builtin_4 - [(lam anf_1 - [(lam anf_2 [(lam a_3 (error)) [[builtin_4 (con integer 1)] anf_2]]) - [[builtin_4 (con integer 2)] anf_1]]) - [[builtin_4 (con integer 3)] (con (list integer) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 (error)) --- result error: ExplicitErrorTerm --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__foldl_type_mismatch.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__foldl_type_mismatch.snap index fb268247..8fb1579f 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__foldl_type_mismatch.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__foldl_type_mismatch.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 326 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nimport Lift exposing (lower, lift)\ntype Option 'a = None | Some 'a\ntype Address = Address { paymentCredential : Bytes, stakeCredential : Option Bytes }\ntype Output = Output { address : Address, value : List Int, datum : Option Int, referenceScript : Option Int }\nfoldl self with zero =\n case self of\n [] -> zero\n x :: xs -> foldl xs with (with x zero)\nmain =\n let\n addr1 = Address { paymentCredential = #\"61646666\", stakeCredential = None }\n out = Output { address = addr1, value = (lift empty), datum = None, referenceScript = None }\n empty : list Int\n empty = []\n outputs : list Output\n outputs = [out, out, out]\n cry =\n foldl outputs\n (\\o mbB ->\n case mbB of\n None -> if eq o.address addr1 then Some o else None\n otherwise -> otherwise\n )\n None\n in\n eq cry cry\n" --- --- unoptimized Core @@ -122,22 +121,15 @@ main#1 zero_30])))]) --- optimized Core let anf#80 : Bytes = bData (con bytestring #61646666) in -let anf#82 : Main.Option Bytes = constrData 0 (con (list data) []) in -let anf#78 : list Data = mkCons anf#82 (con (list data) []) in -let anf#79 : list Data = mkCons anf#80 anf#78 in +let anf#79 : list Data = mkCons anf#80 (con (list data) [(Constr 0 [])]) in let addr1#51 : Main.Address = constrData 0 anf#79 in let anf#88 : List Int = listData (con (list data) []) in -let anf#90 : Main.Option Int = constrData 0 (con (list data) []) in -let anf#92 : Main.Option Int = constrData 0 (con (list data) []) in -let anf#83 : list Data = mkCons anf#92 (con (list data) []) in -let anf#84 : list Data = mkCons anf#90 anf#83 in -let anf#85 : list Data = mkCons anf#88 anf#84 in +let anf#85 : list Data = mkCons anf#88 (con (list data) [(Constr 0 []), (Constr 0 [])]) in let anf#86 : list Data = mkCons addr1#51 anf#85 in let out#56 : Main.Output = constrData 0 anf#86 in let anf#93 : list Main.Output = mkCons out#56 (con (list data) []) in let anf#94 : list Main.Output = mkCons out#56 anf#93 in let outputs#57 : list Main.Output = mkCons out#56 anf#94 in -let anf#98 : Main.Option Main.Output = constrData 0 (con (list data) []) in letrec worker#75 : list 'erased -> 'erased -> 'erased [static []] = \self#73 : list 'erased zero#74 : 'erased -> case@List self#73 of Nil -> zero#74 @@ -152,91 +144,77 @@ letrec case@Bool anf#95 of True -> let anf#96 : list Data = mkCons field#42 (con (list data) []) in constrData 1 anf#96 - False -> constrData 0 (con (list data) []) + False -> (con data (Constr 0 [])) 1 -> zero#74 in anf#76 anf#77 in -let cry#71 : Main.Option Main.Output = worker#75 outputs#57 anf#98 in +let cry#71 : Main.Option Main.Output = worker#75 outputs#57 (con data (Constr 0 [])) in equalsData cry#71 cry#71 --- optimized UPLC (program 1.1.0 - [(lam builtin_41 - [(lam partial_42 + [(lam builtin_34 + [(lam partial_35 [(lam anf_4 [(lam anf_5 - [(lam anf_6 + [(lam addr1_6 [(lam anf_7 - [(lam addr1_8 + [(lam anf_8 [(lam anf_9 - [(lam anf_10 + [(lam out_10 [(lam anf_11 [(lam anf_12 - [(lam anf_13 - [(lam anf_14 - [(lam anf_15 - [(lam out_16 - [(lam anf_17 - [(lam anf_18 - [(lam outputs_19 - [(lam anf_20 - [(lam worker_39 - [(lam cry_40 [[(builtin equalsData) cry_40] cry_40]) - [[worker_39 outputs_19] anf_20]]) - [(lam self_21 [self_21 self_21]) - (lam self_22 - (lam self_23 - (lam zero_24 - (case - self_23 - (lam field_25 - (lam field_26 - [(lam anf_27 - [(lam projection_28 - [(lam anf_38 [anf_27 anf_38]) - (case - projection_28 - (lam tag_29 - (lam fields_30 - (case - tag_29 - [(lam projection_31 + [(lam outputs_13 + [(lam worker_32 + [(lam cry_33 [[(builtin equalsData) cry_33] cry_33]) + [[worker_32 outputs_13] (con data (Constr 0 []))]]) + [(lam self_14 [self_14 self_14]) + (lam self_15 + (lam self_16 + (lam zero_17 + (case + self_16 + (lam field_18 + (lam field_19 + [(lam anf_20 + [(lam projection_21 + [(lam anf_31 [anf_20 anf_31]) + (case + projection_21 + (lam tag_22 + (lam fields_23 + (case + tag_22 + [(lam projection_24 + (case + projection_24 + (lam tag_25 + (lam fields_26 + (case + fields_26 + (lam head_27 + (lam tail_28 + [(lam anf_29 (case - projection_31 - (lam tag_32 - (lam fields_33 - (case - fields_33 - (lam head_34 - (lam tail_35 - [(lam anf_36 - (case - anf_36 - [partial_42 (con (list data) [])] - [(lam anf_37 [[(builtin constrData) (con integer 1)] anf_37]) - [[builtin_41 field_25] (con (list data) [])]])) - [[(builtin equalsData) head_34] addr1_8]])) - (error)))))) - [(builtin unConstrData) field_25]] - zero_24))))]) - [(builtin unConstrData) zero_24]]) - [[self_22 self_22] field_26]])) - zero_24))))]]) - [partial_42 (con (list data) [])]]) - [[builtin_41 out_16] anf_18]]) - [[builtin_41 out_16] anf_17]]) - [[builtin_41 out_16] (con (list data) [])]]) - [partial_42 anf_15]]) - [[builtin_41 addr1_8] anf_14]]) - [[builtin_41 anf_9] anf_13]]) - [[builtin_41 anf_10] anf_12]]) - [[builtin_41 anf_11] (con (list data) [])]]) - [partial_42 (con (list data) [])]]) - [partial_42 (con (list data) [])]]) - [(builtin listData) (con (list data) [])]]) - [partial_42 anf_7]]) - [[builtin_41 anf_4] anf_6]]) - [[builtin_41 anf_5] (con (list data) [])]]) - [partial_42 (con (list data) [])]]) + anf_29 + (con data (Constr 0 [])) + [(lam anf_30 [[(builtin constrData) (con integer 1)] anf_30]) + [[builtin_34 field_18] (con (list data) [])]])) + [[(builtin equalsData) head_27] addr1_6]])) + (error)))))) + [(builtin unConstrData) field_18]] + zero_17))))]) + [(builtin unConstrData) zero_17]]) + [[self_15 self_15] field_19]])) + zero_17))))]]) + [[builtin_34 out_10] anf_12]]) + [[builtin_34 out_10] anf_11]]) + [[builtin_34 out_10] (con (list data) [])]]) + [partial_35 anf_9]]) + [[builtin_34 addr1_6] anf_8]]) + [[builtin_34 anf_7] (con (list data) [(Constr 0 []), (Constr 0 [])])]]) + [(builtin listData) (con (list data) [])]]) + [partial_35 anf_5]]) + [[builtin_34 anf_4] (con (list data) [(Constr 0 [])])]]) [(builtin bData) (con bytestring #61646666)]]) [(builtin constrData) (con integer 0)]]) (force (builtin mkCons))]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__general_data_keeps_variant_dispatch.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__general_data_keeps_variant_dispatch.snap index 9f98e318..33799cae 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__general_data_keeps_variant_dispatch.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__general_data_keeps_variant_dispatch.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 920 description: "module Main exposing (..)\nimport Primitive exposing (..)\nclassify : Data -> int\nclassify value = case value of\n Constr _ -> 0\n Map _ -> 1\n List _ -> 2\n I _ -> 3\n B _ -> 4\nmain : (int, int, int, int, int)\nmain = (classify (Builtin.constrData 0 []), classify (Map []), classify (List []), classify (I 42), classify (B #\"aa\"))\n" --- --- unoptimized Core @@ -52,48 +51,37 @@ let classify#27 : Data -> int = \value#20 : Data -> case@Data value#20 of DataList field#24 -> 2 DataI field#25 -> 3 DataB field#26 -> 4 in -let anf#36 : Data = constrData 0 (con (list data) []) in -let anf#37 : int = classify#27 anf#36 in -let anf#38 : Data = mapData (con (list (pair data data)) []) in -let anf#39 : int = classify#27 anf#38 in -let anf#40 : Data = listData (con (list data) []) in -let anf#41 : int = classify#27 anf#40 in -let anf#43 : Data = iData 42 in -let anf#44 : int = classify#27 anf#43 in -let anf#46 : Data = bData (con bytestring #aa) in -let anf#47 : int = classify#27 anf#46 in +let anf#37 : int = classify#27 (con data (Constr 0 [])) in +let anf#39 : int = classify#27 (con data (Map [])) in +let anf#41 : int = classify#27 (con data (List [])) in +let anf#44 : int = classify#27 (con data (I 42)) in +let anf#47 : int = classify#27 (con data (B #aa)) in constr 0 anf#37 anf#39 anf#41 anf#44 anf#47 --- optimized UPLC (program 1.1.0 - [(lam builtin_19 + [(lam builtin_14 [(lam classify_7 [(lam anf_8 [(lam anf_9 [(lam anf_10 [(lam anf_11 - [(lam anf_12 - [(lam anf_13 - [(lam anf_14 - [(lam anf_15 - [(lam anf_16 - [(lam anf_17 (constr 0 anf_9 anf_11 anf_13 anf_15 anf_17)) [classify_7 anf_16]]) - [(builtin bData) (con bytestring #aa)]]) - [classify_7 anf_14]]) - [(builtin iData) (con integer 42)]]) - [classify_7 anf_12]]) - [(builtin listData) (con (list data) [])]]) - [classify_7 anf_10]]) - [(builtin mapData) (con (list (pair data data)) [])]]) - [classify_7 anf_8]]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) + [(lam anf_12 (constr 0 anf_8 anf_9 anf_10 anf_11 anf_12)) + [classify_7 (con data (B #aa))]]) + [classify_7 (con data (I 42))]]) + [classify_7 (con data (List []))]]) + [classify_7 (con data (Map []))]]) + [classify_7 (con data (Constr 0 []))]]) (lam value_1 - [(lam generated_18 - (force - [[[[[[builtin_19 generated_18] (delay (con integer 0))] (delay (con integer 1))] - (delay (con integer 2))] - (delay (con integer 3))] - (delay (con integer 4))])) - value_1])]) + (force + (case + (constr 0 + value_1 + (delay (con integer 0)) + (delay (con integer 1)) + (delay (con integer 2)) + (delay (con integer 3)) + (delay (con integer 4))) + builtin_14)))]) (force (builtin chooseData))]) --- result (constr 0 diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__generic_validator_type_test.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__generic_validator_type_test.snap index 041f6013..3ddb84b7 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__generic_validator_type_test.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__generic_validator_type_test.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 558 description: "validator module Main exposing (main)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\ntype Void = Void\ntype A 'x = NoA | SomeA Void 'x\ntype B = B { something : Void }\ntype Option 'a = None | Some 'a\nmain : Option Data -> A B -> Data -> Data -> unit\nmain datum r outputRef transaction =\n assert\n (case r of\n NoA -> False\n SomeA _ (B something) -> eq something Void\n )\n" --- --- unoptimized Core @@ -81,14 +80,13 @@ case@Pair projection#31 of Cons field#36 fieldTail#37 -> let projection#38 : pair int (list Data) = unConstrData field#36 in case@Pair projection#38 of Pair tag#39 fields#40 -> case@List fields#40 of - Cons field#41 fieldTail#42 -> let anf#45 : Main.Void = constrData 0 (con (list data) []) in - equalsData field#41 anf#45 in + Cons field#41 fieldTail#42 -> equalsData field#41 (con data (Constr 0 [])) in case@Bool anf#46 of True -> () False -> trace "assertion failed" in error --- optimized UPLC (program 1.1.0 - [(lam builtin_19 + [(lam builtin_18 (lam datum_1 (lam r_2 (lam outputRef_3 @@ -98,10 +96,10 @@ case@Pair projection#31 of projection_5 (lam tag_6 (lam fields_7 - [(lam anf_18 + [(lam anf_17 (case - anf_18 - (force [[builtin_19 (con string "assertion failed")] (delay (error))]) + anf_17 + (force [[builtin_18 (con string "assertion failed")] (delay (error))]) (con unit ()))) (case tag_6 @@ -122,9 +120,7 @@ case@Pair projection#31 of (case fields_14 (lam field_15 - (lam fieldTail_16 - [(lam anf_17 [[(builtin equalsData) field_15] anf_17]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]])) + (lam fieldTail_16 [[(builtin equalsData) field_15] (con data (Constr 0 []))])) (error)))))) [(builtin unConstrData) field_10]])) (error)))) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__head_list_on_map.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__head_list_on_map.snap index 73ff8c59..71be7e10 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__head_list_on_map.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__head_list_on_map.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 287 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Data exposing (toData)\nmain =\n let\n x = [mkPairData (I 1) (B #\"\"), mkPairData (I 2) (B #\"aa\")]\n first = headList x\n in\n equalsData (toData (mapData [first])) (toData (mapData [mkPairData (I 1) (B #\"\")]))\n" --- --- unoptimized Core @@ -47,60 +46,9 @@ main#1 (lam value_14 value_14)]) (lam coerce_13 coerce_13)]) --- optimized Core -let anf#34 : Data = iData 1 in -let anf#36 : Data = bData (con bytestring #) in -let anf#37 : pair Data Data = mkPairData anf#34 anf#36 in -let anf#39 : Data = iData 2 in -let anf#41 : Data = bData (con bytestring #aa) in -let anf#42 : pair Data Data = mkPairData anf#39 anf#41 in -let anf#43 : list (pair Data Data) = mkCons anf#42 (con (list (pair data data)) []) in -let x#27 : list (pair Data Data) = mkCons anf#37 anf#43 in -let projection#28 : pair Data Data = headList x#27 in -let anf#44 : list (pair Data Data) = mkCons projection#28 (con (list (pair data data)) []) in -let anf#45 : Map Data Data = mapData anf#44 in -let anf#48 : Data = iData 1 in -let anf#50 : Data = bData (con bytestring #) in -let anf#51 : pair Data Data = mkPairData anf#48 anf#50 in -let anf#52 : list (pair Data Data) = mkCons anf#51 (con (list (pair data data)) []) in -let anf#53 : Map Data Data = mapData anf#52 in -equalsData anf#45 anf#53 +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_17 - [(lam builtin_18 - [(lam anf_1 - [(lam anf_2 - [(lam anf_3 - [(lam anf_4 - [(lam anf_5 - [(lam anf_6 - [(lam anf_7 - [(lam x_8 - [(lam projection_9 - [(lam anf_10 - [(lam anf_11 - [(lam anf_12 - [(lam anf_13 - [(lam anf_14 - [(lam anf_15 - [(lam anf_16 [[(builtin equalsData) anf_11] anf_16]) [(builtin mapData) anf_15]]) - [[builtin_17 anf_14] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_12] anf_13]]) - [(builtin bData) (con bytestring #)]]) - [(builtin iData) (con integer 1)]]) - [(builtin mapData) anf_10]]) - [[builtin_17 projection_9] (con (list (pair data data)) [])]]) - [builtin_18 x_8]]) - [[builtin_17 anf_3] anf_7]]) - [[builtin_17 anf_6] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_4] anf_5]]) - [(builtin bData) (con bytestring #aa)]]) - [(builtin iData) (con integer 2)]]) - [[(builtin mkPairData) anf_1] anf_2]]) - [(builtin bData) (con bytestring #)]]) - [(builtin iData) (con integer 1)]]) - (force (builtin headList))]) - (force (builtin mkCons))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__list_clause_with_assign.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__list_clause_with_assign.snap index 08922c1a..dd30bb7a 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__list_clause_with_assign.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__list_clause_with_assign.snap @@ -113,14 +113,12 @@ let fromInt#69 : int -> Int = iData in let anf#77 : Int = fromInt#69 1 in let anf#76 : list Data = mkCons anf#77 (con (list data) []) in let anf#78 : Main.Option = constrData 0 anf#76 in -let anf#79 : Main.Option = constrData 1 (con (list data) []) in -let anf#80 : list Main.Option = mkCons anf#79 (con (list data) []) in -let anf#81 : list Main.Option = mkCons anf#78 anf#80 in +let anf#81 : list Main.Option = mkCons anf#78 (con (list data) [(Constr 1 [])]) in let projection#51 : pair int (list Data) = unConstrData anf#78 in let anf#82 : list Main.Option = case@Pair projection#51 of Pair tag#52 fields#53 -> case@Tag tag#52 of 0 -> mkCons anf#78 (con (list data) []) - 1 -> mkCons anf#79 (con (list data) []) in + 1 -> (con (list data) [(Constr 1 [])]) in let anf#85 : Int = fromInt#69 1 in let anf#84 : list Data = mkCons anf#85 (con (list data) []) in let anf#86 : Main.Option = constrData 0 anf#84 in @@ -130,43 +128,39 @@ let anf#74 : List 'erased = listData anf#87 in equalsData anf#73 anf#74 --- optimized UPLC (program 1.1.0 - [(lam builtin_18 - [(lam partial_19 + [(lam builtin_16 + [(lam partial_17 [(lam fromInt_1 [(lam anf_2 [(lam anf_3 [(lam anf_4 [(lam anf_5 - [(lam anf_6 - [(lam anf_7 - [(lam projection_8 + [(lam projection_6 + [(lam anf_9 + [(lam anf_10 [(lam anf_11 [(lam anf_12 [(lam anf_13 [(lam anf_14 - [(lam anf_15 - [(lam anf_16 - [(lam anf_17 [[(builtin equalsData) anf_16] anf_17]) - [(builtin listData) anf_15]]) - [(builtin listData) anf_11]]) - [[builtin_18 anf_14] (con (list data) [])]]) - [partial_19 anf_13]]) - [[builtin_18 anf_12] (con (list data) [])]]) - [fromInt_1 (con integer 1)]]) - (case - projection_8 - (lam tag_9 - (lam fields_10 - (case - tag_9 - [[builtin_18 anf_4] (con (list data) [])] - [[builtin_18 anf_5] (con (list data) [])]))))]) - [(builtin unConstrData) anf_4]]) - [[builtin_18 anf_4] anf_6]]) - [[builtin_18 anf_5] (con (list data) [])]]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) - [partial_19 anf_3]]) - [[builtin_18 anf_2] (con (list data) [])]]) + [(lam anf_15 [[(builtin equalsData) anf_14] anf_15]) + [(builtin listData) anf_13]]) + [(builtin listData) anf_9]]) + [[builtin_16 anf_12] (con (list data) [])]]) + [partial_17 anf_11]]) + [[builtin_16 anf_10] (con (list data) [])]]) + [fromInt_1 (con integer 1)]]) + (case + projection_6 + (lam tag_7 + (lam fields_8 + (case + tag_7 + [[builtin_16 anf_4] (con (list data) [])] + (con (list data) [(Constr 1 [])])))))]) + [(builtin unConstrData) anf_4]]) + [[builtin_16 anf_4] (con (list data) [(Constr 1 [])])]]) + [partial_17 anf_3]]) + [[builtin_16 anf_2] (con (list data) [])]]) [fromInt_1 (con integer 1)]]) (builtin iData)]) [(builtin constrData) (con integer 0)]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__list_fields_unwrap.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__list_fields_unwrap.snap index cc2df591..702efc5f 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__list_fields_unwrap.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__list_fields_unwrap.snap @@ -99,15 +99,12 @@ let anf#68 : Main.Fields = constrData 0 anf#64 in let anf#69 : list Main.Fields = mkCons anf#68 (con (list data) []) in let match#45 : list Main.Fields = mkCons anf#62 anf#69 in let projection#48 : pair int (list Data) = unConstrData anf#62 in -case@Pair projection#48 of - Pair tag#49 fields#50 -> case@List fields#50 of - Cons ignored#51 fieldTail#52 -> case@List fieldTail#52 of - Cons field#53 fieldTail#54 -> let anf#72 : int = unIData field#53 in - lessThanInteger 0 anf#72 +let anf#72 : int = unIData anf#61 in +lessThanInteger 0 anf#72 --- optimized UPLC (program 1.1.0 - [(lam builtin_24 - [(lam partial_25 + [(lam builtin_18 + [(lam partial_19 [(lam fromBytes_1 [(lam fromInt_2 [(lam anf_3 @@ -123,33 +120,19 @@ case@Pair projection#48 of [(lam anf_14 [(lam match_15 [(lam projection_16 - (case - projection_16 - (lam tag_17 - (lam fields_18 - (case - fields_18 - (lam ignored_19 - (lam fieldTail_20 - (case - fieldTail_20 - (lam field_21 - (lam fieldTail_22 - [(lam anf_23 [[(builtin lessThanInteger) (con integer 0)] anf_23]) - [(builtin unIData) field_21]])) - (error)))) - (error)))))) + [(lam anf_17 [[(builtin lessThanInteger) (con integer 0)] anf_17]) + [(builtin unIData) anf_4]]) [(builtin unConstrData) anf_7]]) - [[builtin_24 anf_7] anf_14]]) - [[builtin_24 anf_13] (con (list data) [])]]) - [partial_25 anf_12]]) - [[builtin_24 anf_8] anf_10]]) - [[builtin_24 anf_9] (con (list data) [])]]) + [[builtin_18 anf_7] anf_14]]) + [[builtin_18 anf_13] (con (list data) [])]]) + [partial_19 anf_12]]) + [[builtin_18 anf_8] anf_10]]) + [[builtin_18 anf_9] (con (list data) [])]]) [fromInt_2 (con integer 0)]]) [fromBytes_1 (con bytestring #aa)]]) - [partial_25 anf_6]]) - [[builtin_24 anf_3] anf_5]]) - [[builtin_24 anf_4] (con (list data) [])]]) + [partial_19 anf_6]]) + [[builtin_18 anf_3] anf_5]]) + [[builtin_18 anf_4] (con (list data) [])]]) [fromInt_2 (con integer 14)]]) [fromBytes_1 (con bytestring #)]]) (builtin iData)]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mixed_boolean_representations_short_circuit.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mixed_boolean_representations_short_circuit.snap index a3578398..e008ee06 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mixed_boolean_representations_short_circuit.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mixed_boolean_representations_short_circuit.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 772 description: "module Main exposing (..)\nimport Primitive exposing (type bool(..))\nimport Bool\nimport Logic\nimport Lift exposing (Lift)\nboth : (Lift bool 'a, Lift bool 'b) => 'a -> 'b -> bool\nboth a b = Logic.and a b\nbad : unit -> Bool.Bool\nbad _ = fail\nmain : bool\nmain =\n if Logic.or Bool.True (bad ()) then\n both Bool.True True\n else False\n" --- --- unoptimized Core @@ -91,9 +90,7 @@ main#1 (lam arg_19 (case arg_19 (error)))]) (lam value_18 value_18)]) --- optimized Core -let anf#66 : nash/base:Bool.Bool = constrData 1 (con (list data) []) in -let projection#52 : pair int (list Data) = unConstrData anf#66 in -let anf#67 : bool = case@Pair projection#52 of +let anf#67 : bool = case@Pair (con (pair integer (list data)) (1, [])) of Pair tag#54 fields#55 -> case@Tag tag#54 of 0 -> false 1 -> true in @@ -106,9 +103,7 @@ let anf#70 : bool = case@Bool anf#67 of 0 -> false 1 -> true in case@Bool anf#70 of - True -> let anf#71 : nash/base:Bool.Bool = constrData 1 (con (list data) []) in - let projection#44 : pair int (list Data) = unConstrData anf#71 in - let anf#65 : bool = case@Pair projection#44 of + True -> let anf#65 : bool = case@Pair (con (pair integer (list data)) (1, [])) of Pair tag#46 fields#47 -> case@Tag tag#46 of 0 -> false 1 -> true in @@ -118,38 +113,28 @@ case@Bool anf#70 of False -> false --- optimized UPLC (program 1.1.0 - [(lam partial_16 - [(lam anf_1 - [(lam projection_2 - [(lam anf_5 - [(lam anf_10 - (case - anf_10 - (con bool False) - [(lam anf_11 - [(lam projection_12 - [(lam anf_15 (case anf_15 (con bool False) (con bool True))) - (case - projection_12 - (lam tag_13 (lam fields_14 (case tag_13 (con bool False) (con bool True)))))]) - [(builtin unConstrData) anf_11]]) - [partial_16 (con (list data) [])]])) - (case - anf_5 - [(lam anf_6 - [(lam projection_7 - (case - projection_7 - (lam tag_8 (lam fields_9 (case tag_8 (con bool False) (con bool True)))))) - [(builtin unConstrData) anf_6]]) - (error)] - (con bool True))]) + [(lam anf_3 + [(lam anf_8 + (case + anf_8 + (con bool False) + [(lam anf_11 (case anf_11 (con bool False) (con bool True))) (case - projection_2 - (lam tag_3 (lam fields_4 (case tag_3 (con bool False) (con bool True)))))]) - [(builtin unConstrData) anf_1]]) - [partial_16 (con (list data) [])]]) - [(builtin constrData) (con integer 1)]]) + (con (pair integer (list data)) (1, [])) + (lam tag_9 (lam fields_10 (case tag_9 (con bool False) (con bool True)))))])) + (case + anf_3 + [(lam anf_4 + [(lam projection_5 + (case + projection_5 + (lam tag_6 (lam fields_7 (case tag_6 (con bool False) (con bool True)))))) + [(builtin unConstrData) anf_4]]) + (error)] + (con bool True))]) + (case + (con (pair integer (list data)) (1, [])) + (lam tag_1 (lam fields_2 (case tag_1 (con bool False) (con bool True)))))]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mutual_dispatch_mixed_arities_and_partial_application.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mutual_dispatch_mixed_arities_and_partial_application.snap index 71286805..2a52d9a9 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mutual_dispatch_mixed_arities_and_partial_application.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mutual_dispatch_mixed_arities_and_partial_application.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 738 description: "module Main exposing (..)\nimport Builtin exposing (..)\nrun captured =\n let\n first n =\n if equalsInteger n 0 then captured\n else\n let next = second (subtractInteger n 1) in\n next captured\n second n value =\n if equalsInteger n 0 then value\n else (\\f -> f (subtractInteger n 1)) first\n in\n first 7\nmain : int\nmain = run 42\n" --- --- unoptimized Core @@ -53,8 +52,7 @@ letrec case@Bool anf#26 of True -> 42 False -> let anf#28 : int = subtractInteger n#18 1 in - let next#19 : 'erased -> 'erased = second#17 anf#28 in - next#19 42 + second#17 anf#28 42 second#17 : int -> 'erased -> 'erased [static []] = \n#20 : int value#21 : 'erased -> let anf#30 : bool = equalsInteger n#20 0 in case@Bool anf#30 of True -> value#21 @@ -64,35 +62,29 @@ in first#16 7 --- optimized UPLC (program 1.1.0 - [(lam dispatch_37 - [(lam first_39 - [(lam second_42 [first_39 (con integer 7)]) - (lam n_40 (lam value_41 [dispatch_37 (constr 1 dispatch_37 n_40 value_41)]))]) - (lam n_38 [dispatch_37 (constr 0 dispatch_37 n_38)])]) + [(lam dispatch_33 [dispatch_33 (constr 0 dispatch_33 (con integer 7))]) (lam request_14 (case request_14 (lam self_15 - (lam n_22 - [(lam anf_23 + (lam n_19 + [(lam anf_22 (case - anf_23 - [(lam anf_24 - [(lam next_29 [next_29 (con integer 42)]) - [(lam n_25 (lam value_27 [self_15 (constr 1 self_15 n_25 value_27)])) anf_24]]) - [[(builtin subtractInteger) n_22] (con integer 1)]] + anf_22 + [(lam anf_23 [self_15 (constr 1 self_15 anf_23 (con integer 42))]) + [[(builtin subtractInteger) n_19] (con integer 1)]] (con integer 42))) - [[(builtin equalsInteger) n_22] (con integer 0)]])) - (lam self_31 - (lam n_33 - (lam value_34 - [(lam anf_35 + [[(builtin equalsInteger) n_19] (con integer 0)]])) + (lam self_24 + (lam n_25 + (lam value_27 + [(lam anf_29 (case - anf_35 - [(lam anf_36 [self_31 (constr 0 self_31 anf_36)]) - [[(builtin subtractInteger) n_33] (con integer 1)]] - value_34)) - [[(builtin equalsInteger) n_33] (con integer 0)]])))))]) + anf_29 + [(lam anf_31 [self_24 (constr 0 self_24 anf_31)]) + [[(builtin subtractInteger) n_25] (con integer 1)]] + value_27)) + [[(builtin equalsInteger) n_25] (con integer 0)]])))))]) --- result (con integer 42) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mutual_dispatch_selected_body_is_lazy.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mutual_dispatch_selected_body_is_lazy.snap index 8eab9578..5fb369ef 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mutual_dispatch_selected_body_is_lazy.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__mutual_dispatch_selected_body_is_lazy.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 760 description: "module Main exposing (..)\nimport Builtin exposing (..)\nfirst n = if equalsInteger n 0 then 42 else second (subtractInteger n 1)\nsecond n = if equalsInteger n 0 then fail else first (subtractInteger n 1)\nmain : int\nmain = first 2\n" --- --- unoptimized Core @@ -57,11 +56,7 @@ in first#10 2 --- optimized UPLC (program 1.1.0 - [(lam dispatch_28 - [(lam first_30 - [(lam second_32 [first_30 (con integer 2)]) - (lam n_31 [dispatch_28 (constr 1 dispatch_28 n_31)])]) - (lam n_29 [dispatch_28 (constr 0 dispatch_28 n_29)])]) + [(lam dispatch_28 [dispatch_28 (constr 0 dispatch_28 (con integer 2))]) (lam request_15 (case request_15 diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__opaque_value_in_test.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__opaque_value_in_test.snap index bd77c7de..bf69c58a 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__opaque_value_in_test.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__opaque_value_in_test.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 579 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nimport Lift exposing (lift, lower)\ntype Pair 'v = Pair Bytes 'v\ntype Dict 'v = Dict { inner : List (Pair 'v) }\ntype Value = Value { inner : Dict (Dict Int) }\ntype Dat = Dat { c : Int, a : Value }\ndat : Dat\ndat =\n let\n innerEntries : list (Pair Int)\n innerEntries = [Pair #\"aa\" 4]\n innerDict : Dict Int\n innerDict = Dict { inner = (lift innerEntries) }\n v = Value { inner = (Dict { inner = (lift [Pair #\"\" innerDict]) }) }\n in\n Dat { c = 0, a = v }\nmain =\n let\n val = dat.a\n entries : list (Pair (Dict Int))\n entries = lower val.inner.inner\n finalEntries : list (Pair Int)\n finalEntries = [Pair #\"AA\" 4]\n finalAmount : Dict Int\n finalAmount = Dict { inner = (lift finalEntries) }\n in\n case entries of\n [Pair _ amount] -> eq finalAmount amount\n _ -> fail\n" --- --- unoptimized Core @@ -204,39 +203,32 @@ let anf#130 : list Data = mkCons v#70 (con (list data) []) in let anf#131 : list Data = mkCons anf#132 anf#130 in let dat#73 : Main.Dat = constrData 0 anf#131 in let projection#74 : pair int (list Data) = unConstrData dat#73 in -case@Pair projection#74 of - Pair tag#75 fields#76 -> case@List fields#76 of - Cons head#77 tail#78 -> case@List tail#78 of - Cons head#79 tail#80 -> let anf#135 : Bytes = fromBytes#10 (con bytestring #aa) in - let anf#137 : Int = fromInt#11 4 in - let anf#133 : list Data = mkCons anf#137 (con (list data) []) in - let anf#134 : list Data = mkCons anf#135 anf#133 in - let anf#138 : Main.Pair Int = constrData 0 anf#134 in - let finalEntries#84 : list (Main.Pair Int) = mkCons anf#138 (con (list data) []) in - let anf#140 : List (Main.Pair Int) = lift#9 finalEntries#84 in - let anf#139 : list Data = mkCons anf#140 (con (list data) []) in - let finalAmount#86 : Main.Dict Int = constrData 0 anf#139 in - let projection#87 : pair int (list Data) = unConstrData head#79 in - case@Pair projection#87 of - Pair tag#88 fields#89 -> case@List fields#89 of - Cons head#90 tail#91 -> let projection#92 : pair int (list Data) = unConstrData head#90 in - case@Pair projection#92 of - Pair tag#93 fields#94 -> case@List fields#94 of - Cons head#95 tail#96 -> let entries#97 : list (Main.Pair (Main.Dict Int)) = unListData head#95 in - let leaf#99 : @delay bool = delay error in - case@List entries#97 of - Nil -> force leaf#99 - Cons field#100 field#101 -> let projection#102 : pair int (list Data) = unConstrData field#100 in - case@Pair projection#102 of - Pair tag#103 fields#104 -> case@List fields#104 of - Cons ignored#105 fieldTail#106 -> case@List fieldTail#106 of - Cons field#107 fieldTail#108 -> case@List field#101 of - Nil -> equalsData finalAmount#86 field#107 - Cons field#110 field#111 -> force leaf#99 +let anf#135 : Bytes = fromBytes#10 (con bytestring #aa) in +let anf#137 : Int = fromInt#11 4 in +let anf#133 : list Data = mkCons anf#137 (con (list data) []) in +let anf#134 : list Data = mkCons anf#135 anf#133 in +let anf#138 : Main.Pair Int = constrData 0 anf#134 in +let finalEntries#84 : list (Main.Pair Int) = mkCons anf#138 (con (list data) []) in +let anf#140 : List (Main.Pair Int) = lift#9 finalEntries#84 in +let anf#139 : list Data = mkCons anf#140 (con (list data) []) in +let finalAmount#86 : Main.Dict Int = constrData 0 anf#139 in +let projection#87 : pair int (list Data) = unConstrData v#70 in +let projection#92 : pair int (list Data) = unConstrData anf#129 in +let entries#97 : list (Main.Pair (Main.Dict Int)) = unListData anf#128 in +let leaf#99 : @delay bool = delay error in +case@List entries#97 of + Nil -> force leaf#99 + Cons field#100 field#101 -> let projection#102 : pair int (list Data) = unConstrData field#100 in + case@Pair projection#102 of + Pair tag#103 fields#104 -> case@List fields#104 of + Cons ignored#105 fieldTail#106 -> case@List fieldTail#106 of + Cons field#107 fieldTail#108 -> case@List field#101 of + Nil -> equalsData finalAmount#86 field#107 + Cons field#110 field#111 -> force leaf#99 --- optimized UPLC (program 1.1.0 - [(lam builtin_72 - [(lam partial_73 + [(lam builtin_57 + [(lam partial_58 [(lam lift_1 [(lam fromBytes_2 [(lam fromInt_3 @@ -264,111 +256,79 @@ case@Pair projection#74 of [(lam anf_30 [(lam dat_31 [(lam projection_32 - (case - projection_32 - (lam tag_33 - (lam fields_34 - (case - fields_34 - (lam head_35 - (lam tail_36 - (case - tail_36 - (lam head_37 - (lam tail_38 - [(lam anf_39 - [(lam anf_40 - [(lam anf_41 - [(lam anf_42 - [(lam anf_43 - [(lam finalEntries_44 - [(lam anf_45 - [(lam anf_46 - [(lam finalAmount_47 - [(lam projection_48 - (case - projection_48 - (lam tag_49 - (lam fields_50 - (case - fields_50 - (lam head_51 - (lam tail_52 - [(lam projection_53 + [(lam anf_33 + [(lam anf_34 + [(lam anf_35 + [(lam anf_36 + [(lam anf_37 + [(lam finalEntries_38 + [(lam anf_39 + [(lam anf_40 + [(lam finalAmount_41 + [(lam projection_42 + [(lam projection_43 + [(lam entries_44 + [(lam leaf_45 + (case + entries_44 + (lam field_46 + (lam field_47 + [(lam projection_48 + (case + projection_48 + (lam tag_49 + (lam fields_50 + (case + fields_50 + (lam ignored_51 + (lam fieldTail_52 + (case + fieldTail_52 + (lam field_53 + (lam fieldTail_54 (case - projection_53 - (lam tag_54 - (lam fields_55 - (case - fields_55 - (lam head_56 - (lam tail_57 - [(lam entries_58 - [(lam leaf_59 - (case - entries_58 - (lam field_60 - (lam field_61 - [(lam projection_62 - (case - projection_62 - (lam tag_63 - (lam fields_64 - (case - fields_64 - (lam ignored_65 - (lam fieldTail_66 - (case - fieldTail_66 - (lam field_67 - (lam fieldTail_68 - (case - field_61 - (lam field_69 (lam field_71 (force leaf_59))) - [[(builtin equalsData) finalAmount_47] field_67]))) - (error)))) - (error)))))) - [(builtin unConstrData) field_60]])) - (force leaf_59))) - (delay (error))]) - [(builtin unListData) head_56]])) - (error)))))) - [(builtin unConstrData) head_51]])) - (error)))))) - [(builtin unConstrData) head_37]]) - [partial_73 anf_46]]) - [[builtin_72 anf_45] (con (list data) [])]]) - [lift_1 finalEntries_44]]) - [[builtin_72 anf_43] (con (list data) [])]]) - [partial_73 anf_42]]) - [[builtin_72 anf_39] anf_41]]) - [[builtin_72 anf_40] (con (list data) [])]]) - [fromInt_3 (con integer 4)]]) - [fromBytes_2 (con bytestring #aa)]])) - (error)))) - (error)))))) + field_47 + (lam field_55 (lam field_56 (force leaf_45))) + [[(builtin equalsData) finalAmount_41] field_53]))) + (error)))) + (error)))))) + [(builtin unConstrData) field_46]])) + (force leaf_45))) + (delay (error))]) + [(builtin unListData) anf_23]]) + [(builtin unConstrData) anf_25]]) + [(builtin unConstrData) v_27]]) + [partial_58 anf_40]]) + [[builtin_57 anf_39] (con (list data) [])]]) + [lift_1 finalEntries_38]]) + [[builtin_57 anf_37] (con (list data) [])]]) + [partial_58 anf_36]]) + [[builtin_57 anf_33] anf_35]]) + [[builtin_57 anf_34] (con (list data) [])]]) + [fromInt_3 (con integer 4)]]) + [fromBytes_2 (con bytestring #aa)]]) [(builtin unConstrData) dat_31]]) - [partial_73 anf_30]]) - [[builtin_72 anf_28] anf_29]]) - [[builtin_72 v_27] (con (list data) [])]]) + [partial_58 anf_30]]) + [[builtin_57 anf_28] anf_29]]) + [[builtin_57 v_27] (con (list data) [])]]) [fromInt_3 (con integer 0)]]) - [partial_73 anf_26]]) - [[builtin_72 anf_25] (con (list data) [])]]) - [partial_73 anf_24]]) - [[builtin_72 anf_23] (con (list data) [])]]) + [partial_58 anf_26]]) + [[builtin_57 anf_25] (con (list data) [])]]) + [partial_58 anf_24]]) + [[builtin_57 anf_23] (con (list data) [])]]) [lift_1 anf_22]]) - [[builtin_72 anf_21] (con (list data) [])]]) - [partial_73 anf_20]]) - [[builtin_72 anf_18] anf_19]]) - [[builtin_72 innerDict_17] (con (list data) [])]]) + [[builtin_57 anf_21] (con (list data) [])]]) + [partial_58 anf_20]]) + [[builtin_57 anf_18] anf_19]]) + [[builtin_57 innerDict_17] (con (list data) [])]]) [fromBytes_2 (con bytestring #)]]) - [partial_73 anf_15]]) - [[builtin_72 anf_13] (con (list data) [])]]) + [partial_58 anf_15]]) + [[builtin_57 anf_13] (con (list data) [])]]) [lift_1 innerEntries_12]]) - [[builtin_72 anf_8] (con (list data) [])]]) - [partial_73 anf_7]]) - [[builtin_72 anf_4] anf_6]]) - [[builtin_72 anf_5] (con (list data) [])]]) + [[builtin_57 anf_8] (con (list data) [])]]) + [partial_58 anf_7]]) + [[builtin_57 anf_4] anf_6]]) + [[builtin_57 anf_5] (con (list data) [])]]) [fromInt_3 (con integer 4)]]) [fromBytes_2 (con bytestring #aa)]]) (builtin iData)]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__partial_big_boolean_application_is_strict.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__partial_big_boolean_application_is_strict.snap index c67c21c9..d52afa11 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__partial_big_boolean_application_is_strict.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__partial_big_boolean_application_is_strict.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 792 description: "module Main exposing (..)\nimport Primitive exposing (type bool(..))\nimport Bool\nimport Logic\nbad : unit -> Bool.Bool\nbad _ = fail\nmain : bool\nmain =\n let\n partial : Bool.Bool -> bool\n partial = Logic.or Bool.True\n in\n partial (bad ())\n" --- --- unoptimized Core @@ -45,9 +44,8 @@ case@Pair projection#24 of Pair tag#25 fields#26 -> case@Tag tag#25 of 0 -> false 1 -> true in -let anf#34 : nash/base:Bool.Bool = constrData 1 (con (list data) []) in let anf#36 : nash/base:Bool.Bool = error in -let anf#33 : bool = lower#27 anf#34 in +let anf#33 : bool = lower#27 (con data (Constr 1 [])) in case@Bool anf#33 of True -> true False -> lower#27 anf#36 @@ -55,10 +53,9 @@ case@Bool anf#33 of (program 1.1.0 [(lam lower_5 [(lam anf_6 - [(lam anf_7 - [(lam anf_8 (case anf_8 [lower_5 anf_7] (con bool True))) [lower_5 anf_6]]) - (error)]) - [[(builtin constrData) (con integer 1)] (con (list data) [])]]) + [(lam anf_7 (case anf_7 [lower_5 anf_6] (con bool True))) + [lower_5 (con data (Constr 1 []))]]) + (error)]) (lam value_1 [(lam projection_2 (case diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__pass_constr_as_function.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__pass_constr_as_function.snap index 4118536b..dfa72d93 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__pass_constr_as_function.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__pass_constr_as_function.snap @@ -84,18 +84,9 @@ main#1 arg_29]))]) (lam value_28 value_28)]) --- optimized Core -let anf#73 : bool = equalsInteger 3 3 in -case@Bool anf#73 of - True -> equalsInteger 1 1 - False -> false +true --- optimized UPLC -(program 1.1.0 - [(lam anf_1 - (case - anf_1 - (con bool False) - [[(builtin equalsInteger) (con integer 1)] (con integer 1)])) - [[(builtin equalsInteger) (con integer 3)] (con integer 3)]]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_1_val.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_1_val.snap index 98732043..28954890 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_1_val.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_1_val.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 399 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nimport Lift exposing (lift)\nimport Data exposing (toData)\ntype MyDatum = MyDatum { a : Int }\nencodeMyDatum (MyDatum n) = Builtin.constrData 0 [toData n]\ntype Address = Address { thing : Bytes }\ntype Datum = NoDatum | InlineDatum Data\ntype Option 'a = None | Some 'a\ntype alias Output =\n { address : Address\n , value : Map Bytes (Map Bytes Int)\n , datum : Datum\n , scriptRef : Option Bytes\n }\nmain =\n let\n emptyPairs : map Bytes (Map Bytes Int)\n emptyPairs = []\n prevOutput : Output\n prevOutput =\n { address = (Address { thing = #\"7363726970745f686173685f30\" })\n , value = (lift emptyPairs)\n , datum = (InlineDatum (encodeMyDatum (MyDatum 3)))\n , scriptRef = None\n }\n nextOutput = { prevOutput | datum = prevOutput.datum }\n in\n eq prevOutput nextOutput\n" --- --- unoptimized Core @@ -112,15 +111,11 @@ let anf#72 : Int = iData 3 in let anf#71 : list Data = mkCons anf#72 (con (list data) []) in let anf#73 : Main.MyDatum = constrData 0 anf#71 in let projection#40 : pair int (list Data) = unConstrData anf#73 in -let anf#74 : Data = case@Pair projection#40 of - Pair tag#41 fields#42 -> case@List fields#42 of - Cons field#43 fieldTail#44 -> let anf#65 : list Data = mkCons field#43 (con (list data) []) in - constrData 0 anf#65 in +let anf#65 : list Data = mkCons anf#72 (con (list data) []) in +let anf#74 : Data = constrData 0 anf#65 in let anf#70 : list Data = mkCons anf#74 (con (list data) []) in let anf#75 : Main.Datum = constrData 1 anf#70 in -let anf#76 : Main.Option Bytes = constrData 0 (con (list data) []) in -let anf#77 : list Data = mkCons anf#76 (con (list data) []) in -let anf#78 : list Data = mkCons anf#75 anf#77 in +let anf#78 : list Data = mkCons anf#75 (con (list data) [(Constr 0 [])]) in let anf#79 : list Data = mkCons anf#69 anf#78 in let anf#80 : list Data = mkCons anf#68 anf#79 in let prevOutput#52 : { _0 : Main.Address, _1 : Map Bytes (Map Bytes Int), _2 : Main.Datum, _3 : Main.Option Bytes } = listData anf#80 in @@ -135,8 +130,8 @@ case@List projection#54 of equalsData prevOutput#52 nextOutput#61 --- optimized UPLC (program 1.1.0 - [(lam builtin_34 - [(lam partial_35 + [(lam builtin_28 + [(lam partial_29 [(lam anf_1 [(lam anf_2 [(lam anf_3 @@ -145,65 +140,54 @@ case@List projection#54 of [(lam anf_6 [(lam anf_7 [(lam projection_8 - [(lam anf_14 - [(lam anf_15 - [(lam anf_16 - [(lam anf_17 - [(lam anf_18 - [(lam anf_19 - [(lam anf_20 - [(lam anf_21 - [(lam prevOutput_22 - [(lam projection_23 - (case - projection_23 - (lam head_24 - (lam tail_25 - (case - tail_25 - (lam head_26 - (lam tail_27 - (case - tail_27 - (lam head_28 - (lam tail_29 - [(lam anf_30 - [(lam anf_31 - [(lam anf_32 - [(lam nextOutput_33 [[(builtin equalsData) prevOutput_22] nextOutput_33]) - [(builtin listData) anf_32]]) - [[builtin_34 head_24] anf_31]]) - [[builtin_34 head_26] anf_30]]) - [[builtin_34 head_28] tail_29]])) - (error)))) - (error)))) - (error))) - [(builtin unListData) prevOutput_22]]) - [(builtin listData) anf_21]]) - [[builtin_34 anf_3] anf_20]]) - [[builtin_34 anf_4] anf_19]]) - [[builtin_34 anf_16] anf_18]]) - [[builtin_34 anf_17] (con (list data) [])]]) - [partial_35 (con (list data) [])]]) - [[(builtin constrData) (con integer 1)] anf_15]]) - [[builtin_34 anf_14] (con (list data) [])]]) - (case - projection_8 - (lam tag_9 - (lam fields_10 - (case - fields_10 - (lam field_11 - (lam fieldTail_12 - [(lam anf_13 [partial_35 anf_13]) [[builtin_34 field_11] (con (list data) [])]])) - (error)))))]) + [(lam anf_9 + [(lam anf_10 + [(lam anf_11 + [(lam anf_12 + [(lam anf_13 + [(lam anf_14 + [(lam anf_15 + [(lam prevOutput_16 + [(lam projection_17 + (case + projection_17 + (lam head_18 + (lam tail_19 + (case + tail_19 + (lam head_20 + (lam tail_21 + (case + tail_21 + (lam head_22 + (lam tail_23 + [(lam anf_24 + [(lam anf_25 + [(lam anf_26 + [(lam nextOutput_27 [[(builtin equalsData) prevOutput_16] nextOutput_27]) + [(builtin listData) anf_26]]) + [[builtin_28 head_18] anf_25]]) + [[builtin_28 head_20] anf_24]]) + [[builtin_28 head_22] tail_23]])) + (error)))) + (error)))) + (error))) + [(builtin unListData) prevOutput_16]]) + [(builtin listData) anf_15]]) + [[builtin_28 anf_3] anf_14]]) + [[builtin_28 anf_4] anf_13]]) + [[builtin_28 anf_12] (con (list data) [(Constr 0 [])])]]) + [[(builtin constrData) (con integer 1)] anf_11]]) + [[builtin_28 anf_10] (con (list data) [])]]) + [partial_29 anf_9]]) + [[builtin_28 anf_5] (con (list data) [])]]) [(builtin unConstrData) anf_7]]) - [partial_35 anf_6]]) - [[builtin_34 anf_5] (con (list data) [])]]) + [partial_29 anf_6]]) + [[builtin_28 anf_5] (con (list data) [])]]) [(builtin iData) (con integer 3)]]) [(builtin mapData) (con (list (pair data data)) [])]]) - [partial_35 anf_2]]) - [[builtin_34 anf_1] (con (list data) [])]]) + [partial_29 anf_2]]) + [[builtin_28 anf_1] (con (list data) [])]]) [(builtin bData) (con bytestring #7363726970745f686173685f30)]]) [(builtin constrData) (con integer 0)]]) (force (builtin mkCons))]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_2_vals.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_2_vals.snap index 1cfae7e3..09fbd6c5 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_2_vals.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_2_vals.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 362 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nimport Lift exposing (lift)\nimport Data exposing (toData)\ntype MyDatum = MyDatum { a : Int }\nencodeMyDatum (MyDatum n) = Builtin.constrData 0 [toData n]\ntype Address = Address { thing : Bytes }\ntype Datum = NoDatum | InlineDatum Data\ntype Option 'a = None | Some 'a\ntype alias Output =\n { address : Address\n , value : Map Bytes (Map Bytes Int)\n , datum : Datum\n , scriptRef : Option Bytes\n }\nmain =\n let\n emptyPairs : map Bytes (Map Bytes Int)\n emptyPairs = []\n prevOutput : Output\n prevOutput =\n { address = (Address { thing = #\"7363726970745f686173685f30\" })\n , value = (lift emptyPairs)\n , datum = (InlineDatum (encodeMyDatum (MyDatum 3)))\n , scriptRef = None\n }\n nextOutput = { prevOutput | value = (lift emptyPairs), datum = prevOutput.datum }\n in\n eq prevOutput nextOutput\n" --- --- unoptimized Core @@ -117,15 +116,11 @@ let anf#74 : Int = iData 3 in let anf#73 : list Data = mkCons anf#74 (con (list data) []) in let anf#75 : Main.MyDatum = constrData 0 anf#73 in let projection#41 : pair int (list Data) = unConstrData anf#75 in -let anf#76 : Data = case@Pair projection#41 of - Pair tag#42 fields#43 -> case@List fields#43 of - Cons field#44 fieldTail#45 -> let anf#67 : list Data = mkCons field#44 (con (list data) []) in - constrData 0 anf#67 in +let anf#67 : list Data = mkCons anf#74 (con (list data) []) in +let anf#76 : Data = constrData 0 anf#67 in let anf#72 : list Data = mkCons anf#76 (con (list data) []) in let anf#77 : Main.Datum = constrData 1 anf#72 in -let anf#78 : Main.Option Bytes = constrData 0 (con (list data) []) in -let anf#79 : list Data = mkCons anf#78 (con (list data) []) in -let anf#80 : list Data = mkCons anf#77 anf#79 in +let anf#80 : list Data = mkCons anf#77 (con (list data) [(Constr 0 [])]) in let anf#81 : list Data = mkCons anf#71 anf#80 in let anf#82 : list Data = mkCons anf#70 anf#81 in let prevOutput#53 : { _0 : Main.Address, _1 : Map Bytes (Map Bytes Int), _2 : Main.Datum, _3 : Main.Option Bytes } = listData anf#82 in @@ -141,8 +136,8 @@ case@List projection#55 of equalsData prevOutput#53 nextOutput#63 --- optimized UPLC (program 1.1.0 - [(lam builtin_38 - [(lam partial_39 + [(lam builtin_31 + [(lam partial_32 [(lam lift_1 [(lam emptyPairs_2 [(lam anf_3 @@ -153,67 +148,56 @@ case@List projection#55 of [(lam anf_8 [(lam anf_9 [(lam projection_10 - [(lam anf_16 - [(lam anf_17 - [(lam anf_18 - [(lam anf_19 - [(lam anf_20 - [(lam anf_21 - [(lam anf_22 - [(lam anf_23 - [(lam prevOutput_24 - [(lam projection_25 - (case - projection_25 - (lam head_26 - (lam tail_27 - [(lam evaluated_28 - (case - tail_27 - (lam head_29 - (lam tail_30 - (case - tail_30 - (lam head_31 - (lam tail_32 - [(lam anf_34 - [(lam anf_35 - [(lam anf_36 - [(lam nextOutput_37 [[(builtin equalsData) prevOutput_24] nextOutput_37]) - [(builtin listData) anf_36]]) - [[builtin_38 head_26] anf_35]]) - [[builtin_38 evaluated_28] anf_34]]) - [[builtin_38 head_31] tail_32]])) - (error)))) - (error))) - [lift_1 emptyPairs_2]])) - (error))) - [(builtin unListData) prevOutput_24]]) - [(builtin listData) anf_23]]) - [[builtin_38 anf_5] anf_22]]) - [[builtin_38 anf_6] anf_21]]) - [[builtin_38 anf_18] anf_20]]) - [[builtin_38 anf_19] (con (list data) [])]]) - [partial_39 (con (list data) [])]]) - [[(builtin constrData) (con integer 1)] anf_17]]) - [[builtin_38 anf_16] (con (list data) [])]]) - (case - projection_10 - (lam tag_11 - (lam fields_12 - (case - fields_12 - (lam field_13 - (lam fieldTail_14 - [(lam anf_15 [partial_39 anf_15]) [[builtin_38 field_13] (con (list data) [])]])) - (error)))))]) + [(lam anf_11 + [(lam anf_12 + [(lam anf_13 + [(lam anf_14 + [(lam anf_15 + [(lam anf_16 + [(lam anf_17 + [(lam prevOutput_18 + [(lam projection_19 + (case + projection_19 + (lam head_20 + (lam tail_21 + [(lam evaluated_22 + (case + tail_21 + (lam head_23 + (lam tail_24 + (case + tail_24 + (lam head_25 + (lam tail_26 + [(lam anf_27 + [(lam anf_28 + [(lam anf_29 + [(lam nextOutput_30 [[(builtin equalsData) prevOutput_18] nextOutput_30]) + [(builtin listData) anf_29]]) + [[builtin_31 head_20] anf_28]]) + [[builtin_31 evaluated_22] anf_27]]) + [[builtin_31 head_25] tail_26]])) + (error)))) + (error))) + [lift_1 emptyPairs_2]])) + (error))) + [(builtin unListData) prevOutput_18]]) + [(builtin listData) anf_17]]) + [[builtin_31 anf_5] anf_16]]) + [[builtin_31 anf_6] anf_15]]) + [[builtin_31 anf_14] (con (list data) [(Constr 0 [])])]]) + [[(builtin constrData) (con integer 1)] anf_13]]) + [[builtin_31 anf_12] (con (list data) [])]]) + [partial_32 anf_11]]) + [[builtin_31 anf_7] (con (list data) [])]]) [(builtin unConstrData) anf_9]]) - [partial_39 anf_8]]) - [[builtin_38 anf_7] (con (list data) [])]]) + [partial_32 anf_8]]) + [[builtin_31 anf_7] (con (list data) [])]]) [(builtin iData) (con integer 3)]]) [lift_1 emptyPairs_2]]) - [partial_39 anf_4]]) - [[builtin_38 anf_3] (con (list data) [])]]) + [partial_32 anf_4]]) + [[builtin_31 anf_3] (con (list data) [])]]) [(builtin bData) (con bytestring #7363726970745f686173685f30)]]) (con (list (pair data data)) [])]) (builtin mapData)]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_first_last_val.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_first_last_val.snap index bd1ab8a9..ad2b1567 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_first_last_val.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__record_update_output_first_last_val.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 436 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (..)\nimport Lift exposing (lift)\nimport Data exposing (toData)\ntype MyDatum = MyDatum { a : Int }\nencodeMyDatum (MyDatum n) = Builtin.constrData 0 [toData n]\ntype Address = Address { thing : Bytes }\ntype Datum = NoDatum | InlineDatum Data\ntype Option 'a = None | Some 'a\ntype alias Output =\n { address : Address\n , value : Map Bytes (Map Bytes Int)\n , datum : Datum\n , scriptRef : Option Bytes\n }\nmain =\n let\n emptyPairs : map Bytes (Map Bytes Int)\n emptyPairs = []\n prevOutput : Output\n prevOutput =\n { address = (Address { thing = #\"7363726970745f686173685f30\" })\n , value = (lift emptyPairs)\n , datum = (InlineDatum (encodeMyDatum (MyDatum 3)))\n , scriptRef = None\n }\n nextOutput = { prevOutput | scriptRef = None, address = (Address { thing = #\"7363726970745f686173685f30\" }) }\n in\n eq prevOutput nextOutput\n" --- --- unoptimized Core @@ -122,15 +121,11 @@ let anf#76 : Int = iData 3 in let anf#75 : list Data = mkCons anf#76 (con (list data) []) in let anf#77 : Main.MyDatum = constrData 0 anf#75 in let projection#42 : pair int (list Data) = unConstrData anf#77 in -let anf#78 : Data = case@Pair projection#42 of - Pair tag#43 fields#44 -> case@List fields#44 of - Cons field#45 fieldTail#46 -> let anf#69 : list Data = mkCons field#45 (con (list data) []) in - constrData 0 anf#69 in +let anf#69 : list Data = mkCons anf#76 (con (list data) []) in +let anf#78 : Data = constrData 0 anf#69 in let anf#74 : list Data = mkCons anf#78 (con (list data) []) in let anf#79 : Main.Datum = constrData 1 anf#74 in -let anf#80 : Main.Option Bytes = constrData 0 (con (list data) []) in -let anf#81 : list Data = mkCons anf#80 (con (list data) []) in -let anf#82 : list Data = mkCons anf#79 anf#81 in +let anf#82 : list Data = mkCons anf#79 (con (list data) [(Constr 0 [])]) in let anf#83 : list Data = mkCons anf#73 anf#82 in let anf#84 : list Data = mkCons anf#72 anf#83 in let prevOutput#54 : { _0 : Main.Address, _1 : Map Bytes (Map Bytes Int), _2 : Main.Datum, _3 : Main.Option Bytes } = listData anf#84 in @@ -141,17 +136,15 @@ let projection#58 : list Data = unListData prevOutput#54 in case@List projection#58 of Cons head#59 tail#60 -> case@List tail#60 of Cons head#61 tail#62 -> case@List tail#62 of - Cons head#63 tail#64 -> let anf#87 : Main.Option Bytes = constrData 0 (con (list data) []) in - let anf#88 : list Data = mkCons anf#87 (con (list data) []) in - let anf#89 : list Data = mkCons head#63 anf#88 in + Cons head#63 tail#64 -> let anf#89 : list Data = mkCons head#63 (con (list data) [(Constr 0 [])]) in let anf#90 : list Data = mkCons head#61 anf#89 in let anf#91 : list Data = mkCons evaluated#57 anf#90 in let nextOutput#65 : { _0 : Main.Address, _1 : Map Bytes (Map Bytes Int), _2 : Main.Datum, _3 : Main.Option Bytes } = listData anf#91 in equalsData prevOutput#54 nextOutput#65 --- optimized UPLC (program 1.1.0 - [(lam builtin_41 - [(lam partial_42 + [(lam builtin_32 + [(lam partial_33 [(lam fromBytes_1 [(lam anf_2 [(lam anf_3 @@ -161,75 +154,60 @@ case@List projection#58 of [(lam anf_7 [(lam anf_8 [(lam projection_9 - [(lam anf_15 - [(lam anf_16 - [(lam anf_17 - [(lam anf_18 - [(lam anf_19 - [(lam anf_20 - [(lam anf_21 - [(lam anf_22 - [(lam prevOutput_23 - [(lam anf_24 - [(lam anf_25 - [(lam evaluated_26 - [(lam projection_27 - (case - projection_27 - (lam head_28 - (lam tail_29 - (case - tail_29 - (lam head_30 - (lam tail_31 - (case - tail_31 - (lam head_32 - (lam tail_33 - [(lam anf_35 - [(lam anf_36 - [(lam anf_37 - [(lam anf_38 - [(lam anf_39 - [(lam nextOutput_40 [[(builtin equalsData) prevOutput_23] nextOutput_40]) - [(builtin listData) anf_39]]) - [[builtin_41 evaluated_26] anf_38]]) - [[builtin_41 head_30] anf_37]]) - [[builtin_41 head_32] anf_36]]) - [[builtin_41 anf_35] (con (list data) [])]]) - [partial_42 (con (list data) [])]])) - (error)))) - (error)))) - (error))) - [(builtin unListData) prevOutput_23]]) - [partial_42 anf_25]]) - [[builtin_41 anf_24] (con (list data) [])]]) - [fromBytes_1 (con bytestring #7363726970745f686173685f30)]]) - [(builtin listData) anf_22]]) - [[builtin_41 anf_4] anf_21]]) - [[builtin_41 anf_5] anf_20]]) - [[builtin_41 anf_17] anf_19]]) - [[builtin_41 anf_18] (con (list data) [])]]) - [partial_42 (con (list data) [])]]) - [[(builtin constrData) (con integer 1)] anf_16]]) - [[builtin_41 anf_15] (con (list data) [])]]) - (case - projection_9 - (lam tag_10 - (lam fields_11 - (case - fields_11 - (lam field_12 - (lam fieldTail_13 - [(lam anf_14 [partial_42 anf_14]) [[builtin_41 field_12] (con (list data) [])]])) - (error)))))]) + [(lam anf_10 + [(lam anf_11 + [(lam anf_12 + [(lam anf_13 + [(lam anf_14 + [(lam anf_15 + [(lam anf_16 + [(lam prevOutput_17 + [(lam anf_18 + [(lam anf_19 + [(lam evaluated_20 + [(lam projection_21 + (case + projection_21 + (lam head_22 + (lam tail_23 + (case + tail_23 + (lam head_24 + (lam tail_25 + (case + tail_25 + (lam head_26 + (lam tail_27 + [(lam anf_28 + [(lam anf_29 + [(lam anf_30 + [(lam nextOutput_31 [[(builtin equalsData) prevOutput_17] nextOutput_31]) + [(builtin listData) anf_30]]) + [[builtin_32 evaluated_20] anf_29]]) + [[builtin_32 head_24] anf_28]]) + [[builtin_32 head_26] (con (list data) [(Constr 0 [])])]])) + (error)))) + (error)))) + (error))) + [(builtin unListData) prevOutput_17]]) + [partial_33 anf_19]]) + [[builtin_32 anf_18] (con (list data) [])]]) + [fromBytes_1 (con bytestring #7363726970745f686173685f30)]]) + [(builtin listData) anf_16]]) + [[builtin_32 anf_4] anf_15]]) + [[builtin_32 anf_5] anf_14]]) + [[builtin_32 anf_13] (con (list data) [(Constr 0 [])])]]) + [[(builtin constrData) (con integer 1)] anf_12]]) + [[builtin_32 anf_11] (con (list data) [])]]) + [partial_33 anf_10]]) + [[builtin_32 anf_6] (con (list data) [])]]) [(builtin unConstrData) anf_8]]) - [partial_42 anf_7]]) - [[builtin_41 anf_6] (con (list data) [])]]) + [partial_33 anf_7]]) + [[builtin_32 anf_6] (con (list data) [])]]) [(builtin iData) (con integer 3)]]) [(builtin mapData) (con (list (pair data data)) [])]]) - [partial_42 anf_3]]) - [[builtin_41 anf_2] (con (list data) [])]]) + [partial_33 anf_3]]) + [[builtin_32 anf_2] (con (list data) [])]]) [fromBytes_1 (con bytestring #7363726970745f686173685f30)]]) (builtin bData)]) [(builtin constrData) (con integer 0)]]) diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__test_init_3.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__test_init_3.snap index 8bb354ee..f806defe 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__test_init_3.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__test_init_3.snap @@ -183,74 +183,49 @@ letrec Cons field#94 field#95 -> let anf#111 : list int = doInit#89 field#93 in mkCons field#92 anf#111 in -let anf#117 : list int = mkCons 4 (con (list integer) []) in -let anf#118 : list int = mkCons 3 anf#117 in -let anf#119 : list int = mkCons 2 anf#118 in -let values#106 : list int = mkCons 1 anf#119 in -let anf#112 : list int = doInit#89 values#106 in -let anf#125 : list int = mkCons 3 (con (list integer) []) in -let anf#126 : list int = mkCons 2 anf#125 in -let anf#127 : list int = mkCons 1 anf#126 in -eq#18 anf#112 anf#127 +let anf#112 : list int = doInit#89 (con (list integer) [1, 2, 3, 4]) in +eq#18 anf#112 (con (list integer) [1, 2, 3]) --- optimized UPLC (program 1.1.0 - [(lam builtin_36 - [(lam builtin_37 - [(lam partial_38 - [(lam partial_39 - [(lam partial_40 - [(lam eq_17 - [(lam doInit_27 - [(lam anf_28 - [(lam anf_29 - [(lam anf_30 - [(lam values_31 - [(lam anf_32 - [(lam anf_33 - [(lam anf_34 [(lam anf_35 [[eq_17 anf_32] anf_35]) [partial_38 anf_34]]) - [partial_39 anf_33]]) - [partial_40 (con (list integer) [])]]) - [doInit_27 values_31]]) - [partial_38 anf_30]]) - [partial_39 anf_29]]) - [partial_40 anf_28]]) - [[builtin_36 (con integer 4)] (con (list integer) [])]]) - [(lam self_19 [self_19 self_19]) - (lam self_20 - (lam self_21 + [(lam builtin_29 + [(lam builtin_30 + [(lam eq_17 + [(lam doInit_27 + [(lam anf_28 [[eq_17 anf_28] (con (list integer) [1, 2, 3])]) + [doInit_27 (con (list integer) [1, 2, 3, 4])]]) + [(lam self_19 [self_19 self_19]) + (lam self_20 + (lam self_21 + (case + self_21 + (lam field_22 + (lam field_23 (case - self_21 - (lam field_22 - (lam field_23 - (case - field_23 - (lam field_24 - (lam field_25 - [(lam anf_26 [[builtin_36 field_22] anf_26]) [[self_20 self_20] field_23]])) - (con (list integer) [])))) - (force [[builtin_37 (con string "unreachable")] (delay (error))]))))]]) - [(lam self_6 [self_6 self_6]) - (lam self_7 - (lam xs_8 - (lam ys_9 + field_23 + (lam field_24 + (lam field_25 + [(lam anf_26 [[builtin_30 field_22] anf_26]) [[self_20 self_20] field_23]])) + (con (list integer) [])))) + (force [[builtin_29 (con string "unreachable")] (delay (error))]))))]]) + [(lam self_6 [self_6 self_6]) + (lam self_7 + (lam xs_8 + (lam ys_9 + (case + xs_8 + (lam field_12 + (lam field_13 (case - xs_8 - (lam field_12 - (lam field_13 - (case - ys_9 - (lam field_14 - (lam field_15 - [(lam anf_16 - (case anf_16 (con bool False) [[[self_7 self_7] field_13] field_15])) - [[(builtin equalsInteger) field_12] field_14]])) - (con bool False)))) - (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) - [builtin_36 (con integer 3)]]) - [builtin_36 (con integer 2)]]) - [builtin_36 (con integer 1)]]) - (force (builtin trace))]) - (force (builtin mkCons))]) + ys_9 + (lam field_14 + (lam field_15 + [(lam anf_16 + (case anf_16 (con bool False) (case (constr 0 self_7 field_13 field_15) self_7))) + [[(builtin equalsInteger) field_12] field_14]])) + (con bool False)))) + (case ys_9 (lam field_10 (lam field_11 (con bool False))) (con bool True))))))]]) + (force (builtin mkCons))]) + (force (builtin trace))]) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_bytes_preserves_original_data.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_bytes_preserves_original_data.snap index 48b2a49e..9eb35982 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_bytes_preserves_original_data.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_bytes_preserves_original_data.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 1044 description: "module Main exposing (..)\nimport Data exposing (ToData, Validate)\nmain : Bytes\nmain = validate (toData (Builtin.bData #\"ff\"))\n" --- --- unoptimized Core @@ -24,13 +23,9 @@ main#1 [(lam candidate_6 [(lam destruct_7 candidate_6) [(builtin unBData) candidate_6]]) [(lam coerce_8 coerce_8) value_5]])]) --- optimized Core -let anf#22 : Bytes = bData (con bytestring #ff) in -let destruct#14 : bytes = unBData anf#22 in -anf#22 +(con data (B #ff)) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(lam destruct_2 anf_1) [(builtin unBData) anf_1]]) - [(builtin bData) (con bytestring #ff)]]) +(program 1.1.0 (con data (B #ff))) --- result (con data (B #ff)) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_bytes_rejects_integer.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_bytes_rejects_integer.snap index 9ceb4752..d123e828 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_bytes_rejects_integer.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_bytes_rejects_integer.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 1021 description: "module Main exposing (..)\nimport Data exposing (ToData, Validate)\nmain : Bytes\nmain = validate (toData (Builtin.iData 42))\n" --- --- unoptimized Core @@ -24,13 +23,13 @@ main#1 [(lam candidate_6 [(lam destruct_7 candidate_6) [(builtin unBData) candidate_6]]) [(lam coerce_8 coerce_8) value_5]])]) --- optimized Core -let anf#22 : Int = iData 42 in +let anf#22 : Int = (con data (I 42)) in let destruct#14 : bytes = unBData anf#22 in anf#22 --- optimized UPLC (program 1.1.0 [(lam anf_1 [(lam destruct_2 anf_1) [(builtin unBData) anf_1]]) - [(builtin iData) (con integer 42)]]) + (con data (I 42))]) --- result error: Runtime(MalFormedData(Integer(42))) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_int_preserves_original_data.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_int_preserves_original_data.snap index 926c9dd5..b38ea237 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_int_preserves_original_data.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_int_preserves_original_data.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 1001 description: "module Main exposing (..)\nimport Data exposing (ToData, Validate)\nmain : Int\nmain = validate (toData (Builtin.iData 42))\n" --- --- unoptimized Core @@ -24,13 +23,9 @@ main#1 [(lam candidate_6 [(lam destruct_7 candidate_6) [(builtin unIData) candidate_6]]) [(lam coerce_8 coerce_8) value_5]])]) --- optimized Core -let anf#22 : Int = iData 42 in -let destruct#14 : int = unIData anf#22 in -anf#22 +(con data (I 42)) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(lam destruct_2 anf_1) [(builtin unIData) anf_1]]) - [(builtin iData) (con integer 42)]]) +(program 1.1.0 (con data (I 42))) --- result (con data (I 42)) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_int_rejects_bytes.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_int_rejects_bytes.snap index cbad6c62..7aaaffce 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_int_rejects_bytes.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_int_rejects_bytes.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 1011 description: "module Main exposing (..)\nimport Data exposing (ToData, Validate)\nmain : Int\nmain = validate (toData (Builtin.bData #\"ff\"))\n" --- --- unoptimized Core @@ -24,13 +23,13 @@ main#1 [(lam candidate_6 [(lam destruct_7 candidate_6) [(builtin unIData) candidate_6]]) [(lam coerce_8 coerce_8) value_5]])]) --- optimized Core -let anf#22 : Bytes = bData (con bytestring #ff) in +let anf#22 : Bytes = (con data (B #ff)) in let destruct#14 : int = unIData anf#22 in anf#22 --- optimized UPLC (program 1.1.0 [(lam anf_1 [(lam destruct_2 anf_1) [(builtin unIData) anf_1]]) - [(builtin bData) (con bytestring #ff)]]) + (con data (B #ff))]) --- result error: Runtime(MalFormedData(ByteString([255]))) --- logs diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_list_rejects_wrong_element.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_list_rejects_wrong_element.snap index 9ac326b3..d9c82f31 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_list_rejects_wrong_element.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_list_rejects_wrong_element.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 1054 description: "module Main exposing (..)\nimport Data exposing (ToData, Validate)\nmain : List Int\nmain = validate (toData (Builtin.listData [Builtin.bData #\"ff\"]))\n" --- --- unoptimized Core @@ -70,10 +69,7 @@ main#1 (lam x_13 (lam f_14 [f_14 x_13]))]) --- optimized Core let applyForward#28 : 'erased -> ('erased -> 'erased) -> 'erased = \x#26 : 'erased (f#27 : 'erased -> 'erased) -> f#27 x#26 in -let anf#60 : Bytes = bData (con bytestring #ff) in -let anf#61 : list Bytes = mkCons anf#60 (con (list data) []) in -let anf#62 : List Bytes = listData anf#61 in -let anf#55 : list Data = applyForward#28 anf#62 unListData in +let anf#55 : list Data = applyForward#28 (con data (List [B #ff])) unListData in let anf#56 : (list Data -> list Data) -> list Data = applyForward#28 anf#55 in let anf#58 : list Data = anf#56 (\values#31 : list 'erased -> letrec worker#52 : list 'erased -> list Data [static []] = \values#51 : list 'erased -> case@List values#51 of @@ -86,33 +82,27 @@ worker#52 values#31) in applyForward#28 anf#58 listData --- optimized UPLC (program 1.1.0 - [(lam builtin_21 + [(lam builtin_18 [(lam applyForward_5 [(lam anf_6 [(lam anf_7 - [(lam anf_8 - [(lam anf_9 - [(lam anf_10 - [(lam anf_20 [[applyForward_5 anf_20] (builtin listData)]) - [anf_10 - (lam values_11 - [(lam worker_19 [worker_19 values_11]) - [(lam self_12 [self_12 self_12]) - (lam self_13 - (lam values_14 - (case - values_14 - (lam field_15 - (lam field_16 - [(lam destruct_17 - [(lam anf_18 [[builtin_21 field_15] anf_18]) [[self_13 self_13] field_16]]) - [(builtin unIData) field_15]])) - (con (list data) []))))]])]]) - [applyForward_5 anf_9]]) - [[applyForward_5 anf_8] (builtin unListData)]]) - [(builtin listData) anf_7]]) - [[builtin_21 anf_6] (con (list data) [])]]) - [(builtin bData) (con bytestring #ff)]]) + [(lam anf_17 [[applyForward_5 anf_17] (builtin listData)]) + [anf_7 + (lam values_8 + [(lam worker_16 [worker_16 values_8]) + [(lam self_9 [self_9 self_9]) + (lam self_10 + (lam values_11 + (case + values_11 + (lam field_12 + (lam field_13 + [(lam destruct_14 + [(lam anf_15 [[builtin_18 field_12] anf_15]) [[self_10 self_10] field_13]]) + [(builtin unIData) field_12]])) + (con (list data) []))))]])]]) + [applyForward_5 anf_6]]) + [[applyForward_5 (con data (List [B #ff]))] (builtin unListData)]]) (lam x_3 (lam f_4 [f_4 x_3]))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_map_rejects_wrong_key.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_map_rejects_wrong_key.snap index aef94e36..c35134df 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_map_rejects_wrong_key.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__validate_map_rejects_wrong_key.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/build/tests/source/patterns.rs -assertion_line: 1064 description: "module Main exposing (..)\nimport Data exposing (ToData, Validate)\nmain : Map Int Bytes\nmain = validate (toData (Builtin.mapData [Builtin.mkPairData (Builtin.bData #\"aa\") (Builtin.bData #\"bb\")]))\n" --- --- unoptimized Core @@ -98,12 +97,7 @@ main#1 (lam x_13 (lam f_14 [f_14 x_13]))]) --- optimized Core let applyForward#40 : 'erased -> ('erased -> 'erased) -> 'erased = \x#38 : 'erased (f#39 : 'erased -> 'erased) -> f#39 x#38 in -let anf#86 : Bytes = bData (con bytestring #aa) in -let anf#88 : Bytes = bData (con bytestring #bb) in -let anf#89 : pair Bytes Bytes = mkPairData anf#86 anf#88 in -let anf#90 : list (pair Bytes Bytes) = mkCons anf#89 (con (list (pair data data)) []) in -let anf#91 : Map Bytes Bytes = mapData anf#90 in -let anf#81 : list (pair Data Data) = applyForward#40 anf#91 unMapData in +let anf#81 : list (pair Data Data) = applyForward#40 (con data (Map [(B #aa, B #bb)])) unMapData in let anf#82 : (list (pair Data Data) -> list (pair Data Data)) -> list (pair Data Data) = applyForward#40 anf#81 in let anf#84 : list (pair Data Data) = anf#82 (\values#43 : list 'erased -> letrec worker#76 : list 'erased -> list (pair Data Data) [static []] = \values#75 : list 'erased -> case@List values#75 of @@ -119,44 +113,34 @@ worker#76 values#43) in applyForward#40 anf#84 mapData --- optimized UPLC (program 1.1.0 - [(lam builtin_27 + [(lam builtin_22 [(lam applyForward_5 [(lam anf_6 [(lam anf_7 - [(lam anf_8 - [(lam anf_9 - [(lam anf_10 - [(lam anf_11 - [(lam anf_12 - [(lam anf_26 [[applyForward_5 anf_26] (builtin mapData)]) - [anf_12 - (lam values_13 - [(lam worker_25 [worker_25 values_13]) - [(lam self_14 [self_14 self_14]) - (lam self_15 - (lam values_16 - (case - values_16 - (lam field_17 - (lam field_18 - [(lam anf_23 - [(lam anf_24 [[builtin_27 anf_23] anf_24]) [[self_15 self_15] field_18]]) - (case - field_17 - (lam field_19 - (lam field_20 - [(lam destruct_21 - [(lam destruct_22 [[(builtin mkPairData) field_19] field_20]) - [(builtin unBData) field_20]]) - [(builtin unIData) field_19]])))])) - (con (list (pair data data)) []))))]])]]) - [applyForward_5 anf_11]]) - [[applyForward_5 anf_10] (builtin unMapData)]]) - [(builtin mapData) anf_9]]) - [[builtin_27 anf_8] (con (list (pair data data)) [])]]) - [[(builtin mkPairData) anf_6] anf_7]]) - [(builtin bData) (con bytestring #bb)]]) - [(builtin bData) (con bytestring #aa)]]) + [(lam anf_21 [[applyForward_5 anf_21] (builtin mapData)]) + [anf_7 + (lam values_8 + [(lam worker_20 [worker_20 values_8]) + [(lam self_9 [self_9 self_9]) + (lam self_10 + (lam values_11 + (case + values_11 + (lam field_12 + (lam field_13 + [(lam anf_18 + [(lam anf_19 [[builtin_22 anf_18] anf_19]) [[self_10 self_10] field_13]]) + (case + field_12 + (lam field_14 + (lam field_15 + [(lam destruct_16 + [(lam destruct_17 [[(builtin mkPairData) field_14] field_15]) + [(builtin unBData) field_15]]) + [(builtin unIData) field_14]])))])) + (con (list (pair data data)) []))))]])]]) + [applyForward_5 anf_6]]) + [[applyForward_5 (con data (Map [(B #aa, B #bb)]))] (builtin unMapData)]]) (lam x_3 (lam f_4 [f_4 x_3]))]) (force (builtin mkCons))]) --- result diff --git a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__when_tuple_empty_lists.snap b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__when_tuple_empty_lists.snap index e680d488..b234a472 100644 --- a/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__when_tuple_empty_lists.snap +++ b/crates/nash-codegen/src/build/tests/source/snapshots/nash_codegen__build__tests__source__patterns__when_tuple_empty_lists.snap @@ -53,31 +53,9 @@ main#1 (lam value_17 value_17)]) (lam value_16 value_16)]) --- optimized Core -let anf#38 : list int = mkCons 6 (con (list integer) []) in -let anf#39 : list int = mkCons 5 anf#38 in -let bucket2#22 : list int = mkCons 1 anf#39 in -let anf#43 : list int = mkCons 3 (con (list integer) []) in -let anf#44 : list int = mkCons 2 anf#43 in -let bucket1#23 : list int = mkCons 1 anf#44 in -equalsInteger 1 1 +true --- optimized UPLC -(program 1.1.0 - [(lam builtin_7 - [(lam partial_8 - [(lam anf_1 - [(lam anf_2 - [(lam bucket2_3 - [(lam anf_4 - [(lam anf_5 - [(lam bucket1_6 [[(builtin equalsInteger) (con integer 1)] (con integer 1)]) - [partial_8 anf_5]]) - [[builtin_7 (con integer 2)] anf_4]]) - [[builtin_7 (con integer 3)] (con (list integer) [])]]) - [partial_8 anf_2]]) - [[builtin_7 (con integer 5)] anf_1]]) - [[builtin_7 (con integer 6)] (con (list integer) [])]]) - [builtin_7 (con integer 1)]]) - (force (builtin mkCons))]) +(program 1.1.0 (con bool True)) --- result (con bool True) --- logs diff --git a/crates/nash-codegen/src/can_to_core.rs b/crates/nash-codegen/src/can_to_core.rs index dd9762e4..823a49cf 100644 --- a/crates/nash-codegen/src/can_to_core.rs +++ b/crates/nash-codegen/src/can_to_core.rs @@ -596,6 +596,13 @@ impl<'a> Engine<'a, '_, '_> { result_ty: Ty<'a>, ) -> Result<&'a Core<'a>, Error<'a>> { let mut list = match ty { + Ty::Const(ConstTy::Pair(_, _)) if arity == 2 && index < 2 => { + return Ok(self.ir.builtin( + if index == 0 { F::FstPair } else { F::SndPair }, + &[value], + result_ty, + )); + } Ty::Big(BigTy::Record(_)) => self.ir.builtin(F::UnListData, &[value], DATA_LIST), Ty::Big(BigTy::Adt(_)) => { let tag = Binder { diff --git a/crates/nash-codegen/src/constant_fold.rs b/crates/nash-codegen/src/constant_fold.rs new file mode 100644 index 00000000..301cb0f9 --- /dev/null +++ b/crates/nash-codegen/src/constant_fold.rs @@ -0,0 +1,94 @@ +//! Constant builtin evaluation and cleanup to a fixed point. +use nash_ir::{build::Builder, core::Core}; +use nash_plutus::{ + arena::Arena, constant::Constant as C, data::PlutusData as D, machine::eval_constant_builtin, + typ::Type, +}; + +/// Fold every representable pure constant call, with no size or execution budget. +pub(crate) fn simplify<'a>(b: &Builder<'a>, mut core: &'a Core<'a>) -> &'a Core<'a> { + loop { + let folded = nash_ir::constant_fold::reduce(b, core, &mut |func, args| { + if !args.iter().all(|c| valid(b.arena, c)) { + return None; + } + let result = eval_constant_builtin(b.arena, func, args)?; + valid(b.arena, result).then_some(result) + }); + let next = nash_ir::known_case::simplify_constr_data(b, folded); + debug_assert!(nash_ir::anf::validate(next).is_ok()); + debug_assert!(nash_ir::hygiene::validate(next, &[]).is_ok()); + if std::ptr::eq(core, next) { + return next; + } + core = next; + } +} + +// Validate metadata, payloads and literal representation with heap worklists. +// These checks impose no depth, node, byte or output-growth limit. +fn valid<'a>(arena: &'a Arena, c: &'a C<'a>) -> bool { + let mut constants = vec![c]; + let mut types = Vec::new(); + let mut pairs = Vec::new(); + let mut data = Vec::new(); + while let Some(c) = constants.pop() { + match c { + C::ProtoList(t, xs) | C::ProtoArray(t, xs) => { + types.push(*t); + for x in *xs { + constants.push(x); + pairs.push((*t, x.type_of(arena))); + } + } + C::ProtoPair(ta, tb, a, b) => { + types.extend([*ta, *tb]); + constants.extend([*a, *b]); + pairs.extend([(*ta, a.type_of(arena)), (*tb, b.type_of(arena))]); + } + C::Data(d) => data.push(*d), + // UPLC's Flat format does not permit BLS constants in scripts. + C::Bls12_381G1Element(_) | C::Bls12_381G2Element(_) | C::Bls12_381MlResult(_) => { + return false; + } + _ => {} + } + } + while let Some(t) = types.pop() { + match t { + Type::List(t) | Type::Array(t) => types.push(t), + Type::Pair(a, b) => types.extend([*a, *b]), + Type::Bls12_381G1Element | Type::Bls12_381G2Element | Type::Bls12_381MlResult => { + return false; + } + _ => {} + } + } + while let Some((a, b)) = pairs.pop() { + match (a, b) { + (Type::List(a), Type::List(b)) | (Type::Array(a), Type::Array(b)) => pairs.push((a, b)), + (Type::Pair(a, b), Type::Pair(c, d)) => pairs.extend([(*a, *c), (*b, *d)]), + _ if std::mem::discriminant(a) == std::mem::discriminant(b) => {} + _ => return false, + } + } + while let Some(d) = data.pop() { + match d { + // Existing CBOR encoding mishandles negative multi-limb Data integers. + // Keep evaluation at runtime until that serialization bug is fixed. + D::Integer(i) if i.bits() > 64 && *i < &0.into() => return false, + D::List(xs) | D::Constr { fields: xs, .. } => data.extend(*xs), + D::Map(xs) => { + for (a, b) in *xs { + data.extend([*a, *b]); + } + } + _ => {} + } + } + true +} + +#[cfg(test)] +#[path = "constant_fold/tests.rs"] +mod tests; diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__array_index.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__array_index.snap new file mode 100644 index 00000000..2172f8ee --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__array_index.snap @@ -0,0 +1,17 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- result\\n{}\\n--- logs\\n{:?}\", fixture.code_snapshot(),\nfixture.evaluated.result, fixture.evaluated.logs)" +--- +--- unoptimized Core +indexArray (con (array integer) [1]) 0 +--- unoptimized UPLC +(program 1.1.0 + [[(force (builtin indexArray)) (con (array integer) [1])] (con integer 0)]) +--- optimized Core +1 +--- optimized UPLC +(program 1.1.0 (con integer 1)) +--- result +(con integer 1) +--- logs +[] diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__cleanup_exposes_folding_even_when_first_fold_pass_does_not_change.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__cleanup_exposes_folding_even_when_first_fold_pass_does_not_change.snap new file mode 100644 index 00000000..769ee606 --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__cleanup_exposes_folding_even_when_first_fold_pass_does_not_change.snap @@ -0,0 +1,26 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated fixed point\\n{}\\n--- isolated UPLC\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nfixture.code_snapshot(), pretty(core), pretty(after), evaluated.uplc,\nevaluated.result, evaluated.logs)" +--- +--- unoptimized Core +let f#2 : int -> int = \x#1 : int -> addInteger x#1 22 in +f#2 20 +--- unoptimized UPLC +(program 1.1.0 + [(lam f_2 [f_2 (con integer 20)]) + (lam x_1 [[(builtin addInteger) x_1] (con integer 22)])]) +--- optimized Core +42 +--- optimized UPLC +(program 1.1.0 (con integer 42)) +--- isolated Core before +let f#2 : int -> int = \x#1 : int -> addInteger x#1 22 in +f#2 20 +--- isolated fixed point +42 +--- isolated UPLC +(program 1.1.0 (con integer 42)) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__cons_byte.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__cons_byte.snap new file mode 100644 index 00000000..44a6b3fe --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__cons_byte.snap @@ -0,0 +1,17 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- result\\n{}\\n--- logs\\n{:?}\", fixture.code_snapshot(),\nfixture.evaluated.result, fixture.evaluated.logs)" +--- +--- unoptimized Core +consByteString 42 (con bytestring #010203) +--- unoptimized UPLC +(program 1.1.0 + [[(builtin consByteString) (con integer 42)] (con bytestring #010203)]) +--- optimized Core +(con bytestring #2a010203) +--- optimized UPLC +(program 1.1.0 (con bytestring #2a010203)) +--- result +(con bytestring #2a010203) +--- logs +[] diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__construct_data.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__construct_data.snap new file mode 100644 index 00000000..3a6215d8 --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__construct_data.snap @@ -0,0 +1,16 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- isolated Core\\n{}\\n--- result\\n{}\", fixture.code_snapshot(),\npretty(after), evaluated.result)" +--- +--- unoptimized Core +constrData 0 (con (list data) []) +--- unoptimized UPLC +(program 1.1.0 [[(builtin constrData) (con integer 0)] (con (list data) [])]) +--- optimized Core +(con data (Constr 0 [])) +--- optimized UPLC +(program 1.1.0 (con data (Constr 0 []))) +--- isolated Core +(con data (Constr 0 [])) +--- result +(con data (Constr 0 [])) diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__failed_calls_do_not_stop_folding_or_cleanup.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__failed_calls_do_not_stop_folding_or_cleanup.snap new file mode 100644 index 00000000..c0aa822e --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__failed_calls_do_not_stop_folding_or_cleanup.snap @@ -0,0 +1,31 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- isolated pass Core\\n{}\\n--- isolated pass UPLC\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nfixture.code_snapshot(), pretty(after), evaluated.uplc, evaluated.result,\nevaluated.logs)" +--- +--- unoptimized Core +constr 0 (divideInteger 1 0) (multiplyInteger (addInteger 20 22) 2) +--- unoptimized UPLC +(program 1.1.0 + (constr 0 + [[(builtin divideInteger) (con integer 1)] (con integer 0)] + [[(builtin multiplyInteger) + [[(builtin addInteger) (con integer 20)] (con integer 22)]] + (con integer 2)])) +--- optimized Core +let anf#1 : int = divideInteger 1 0 in +constr 0 anf#1 84 +--- optimized UPLC +(program 1.1.0 + [(lam anf_2 (constr 0 anf_2 (con integer 84))) + [[(builtin divideInteger) (con integer 1)] (con integer 0)]]) +--- isolated pass Core +let anf#1 : int = divideInteger 1 0 in +constr 0 anf#1 84 +--- isolated pass UPLC +(program 1.1.0 + [(lam anf_1 (constr 0 anf_1 (con integer 84))) + [[(builtin divideInteger) (con integer 1)] (con integer 0)]]) +--- result +error: Runtime(DivisionByZero(1, 0)) +--- logs +[] diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__growing_output.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__growing_output.snap new file mode 100644 index 00000000..a2c32c2a --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__growing_output.snap @@ -0,0 +1,17 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- isolated Core\\n{}\\n--- result\\n{}\", fixture.code_snapshot(),\npretty(after), evaluated.result)" +--- +--- unoptimized Core +replicateByte 5000 42 +--- unoptimized UPLC +(program 1.1.0 [[(builtin replicateByte) (con integer 5000)] (con integer 42)]) +--- optimized Core +(con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2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a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a) diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_array_index.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_array_index.snap new file mode 100644 index 00000000..279d16db --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_array_index.snap @@ -0,0 +1,22 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- result\\n{}\\n--- logs\\n{:?}\", fixture.code_snapshot(),\nfixture.evaluated.result, fixture.evaluated.logs)" +--- +--- unoptimized Core +indexArray (con (array integer) [1]) 1606938044258990275541962092341162602522202993782792835301376 +--- unoptimized UPLC +(program 1.1.0 + [[(force (builtin indexArray)) (con (array integer) [1])] + (con integer 1606938044258990275541962092341162602522202993782792835301376)]) +--- optimized Core +indexArray (con (array integer) [1]) 1606938044258990275541962092341162602522202993782792835301376 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_1 + [[builtin_1 (con (array integer) [1])] + (con integer 1606938044258990275541962092341162602522202993782792835301376)]) + (force (builtin indexArray))]) +--- result +error: Runtime(IndexArrayOutOfBounds(1606938044258990275541962092341162602522202993782792835301376, 1)) +--- logs +[] diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_byte_index.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_byte_index.snap new file mode 100644 index 00000000..1d14c2cf --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_byte_index.snap @@ -0,0 +1,20 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- result\\n{}\\n--- logs\\n{:?}\", fixture.code_snapshot(),\nfixture.evaluated.result, fixture.evaluated.logs)" +--- +--- unoptimized Core +indexByteString (con bytestring #010203) 1606938044258990275541962092341162602522202993782792835301376 +--- unoptimized UPLC +(program 1.1.0 + [[(builtin indexByteString) (con bytestring #010203)] + (con integer 1606938044258990275541962092341162602522202993782792835301376)]) +--- optimized Core +indexByteString (con bytestring #010203) 1606938044258990275541962092341162602522202993782792835301376 +--- optimized UPLC +(program 1.1.0 + [[(builtin indexByteString) (con bytestring #010203)] + (con integer 1606938044258990275541962092341162602522202993782792835301376)]) +--- result +error: Runtime(ByteStringOutOfBounds([1, 2, 3], 1606938044258990275541962092341162602522202993782792835301376)) +--- logs +[] diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_constr_tag.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_constr_tag.snap new file mode 100644 index 00000000..889d2d23 --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_constr_tag.snap @@ -0,0 +1,22 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- result\\n{}\\n--- logs\\n{:?}\", fixture.code_snapshot(),\nfixture.evaluated.result, fixture.evaluated.logs)" +--- +--- unoptimized Core +constrData 1606938044258990275541962092341162602522202993782792835301376 (con (list data) []) +--- unoptimized UPLC +(program 1.1.0 + [[(builtin constrData) + (con integer 1606938044258990275541962092341162602522202993782792835301376)] + (con (list data) [])]) +--- optimized Core +constrData 1606938044258990275541962092341162602522202993782792835301376 (con (list data) []) +--- optimized UPLC +(program 1.1.0 + [[(builtin constrData) + (con integer 1606938044258990275541962092341162602522202993782792835301376)] + (con (list data) [])]) +--- result +error: MaxConstrTagExceeded(Con(Integer(1606938044258990275541962092341162602522202993782792835301376))) +--- logs +[] diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_rotation.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_rotation.snap new file mode 100644 index 00000000..e0f4a325 --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_rotation.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- result\\n{}\\n--- logs\\n{:?}\", fixture.code_snapshot(),\nfixture.evaluated.result, fixture.evaluated.logs)" +--- +--- unoptimized Core +rotateByteString (con bytestring #010203) 1606938044258990275541962092341162602522202993782792835301376 +--- unoptimized UPLC +(program 1.1.0 + [[(builtin rotateByteString) (con bytestring #010203)] + (con integer 1606938044258990275541962092341162602522202993782792835301376)]) +--- optimized Core +(con bytestring #030102) +--- optimized UPLC +(program 1.1.0 (con bytestring #030102)) +--- result +(con bytestring #030102) +--- logs +[] diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_shift.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_shift.snap new file mode 100644 index 00000000..1052cb1b --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__huge_shift.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- result\\n{}\\n--- logs\\n{:?}\", fixture.code_snapshot(),\nfixture.evaluated.result, fixture.evaluated.logs)" +--- +--- unoptimized Core +shiftByteString (con bytestring #010203) 1606938044258990275541962092341162602522202993782792835301376 +--- unoptimized UPLC +(program 1.1.0 + [[(builtin shiftByteString) (con bytestring #010203)] + (con integer 1606938044258990275541962092341162602522202993782792835301376)]) +--- optimized Core +(con bytestring #000000) +--- optimized UPLC +(program 1.1.0 (con bytestring #000000)) +--- result +(con bytestring #000000) +--- logs +[] diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__large_input.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__large_input.snap new file mode 100644 index 00000000..0a11ebd0 --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__large_input.snap @@ -0,0 +1,19 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- isolated Core\\n{}\\n--- result\\n{}\", fixture.code_snapshot(),\npretty(after), evaluated.result)" +--- +--- unoptimized Core +sha2_256 (con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2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--- optimized Core +(con bytestring #e4a7e38e1211586cbc31cd9d9000ca02b5d459235726f7ccd91cfc9811da9939) +--- optimized UPLC +(program 1.1.0 + (con bytestring #e4a7e38e1211586cbc31cd9d9000ca02b5d459235726f7ccd91cfc9811da9939)) +--- isolated Core +(con bytestring #e4a7e38e1211586cbc31cd9d9000ca02b5d459235726f7ccd91cfc9811da9939) +--- result +(con bytestring #e4a7e38e1211586cbc31cd9d9000ca02b5d459235726f7ccd91cfc9811da9939) diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__negative_constr_tag.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__negative_constr_tag.snap new file mode 100644 index 00000000..2bed3b06 --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__negative_constr_tag.snap @@ -0,0 +1,16 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- result\\n{}\\n--- logs\\n{:?}\", fixture.code_snapshot(),\nfixture.evaluated.result, fixture.evaluated.logs)" +--- +--- unoptimized Core +constrData -1 (con (list data) []) +--- unoptimized UPLC +(program 1.1.0 [[(builtin constrData) (con integer -1)] (con (list data) [])]) +--- optimized Core +constrData -1 (con (list data) []) +--- optimized UPLC +(program 1.1.0 [[(builtin constrData) (con integer -1)] (con (list data) [])]) +--- result +error: MaxConstrTagExceeded(Con(Integer(-1))) +--- logs +[] diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__pure_conditional.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__pure_conditional.snap new file mode 100644 index 00000000..b4a6e6cf --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__pure_conditional.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- isolated Core\\n{}\\n--- result\\n{}\", fixture.code_snapshot(),\npretty(after), evaluated.result)" +--- +--- unoptimized Core +ifThenElse true 20 22 +--- unoptimized UPLC +(program 1.1.0 + [[[(force (builtin ifThenElse)) (con bool True)] (con integer 20)] + (con integer 22)]) +--- optimized Core +20 +--- optimized UPLC +(program 1.1.0 (con integer 20)) +--- isolated Core +20 +--- result +(con integer 20) diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__unsafe_serialized_result_keeps_runtime_call.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__unsafe_serialized_result_keeps_runtime_call.snap new file mode 100644 index 00000000..4c811801 --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__unsafe_serialized_result_keeps_runtime_call.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +iData -18446744073709551617 +--- unoptimized UPLC +(program 1.1.0 [(builtin iData) (con integer -18446744073709551617)]) +--- optimized Core +iData -18446744073709551617 +--- optimized UPLC +(program 1.1.0 [(builtin iData) (con integer -18446744073709551617)]) +--- result +(con data (I -18446744073709551617)) +--- logs +[] +--- budget +cpu: 63399, memory: 432 diff --git a/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__whole_byte_shift.snap b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__whole_byte_shift.snap new file mode 100644 index 00000000..d8f464af --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/snapshots/nash_codegen__constant_fold__tests__whole_byte_shift.snap @@ -0,0 +1,17 @@ +--- +source: crates/nash-codegen/src/constant_fold/tests.rs +expression: "format!(\"{}\\n--- result\\n{}\\n--- logs\\n{:?}\", fixture.code_snapshot(),\nfixture.evaluated.result, fixture.evaluated.logs)" +--- +--- unoptimized Core +shiftByteString (con bytestring #010203) 8 +--- unoptimized UPLC +(program 1.1.0 + [[(builtin shiftByteString) (con bytestring #010203)] (con integer 8)]) +--- optimized Core +(con bytestring #020300) +--- optimized UPLC +(program 1.1.0 (con bytestring #020300)) +--- result +(con bytestring #020300) +--- logs +[] diff --git a/crates/nash-codegen/src/constant_fold/tests.rs b/crates/nash-codegen/src/constant_fold/tests.rs new file mode 100644 index 00000000..61e467da --- /dev/null +++ b/crates/nash-codegen/src/constant_fold/tests.rs @@ -0,0 +1,217 @@ +use super::*; +use nash_ir::pretty::pretty; +use nash_ir::ty::Ty; +use nash_plutus::builtin::DefaultFunction as F; + +#[test] +fn pure_builtins_fold_without_size_or_cost_limits() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let bytes = b.lit(C::byte_string(&arena, arena.alloc_slice_copy(&[42; 5000]))); + let calls = [ + ("large_input", b.builtin(F::Sha2_256, &[bytes], Ty::Erased)), + ( + "growing_output", + b.builtin(F::ReplicateByte, &[b.int(5000), b.int(42)], Ty::Erased), + ), + ( + "pure_conditional", + b.builtin( + F::IfThenElse, + &[b.lit(C::bool(&arena, true)), b.int(20), b.int(22)], + Ty::Erased, + ), + ), + ( + "construct_data", + b.builtin( + F::ConstrData, + &[b.int(0), b.lit(C::proto_list(&arena, &Type::Data, &[]))], + Ty::Erased, + ), + ), + ]; + for (name, core) in calls { + let fixture = crate::harness::prepare_fixture(&arena, core); + let after = simplify(&b, core); + let evaluated = crate::harness::eval_core_raw(&arena, after); + assert!(!evaluated.result.starts_with("error:")); + insta::assert_snapshot!( + name, + format!( + "{}\n--- isolated Core\n{}\n--- result\n{}", + fixture.code_snapshot(), + pretty(after), + evaluated.result + ) + ); + fixture.assert_equivalent(&arena); + assert_eq!(fixture.evaluated.observable, evaluated.observable); + assert_eq!(fixture.evaluated.logs, evaluated.logs); + assert!(std::ptr::eq(after, simplify(&b, after))); + } +} + +#[test] +fn newly_enabled_builtins_preserve_results_and_errors() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let bytes = b.lit(C::byte_string(&arena, &[1, 2, 3])); + let huge = b.lit(C::integer( + &arena, + arena.alloc_integer(nash_plutus::constant::Integer::from(1) << 200), + )); + let array = b.lit(C::proto_array( + &arena, + &Type::Integer, + arena.alloc([C::integer_from(&arena, 1)]), + )); + let cases: &[(&str, F, &[&Core<'_>])] = &[ + ("whole_byte_shift", F::ShiftByteString, &[bytes, b.int(8)]), + ("huge_shift", F::ShiftByteString, &[bytes, huge]), + ("huge_rotation", F::RotateByteString, &[bytes, huge]), + ("huge_byte_index", F::IndexByteString, &[bytes, huge]), + ("huge_array_index", F::IndexArray, &[array, huge]), + ( + "negative_constr_tag", + F::ConstrData, + &[b.int(-1), b.lit(C::proto_list(&arena, &Type::Data, &[]))], + ), + ( + "huge_constr_tag", + F::ConstrData, + &[huge, b.lit(C::proto_list(&arena, &Type::Data, &[]))], + ), + ("array_index", F::IndexArray, &[array, b.int(0)]), + ("cons_byte", F::ConsByteString, &[b.int(42), bytes]), + ]; + for (name, func, args) in cases { + let core = b.builtin(*func, args, Ty::Erased); + let fixture = crate::harness::prepare_fixture(&arena, core); + insta::assert_snapshot!( + *name, + format!( + "{}\n--- result\n{}\n--- logs\n{:?}", + fixture.code_snapshot(), + fixture.evaluated.result, + fixture.evaluated.logs + ) + ); + fixture.assert_equivalent(&arena); + } +} + +#[test] +fn validity_checks_structure_without_depth_or_node_limits() { + let arena = Arena::new(); + let wrong = C::bool(&arena, false); + let pair = C::proto_pair(&arena, &Type::Data, &Type::Data, wrong, wrong); + for c in [ + C::proto_list(&arena, &Type::Data, arena.alloc([wrong])), + C::proto_list( + &arena, + arena.alloc(Type::Pair(&Type::Data, &Type::Data)), + arena.alloc([pair]), + ), + ] { + assert!(!valid(&arena, c)); + } + let mut typ = &Type::Integer; + for _ in 0..100 { + typ = arena.alloc(Type::List(typ)); + } + assert!(valid(&arena, C::proto_list(&arena, typ, &[]))); + let many = arena.alloc_slice_copy(&vec![wrong; 1100]); + assert!(valid(&arena, C::proto_list(&arena, &Type::Bool, many))); + let unsafe_data = C::data(&arena, D::integer_from(&arena, -(1_i128 << 64) - 1)); + assert!(!valid(&arena, unsafe_data)); +} + +#[test] +fn failed_calls_do_not_stop_folding_or_cleanup() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let sum = b.builtin(F::AddInteger, &[b.int(20), b.int(22)], b.int(0).ty); + let core = b.constr( + 0, + &[ + b.builtin(F::DivideInteger, &[b.int(1), b.int(0)], sum.ty), + b.builtin(F::MultiplyInteger, &[sum, b.int(2)], sum.ty), + ], + Ty::Erased, + ); + let fixture = crate::harness::prepare_fixture(&arena, core); + let anf = nash_ir::anf::normalize(&b, core); + let after = simplify(&b, anf); + let evaluated = crate::harness::eval_core_raw(&arena, after); + assert!(evaluated.result.starts_with("error:")); + insta::assert_snapshot!(format!( + "{}\n--- isolated pass Core\n{}\n--- isolated pass UPLC\n{}\n--- result\n{}\n--- logs\n{:?}", + fixture.code_snapshot(), + pretty(after), + evaluated.uplc, + evaluated.result, + evaluated.logs + )); + fixture.assert_equivalent(&arena); + assert!(std::ptr::eq(after, simplify(&b, after))); + assert_eq!(fixture.evaluated.observable, evaluated.observable); + assert_eq!(fixture.evaluated.logs, evaluated.logs); + nash_ir::anf::validate(after).unwrap(); + nash_ir::hygiene::validate(after, &[]).unwrap(); +} + +#[test] +fn unsafe_serialized_result_keeps_runtime_call() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let core = b.builtin(F::IData, &[b.int(-(1_i128 << 64) - 1)], Ty::Erased); + let fixture = crate::harness::prepare_fixture(&arena, core); + insta::assert_snapshot!(fixture.snapshot()); + fixture.assert_equivalent(&arena); + assert!(std::ptr::eq(core, simplify(&b, core))); +} + +#[test] +fn cleanup_exposes_folding_even_when_first_fold_pass_does_not_change() { + use nash_ir::core::Binder; + let arena = Arena::new(); + let b = Builder::new(&arena); + let int = b.int(0).ty; + let x = Binder { + name: b.fresh("x"), + ty: int, + }; + let value = b.lam( + &[x], + b.builtin(F::AddInteger, &[b.var(x.name, int), b.int(22)], int), + ); + let f = Binder { + name: b.fresh("f"), + ty: value.ty, + }; + let core = b.let_(f, value, b.app(b.var(f.name, f.ty), &[b.int(20)], int)); + let fixture = crate::harness::prepare_fixture(&arena, core); + let after = simplify(&b, core); + let evaluated = crate::harness::eval_core_raw(&arena, after); + assert!(!evaluated.result.starts_with("error:")); + insta::assert_snapshot!(format!( + "{}\n--- isolated Core before\n{}\n--- isolated fixed point\n{}\n--- isolated UPLC\n{}\n--- result\n{}\n--- logs\n{:?}", + fixture.code_snapshot(), + pretty(core), + pretty(after), + evaluated.uplc, + evaluated.result, + evaluated.logs + )); + fixture.assert_equivalent(&arena); + assert_eq!(fixture.evaluated.observable, evaluated.observable); + assert_eq!(fixture.evaluated.logs, evaluated.logs); + assert!(std::ptr::eq(after, simplify(&b, after))); + assert!(std::ptr::eq( + after, + nash_ir::known_case::simplify_constr_data(&b, after) + )); + nash_ir::anf::validate(after).unwrap(); + nash_ir::hygiene::validate(after, &[]).unwrap(); +} diff --git a/crates/nash-codegen/src/harness.rs b/crates/nash-codegen/src/harness.rs index e3aea69f..88e9dcd7 100644 --- a/crates/nash-codegen/src/harness.rs +++ b/crates/nash-codegen/src/harness.rs @@ -127,6 +127,27 @@ impl<'a> Fixture<'a> { self.evaluated.logs, optimized.logs, "candidate passes preserve trace order" ); + let once = crate::program::assemble_core(arena, self.prepared.optimized).unwrap(); + let original_bytes = nash_plutus::flat::encode(once.program).unwrap(); + let mut repeated = self.prepared.optimized; + for _ in 0..2 { + repeated = crate::snapshot_optimizer::optimize(arena, repeated); + let compiled = crate::program::assemble_core(arena, repeated).unwrap(); + assert_eq!( + original_bytes, + nash_plutus::flat::encode(compiled.program).unwrap(), + "repeated O1 Core optimization must not change the program" + ); + } + let late = crate::uplc_optimizer::optimize(arena, self.prepared.after.named); + assert!( + std::ptr::eq(self.prepared.after.named, late), + "late O1 must already be at a fixed point" + ); + assert!(std::ptr::eq( + late, + crate::uplc_optimizer::optimize(arena, late) + )); } } diff --git a/crates/nash-codegen/src/lib.rs b/crates/nash-codegen/src/lib.rs index d65458de..c8a71408 100644 --- a/crates/nash-codegen/src/lib.rs +++ b/crates/nash-codegen/src/lib.rs @@ -18,6 +18,8 @@ pub mod evidence; pub mod comptime; pub mod optimizer; pub mod program; +pub mod silent; +pub mod uplc_optimizer; mod assertion; pub mod build; @@ -30,3 +32,5 @@ mod optimizer_tests; #[cfg(test)] #[path = "../tests/support/optimizer.rs"] mod snapshot_optimizer; + +mod constant_fold; diff --git a/crates/nash-codegen/src/lower.rs b/crates/nash-codegen/src/lower.rs index bd868ed0..812b5fda 100644 --- a/crates/nash-codegen/src/lower.rs +++ b/crates/nash-codegen/src/lower.rs @@ -43,6 +43,14 @@ pub fn lower_with_constant_sharing<'a>( lower_inner(arena, core, Sharing::ForcesAndConstants) } +/// Complete O1 lowering: share builtin work, clean up generated bindings, then +/// pack eligible application spines. Ordinary and isolated sharing APIs stay +/// available for O0 and pass comparisons. +pub fn lower_optimized<'a>(arena: &'a Arena, core: &'a Core<'a>) -> Result, Error> { + let term = lower_with_constant_sharing(arena, core)?; + Ok(crate::uplc_optimizer::optimize(arena, term)) +} + #[derive(Clone, Copy, PartialEq, Eq)] enum Sharing { None, diff --git a/crates/nash-codegen/src/optimizer.rs b/crates/nash-codegen/src/optimizer.rs index 0973434b..df01dff5 100644 --- a/crates/nash-codegen/src/optimizer.rs +++ b/crates/nash-codegen/src/optimizer.rs @@ -6,6 +6,7 @@ pub fn optimize<'a>(arena: &'a Arena, core: &'a Core<'a>) -> &'a Core<'a> { optimize_with(&Builder::new(arena), core) } +/// Normalize once, then lift statics, remove unused parameters and simplify to a joint fixed point. pub fn optimize_with<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { let original_ty = core.ty; let core = hygiene::freshen(b, core); @@ -14,18 +15,39 @@ pub fn optimize_with<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { debug_assert!(hygiene::validate(core, &[]).is_ok()); let core = nash_ir::unused_params::reduce(b, core); debug_assert!(hygiene::validate(core, &[]).is_ok()); - let core = nash_ir::known_case::reduce_constr(b, core); - debug_assert!(hygiene::validate(core, &[]).is_ok()); - let core = nash_ir::inverse::reduce(b, core); - debug_assert!(hygiene::validate(core, &[]).is_ok()); let core = anf::normalize(b, core); debug_assert!(hygiene::validate(core, &[]).is_ok()); debug_assert!(anf::validate(core).is_ok()); + // Fold representations and constructors through ANF bindings in the cleanup + // loops, including opportunities exposed by inlining and propagation. let core = nash_ir::small_inline::simplify(b, core); debug_assert!(hygiene::validate(core, &[]).is_ok()); let core = nash_ir::known_case::simplify_constr_data(b, core); debug_assert!(hygiene::validate(core, &[]).is_ok()); debug_assert!(anf::validate(core).is_ok()); + let mut core = core; + loop { + // Branch cleanup and recursive pruning can reveal new static parameters. + // Lifting keeps call operands atomic; the existing cleanup flattens any + // binding prefixes it introduces, without another normalization pass. + let next = nash_ir::static_lift::lift(b, core); + let next = nash_ir::unused_params::reduce(b, next); + let next = crate::constant_fold::simplify(b, next); + if std::ptr::eq(core, next) { + break; + } + core = next; + } + debug_assert!(hygiene::validate(core, &[]).is_ok()); + debug_assert!(anf::validate(core).is_ok()); debug_assert_eq!(original_ty, core.ty); core } + +/// O2 uses the O1 pipeline after removing every Core trace operation. +pub fn optimize_silent<'a>( + arena: &'a Arena, + core: &'a Core<'a>, +) -> Result<&'a Core<'a>, crate::silent::Error> { + Ok(optimize(arena, crate::silent::erase(arena, core)?)) +} diff --git a/crates/nash-codegen/src/optimizer_tests/composition.rs b/crates/nash-codegen/src/optimizer_tests/composition.rs new file mode 100644 index 00000000..ec413bdb --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/composition.rs @@ -0,0 +1,416 @@ +//! Composition contracts: deterministic progress, phase boundaries and fixed points. +use nash_ir::{ + anf, beta, + build::Builder, + core::*, + dead_code, force_delay, hygiene, inverse, known_case, pair_projection, + pretty::pretty, + propagate, single_use, small_inline, static_lift, + ty::{BigTy, TermTy, Ty}, + unused_params, +}; +use nash_plutus::{arena::Arena, builtin::DefaultFunction as F, constant::Constant as C, flat}; + +// Semantic snapshots omit evaluator costs; budget regression checks live in the +// separate optimizer-perf workspace. +fn semantic_snapshot(fixture: &crate::harness::Fixture<'_>) -> String { + format!( + "{}\n--- result\n{}\n--- logs\n{:?}", + fixture.code_snapshot(), + fixture.evaluated.result, + fixture.evaluated.logs + ) +} + +fn bind<'a>(b: &Builder<'a>, text: &'a str, ty: Ty<'a>) -> Binder<'a> { + Binder { + name: b.fresh(text), + ty, + } +} +fn trace<'a>(b: &Builder<'a>, text: &'a str, core: &'a Core<'a>) -> &'a Core<'a> { + b.trace(b.lit(C::string(b.arena, text)), core) +} +fn encoded(arena: &Arena, core: &Core<'_>) -> Vec { + flat::encode(crate::program::assemble_core(arena, core).unwrap().program).unwrap() +} +fn chain<'a>(b: &Builder<'a>) -> &'a Core<'a> { + let int = b.int(0).ty; + let data = Ty::Big(&BigTy::Data); + let x = bind(b, "x", int); + let wrap = b.lam(&[x], b.builtin(F::IData, &[b.var(x.name, int)], data)); + let f = bind(b, "wrap", wrap.ty); + let packed = bind(b, "packed", data); + let sum = b.builtin(F::AddInteger, &[b.int(20), b.int(22)], int); + b.let_( + f, + wrap, + b.let_( + packed, + b.app(b.var(f.name, f.ty), &[sum], data), + trace( + b, + "answer", + b.if_( + b.lit(C::bool(b.arena, true)), + b.builtin(F::UnIData, &[b.var(packed.name, data)], int), + b.error(int), + ), + ), + ), + ) +} + +#[test] +fn composed_phases_are_hygienic_and_deterministic() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let core = chain(&b); + let fixture = crate::harness::prepare_fixture(&arena, core); + assert!(!fixture.evaluated.result.starts_with("error:")); + let fresh = hygiene::freshen(&b, core); + let lifted = static_lift::lift(&b, fresh); + let shortened = unused_params::reduce(&b, lifted); + let normalized = anf::normalize(&b, shortened); + let optimized = crate::optimizer::optimize(&arena, core); + let rewritten = crate::recursion::rewrite(&b, optimized).unwrap(); + let lowered = crate::harness::eval_core_raw(&arena, rewritten); + insta::assert_snapshot!(format!( + "{}\n--- fresh Core\n{}\n--- lifted Core\n{}\n--- signatures before ANF\n{}\n--- ANF Core\n{}\n--- optimized recursive Core\n{}\n--- rewritten Core (no second ANF)\n{}\n--- ordinary lowered output\n{}", + semantic_snapshot(&fixture), + pretty(fresh), + pretty(lifted), + pretty(shortened), + pretty(normalized), + pretty(optimized), + pretty(rewritten), + lowered.uplc + )); + fixture.assert_equivalent(&arena); + for phase in [fresh, lifted, shortened, normalized, optimized, rewritten] { + hygiene::validate(phase, &[]).unwrap(); + assert_eq!(core.ty, phase.ty); + } + anf::validate(normalized).unwrap(); + anf::validate(optimized).unwrap(); + // Check each constituent rewrite, including intermediate nested binding forms. + let mut phase = normalized; + for pass in [ + inverse::reduce, + force_delay::reduce, + known_case::reduce_bool, + known_case::reduce_literals, + propagate::propagate, + beta::reduce, + single_use::inline, + small_inline::inline, + dead_code::simplify_bindings, + dead_code::prune_recursive, + known_case::reduce_constr, + known_case::reduce_bound_constr, + known_case::reduce_list, + known_case::reduce_data, + known_case::reduce_data_wrappers, + pair_projection::reduce, + known_case::reduce_constr_data, + ] { + phase = pass(&b, phase); + hygiene::validate(phase, &[]).unwrap(); + assert_eq!(core.ty, phase.ty); + } + let cleaned = known_case::simplify_constr_data(&b, phase); + anf::validate(cleaned).unwrap(); + assert!(std::ptr::eq( + cleaned, + known_case::simplify_constr_data(&b, cleaned) + )); + assert!(std::ptr::eq( + optimized, + known_case::simplify_constr_data(&b, optimized) + )); + let repeat = crate::optimizer::optimize(&arena, core); + assert_eq!(pretty(optimized), pretty(repeat)); + assert_eq!(encoded(&arena, optimized), encoded(&arena, repeat)); + let twice = crate::optimizer::optimize(&arena, optimized); + assert_eq!(encoded(&arena, optimized), encoded(&arena, twice)); + assert_eq!(fixture.evaluated.observable, lowered.observable); + assert_eq!(fixture.evaluated.logs, lowered.logs); +} + +#[test] +fn same_size_binding_reassociation_exposes_more_cleanup() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let int = b.int(0).ty; + let x = bind(&b, "x", int); + let note = bind(&b, "note", int); + let lambda = b.lam(&[x], b.var(x.name, int)); + let f = bind(&b, "f", lambda.ty); + // Nested lets arise from accepted cancellation and inlining; beta flattens them. + let core = b.let_( + f, + b.let_(note, trace(&b, "before", b.int(0)), lambda), + b.app(b.var(f.name, f.ty), &[b.int(42)], int), + ); + let step = beta::reduce(&b, core); + let after = small_inline::simplify(&b, step); + let fixture = crate::harness::prepare_fixture(&arena, core); + let result = crate::harness::eval_core_raw(&arena, after); + assert!(!result.result.starts_with("error:")); + insta::assert_snapshot!(format!( + "{}\n--- isolated before\n{}\n--- same-size reassociation\n{}\n--- cleanup fixed point\n{}\n--- lowered\n{}", + semantic_snapshot(&fixture), + pretty(core), + pretty(step), + pretty(after), + result.uplc + )); + fixture.assert_equivalent(&arena); + let count = |core: &Core<'_>| { + let mut n = 0; + core.walk(&mut |_| n += 1); + n + }; + assert_eq!(count(core), count(step)); + assert!(!std::ptr::eq(core, step)); + assert!(!std::ptr::eq(step, after)); + assert!(std::ptr::eq(after, small_inline::simplify(&b, after))); + hygiene::validate(after, &[]).unwrap(); + anf::validate(after).unwrap(); + assert_eq!(fixture.evaluated.observable, result.observable); + assert_eq!(fixture.evaluated.logs, result.logs); +} + +#[test] +fn reachable_cycle_reaches_cleanup_fixed_point_without_execution() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let int = b.int(0).ty; + let ty = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int]), int))); + let f = bind(&b, "loop", ty); + let n = bind(&b, "n", int); + let core = b.let_rec( + &[RecBinder { + binder: f, + params: arena.alloc_slice_copy(&[n]), + static_params: &[], + body: trace( + &b, + "loop", + b.app(b.var(f.name, ty), &[b.var(n.name, int)], int), + ), + }], + b.app(b.var(f.name, ty), &[b.int(0)], int), + ); + let after = crate::optimizer::optimize(&arena, core); + insta::assert_snapshot!(crate::harness::pass_snapshot( + &arena, + core, + format!( + "--- recursive cleanup fixed point (not evaluated)\n{}", + pretty(after) + ) + )); + hygiene::validate(after, &[]).unwrap(); + anf::validate(after).unwrap(); + assert!(std::ptr::eq( + after, + known_case::simplify_constr_data(&b, after) + )); + assert_eq!( + pretty(after), + pretty(crate::optimizer::optimize(&arena, core)) + ); +} + +#[test] +fn later_cleanup_and_signature_removal_reach_a_joint_fixed_point() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let int = b.int(0).ty; + let x = bind(&b, "x", int); + let y = bind(&b, "y", int); + let value = b.lam( + &[x, y], + b.if_( + b.lit(C::bool(&arena, true)), + b.var(y.name, int), + b.var(x.name, int), + ), + ); + let f = bind(&b, "f", value.ty); + let call = |n| b.app(b.var(f.name, f.ty), &[b.int(7), b.int(n)], int); + let core = b.let_( + f, + value, + b.builtin(F::AddInteger, &[call(20), call(22)], int), + ); + let once = crate::optimizer::optimize(&arena, core); + let twice = crate::optimizer::optimize(&arena, once); + let fixture = crate::harness::prepare_fixture(&arena, core); + let result = + crate::harness::eval_core_raw(&arena, crate::recursion::rewrite(&b, twice).unwrap()); + insta::assert_snapshot!(format!( + "{}\n--- second invocation\n{}\n--- second lowered\n{}", + semantic_snapshot(&fixture), + pretty(twice), + result.uplc + )); + fixture.assert_equivalent(&arena); + assert_eq!(encoded(&arena, once), encoded(&arena, twice)); + hygiene::validate(twice, &[]).unwrap(); + anf::validate(twice).unwrap(); + assert_eq!(fixture.evaluated.observable, result.observable); + assert_eq!(fixture.evaluated.logs, result.logs); +} + +#[test] +fn folding_reaches_fixed_point_beyond_128_calls() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let int = b.int(0).ty; + let fields: Vec<_> = (0..130) + .map(|i| b.builtin(F::AddInteger, &[b.int(i), b.int(1)], int)) + .collect(); + let core = b.constr(0, &fields, Ty::Erased); + let once = crate::optimizer::optimize(&arena, core); + let twice = crate::optimizer::optimize(&arena, once); + let fixture = crate::harness::prepare_fixture(&arena, core); + let result = crate::harness::eval_core_raw(&arena, twice); + assert!(!result.result.starts_with("error:")); + insta::assert_snapshot!(format!( + "{}\n--- second invocation Core\n{}\n--- second invocation UPLC\n{}", + semantic_snapshot(&fixture), + pretty(twice), + result.uplc + )); + fixture.assert_equivalent(&arena); + assert_eq!( + pretty(once), + pretty(crate::optimizer::optimize(&arena, core)) + ); + assert_eq!(encoded(&arena, once), encoded(&arena, twice)); + assert!(std::ptr::eq(once, crate::constant_fold::simplify(&b, once))); + assert_eq!(fixture.evaluated.observable, result.observable); + assert_eq!(fixture.evaluated.logs, result.logs); + for phase in [once, twice] { + hygiene::validate(phase, &[]).unwrap(); + anf::validate(phase).unwrap(); + } + assert!(std::ptr::eq( + once, + known_case::simplify_constr_data(&b, once) + )); +} + +#[test] +fn cleanup_exposed_static_parameters_reach_a_fixed_point() { + for (name, hidden_argument, dead_peer) in [ + ("static_argument_after_branch_cleanup", true, false), + ("static_argument_after_recursive_pruning", false, true), + ] { + let arena = Arena::new(); + let b = Builder::new(&arena); + let int = b.int(0).ty; + let ty = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int, int]), int))); + let f = bind(&b, "loop", ty); + let x = bind(&b, "x", int); + let n = bind(&b, "n", int); + let next = bind(&b, "next", int); + let condition = b.builtin( + F::EqualsInteger, + &[b.var(n.name, int), b.int(0)], + b.lit(C::bool(&arena, true)).ty, + ); + let recursive_argument = if hidden_argument { + b.if_(b.lit(C::bool(&arena, true)), b.var(x.name, int), b.int(0)) + } else { + b.var(x.name, int) + }; + let body = b.if_( + condition, + b.var(x.name, int), + b.let_( + next, + b.builtin(F::SubtractInteger, &[b.var(n.name, int), b.int(1)], int), + b.app( + b.var(f.name, ty), + &[recursive_argument, b.var(next.name, int)], + int, + ), + ), + ); + let mut group = vec![RecBinder { + binder: f, + params: arena.alloc_slice_copy(&[x, n]), + static_params: &[], + body, + }]; + if dead_peer { + let unused = bind(&b, "unused", ty); + let a = bind(&b, "a", int); + let c = bind(&b, "c", int); + group.push(RecBinder { + binder: unused, + params: arena.alloc_slice_copy(&[a, c]), + static_params: &[], + body: b.var(a.name, int), + }); + } + let core = b.let_rec( + &group, + b.app(b.var(f.name, ty), &[b.int(42), b.int(3)], int), + ); + let fixture = crate::harness::prepare_fixture(&arena, core); + insta::assert_snapshot!(name, semantic_snapshot(&fixture)); + fixture.assert_equivalent(&arena); + } +} + +#[test] +fn late_all_static_lifting_preserves_oversaturated_call_order() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let int = b.int(0).ty; + let returned_ty = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int]), int))); + let ty = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int]), returned_ty))); + let f = bind(&b, "loop", ty); + let x = bind(&b, "x", int); + let n = bind(&b, "n", int); + let next = bind(&b, "next", int); + let result = bind(&b, "result", int); + let hidden = b.if_(b.lit(C::bool(&arena, true)), b.var(x.name, int), b.int(0)); + let call = b.app(b.var(f.name, ty), &[hidden, b.var(next.name, int)], int); + let body = b.lam( + &[n], + b.if_( + b.builtin( + F::EqualsInteger, + &[b.var(n.name, int), b.int(0)], + b.lit(C::bool(&arena, true)).ty, + ), + b.var(x.name, int), + b.let_( + next, + b.builtin(F::SubtractInteger, &[b.var(n.name, int), b.int(1)], int), + b.let_( + result, + trace(&b, "recurse", call), + b.builtin(F::AddInteger, &[b.var(result.name, int), b.int(1)], int), + ), + ), + ), + ); + let core = b.let_rec( + &[RecBinder { + binder: f, + params: arena.alloc_slice_copy(&[x]), + static_params: &[], + body, + }], + b.app(b.var(f.name, ty), &[b.int(42), b.int(3)], int), + ); + let fixture = crate::harness::prepare_fixture(&arena, core); + insta::assert_snapshot!(semantic_snapshot(&fixture)); + fixture.assert_equivalent(&arena); +} diff --git a/crates/nash-codegen/src/optimizer_tests/constant_fold.rs b/crates/nash-codegen/src/optimizer_tests/constant_fold.rs new file mode 100644 index 00000000..f1ade18c --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/constant_fold.rs @@ -0,0 +1,16 @@ +use nash_ir::build::Builder; +use nash_plutus::arena::Arena; +#[path = "../../tests/support/constant_fold.rs"] +mod inputs; + +#[test] +fn constant_evaluation() { + let arena = Arena::new(); + let b = Builder::new(&arena); + for (name, before, fails) in inputs::cases(&b) { + let fixture = crate::harness::prepare_fixture(&arena, before); + assert_eq!(fixture.evaluated.result.starts_with("error:"), fails); + insta::assert_snapshot!(name, fixture.snapshot()); + fixture.assert_equivalent(&arena); + } +} diff --git a/crates/nash-codegen/src/optimizer_tests/mod.rs b/crates/nash-codegen/src/optimizer_tests/mod.rs index c3116f4a..a18e51ca 100644 --- a/crates/nash-codegen/src/optimizer_tests/mod.rs +++ b/crates/nash-codegen/src/optimizer_tests/mod.rs @@ -13,4 +13,11 @@ mod single_use; mod small_inline; mod unused_params; +mod constant_fold; mod inverse; + +mod pair_projection; + +mod recursive_params; + +mod composition; diff --git a/crates/nash-codegen/src/optimizer_tests/pair_projection.rs b/crates/nash-codegen/src/optimizer_tests/pair_projection.rs new file mode 100644 index 00000000..80a2d24c --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/pair_projection.rs @@ -0,0 +1,131 @@ +use nash_ir::{build::Builder, hygiene, pretty::pretty}; +use nash_plutus::arena::Arena; +#[path = "../../tests/support/pair_projection.rs"] +mod inputs; + +#[test] +fn pair_projection() { + let arena = Arena::new(); + let b = Builder::new(&arena); + for (name, before, fails) in inputs::cases(&b) { + let fixture = crate::harness::prepare_fixture(&arena, before); + assert_eq!(fixture.evaluated.result.starts_with("error:"), fails); + let anf = nash_ir::anf::normalize(&b, before); + let isolated = nash_ir::pair_projection::reduce(&b, anf); + insta::assert_snapshot!( + name, + format!( + "{}\n--- isolated Core before\n{}\n--- isolated Core after\n{}", + fixture.snapshot(), + pretty(anf), + pretty(isolated) + ) + ); + assert_eq!(anf.ty, isolated.ty); + hygiene::validate(isolated, &[]).unwrap(); + nash_ir::anf::validate(isolated).unwrap(); + fixture.assert_equivalent(&arena); + } +} + +#[test] +fn pair_projection_guards() { + use nash_ir::core::{Binder, Branch, CaseKind, Test}; + use nash_plutus::{constant::Constant as C, typ::Type}; + let arena = Arena::new(); + let b = Builder::new(&arena); + let pair = b.lit(C::proto_pair( + &arena, + &Type::Integer, + &Type::Integer, + C::integer_from(&arena, 7), + C::integer_from(&arena, 8), + )); + for mode in [ + "default", + "wrong_test", + "one_binder", + "no_branches", + "field_type", + "unknown_parameter", + ] { + let x = Binder { + name: b.fresh("x"), + ty: if mode == "field_type" { + nash_ir::ty::Ty::Erased + } else { + b.int(0).ty + }, + }; + let y = Binder { + name: b.fresh("y"), + ty: b.int(0).ty, + }; + let p = Binder { + name: b.fresh("p"), + ty: pair.ty, + }; + let binders = if mode == "one_binder" { + arena.alloc_slice_copy(&[x]) + } else { + arena.alloc_slice_copy(&[x, y]) + }; + let branch = Branch { + test: if mode == "wrong_test" { + Test::Tag(0) + } else { + Test::Pair + }, + binders, + body: b.var(x.name, x.ty), + }; + let branches = if mode == "no_branches" { + &[][..] + } else { + arena.alloc_slice_copy(&[branch]) + }; + let subject = if mode == "unknown_parameter" { + b.var(p.name, p.ty) + } else { + pair + }; + let before = b.case( + CaseKind::Pair, + subject, + branches, + (mode == "default").then(|| b.int(0)), + x.ty, + ); + let before = if mode == "unknown_parameter" { + b.lam(&[p], before) + } else { + before + }; + let after = nash_ir::pair_projection::reduce(&b, before); + let lowered = |core| match crate::lower::lower(&arena, core) { + Ok(term) => nash_plutus::pretty::term(term), + Err(error) => format!("error: {error}"), + }; + let pipeline = if matches!(mode, "field_type" | "unknown_parameter") { + crate::snapshot_optimizer::prepare(&arena, before).snapshot() + } else { + String::new() + }; + insta::assert_snapshot!( + mode, + format!( + "{}--- isolated Core before\n{}\n--- UPLC before\n{}\n--- isolated Core after\n{}\n--- UPLC after\n{}", + if pipeline.is_empty() { + pipeline + } else { + format!("{pipeline}\n") + }, + pretty(before), + lowered(before), + pretty(after), + lowered(after) + ) + ); + assert!(std::ptr::eq(before, after)); + } +} diff --git a/crates/nash-codegen/src/optimizer_tests/recursive_params.rs b/crates/nash-codegen/src/optimizer_tests/recursive_params.rs new file mode 100644 index 00000000..3c6f0d3d --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/recursive_params.rs @@ -0,0 +1,333 @@ +//! Recursive signature reduction before ANF, including forwarding dependencies. +#[path = "../../tests/support/recursive_params.rs"] +mod input; +use nash_ir::{anf, build::Builder, hygiene, pretty::pretty, unused_params}; +use nash_plutus::arena::Arena; + +#[test] +fn recursive_parameter_cases() { + let arena = Arena::new(); + let b = Builder::new(&arena); + for (name, before, fails) in input::cases(&b) { + let fresh = Builder::new(&arena); + let after = unused_params::reduce(&fresh, before); + let original = + crate::harness::eval_core_raw(&arena, crate::recursion::rewrite(&b, before).unwrap()); + let normalized = anf::normalize(&fresh, after); + let result = crate::harness::eval_core_raw( + &arena, + crate::recursion::rewrite(&b, normalized).unwrap(), + ); + assert_eq!(result.result.starts_with("error:"), fails); + insta::assert_snapshot!( + name, + crate::harness::pass_snapshot( + &arena, + before, + format!( + "--- isolated Core before\n{}\n--- isolated Core after\n{}\n--- isolated UPLC before\n{}\n--- isolated UPLC after\n{}\n--- result\n{}\n--- logs\n{:?}", + pretty(before), + pretty(after), + original.uplc, + result.uplc, + result.result, + result.logs + ) + ) + ); + assert_eq!( + !std::ptr::eq(before, after), + !matches!( + name, + "mutual_consumed" + | "partial" + | "escaping" + | "oversaturated" + | "compound_dependency" + ) + ); + assert_eq!(original.observable, result.observable); + assert_eq!(original.logs, result.logs); + assert_eq!(before.ty, after.ty); + hygiene::validate(after, &[]).unwrap(); + anf::validate(normalized).unwrap(); + assert!(std::ptr::eq(after, unused_params::reduce(&fresh, after))); + } +} + +#[test] +fn static_indices_and_call_type_views_survive() { + use nash_ir::{ + core::*, + ty::{ConstTy, TermTy, Ty}, + }; + let arena = Arena::new(); + let b = Builder::new(&arena); + let int = b.int(0).ty; + let bytes = Ty::Const(&ConstTy::Bytes); + let fun = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int, int]), int))); + let f = Binder { + name: b.fresh("f"), + ty: fun, + }; + let x = Binder { + name: b.fresh("unused"), + ty: int, + }; + let y = Binder { + name: b.fresh("used"), + ty: int, + }; + let view = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int, int]), bytes))); + let before = b.with_type( + b.let_rec( + &[RecBinder { + binder: f, + params: arena.alloc_slice_copy(&[x, y]), + static_params: &[1], + body: b.var(y.name, int), + }], + b.app(b.var(f.name, view), &[b.int(0), b.int(42)], bytes), + ), + Ty::Erased, + ); + let after = unused_params::reduce(&b, before); + insta::assert_snapshot!(crate::harness::pass_snapshot( + &arena, + before, + format!( + "--- isolated Core before\n{}\n--- isolated Core after\n{}", + pretty(before), + pretty(after) + ) + )); + assert_eq!(after.ty, Ty::Erased); + let CoreKind::LetRec { binders: [r], body } = after.kind else { + panic!("group") + }; + assert_eq!( + r.binder.ty, + Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int]), int))) + ); + let CoreKind::App { func, .. } = body.kind else { + panic!("call") + }; + assert_eq!( + func.ty, + Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int]), bytes))) + ); + hygiene::validate(after, &[]).unwrap(); +} + +#[test] +fn forwarding_divergence_remains_delayed_and_strict() { + use nash_ir::{ + core::*, + ty::{TermTy, Ty}, + }; + use nash_plutus::builtin::DefaultFunction as F; + let arena = Arena::new(); + let b = Builder::new(&arena); + let int = b.int(0).ty; + let fun = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int]), int))); + let f = Binder { + name: b.fresh("f"), + ty: fun, + }; + let g = Binder { + name: b.fresh("g"), + ty: fun, + }; + let x = Binder { + name: b.fresh("x"), + ty: int, + }; + let y = Binder { + name: b.fresh("y"), + ty: int, + }; + let invoke = |use_f: bool, x| b.app(b.var(if use_f { f.name } else { g.name }, fun), &[x], int); + let before = b.let_rec( + &[ + RecBinder { + binder: f, + params: arena.alloc_slice_copy(&[x]), + static_params: &[], + body: invoke(false, b.var(x.name, int)), + }, + RecBinder { + binder: g, + params: arena.alloc_slice_copy(&[y]), + static_params: &[], + body: invoke(true, b.var(y.name, int)), + }, + ], + invoke(true, b.builtin(F::AddInteger, &[b.int(1), b.int(2)], int)), + ); + let after = unused_params::reduce(&b, before); + // Render deliberate divergence without evaluating it. + insta::assert_snapshot!(crate::harness::pass_snapshot( + &arena, + before, + format!( + "--- isolated Core before\n{}\n--- isolated Core after\n{}", + pretty(before), + pretty(after) + ) + )); + hygiene::validate(after, &[]).unwrap(); + assert!(std::ptr::eq(after, unused_params::reduce(&b, after))); + crate::recursion::rewrite(&b, after).unwrap(); +} + +#[test] +fn delayed_mutual_worker_returns_captured_closure() { + use nash_ir::{ + core::*, + ty::{TermTy, Ty}, + }; + use nash_plutus::{builtin::DefaultFunction as F, constant::Constant}; + let arena = Arena::new(); + let b = Builder::new(&arena); + let int = b.int(0).ty; + let unary = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int]), int))); + let fun = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int]), unary))); + let bind = |text, ty| Binder { + name: b.fresh(text), + ty, + }; + let outer = bind("captured", int); + let f = bind("f", fun); + let g = bind("g", fun); + let x = bind("x", int); + let y = bind("y", int); + let z = bind("z", int); + let f_body = b.lam( + &[z], + b.builtin( + F::AddInteger, + &[b.var(outer.name, int), b.var(z.name, int)], + int, + ), + ); + let g_body = b.trace( + b.lit(Constant::string(&arena, "worker")), + b.app(b.var(f.name, fun), &[b.var(y.name, int)], unary), + ); + let before = b.let_( + outer, + b.int(40), + b.let_rec( + &[ + RecBinder { + binder: f, + params: arena.alloc_slice_copy(&[x]), + static_params: &[], + body: f_body, + }, + RecBinder { + binder: g, + params: arena.alloc_slice_copy(&[y]), + static_params: &[], + body: g_body, + }, + ], + b.app( + b.app(b.var(g.name, fun), &[b.int(7)], unary), + &[b.int(2)], + int, + ), + ), + ); + let after = unused_params::reduce(&b, before); + let original = + crate::harness::eval_core_raw(&arena, crate::recursion::rewrite(&b, before).unwrap()); + let result = + crate::harness::eval_core_raw(&arena, crate::recursion::rewrite(&b, after).unwrap()); + assert!(!result.result.starts_with("error:")); + insta::assert_snapshot!(crate::harness::pass_snapshot( + &arena, + before, + format!( + "--- isolated Core before\n{}\n--- isolated Core after\n{}\n--- isolated UPLC after\n{}\n--- result\n{}\n--- logs\n{:?}", + pretty(before), + pretty(after), + result.uplc, + result.result, + result.logs + ) + )); + assert_eq!(original.observable, result.observable); + assert_eq!(original.logs, result.logs); + hygiene::validate(after, &[]).unwrap(); +} + +#[test] +fn mixed_group_prunes_to_single_delayed_worker() { + use nash_ir::{ + core::*, + ty::{TermTy, Ty}, + }; + use nash_plutus::constant::Constant; + let arena = Arena::new(); + let b = Builder::new(&arena); + let int = b.int(0).ty; + let fun = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int]), int))); + let bind = |text| Binder { + name: b.fresh(text), + ty: int, + }; + let f = Binder { + name: b.fresh("delayed"), + ty: fun, + }; + let g = Binder { + name: b.fresh("unusedFunction"), + ty: fun, + }; + let x = bind("x"); + let y = bind("y"); + let before = b.let_rec( + &[ + RecBinder { + binder: f, + params: arena.alloc_slice_copy(&[x]), + static_params: &[], + body: b.trace(b.lit(Constant::string(&arena, "body")), b.int(42)), + }, + RecBinder { + binder: g, + params: arena.alloc_slice_copy(&[y]), + static_params: &[], + body: b.var(y.name, int), + }, + ], + b.app(b.var(f.name, fun), &[b.int(0)], int), + ); + let reduced = unused_params::reduce(&b, before); + let after = nash_ir::dead_code::prune_recursive(&b, reduced); + let original = + crate::harness::eval_core_raw(&arena, crate::recursion::rewrite(&b, before).unwrap()); + let result = + crate::harness::eval_core_raw(&arena, crate::recursion::rewrite(&b, after).unwrap()); + assert!(!result.result.starts_with("error:")); + insta::assert_snapshot!(crate::harness::pass_snapshot( + &arena, + before, + format!( + "--- reduced mixed group\n{}\n--- pruned group\n{}\n--- lowered\n{}\n--- result\n{}\n--- logs\n{:?}", + pretty(reduced), + pretty(after), + result.uplc, + result.result, + result.logs + ) + )); + assert_eq!(original.observable, result.observable); + assert_eq!(original.logs, result.logs); + hygiene::validate(after, &[]).unwrap(); + assert!(std::ptr::eq( + after, + nash_ir::dead_code::prune_recursive(&b, after) + )); +} diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__anf__mutual_static_lift_fallback.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__anf__mutual_static_lift_fallback.snap index 7a5c7d25..1e47d878 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__anf__mutual_static_lift_fallback.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__anf__mutual_static_lift_fallback.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/anf.rs -assertion_line: 53 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before static lifting\\n{}\\n--- core after static lifting / before ANF\\n{}\\n--- core after ANF\\n{}\\n--- rewritten core (no second ANF)\\n{}\\n--- baseline\\n{}\\n--- candidate\\n{}\",\npretty(fresh), pretty(lifted), pretty(first_anf), pretty(after),\nsemantic_output(&baseline), semantic_output(&normalized),))" --- --- unoptimized Core @@ -57,10 +56,7 @@ even#7 42 3 --- optimized UPLC (program 1.1.0 [(lam dispatch_46 - [(lam even_49 - [(lam odd_52 [[even_49 (con integer 42)] (con integer 3)]) - (lam y_50 (lam m_51 [dispatch_46 (constr 1 dispatch_46 y_50 m_51)]))]) - (lam x_47 (lam n_48 [dispatch_46 (constr 0 dispatch_46 x_47 n_48)]))]) + [dispatch_46 (constr 0 dispatch_46 (con integer 42) (con integer 3))]) (lam request_29 (case request_29 @@ -70,10 +66,8 @@ even#7 42 3 [(lam anf_33 (case anf_33 - [(lam anf_36 - [(lam anf_37 [anf_36 anf_37]) - [[(builtin subtractInteger) n_32] (con integer 1)]]) - [(lam y_34 (lam m_35 [self_30 (constr 1 self_30 y_34 m_35)])) x_31]] + [(lam anf_37 [self_30 (constr 1 self_30 x_31 anf_37)]) + [[(builtin subtractInteger) n_32] (con integer 1)]] x_31)) [[(builtin equalsInteger) n_32] (con integer 0)]]))) (lam self_38 @@ -82,10 +76,8 @@ even#7 42 3 [(lam anf_41 (case anf_41 - [(lam anf_44 - [(lam anf_45 [anf_44 anf_45]) - [[(builtin subtractInteger) m_40] (con integer 1)]]) - [(lam x_42 (lam n_43 [self_38 (constr 0 self_38 x_42 n_43)])) y_39]] + [(lam anf_45 [self_38 (constr 0 self_38 y_39 anf_45)]) + [[(builtin subtractInteger) m_40] (con integer 1)]] y_39)) [[(builtin equalsInteger) m_40] (con integer 0)]])))))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__beta__oversaturation_repeated_integer.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__beta__oversaturation_repeated_integer.snap index aa6bad25..f0909de6 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__beta__oversaturation_repeated_integer.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__beta__oversaturation_repeated_integer.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/beta.rs -assertion_line: 40 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline\\n{}\\n--- core after\\n{}\\n--- candidate\\n{}\",\npretty(before), output(&baseline), pretty(after), output(&candidate)))" --- --- unoptimized Core @@ -14,15 +13,14 @@ expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core be (con integer 21)] (con integer 0)]) --- optimized Core -let beta#5 : int -> int = trace "intermediate" in \y#4 : int -> addInteger 21 21 in +let beta#5 : int -> int = trace "intermediate" in \y#4 : int -> 42 in beta#5 0 --- optimized UPLC (program 1.1.0 [(lam builtin_3 [(lam beta_2 [beta_2 (con integer 0)]) (force - [[builtin_3 (con string "intermediate")] - (delay (lam y_1 [[(builtin addInteger) (con integer 21)] (con integer 21)]))])]) + [[builtin_3 (con string "intermediate")] (delay (lam y_1 (con integer 42)))])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__discarded_data_default.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__discarded_data_default.snap index 770e5034..6bf3021c 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__discarded_data_default.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__discarded_data_default.snap @@ -23,11 +23,9 @@ case@Data iData 42 of (delay (con integer 42))])) [(builtin iData) (con integer 42)]]) --- optimized Core -let anf#11 : Data = iData 42 in 42 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 (con integer 42)) [(builtin iData) (con integer 42)]]) +(program 1.1.0 (con integer 42)) --- isolated pass --- uplc before [(lam generated_8 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__discarded_list_default.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__discarded_list_default.snap index f090732b..010efa7e 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__discarded_list_default.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__discarded_list_default.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/builtin_sharing.rs -assertion_line: 45 expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- uplc before\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nnash_plutus::pretty::term(before), nash_plutus::pretty::term(after),\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -17,16 +16,9 @@ case@List mkNilData () of (lam head_1 (lam tail_2 (con integer 0))) (con integer 42))) --- optimized Core -let anf#5 : list Data = mkNilData () in -case@List anf#5 of - Nil -> 42 - Cons head#3 tail#4 -> 0 - _ -> trace "never" in error +42 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 - (case anf_1 (lam head_2 (lam tail_6 (con integer 0))) (con integer 42))) - [(builtin mkNilData) (con unit ())]]) +(program 1.1.0 (con integer 42)) --- isolated pass --- uplc before (case diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__lowered_data.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__lowered_data.snap index 1cbbcb3a..db908fc9 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__lowered_data.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__lowered_data.snap @@ -19,14 +19,11 @@ case@Data iData 42 of (delay (error))])) [(builtin iData) (con integer 42)]]) --- optimized Core -let anf#3 : Data = iData 42 in trace "integer" in 42 --- optimized UPLC (program 1.1.0 - [(lam builtin_2 - [(lam anf_1 - (force [[builtin_2 (con string "integer")] (delay (con integer 42))])) - [(builtin iData) (con integer 42)]]) + [(lam builtin_1 + (force [[builtin_1 (con string "integer")] (delay (con integer 42))])) (force (builtin trace))]) --- isolated pass --- uplc before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__partial.snap index 4d2af159..3847f8dc 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__partial.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/builtin_sharing.rs -assertion_line: 45 expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- uplc before\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nnash_plutus::pretty::term(before), nash_plutus::pretty::term(after),\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -24,13 +23,11 @@ addInteger anf#5 anf#6 --- optimized UPLC (program 1.1.0 [(lam builtin_9 - [(lam bare_1 - [(lam partial_2 - [(lam anf_7 - [(lam anf_8 [[(builtin addInteger) anf_7] anf_8]) [partial_2 (con integer 22)]]) - [[bare_1 (con string "bare")] (con integer 20)]]) - [builtin_9 (con string "partial")]]) - builtin_9]) + [(lam partial_2 + [(lam anf_7 + [(lam anf_8 [[(builtin addInteger) anf_7] anf_8]) [partial_2 (con integer 22)]]) + [[builtin_9 (con string "bare")] (con integer 20)]]) + [builtin_9 (con string "partial")]]) (force (builtin trace))]) --- isolated pass --- uplc before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__polymorphic.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__polymorphic.snap index edfb2e11..552d8113 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__polymorphic.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__polymorphic.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/builtin_sharing.rs -assertion_line: 45 expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- uplc before\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nnash_plutus::pretty::term(before), nash_plutus::pretty::term(after),\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -16,19 +15,9 @@ case@Bool ifThenElse true true false of [[[(force (builtin ifThenElse)) (con bool True)] (con integer 42)] (con integer 0)])) --- optimized Core -let anf#1 : bool = ifThenElse true true false in -case@Bool anf#1 of - True -> ifThenElse true 42 0 - False -> 0 +42 --- optimized UPLC -(program 1.1.0 - [(lam builtin_3 - [(lam partial_4 - [(lam anf_2 - (case anf_2 (con integer 0) [[partial_4 (con integer 42)] (con integer 0)])) - [[partial_4 (con bool True)] (con bool False)]]) - [builtin_3 (con bool True)]]) - (force (builtin ifThenElse))]) +(program 1.1.0 (con integer 42)) --- isolated pass --- uplc before (case diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__two_forces.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__two_forces.snap index ef9b4ecc..db8a77d3 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__two_forces.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__two_forces.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/builtin_sharing.rs -assertion_line: 45 expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- uplc before\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nnash_plutus::pretty::term(before), nash_plutus::pretty::term(after),\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -12,21 +11,9 @@ unIData (fstPair (mkPairData (iData 42) (iData 42))) [[(builtin mkPairData) [(builtin iData) (con integer 42)]] [(builtin iData) (con integer 42)]]]]) --- optimized Core -let anf#1 : Data = iData 42 in -let anf#2 : Data = iData 42 in -let anf#3 : pair Data Data = mkPairData anf#1 anf#2 in -let anf#4 : Data = fstPair anf#3 in -unIData anf#4 +42 --- optimized UPLC -(program 1.1.0 - [(lam builtin_9 - [(lam anf_5 - [(lam anf_6 - [(lam anf_7 [(lam anf_8 [(builtin unIData) anf_8]) [builtin_9 anf_7]]) - [[(builtin mkPairData) anf_5] anf_6]]) - [(builtin iData) (con integer 42)]]) - [(builtin iData) (con integer 42)]]) - (force (force (builtin fstPair)))]) +(program 1.1.0 (con integer 42)) --- isolated pass --- uplc before [(builtin unIData) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__unforced.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__unforced.snap index ee125577..c18c35c3 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__unforced.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__builtin_sharing__unforced.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/builtin_sharing.rs -assertion_line: 45 expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- uplc before\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nnash_plutus::pretty::term(before), nash_plutus::pretty::term(after),\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -8,9 +7,9 @@ addInteger 20 22 --- unoptimized UPLC (program 1.1.0 [[(builtin addInteger) (con integer 20)] (con integer 22)]) --- optimized Core -addInteger 20 22 +42 --- optimized UPLC -(program 1.1.0 [[(builtin addInteger) (con integer 20)] (con integer 22)]) +(program 1.1.0 (con integer 42)) --- isolated pass --- uplc before [[(builtin addInteger) (con integer 20)] (con integer 22)] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__composed_phases_are_hygienic_and_deterministic.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__composed_phases_are_hygienic_and_deterministic.snap new file mode 100644 index 00000000..8a04a227 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__composed_phases_are_hygienic_and_deterministic.snap @@ -0,0 +1,63 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/composition.rs +expression: "format!(\"{}\\n--- fresh Core\\n{}\\n--- lifted Core\\n{}\\n--- signatures before ANF\\n{}\\n--- ANF Core\\n{}\\n--- optimized recursive Core\\n{}\\n--- rewritten Core (no second ANF)\\n{}\\n--- ordinary lowered output\\n{}\",\nsemantic_snapshot(&fixture), pretty(fresh), pretty(lifted), pretty(shortened),\npretty(normalized), pretty(optimized), pretty(rewritten), lowered.uplc)" +--- +--- unoptimized Core +let wrap#2 : int -> Data = \x#1 : int -> iData x#1 in +let packed#3 : Data = wrap#2 (addInteger 20 22) in +trace "answer" in case@Bool true of + True -> unIData packed#3 + False -> error +--- unoptimized UPLC +(program 1.1.0 + [(lam wrap_2 + [(lam packed_3 + (force + [[(force (builtin trace)) (con string "answer")] + (delay (case (con bool True) (error) [(builtin unIData) packed_3]))])) + [wrap_2 [[(builtin addInteger) (con integer 20)] (con integer 22)]]]) + (lam x_1 [(builtin iData) x_1])]) +--- optimized Core +trace "answer" in 42 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_1 + (force [[builtin_1 (con string "answer")] (delay (con integer 42))])) + (force (builtin trace))]) +--- result +(con integer 42) +--- logs +["answer"] +--- fresh Core +let wrap#5 : int -> Data = \x#4 : int -> iData x#4 in +let packed#6 : Data = wrap#5 (addInteger 20 22) in +trace "answer" in case@Bool true of + True -> unIData packed#6 + False -> error +--- lifted Core +let wrap#5 : int -> Data = \x#4 : int -> iData x#4 in +let packed#6 : Data = wrap#5 (addInteger 20 22) in +trace "answer" in case@Bool true of + True -> unIData packed#6 + False -> error +--- signatures before ANF +let wrap#5 : int -> Data = \x#4 : int -> iData x#4 in +let packed#6 : Data = wrap#5 (addInteger 20 22) in +trace "answer" in case@Bool true of + True -> unIData packed#6 + False -> error +--- ANF Core +let wrap#5 : int -> Data = \x#4 : int -> iData x#4 in +let anf#7 : int = addInteger 20 22 in +let packed#6 : Data = wrap#5 anf#7 in +trace "answer" in case@Bool true of + True -> unIData packed#6 + False -> error +--- optimized recursive Core +trace "answer" in 42 +--- rewritten Core (no second ANF) +trace "answer" in 42 +--- ordinary lowered output +(program 1.1.0 + (force + [[(force (builtin trace)) (con string "answer")] (delay (con integer 42))])) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__folding_reaches_fixed_point_beyond_128_calls.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__folding_reaches_fixed_point_beyond_128_calls.snap new file mode 100644 index 00000000..ccb6ba17 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__folding_reaches_fixed_point_beyond_128_calls.snap @@ -0,0 +1,543 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/composition.rs +expression: "format!(\"{}\\n--- second invocation Core\\n{}\\n--- second invocation UPLC\\n{}\",\nsemantic_snapshot(&fixture), pretty(twice), result.uplc)" +--- +--- unoptimized Core +constr 0 (addInteger 0 1) (addInteger 1 1) (addInteger 2 1) (addInteger 3 1) (addInteger 4 1) (addInteger 5 1) (addInteger 6 1) (addInteger 7 1) (addInteger 8 1) (addInteger 9 1) (addInteger 10 1) (addInteger 11 1) (addInteger 12 1) (addInteger 13 1) (addInteger 14 1) (addInteger 15 1) (addInteger 16 1) (addInteger 17 1) (addInteger 18 1) (addInteger 19 1) (addInteger 20 1) (addInteger 21 1) (addInteger 22 1) (addInteger 23 1) (addInteger 24 1) (addInteger 25 1) (addInteger 26 1) (addInteger 27 1) (addInteger 28 1) (addInteger 29 1) (addInteger 30 1) (addInteger 31 1) (addInteger 32 1) (addInteger 33 1) (addInteger 34 1) (addInteger 35 1) (addInteger 36 1) (addInteger 37 1) (addInteger 38 1) (addInteger 39 1) (addInteger 40 1) (addInteger 41 1) (addInteger 42 1) (addInteger 43 1) (addInteger 44 1) (addInteger 45 1) (addInteger 46 1) (addInteger 47 1) (addInteger 48 1) (addInteger 49 1) (addInteger 50 1) (addInteger 51 1) (addInteger 52 1) (addInteger 53 1) (addInteger 54 1) (addInteger 55 1) (addInteger 56 1) (addInteger 57 1) (addInteger 58 1) (addInteger 59 1) (addInteger 60 1) (addInteger 61 1) (addInteger 62 1) (addInteger 63 1) (addInteger 64 1) (addInteger 65 1) (addInteger 66 1) (addInteger 67 1) (addInteger 68 1) (addInteger 69 1) (addInteger 70 1) (addInteger 71 1) (addInteger 72 1) (addInteger 73 1) (addInteger 74 1) (addInteger 75 1) (addInteger 76 1) (addInteger 77 1) (addInteger 78 1) (addInteger 79 1) (addInteger 80 1) (addInteger 81 1) (addInteger 82 1) (addInteger 83 1) (addInteger 84 1) (addInteger 85 1) (addInteger 86 1) (addInteger 87 1) (addInteger 88 1) (addInteger 89 1) (addInteger 90 1) (addInteger 91 1) (addInteger 92 1) (addInteger 93 1) (addInteger 94 1) (addInteger 95 1) (addInteger 96 1) (addInteger 97 1) (addInteger 98 1) (addInteger 99 1) (addInteger 100 1) (addInteger 101 1) (addInteger 102 1) (addInteger 103 1) (addInteger 104 1) (addInteger 105 1) (addInteger 106 1) (addInteger 107 1) (addInteger 108 1) (addInteger 109 1) (addInteger 110 1) (addInteger 111 1) (addInteger 112 1) (addInteger 113 1) (addInteger 114 1) (addInteger 115 1) (addInteger 116 1) (addInteger 117 1) (addInteger 118 1) (addInteger 119 1) (addInteger 120 1) (addInteger 121 1) (addInteger 122 1) (addInteger 123 1) (addInteger 124 1) (addInteger 125 1) (addInteger 126 1) (addInteger 127 1) (addInteger 128 1) (addInteger 129 1) +--- unoptimized UPLC +(program 1.1.0 + (constr 0 + [[(builtin addInteger) (con integer 0)] (con integer 1)] + [[(builtin addInteger) (con integer 1)] (con integer 1)] + [[(builtin addInteger) (con integer 2)] (con integer 1)] + [[(builtin addInteger) (con integer 3)] (con integer 1)] + [[(builtin addInteger) (con integer 4)] (con integer 1)] + [[(builtin addInteger) (con integer 5)] (con integer 1)] + [[(builtin addInteger) (con integer 6)] (con integer 1)] + [[(builtin addInteger) (con integer 7)] (con integer 1)] + [[(builtin addInteger) (con integer 8)] (con integer 1)] + [[(builtin addInteger) (con integer 9)] (con integer 1)] + [[(builtin addInteger) (con integer 10)] (con integer 1)] + [[(builtin addInteger) (con integer 11)] (con integer 1)] + [[(builtin addInteger) (con integer 12)] (con integer 1)] + [[(builtin addInteger) (con integer 13)] (con integer 1)] + [[(builtin addInteger) (con integer 14)] (con integer 1)] + [[(builtin addInteger) (con integer 15)] (con integer 1)] + [[(builtin addInteger) (con integer 16)] (con integer 1)] + [[(builtin addInteger) (con integer 17)] (con integer 1)] + [[(builtin addInteger) (con integer 18)] (con integer 1)] + [[(builtin addInteger) (con integer 19)] (con integer 1)] + [[(builtin addInteger) (con integer 20)] (con integer 1)] + [[(builtin addInteger) (con integer 21)] (con integer 1)] + [[(builtin addInteger) (con integer 22)] (con integer 1)] + [[(builtin addInteger) (con integer 23)] (con integer 1)] + [[(builtin addInteger) (con integer 24)] (con integer 1)] + [[(builtin addInteger) (con integer 25)] (con integer 1)] + [[(builtin addInteger) (con integer 26)] (con integer 1)] + [[(builtin addInteger) (con integer 27)] (con integer 1)] + [[(builtin addInteger) (con integer 28)] (con integer 1)] + [[(builtin addInteger) (con integer 29)] (con integer 1)] + [[(builtin addInteger) (con integer 30)] (con integer 1)] + [[(builtin addInteger) (con integer 31)] (con integer 1)] + [[(builtin addInteger) (con integer 32)] (con integer 1)] + [[(builtin addInteger) (con integer 33)] (con integer 1)] + [[(builtin addInteger) (con integer 34)] (con integer 1)] + [[(builtin addInteger) (con integer 35)] (con integer 1)] + [[(builtin addInteger) (con integer 36)] (con integer 1)] + [[(builtin addInteger) (con integer 37)] (con integer 1)] + [[(builtin addInteger) (con integer 38)] (con integer 1)] + [[(builtin addInteger) (con integer 39)] (con integer 1)] + [[(builtin addInteger) (con integer 40)] (con integer 1)] + [[(builtin addInteger) (con integer 41)] (con integer 1)] + [[(builtin addInteger) (con integer 42)] (con integer 1)] + [[(builtin addInteger) (con integer 43)] (con integer 1)] + [[(builtin addInteger) (con integer 44)] (con integer 1)] + [[(builtin addInteger) (con integer 45)] (con integer 1)] + [[(builtin addInteger) (con integer 46)] (con integer 1)] + [[(builtin addInteger) (con integer 47)] (con integer 1)] + [[(builtin addInteger) (con integer 48)] (con integer 1)] + [[(builtin addInteger) (con integer 49)] (con integer 1)] + [[(builtin addInteger) (con integer 50)] (con integer 1)] + [[(builtin addInteger) (con integer 51)] (con integer 1)] + [[(builtin addInteger) (con integer 52)] (con integer 1)] + [[(builtin addInteger) (con integer 53)] (con integer 1)] + [[(builtin addInteger) (con integer 54)] (con integer 1)] + [[(builtin addInteger) (con integer 55)] (con integer 1)] + [[(builtin addInteger) (con integer 56)] (con integer 1)] + [[(builtin addInteger) (con integer 57)] (con integer 1)] + [[(builtin addInteger) (con integer 58)] (con integer 1)] + [[(builtin addInteger) (con integer 59)] (con integer 1)] + [[(builtin addInteger) (con integer 60)] (con integer 1)] + [[(builtin addInteger) (con integer 61)] (con integer 1)] + [[(builtin addInteger) (con integer 62)] (con integer 1)] + [[(builtin addInteger) (con integer 63)] (con integer 1)] + [[(builtin addInteger) (con integer 64)] (con integer 1)] + [[(builtin addInteger) (con integer 65)] (con integer 1)] + [[(builtin addInteger) (con integer 66)] (con integer 1)] + [[(builtin addInteger) (con integer 67)] (con integer 1)] + [[(builtin addInteger) (con integer 68)] (con integer 1)] + [[(builtin addInteger) (con integer 69)] (con integer 1)] + [[(builtin addInteger) (con integer 70)] (con integer 1)] + [[(builtin addInteger) (con integer 71)] (con integer 1)] + [[(builtin addInteger) (con integer 72)] (con integer 1)] + [[(builtin addInteger) (con integer 73)] (con integer 1)] + [[(builtin addInteger) (con integer 74)] (con integer 1)] + [[(builtin addInteger) (con integer 75)] (con integer 1)] + [[(builtin addInteger) (con integer 76)] (con integer 1)] + [[(builtin addInteger) (con integer 77)] (con integer 1)] + [[(builtin addInteger) (con integer 78)] (con integer 1)] + [[(builtin addInteger) (con integer 79)] (con integer 1)] + [[(builtin addInteger) (con integer 80)] (con integer 1)] + [[(builtin addInteger) (con integer 81)] (con integer 1)] + [[(builtin addInteger) (con integer 82)] (con integer 1)] + [[(builtin addInteger) (con integer 83)] (con integer 1)] + [[(builtin addInteger) (con integer 84)] (con integer 1)] + [[(builtin addInteger) (con integer 85)] (con integer 1)] + [[(builtin addInteger) (con integer 86)] (con integer 1)] + [[(builtin addInteger) (con integer 87)] (con integer 1)] + [[(builtin addInteger) (con integer 88)] (con integer 1)] + [[(builtin addInteger) (con integer 89)] (con integer 1)] + [[(builtin addInteger) (con integer 90)] (con integer 1)] + [[(builtin addInteger) (con integer 91)] (con integer 1)] + [[(builtin addInteger) (con integer 92)] (con integer 1)] + [[(builtin addInteger) (con integer 93)] (con integer 1)] + [[(builtin addInteger) (con integer 94)] (con integer 1)] + [[(builtin addInteger) (con integer 95)] (con integer 1)] + [[(builtin addInteger) (con integer 96)] (con integer 1)] + [[(builtin addInteger) (con integer 97)] (con integer 1)] + [[(builtin addInteger) (con integer 98)] (con integer 1)] + [[(builtin addInteger) (con integer 99)] (con integer 1)] + [[(builtin addInteger) (con integer 100)] (con integer 1)] + [[(builtin addInteger) (con integer 101)] (con integer 1)] + [[(builtin addInteger) (con integer 102)] (con integer 1)] + [[(builtin addInteger) (con integer 103)] (con integer 1)] + [[(builtin addInteger) (con integer 104)] (con integer 1)] + [[(builtin addInteger) (con integer 105)] (con integer 1)] + [[(builtin addInteger) (con integer 106)] (con integer 1)] + [[(builtin addInteger) (con integer 107)] (con integer 1)] + [[(builtin addInteger) (con integer 108)] (con integer 1)] + [[(builtin addInteger) (con integer 109)] (con integer 1)] + [[(builtin addInteger) (con integer 110)] (con integer 1)] + [[(builtin addInteger) (con integer 111)] (con integer 1)] + [[(builtin addInteger) (con integer 112)] (con integer 1)] + [[(builtin addInteger) (con integer 113)] (con integer 1)] + [[(builtin addInteger) (con integer 114)] (con integer 1)] + [[(builtin addInteger) (con integer 115)] (con integer 1)] + [[(builtin addInteger) (con integer 116)] (con integer 1)] + [[(builtin addInteger) (con integer 117)] (con integer 1)] + [[(builtin addInteger) (con integer 118)] (con integer 1)] + [[(builtin addInteger) (con integer 119)] (con integer 1)] + [[(builtin addInteger) (con integer 120)] (con integer 1)] + [[(builtin addInteger) (con integer 121)] (con integer 1)] + [[(builtin addInteger) (con integer 122)] (con integer 1)] + [[(builtin addInteger) (con integer 123)] (con integer 1)] + [[(builtin addInteger) (con integer 124)] (con integer 1)] + [[(builtin addInteger) (con integer 125)] (con integer 1)] + [[(builtin addInteger) (con integer 126)] (con integer 1)] + [[(builtin addInteger) (con integer 127)] (con integer 1)] + [[(builtin addInteger) (con integer 128)] (con integer 1)] + [[(builtin addInteger) (con integer 129)] (con integer 1)])) +--- optimized Core +constr 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 +--- optimized UPLC +(program 1.1.0 + (constr 0 + (con integer 1) + (con integer 2) + (con integer 3) + (con integer 4) + (con integer 5) + (con integer 6) + (con integer 7) + (con integer 8) + (con integer 9) + (con integer 10) + (con integer 11) + (con integer 12) + (con integer 13) + (con integer 14) + (con integer 15) + (con integer 16) + (con integer 17) + (con integer 18) + (con integer 19) + (con integer 20) + (con integer 21) + (con integer 22) + (con integer 23) + (con integer 24) + (con integer 25) + (con integer 26) + (con integer 27) + (con integer 28) + (con integer 29) + (con integer 30) + (con integer 31) + (con integer 32) + (con integer 33) + (con integer 34) + (con integer 35) + (con integer 36) + (con integer 37) + (con integer 38) + (con integer 39) + (con integer 40) + (con integer 41) + (con integer 42) + (con integer 43) + (con integer 44) + (con integer 45) + (con integer 46) + (con integer 47) + (con integer 48) + (con integer 49) + (con integer 50) + (con integer 51) + (con integer 52) + (con integer 53) + (con integer 54) + (con integer 55) + (con integer 56) + (con integer 57) + (con integer 58) + (con integer 59) + (con integer 60) + (con integer 61) + (con integer 62) + (con integer 63) + (con integer 64) + (con integer 65) + (con integer 66) + (con integer 67) + (con integer 68) + (con integer 69) + (con integer 70) + (con integer 71) + (con integer 72) + (con integer 73) + (con integer 74) + (con integer 75) + (con integer 76) + (con integer 77) + (con integer 78) + (con integer 79) + (con integer 80) + (con integer 81) + (con integer 82) + (con integer 83) + (con integer 84) + (con integer 85) + (con integer 86) + (con integer 87) + (con integer 88) + (con integer 89) + (con integer 90) + (con integer 91) + (con integer 92) + (con integer 93) + (con integer 94) + (con integer 95) + (con integer 96) + (con integer 97) + (con integer 98) + (con integer 99) + (con integer 100) + (con integer 101) + (con integer 102) + (con integer 103) + (con integer 104) + (con integer 105) + (con integer 106) + (con integer 107) + (con integer 108) + (con integer 109) + (con integer 110) + (con integer 111) + (con integer 112) + (con integer 113) + (con integer 114) + (con integer 115) + (con integer 116) + (con integer 117) + (con integer 118) + (con integer 119) + (con integer 120) + (con integer 121) + (con integer 122) + (con integer 123) + (con integer 124) + (con integer 125) + (con integer 126) + (con integer 127) + (con integer 128) + (con integer 129) + (con integer 130))) +--- result +(constr 0 + (con integer 1) + (con integer 2) + (con integer 3) + (con integer 4) + (con integer 5) + (con integer 6) + (con integer 7) + (con integer 8) + (con integer 9) + (con integer 10) + (con integer 11) + (con integer 12) + (con integer 13) + (con integer 14) + (con integer 15) + (con integer 16) + (con integer 17) + (con integer 18) + (con integer 19) + (con integer 20) + (con integer 21) + (con integer 22) + (con integer 23) + (con integer 24) + (con integer 25) + (con integer 26) + (con integer 27) + (con integer 28) + (con integer 29) + (con integer 30) + (con integer 31) + (con integer 32) + (con integer 33) + (con integer 34) + (con integer 35) + (con integer 36) + (con integer 37) + (con integer 38) + (con integer 39) + (con integer 40) + (con integer 41) + (con integer 42) + (con integer 43) + (con integer 44) + (con integer 45) + (con integer 46) + (con integer 47) + (con integer 48) + (con integer 49) + (con integer 50) + (con integer 51) + (con integer 52) + (con integer 53) + (con integer 54) + (con integer 55) + (con integer 56) + (con integer 57) + (con integer 58) + (con integer 59) + (con integer 60) + (con integer 61) + (con integer 62) + (con integer 63) + (con integer 64) + (con integer 65) + (con integer 66) + (con integer 67) + (con integer 68) + (con integer 69) + (con integer 70) + (con integer 71) + (con integer 72) + (con integer 73) + (con integer 74) + (con integer 75) + (con integer 76) + (con integer 77) + (con integer 78) + (con integer 79) + (con integer 80) + (con integer 81) + (con integer 82) + (con integer 83) + (con integer 84) + (con integer 85) + (con integer 86) + (con integer 87) + (con integer 88) + (con integer 89) + (con integer 90) + (con integer 91) + (con integer 92) + (con integer 93) + (con integer 94) + (con integer 95) + (con integer 96) + (con integer 97) + (con integer 98) + (con integer 99) + (con integer 100) + (con integer 101) + (con integer 102) + (con integer 103) + (con integer 104) + (con integer 105) + (con integer 106) + (con integer 107) + (con integer 108) + (con integer 109) + (con integer 110) + (con integer 111) + (con integer 112) + (con integer 113) + (con integer 114) + (con integer 115) + (con integer 116) + (con integer 117) + (con integer 118) + (con integer 119) + (con integer 120) + (con integer 121) + (con integer 122) + (con integer 123) + (con integer 124) + (con integer 125) + (con integer 126) + (con integer 127) + (con integer 128) + (con integer 129) + (con integer 130)) +--- logs +[] +--- second invocation Core +constr 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 +--- second invocation UPLC +(program 1.1.0 + (constr 0 + (con integer 1) + (con integer 2) + (con integer 3) + (con integer 4) + (con integer 5) + (con integer 6) + (con integer 7) + (con integer 8) + (con integer 9) + (con integer 10) + (con integer 11) + (con integer 12) + (con integer 13) + (con integer 14) + (con integer 15) + (con integer 16) + (con integer 17) + (con integer 18) + (con integer 19) + (con integer 20) + (con integer 21) + (con integer 22) + (con integer 23) + (con integer 24) + (con integer 25) + (con integer 26) + (con integer 27) + (con integer 28) + (con integer 29) + (con integer 30) + (con integer 31) + (con integer 32) + (con integer 33) + (con integer 34) + (con integer 35) + (con integer 36) + (con integer 37) + (con integer 38) + (con integer 39) + (con integer 40) + (con integer 41) + (con integer 42) + (con integer 43) + (con integer 44) + (con integer 45) + (con integer 46) + (con integer 47) + (con integer 48) + (con integer 49) + (con integer 50) + (con integer 51) + (con integer 52) + (con integer 53) + (con integer 54) + (con integer 55) + (con integer 56) + (con integer 57) + (con integer 58) + (con integer 59) + (con integer 60) + (con integer 61) + (con integer 62) + (con integer 63) + (con integer 64) + (con integer 65) + (con integer 66) + (con integer 67) + (con integer 68) + (con integer 69) + (con integer 70) + (con integer 71) + (con integer 72) + (con integer 73) + (con integer 74) + (con integer 75) + (con integer 76) + (con integer 77) + (con integer 78) + (con integer 79) + (con integer 80) + (con integer 81) + (con integer 82) + (con integer 83) + (con integer 84) + (con integer 85) + (con integer 86) + (con integer 87) + (con integer 88) + (con integer 89) + (con integer 90) + (con integer 91) + (con integer 92) + (con integer 93) + (con integer 94) + (con integer 95) + (con integer 96) + (con integer 97) + (con integer 98) + (con integer 99) + (con integer 100) + (con integer 101) + (con integer 102) + (con integer 103) + (con integer 104) + (con integer 105) + (con integer 106) + (con integer 107) + (con integer 108) + (con integer 109) + (con integer 110) + (con integer 111) + (con integer 112) + (con integer 113) + (con integer 114) + (con integer 115) + (con integer 116) + (con integer 117) + (con integer 118) + (con integer 119) + (con integer 120) + (con integer 121) + (con integer 122) + (con integer 123) + (con integer 124) + (con integer 125) + (con integer 126) + (con integer 127) + (con integer 128) + (con integer 129) + (con integer 130))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__late_all_static_lifting_preserves_oversaturated_call_order.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__late_all_static_lifting_preserves_oversaturated_call_order.snap new file mode 100644 index 00000000..f58dab3c --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__late_all_static_lifting_preserves_oversaturated_call_order.snap @@ -0,0 +1,67 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/composition.rs +expression: semantic_snapshot(&fixture) +--- +--- unoptimized Core +letrec + loop#1 : int -> int -> int [static []] = \x#2 : int -> \n#3 : int -> case@Bool equalsInteger n#3 0 of + True -> x#2 + False -> let next#4 : int = subtractInteger n#3 1 in + let result#5 : int = trace "recurse" in loop#1 (case@Bool true of + True -> x#2 + False -> 0) next#4 in + addInteger result#5 1 +in +loop#1 42 3 +--- unoptimized UPLC +(program 1.1.0 + [(lam loop_1 [[loop_1 (con integer 42)] (con integer 3)]) + [(lam self_6 [self_6 self_6]) + (lam self_6 + (lam x_2 + (lam n_3 + (case + [[(builtin equalsInteger) n_3] (con integer 0)] + [(lam next_4 + [(lam result_5 [[(builtin addInteger) result_5] (con integer 1)]) + (force + [[(force (builtin trace)) (con string "recurse")] + (delay [[[self_6 self_6] (case (con bool True) (con integer 0) x_2)] next_4])])]) + [[(builtin subtractInteger) n_3] (con integer 1)]] + x_2))))]]) +--- optimized Core +letrec + worker#13 : @delay (int -> int) [static []] = \ -> delay (\n#8 : int -> let anf#11 : bool = equalsInteger n#8 0 in + case@Bool anf#11 of + True -> 42 + False -> let next#9 : int = subtractInteger n#8 1 in + let result#10 : int = trace "recurse" in let forced#14 : int -> int = force worker#13 in + forced#14 next#9 in + addInteger result#10 1) +in +let beta#15 : int -> int = force worker#13 in +beta#15 3 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_18 + [(lam worker_16 [(lam beta_17 [beta_17 (con integer 3)]) (force worker_16)]) + [(lam self_2 [self_2 self_2]) + (lam self_3 + (delay + (lam n_4 + [(lam anf_5 + (case + anf_5 + [(lam next_6 + [(lam result_12 [[(builtin addInteger) result_12] (con integer 1)]) + (force + [[builtin_18 (con string "recurse")] + (delay [(lam forced_7 [forced_7 next_6]) (force [self_3 self_3])])])]) + [[(builtin subtractInteger) n_4] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_4] (con integer 0)]])))]]) + (force (builtin trace))]) +--- result +(con integer 45) +--- logs +["recurse", "recurse", "recurse"] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__later_cleanup_and_signature_removal_reach_a_joint_fixed_point.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__later_cleanup_and_signature_removal_reach_a_joint_fixed_point.snap new file mode 100644 index 00000000..395d8858 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__later_cleanup_and_signature_removal_reach_a_joint_fixed_point.snap @@ -0,0 +1,27 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/composition.rs +expression: "format!(\"{}\\n--- second invocation\\n{}\\n--- second lowered\\n{}\",\nsemantic_snapshot(&fixture), pretty(twice), result.uplc)" +--- +--- unoptimized Core +let f#3 : int -> int -> int = \x#1 : int y#2 : int -> case@Bool true of + True -> y#2 + False -> x#1 in +addInteger (f#3 7 20) (f#3 7 22) +--- unoptimized UPLC +(program 1.1.0 + [(lam f_3 + [[(builtin addInteger) [[f_3 (con integer 7)] (con integer 20)]] + [[f_3 (con integer 7)] (con integer 22)]]) + (lam x_1 (lam y_2 (case (con bool True) x_1 y_2)))]) +--- optimized Core +42 +--- optimized UPLC +(program 1.1.0 (con integer 42)) +--- result +(con integer 42) +--- logs +[] +--- second invocation +42 +--- second lowered +(program 1.1.0 (con integer 42)) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__reachable_cycle_reaches_cleanup_fixed_point_without_execution.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__reachable_cycle_reaches_cleanup_fixed_point_without_execution.snap new file mode 100644 index 00000000..07bf2423 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__reachable_cycle_reaches_cleanup_fixed_point_without_execution.snap @@ -0,0 +1,37 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/composition.rs +expression: "crate::harness::pass_snapshot(&arena, core,\nformat!(\"--- recursive cleanup fixed point (not evaluated)\\n{}\",\npretty(after)))" +--- +--- unoptimized Core +letrec + loop#1 : int -> int [static []] = \n#2 : int -> trace "loop" in loop#1 n#2 +in +loop#1 0 +--- unoptimized UPLC +(program 1.1.0 + [(lam loop_1 [loop_1 (con integer 0)]) + [(lam self_3 [self_3 self_3]) + (lam self_3 + (lam n_2 + (force + [[(force (builtin trace)) (con string "loop")] (delay [[self_3 self_3] n_2])])))]]) +--- optimized Core +letrec + worker#5 : @delay int [static []] = \ -> delay (trace "loop" in force worker#5) +in +force worker#5 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_5 + [(lam worker_4 (force worker_4)) + [(lam self_2 [self_2 self_2]) + (lam self_3 + (delay + (force [[builtin_5 (con string "loop")] (delay (force [self_3 self_3]))])))]]) + (force (builtin trace))]) +--- isolated pass +--- recursive cleanup fixed point (not evaluated) +letrec + worker#5 : @delay int [static []] = \ -> delay (trace "loop" in force worker#5) +in +force worker#5 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__same_size_binding_reassociation_exposes_more_cleanup.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__same_size_binding_reassociation_exposes_more_cleanup.snap new file mode 100644 index 00000000..ea55d092 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__same_size_binding_reassociation_exposes_more_cleanup.snap @@ -0,0 +1,43 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/composition.rs +expression: "format!(\"{}\\n--- isolated before\\n{}\\n--- same-size reassociation\\n{}\\n--- cleanup fixed point\\n{}\\n--- lowered\\n{}\",\nsemantic_snapshot(&fixture), pretty(core), pretty(step), pretty(after),\nresult.uplc)" +--- +--- unoptimized Core +let f#3 : int -> int = let note#2 : int = trace "before" in 0 in +\x#1 : int -> x#1 in +f#3 42 +--- unoptimized UPLC +(program 1.1.0 + [(lam f_3 [f_3 (con integer 42)]) + [(lam note_2 (lam x_1 x_1)) + (force + [[(force (builtin trace)) (con string "before")] (delay (con integer 0))])]]) +--- optimized Core +let note#4 : int = trace "before" in 0 in +42 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_2 + [(lam note_1 (con integer 42)) + (force [[builtin_2 (con string "before")] (delay (con integer 0))])]) + (force (builtin trace))]) +--- result +(con integer 42) +--- logs +["before"] +--- isolated before +let f#3 : int -> int = let note#2 : int = trace "before" in 0 in +\x#1 : int -> x#1 in +f#3 42 +--- same-size reassociation +let note#2 : int = trace "before" in 0 in +let f#3 : int -> int = \x#1 : int -> x#1 in +f#3 42 +--- cleanup fixed point +let note#2 : int = trace "before" in 0 in +42 +--- lowered +(program 1.1.0 + [(lam note_2 (con integer 42)) + (force + [[(force (builtin trace)) (con string "before")] (delay (con integer 0))])]) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__static_argument_after_branch_cleanup.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__static_argument_after_branch_cleanup.snap new file mode 100644 index 00000000..d8eec428 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__static_argument_after_branch_cleanup.snap @@ -0,0 +1,53 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/composition.rs +expression: semantic_snapshot(&fixture) +--- +--- unoptimized Core +letrec + loop#1 : int -> int -> int [static []] = \x#2 : int n#3 : int -> case@Bool equalsInteger n#3 0 of + True -> x#2 + False -> let next#4 : int = subtractInteger n#3 1 in + loop#1 (case@Bool true of + True -> x#2 + False -> 0) next#4 +in +loop#1 42 3 +--- unoptimized UPLC +(program 1.1.0 + [(lam loop_1 [[loop_1 (con integer 42)] (con integer 3)]) + [(lam self_5 [self_5 self_5]) + (lam self_5 + (lam x_2 + (lam n_3 + (case + [[(builtin equalsInteger) n_3] (con integer 0)] + [(lam next_4 + [[[self_5 self_5] (case (con bool True) (con integer 0) x_2)] next_4]) + [[(builtin subtractInteger) n_3] (con integer 1)]] + x_2))))]]) +--- optimized Core +letrec + worker#12 : int -> int [static []] = \n#11 : int -> let anf#9 : bool = equalsInteger n#11 0 in + case@Bool anf#9 of + True -> 42 + False -> let next#8 : int = subtractInteger n#11 1 in + worker#12 next#8 +in +worker#12 3 +--- optimized UPLC +(program 1.1.0 + [(lam worker_10 [worker_10 (con integer 3)]) + [(lam self_3 [self_3 self_3]) + (lam self_4 + (lam n_5 + [(lam anf_6 + (case + anf_6 + [(lam next_7 [[self_4 self_4] next_7]) + [[(builtin subtractInteger) n_5] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_5] (con integer 0)]]))]]) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__static_argument_after_recursive_pruning.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__static_argument_after_recursive_pruning.snap new file mode 100644 index 00000000..89013b09 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__composition__static_argument_after_recursive_pruning.snap @@ -0,0 +1,58 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/composition.rs +expression: semantic_snapshot(&fixture) +--- +--- unoptimized Core +letrec + loop#1 : int -> int -> int [static []] = \x#2 : int n#3 : int -> case@Bool equalsInteger n#3 0 of + True -> x#2 + False -> let next#4 : int = subtractInteger n#3 1 in + loop#1 x#2 next#4 + unused#5 : int -> int -> int [static []] = \a#6 : int c#7 : int -> a#6 +in +loop#1 42 3 +--- unoptimized UPLC +(program 1.1.0 + [(lam dispatch_8 + [(lam loop_1 + [(lam unused_5 [[loop_1 (con integer 42)] (con integer 3)]) + (lam a_20 (lam c_21 [dispatch_8 (constr 1 dispatch_8 a_20 c_21)]))]) + (lam x_22 (lam n_23 [dispatch_8 (constr 0 dispatch_8 x_22 n_23)]))]) + (lam request_9 + (case + request_9 + (lam self_10 + (lam x_2 + (lam n_3 + (case + [[(builtin equalsInteger) n_3] (con integer 0)] + [(lam next_4 [self_10 (constr 0 self_10 x_2 next_4)]) + [[(builtin subtractInteger) n_3] (con integer 1)]] + x_2)))) + (lam self_15 (lam a_6 (lam c_7 a_6)))))]) +--- optimized Core +letrec + worker#17 : int -> int [static []] = \n#16 : int -> let anf#15 : bool = equalsInteger n#16 0 in + case@Bool anf#15 of + True -> 42 + False -> let next#12 : int = subtractInteger n#16 1 in + worker#17 next#12 +in +worker#17 3 +--- optimized UPLC +(program 1.1.0 + [(lam worker_8 [worker_8 (con integer 3)]) + [(lam self_3 [self_3 self_3]) + (lam self_4 + (lam n_5 + [(lam anf_6 + (case + anf_6 + [(lam next_7 [[self_4 self_4] next_7]) + [[(builtin subtractInteger) n_5] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_5] (con integer 0)]]))]]) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__addition.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__addition.snap new file mode 100644 index 00000000..13a9a152 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__addition.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +addInteger 20 22 +--- unoptimized UPLC +(program 1.1.0 [[(builtin addInteger) (con integer 20)] (con integer 22)]) +--- optimized Core +42 +--- optimized UPLC +(program 1.1.0 (con integer 42)) +--- result +(con integer 42) +--- logs +[] +--- budget +cpu: 181308, memory: 602 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__bound_arithmetic.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__bound_arithmetic.snap new file mode 100644 index 00000000..6dd1ed0b --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__bound_arithmetic.snap @@ -0,0 +1,21 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +let x#1 : 'erased = addInteger 20 22 in +multiplyInteger x#1 2 +--- unoptimized UPLC +(program 1.1.0 + [(lam x_1 [[(builtin multiplyInteger) x_1] (con integer 2)]) + [[(builtin addInteger) (con integer 20)] (con integer 22)]]) +--- optimized Core +84 +--- optimized UPLC +(program 1.1.0 (con integer 84)) +--- result +(con integer 84) +--- logs +[] +--- budget +cpu: 384261, memory: 1304 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_append.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_append.snap new file mode 100644 index 00000000..8ac74261 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_append.snap @@ -0,0 +1,19 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +appendByteString (con bytestring #6162) (con bytestring #6364) +--- unoptimized UPLC +(program 1.1.0 + [[(builtin appendByteString) (con bytestring #6162)] (con bytestring #6364)]) +--- optimized Core +(con bytestring #61626364) +--- optimized UPLC +(program 1.1.0 (con bytestring #61626364)) +--- result +(con bytestring #61626364) +--- logs +[] +--- budget +cpu: 81446, memory: 602 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_compare.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_compare.snap new file mode 100644 index 00000000..4bb4f4cf --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_compare.snap @@ -0,0 +1,20 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +lessThanByteString (con bytestring #616263) (con bytestring #616264) +--- unoptimized UPLC +(program 1.1.0 + [[(builtin lessThanByteString) (con bytestring #616263)] + (con bytestring #616264)]) +--- optimized Core +true +--- optimized UPLC +(program 1.1.0 (con bool True)) +--- result +(con bool True) +--- logs +[] +--- budget +cpu: 109173, memory: 601 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_length.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_length.snap new file mode 100644 index 00000000..f971aab5 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_length.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +lengthOfByteString (con bytestring #61626364) +--- unoptimized UPLC +(program 1.1.0 [(builtin lengthOfByteString) (con bytestring #61626364)]) +--- optimized Core +4 +--- optimized UPLC +(program 1.1.0 (con integer 4)) +--- result +(con integer 4) +--- logs +[] +--- budget +cpu: 70200, memory: 410 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_slice.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_slice.snap new file mode 100644 index 00000000..15f91243 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__byte_slice.snap @@ -0,0 +1,20 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +sliceByteString 1 2 (con bytestring #61626364) +--- unoptimized UPLC +(program 1.1.0 + [[[(builtin sliceByteString) (con integer 1)] (con integer 2)] + (con bytestring #61626364)]) +--- optimized Core +(con bytestring #6263) +--- optimized UPLC +(program 1.1.0 (con bytestring #6263)) +--- result +(con bytestring #6263) +--- logs +[] +--- budget +cpu: 132568, memory: 804 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__cold_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__cold_failure.snap new file mode 100644 index 00000000..cf1ee3d4 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__cold_failure.snap @@ -0,0 +1,24 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +case@Bool true of + True -> 7 + False -> divideInteger 7 0 +--- unoptimized UPLC +(program 1.1.0 + (case + (con bool True) + [[(builtin divideInteger) (con integer 7)] (con integer 0)] + (con integer 7))) +--- optimized Core +7 +--- optimized UPLC +(program 1.1.0 (con integer 7)) +--- result +(con integer 7) +--- logs +[] +--- budget +cpu: 48100, memory: 400 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__data_equal.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__data_equal.snap new file mode 100644 index 00000000..028a627c --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__data_equal.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +equalsData (con data (I 7)) (con data (I 7)) +--- unoptimized UPLC +(program 1.1.0 [[(builtin equalsData) (con data (I 7))] (con data (I 7))]) +--- optimized Core +true +--- optimized UPLC +(program 1.1.0 (con bool True)) +--- result +(con bool True) +--- logs +[] +--- budget +cpu: 1114643, memory: 601 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__decode_integer_data.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__decode_integer_data.snap new file mode 100644 index 00000000..a36f4a99 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__decode_integer_data.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +unIData (con data (I 7)) +--- unoptimized UPLC +(program 1.1.0 [(builtin unIData) (con data (I 7))]) +--- optimized Core +7 +--- optimized UPLC +(program 1.1.0 (con integer 7)) +--- result +(con integer 7) +--- logs +[] +--- budget +cpu: 68844, memory: 432 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__decode_utf8.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__decode_utf8.snap new file mode 100644 index 00000000..dd57e696 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__decode_utf8.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +decodeUtf8 (con bytestring #68c3a96c6c6f) +--- unoptimized UPLC +(program 1.1.0 [(builtin decodeUtf8) (con bytestring #68c3a96c6c6f)]) +--- optimized Core +"héllo" +--- optimized UPLC +(program 1.1.0 (con string "héllo")) +--- result +(con string "héllo") +--- logs +[] +--- budget +cpu: 140058, memory: 406 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__division.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__division.snap new file mode 100644 index 00000000..e893e242 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__division.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +divideInteger -7 3 +--- unoptimized UPLC +(program 1.1.0 [[(builtin divideInteger) (con integer -7)] (con integer 3)]) +--- optimized Core +-3 +--- optimized UPLC +(program 1.1.0 (con integer -3)) +--- result +(con integer -3) +--- logs +[] +--- budget +cpu: 212030, memory: 601 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__division_zero.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__division_zero.snap new file mode 100644 index 00000000..361c7763 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__division_zero.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +divideInteger 7 0 +--- unoptimized UPLC +(program 1.1.0 [[(builtin divideInteger) (con integer 7)] (con integer 0)]) +--- optimized Core +divideInteger 7 0 +--- optimized UPLC +(program 1.1.0 [[(builtin divideInteger) (con integer 7)] (con integer 0)]) +--- result +error: Runtime(DivisionByZero(7, 0)) +--- logs +[] +--- budget +cpu: 132030, memory: 101 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__empty_head.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__empty_head.snap new file mode 100644 index 00000000..0b23ffd9 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__empty_head.snap @@ -0,0 +1,19 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +headList (con (list integer) []) +--- unoptimized UPLC +(program 1.1.0 [(force (builtin headList)) (con (list integer) [])]) +--- optimized Core +headList (con (list integer) []) +--- optimized UPLC +(program 1.1.0 + [(lam builtin_1 [builtin_1 (con (list integer) [])]) (force (builtin headList))]) +--- result +error: Runtime(EmptyList([])) +--- logs +[] +--- budget +cpu: 83250, memory: 132 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__empty_tail.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__empty_tail.snap new file mode 100644 index 00000000..6c6f2de6 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__empty_tail.snap @@ -0,0 +1,19 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +tailList (con (list integer) []) +--- unoptimized UPLC +(program 1.1.0 [(force (builtin tailList)) (con (list integer) [])]) +--- optimized Core +tailList (con (list integer) []) +--- optimized UPLC +(program 1.1.0 + [(lam builtin_1 [builtin_1 (con (list integer) [])]) (force (builtin tailList))]) +--- result +error: Runtime(EmptyList([])) +--- logs +[] +--- budget +cpu: 81763, memory: 132 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__encode_utf8.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__encode_utf8.snap new file mode 100644 index 00000000..785160ac --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__encode_utf8.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +encodeUtf8 "สว\u{e31}สด\u{e35}" +--- unoptimized UPLC +(program 1.1.0 [(builtin encodeUtf8) (con string "สวัสดี")]) +--- optimized Core +(con bytestring #e0b8aae0b8a7e0b8b1e0b8aae0b894e0b8b5) +--- optimized UPLC +(program 1.1.0 (con bytestring #e0b8aae0b8a7e0b8b1e0b8aae0b894e0b8b5)) +--- result +(con bytestring #e0b8aae0b8a7e0b8b1e0b8aae0b894e0b8b5) +--- logs +[] +--- budget +cpu: 220784, memory: 412 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__expanding_data_list.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__expanding_data_list.snap new file mode 100644 index 00000000..e98a75ef --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__expanding_data_list.snap @@ -0,0 +1,21 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +unListData (con data (List [I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7])) +--- unoptimized UPLC +(program 1.1.0 + [(builtin unListData) + (con data (List [I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7, I 7]))]) +--- optimized Core +(con (list data) [(I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7)]) +--- optimized UPLC +(program 1.1.0 + (con (list data) [(I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7)])) +--- result +(con (list data) [(I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7)]) +--- logs +[] +--- budget +cpu: 74033, memory: 432 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__integer_data.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__integer_data.snap new file mode 100644 index 00000000..63f496ea --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__integer_data.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +iData 7 +--- unoptimized UPLC +(program 1.1.0 [(builtin iData) (con integer 7)]) +--- optimized Core +(con data (I 7)) +--- optimized UPLC +(program 1.1.0 (con data (I 7))) +--- result +(con data (I 7)) +--- logs +[] +--- budget +cpu: 63399, memory: 432 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__invalid_utf8.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__invalid_utf8.snap new file mode 100644 index 00000000..c87a6e4c --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__invalid_utf8.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +decodeUtf8 (con bytestring #ff) +--- unoptimized UPLC +(program 1.1.0 [(builtin decodeUtf8) (con bytestring #ff)]) +--- optimized Core +decodeUtf8 (con bytestring #ff) +--- optimized UPLC +(program 1.1.0 [(builtin decodeUtf8) (con bytestring #ff)]) +--- result +error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) })) +--- logs +[] +--- budget +cpu: 92058, memory: 106 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__large_input.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__large_input.snap new file mode 100644 index 00000000..78481f95 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__large_input.snap @@ -0,0 +1,22 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +appendByteString (con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a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2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a7a) +--- logs +[] +--- budget +cpu: 169849, memory: 1113 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_data.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_data.snap new file mode 100644 index 00000000..398b97d8 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_data.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +listData (con (list data) [(I 7)]) +--- unoptimized UPLC +(program 1.1.0 [(builtin listData) (con (list data) [(I 7)])]) +--- optimized Core +(con data (List [I 7])) +--- optimized UPLC +(program 1.1.0 (con data (List [I 7]))) +--- result +(con data (List [I 7])) +--- logs +[] +--- budget +cpu: 81952, memory: 432 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_head.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_head.snap new file mode 100644 index 00000000..ae965139 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_head.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +headList (con (list integer) [7, 8]) +--- unoptimized UPLC +(program 1.1.0 [(force (builtin headList)) (con (list integer) [7, 8])]) +--- optimized Core +7 +--- optimized UPLC +(program 1.1.0 (con integer 7)) +--- result +(con integer 7) +--- logs +[] +--- budget +cpu: 147250, memory: 532 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_null.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_null.snap new file mode 100644 index 00000000..2263e6b8 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_null.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +nullList (con (list integer) []) +--- unoptimized UPLC +(program 1.1.0 [(force (builtin nullList)) (con (list integer) [])]) +--- optimized Core +true +--- optimized UPLC +(program 1.1.0 (con bool True)) +--- result +(con bool True) +--- logs +[] +--- budget +cpu: 138533, memory: 532 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_tail.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_tail.snap new file mode 100644 index 00000000..342f6969 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__list_tail.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +tailList (con (list integer) [7, 8]) +--- unoptimized UPLC +(program 1.1.0 [(force (builtin tailList)) (con (list integer) [7, 8])]) +--- optimized Core +(con (list integer) [8]) +--- optimized UPLC +(program 1.1.0 (con (list integer) [8])) +--- result +(con (list integer) [8]) +--- logs +[] +--- budget +cpu: 145763, memory: 532 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__map_data.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__map_data.snap new file mode 100644 index 00000000..09733279 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__map_data.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +mapData (con (list (pair data data)) []) +--- unoptimized UPLC +(program 1.1.0 [(builtin mapData) (con (list (pair data data)) [])]) +--- optimized Core +(con data (Map [])) +--- optimized UPLC +(program 1.1.0 (con data (Map []))) +--- result +(con data (Map [])) +--- logs +[] +--- budget +cpu: 116346, memory: 432 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__nested_arithmetic.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__nested_arithmetic.snap new file mode 100644 index 00000000..16a66f11 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__nested_arithmetic.snap @@ -0,0 +1,21 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +multiplyInteger (addInteger 20 22) 2 +--- unoptimized UPLC +(program 1.1.0 + [[(builtin multiplyInteger) + [[(builtin addInteger) (con integer 20)] (con integer 22)]] + (con integer 2)]) +--- optimized Core +84 +--- optimized UPLC +(program 1.1.0 (con integer 84)) +--- result +(con integer 84) +--- logs +[] +--- budget +cpu: 336261, memory: 1004 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__pair_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__pair_first.snap new file mode 100644 index 00000000..3a4b9892 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__pair_first.snap @@ -0,0 +1,19 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +fstPair (con (pair integer bytestring) (7, #61)) +--- unoptimized UPLC +(program 1.1.0 + [(force (force (builtin fstPair))) (con (pair integer bytestring) (7, #61))]) +--- optimized Core +7 +--- optimized UPLC +(program 1.1.0 (con integer 7)) +--- result +(con integer 7) +--- logs +[] +--- budget +cpu: 221995, memory: 632 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__pair_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__pair_second.snap new file mode 100644 index 00000000..aa9f3781 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__pair_second.snap @@ -0,0 +1,19 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +sndPair (con (pair integer bytestring) (7, #61)) +--- unoptimized UPLC +(program 1.1.0 + [(force (force (builtin sndPair))) (con (pair integer bytestring) (7, #61))]) +--- optimized Core +(con bytestring #61) +--- optimized UPLC +(program 1.1.0 (con bytestring #61)) +--- result +(con bytestring #61) +--- logs +[] +--- budget +cpu: 222092, memory: 632 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__partial.snap new file mode 100644 index 00000000..e7aeb8bb --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__partial.snap @@ -0,0 +1,20 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +addInteger 7 1 +--- unoptimized UPLC +(program 1.1.0 [[(builtin addInteger) (con integer 7)] (con integer 1)]) +--- optimized Core +let anf#1 : 'erased = addInteger 7 in +anf#1 1 +--- optimized UPLC +(program 1.1.0 + [(lam anf_2 [anf_2 (con integer 1)]) [(builtin addInteger) (con integer 7)]]) +--- result +(con integer 8) +--- logs +[] +--- budget +cpu: 181308, memory: 602 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__repeated_call.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__repeated_call.snap new file mode 100644 index 00000000..0355f86f --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__repeated_call.snap @@ -0,0 +1,22 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +constr 0 (addInteger 20 22) (addInteger 20 22) (addInteger 20 22) +--- unoptimized UPLC +(program 1.1.0 + (constr 0 + [[(builtin addInteger) (con integer 20)] (con integer 22)] + [[(builtin addInteger) (con integer 20)] (con integer 22)] + [[(builtin addInteger) (con integer 20)] (con integer 22)])) +--- optimized Core +constr 0 42 42 42 +--- optimized UPLC +(program 1.1.0 (constr 0 (con integer 42) (con integer 42) (con integer 42))) +--- result +(constr 0 (con integer 42) (con integer 42) (con integer 42)) +--- logs +[] +--- budget +cpu: 559724, memory: 1706 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__repeated_literal_distinct_results.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__repeated_literal_distinct_results.snap new file mode 100644 index 00000000..cedcdd1c --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__repeated_literal_distinct_results.snap @@ -0,0 +1,28 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +constr 0 (appendString "prefixprefixprefixprefixprefixprefix" "x") (appendString "prefixprefixprefixprefixprefixprefix" "y") +--- unoptimized UPLC +(program 1.1.0 + (constr 0 + [[(builtin appendString) (con string "prefixprefixprefixprefixprefixprefix")] + (con string "x")] + [[(builtin appendString) (con string "prefixprefixprefixprefixprefixprefix")] + (con string "y")])) +--- optimized Core +constr 0 "prefixprefixprefixprefixprefixprefixx" "prefixprefixprefixprefixprefixprefixy" +--- optimized UPLC +(program 1.1.0 + (constr 0 + (con string "prefixprefixprefixprefixprefixprefixx") + (con string "prefixprefixprefixprefixprefixprefixy"))) +--- result +(constr 0 + (con string "prefixprefixprefixprefixprefixprefixx") + (con string "prefixprefixprefixprefixprefixprefixy")) +--- logs +[] +--- budget +cpu: 1257326, memory: 1226 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__selected_branch.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__selected_branch.snap new file mode 100644 index 00000000..d57484f2 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__selected_branch.snap @@ -0,0 +1,29 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +case@Bool equalsInteger 7 7 of + True -> trace "yes" in addInteger 20 22 + False -> trace "no" in error +--- unoptimized UPLC +(program 1.1.0 + (case + [[(builtin equalsInteger) (con integer 7)] (con integer 7)] + (force [[(force (builtin trace)) (con string "no")] (delay (error))]) + (force + [[(force (builtin trace)) (con string "yes")] + (delay [[(builtin addInteger) (con integer 20)] (con integer 22)])]))) +--- optimized Core +trace "yes" in 42 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_1 + (force [[builtin_1 (con string "yes")] (delay (con integer 42))])) + (force (builtin trace))]) +--- result +(con integer 42) +--- logs +["yes"] +--- budget +cpu: 501139, memory: 1935 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__serialise_data.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__serialise_data.snap new file mode 100644 index 00000000..9bcb0bb6 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__serialise_data.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +serialiseData (con data (I 7)) +--- unoptimized UPLC +(program 1.1.0 [(builtin serialiseData) (con data (I 7))]) +--- optimized Core +(con bytestring #07) +--- optimized UPLC +(program 1.1.0 (con bytestring #07)) +--- result +(con bytestring #07) +--- logs +[] +--- budget +cpu: 2070166, memory: 410 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__shared_prefix_distinct_results.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__shared_prefix_distinct_results.snap new file mode 100644 index 00000000..bddd69da --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__shared_prefix_distinct_results.snap @@ -0,0 +1,29 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +let prefix#2 : string = "prefixprefixprefixprefixprefixprefix" in +constr 0 (appendString prefix#2 "x") (appendString prefix#2 "y") +--- unoptimized UPLC +(program 1.1.0 + [(lam prefix_2 + (constr 0 + [[(builtin appendString) prefix_2] (con string "x")] + [[(builtin appendString) prefix_2] (con string "y")])) + (con string "prefixprefixprefixprefixprefixprefix")]) +--- optimized Core +constr 0 "prefixprefixprefixprefixprefixprefixx" "prefixprefixprefixprefixprefixprefixy" +--- optimized UPLC +(program 1.1.0 + (constr 0 + (con string "prefixprefixprefixprefixprefixprefixx") + (con string "prefixprefixprefixprefixprefixprefixy"))) +--- result +(constr 0 + (con string "prefixprefixprefixprefixprefixprefixx") + (con string "prefixprefixprefixprefixprefixprefixy")) +--- logs +[] +--- budget +cpu: 1305326, memory: 1526 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__strict_failure_order.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__strict_failure_order.snap new file mode 100644 index 00000000..d5871765 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__strict_failure_order.snap @@ -0,0 +1,29 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +addInteger (trace "first" in error) (divideInteger 7 0) +--- unoptimized UPLC +(program 1.1.0 + [[(builtin addInteger) + (force [[(force (builtin trace)) (con string "first")] (delay (error))])] + [[(builtin divideInteger) (con integer 7)] (con integer 0)]]) +--- optimized Core +let anf#1 : int = trace "first" in error in +let anf#2 : 'erased = divideInteger 7 0 in +addInteger anf#1 anf#2 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_5 + [(lam anf_3 + [(lam anf_4 [[(builtin addInteger) anf_3] anf_4]) + [[(builtin divideInteger) (con integer 7)] (con integer 0)]]) + (force [[builtin_5 (con string "first")] (delay (error))])]) + (force (builtin trace))]) +--- result +error: ExplicitErrorTerm +--- logs +["first"] +--- budget +cpu: 59598, memory: 132 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__string_append.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__string_append.snap new file mode 100644 index 00000000..e315bef8 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__string_append.snap @@ -0,0 +1,19 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +appendString "hello " "world" +--- unoptimized UPLC +(program 1.1.0 + [[(builtin appendString) (con string "hello ")] (con string "world")]) +--- optimized Core +"hello world" +--- optimized UPLC +(program 1.1.0 (con string "hello world")) +--- result +(con string "hello world") +--- logs +[] +--- budget +cpu: 201014, memory: 606 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__trace_before.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__trace_before.snap new file mode 100644 index 00000000..8b989fbb --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__trace_before.snap @@ -0,0 +1,24 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +trace "before" in addInteger 20 22 +--- unoptimized UPLC +(program 1.1.0 + (force + [[(force (builtin trace)) (con string "before")] + (delay [[(builtin addInteger) (con integer 20)] (con integer 22)])])) +--- optimized Core +trace "before" in 42 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_1 + (force [[builtin_1 (con string "before")] (delay (con integer 42))])) + (force (builtin trace))]) +--- result +(con integer 42) +--- logs +["before"] +--- budget +cpu: 352806, memory: 1334 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__trace_builtin.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__trace_builtin.snap new file mode 100644 index 00000000..c7eff3ea --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__trace_builtin.snap @@ -0,0 +1,21 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +trace "keep me" 7 +--- unoptimized UPLC +(program 1.1.0 + [[(force (builtin trace)) (con string "keep me")] (con integer 7)]) +--- optimized Core +trace "keep me" 7 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_1 [[builtin_1 (con string "keep me")] (con integer 7)]) + (force (builtin trace))]) +--- result +(con integer 7) +--- logs +["keep me"] +--- budget +cpu: 155598, memory: 732 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__unsupported_hash.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__unsupported_hash.snap new file mode 100644 index 00000000..00cbd87b --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__unsupported_hash.snap @@ -0,0 +1,19 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +sha2_256 (con bytestring #78) +--- unoptimized UPLC +(program 1.1.0 [(builtin sha2_256) (con bytestring #78)]) +--- optimized Core +(con bytestring #2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881) +--- optimized UPLC +(program 1.1.0 + (con bytestring #2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881)) +--- result +(con bytestring #2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881) +--- logs +[] +--- budget +cpu: 341340, memory: 404 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__wrong_data_variant.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__wrong_data_variant.snap new file mode 100644 index 00000000..3e273532 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__wrong_data_variant.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +unBData (con data (I 7)) +--- unoptimized UPLC +(program 1.1.0 [(builtin unBData) (con data (I 7))]) +--- optimized Core +unBData (con data (I 7)) +--- optimized UPLC +(program 1.1.0 [(builtin unBData) (con data (I 7))]) +--- result +error: Runtime(MalFormedData(Integer(7))) +--- logs +[] +--- budget +cpu: 100, memory: 100 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__wrong_integer_shape.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__wrong_integer_shape.snap new file mode 100644 index 00000000..1ab77ddc --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_fold__wrong_integer_shape.snap @@ -0,0 +1,18 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/constant_fold.rs +expression: fixture.snapshot() +--- +--- unoptimized Core +addInteger (con bytestring #78) 7 +--- unoptimized UPLC +(program 1.1.0 [[(builtin addInteger) (con bytestring #78)] (con integer 7)]) +--- optimized Core +addInteger (con bytestring #78) 7 +--- optimized UPLC +(program 1.1.0 [[(builtin addInteger) (con bytestring #78)] (con integer 7)]) +--- result +error: Runtime(TypeMismatch(Integer, ByteString([120]))) +--- logs +[] +--- budget +cpu: 100, memory: 100 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__different.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__different.snap index 66786b64..c7f583c6 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__different.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__different.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/constant_sharing.rs -assertion_line: 34 expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- uplc before\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nnash_plutus::pretty::term(before), nash_plutus::pretty::term(after),\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -11,15 +10,9 @@ addInteger (subtractInteger 100 1) (subtractInteger 99 2) [[(builtin subtractInteger) (con integer 100)] (con integer 1)]] [[(builtin subtractInteger) (con integer 99)] (con integer 2)]]) --- optimized Core -let anf#1 : int = subtractInteger 100 1 in -let anf#2 : int = subtractInteger 99 2 in -addInteger anf#1 anf#2 +196 --- optimized UPLC -(program 1.1.0 - [(lam anf_3 - [(lam anf_4 [[(builtin addInteger) anf_3] anf_4]) - [[(builtin subtractInteger) (con integer 99)] (con integer 2)]]) - [[(builtin subtractInteger) (con integer 100)] (con integer 1)]]) +(program 1.1.0 (con integer 196)) --- isolated pass --- uplc before [[(builtin addInteger) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__different_builtin.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__different_builtin.snap index 1a93d648..ae37df1a 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__different_builtin.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__different_builtin.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/constant_sharing.rs -assertion_line: 34 expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- uplc before\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nnash_plutus::pretty::term(before), nash_plutus::pretty::term(after),\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -11,15 +10,9 @@ addInteger (subtractInteger 100 1) (multiplyInteger 100 2) [[(builtin subtractInteger) (con integer 100)] (con integer 1)]] [[(builtin multiplyInteger) (con integer 100)] (con integer 2)]]) --- optimized Core -let anf#1 : int = subtractInteger 100 1 in -let anf#2 : int = multiplyInteger 100 2 in -addInteger anf#1 anf#2 +299 --- optimized UPLC -(program 1.1.0 - [(lam anf_3 - [(lam anf_4 [[(builtin addInteger) anf_3] anf_4]) - [[(builtin multiplyInteger) (con integer 100)] (con integer 2)]]) - [[(builtin subtractInteger) (con integer 100)] (con integer 1)]]) +(program 1.1.0 (con integer 299)) --- isolated pass --- uplc before [[(builtin addInteger) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__first_literal_only.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__first_literal_only.snap index 9281904e..323c3cb5 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__first_literal_only.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__first_literal_only.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/constant_sharing.rs -assertion_line: 34 expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- uplc before\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nnash_plutus::pretty::term(before), nash_plutus::pretty::term(after),\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -13,17 +12,9 @@ appendByteString (sliceByteString 1 2 (con bytestring #01020304)) (sliceByteStri [[[(builtin sliceByteString) (con integer 1)] (con integer 3)] (con bytestring #01020304)]]) --- optimized Core -let anf#1 : bytes = sliceByteString 1 2 (con bytestring #01020304) in -let anf#2 : bytes = sliceByteString 1 3 (con bytestring #01020304) in -appendByteString anf#1 anf#2 +(con bytestring #0203020304) --- optimized UPLC -(program 1.1.0 - [(lam partial_5 - [(lam anf_3 - [(lam anf_4 [[(builtin appendByteString) anf_3] anf_4]) - [[partial_5 (con integer 3)] (con bytestring #01020304)]]) - [[partial_5 (con integer 2)] (con bytestring #01020304)]]) - [(builtin sliceByteString) (con integer 1)]]) +(program 1.1.0 (con bytestring #0203020304)) --- isolated pass --- uplc before [[(builtin appendByteString) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__partial.snap index 97472456..2072f90c 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__partial.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/constant_sharing.rs -assertion_line: 34 expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- uplc before\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nnash_plutus::pretty::term(before), nash_plutus::pretty::term(after),\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -22,13 +21,9 @@ addInteger anf#5 anf#6 --- optimized UPLC (program 1.1.0 [(lam partial_9 - [(lam x_1 - [(lam y_2 - [(lam anf_7 - [(lam anf_8 [[(builtin addInteger) anf_7] anf_8]) [y_2 (con integer 2)]]) - [x_1 (con integer 1)]]) - partial_9]) - partial_9]) + [(lam anf_7 + [(lam anf_8 [[(builtin addInteger) anf_7] anf_8]) [partial_9 (con integer 2)]]) + [partial_9 (con integer 1)]]) [(builtin subtractInteger) (con integer 100)]]) --- isolated pass --- uplc before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__two_scopes.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__two_scopes.snap index 93a4236a..14ee3367 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__two_scopes.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__constant_sharing__two_scopes.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/constant_sharing.rs -assertion_line: 34 expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- uplc before\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\nnash_plutus::pretty::term(before), nash_plutus::pretty::term(after),\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -11,16 +10,9 @@ addInteger ((\x#1 : int -> subtractInteger 100 x#1) 1) ((\y#2 : int -> subtractI [(lam x_1 [[(builtin subtractInteger) (con integer 100)] x_1]) (con integer 1)]] [(lam y_2 [[(builtin subtractInteger) (con integer 100)] y_2]) (con integer 2)]]) --- optimized Core -let anf#5 : int = subtractInteger 100 1 in -let anf#6 : int = subtractInteger 100 2 in -addInteger anf#5 anf#6 +197 --- optimized UPLC -(program 1.1.0 - [(lam partial_3 - [(lam anf_1 - [(lam anf_2 [[(builtin addInteger) anf_1] anf_2]) [partial_3 (con integer 2)]]) - [partial_3 (con integer 1)]]) - [(builtin subtractInteger) (con integer 100)]]) +(program 1.1.0 (con integer 197)) --- isolated pass --- uplc before [[(builtin addInteger) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__live_mutual_cycle.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__live_mutual_cycle.snap index 67605097..987b68f9 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__live_mutual_cycle.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__live_mutual_cycle.snap @@ -54,11 +54,7 @@ in f#7 4 --- optimized UPLC (program 1.1.0 - [(lam dispatch_28 - [(lam f_30 - [(lam g_32 [f_30 (con integer 4)]) - (lam y_31 [dispatch_28 (constr 1 dispatch_28 y_31)])]) - (lam x_29 [dispatch_28 (constr 0 dispatch_28 x_29)])]) + [(lam dispatch_28 [dispatch_28 (constr 0 dispatch_28 (con integer 4))]) (lam request_19 (case request_19 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__partial.snap index c712f427..83e340a7 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__partial.snap @@ -25,11 +25,10 @@ f#1 40) 2 letrec f#6 : int -> int -> int [static []] = \x#8 : int y#9 : int -> addInteger x#8 y#9 in -let anf#11 : int -> int = f#6 40 in -anf#11 2 +f#6 40 2 --- optimized UPLC (program 1.1.0 - [(lam f_12 [(lam anf_13 [anf_13 (con integer 2)]) [f_12 (con integer 40)]]) + [(lam f_11 [[f_11 (con integer 40)] (con integer 2)]) [(lam self_4 [self_4 self_4]) (lam self_5 (lam x_7 (lam y_10 [[(builtin addInteger) x_7] y_10])))]]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__reachable_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__reachable_failure.snap index 56595997..0e4fcde8 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__reachable_failure.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__reachable_failure.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/dead_code.rs -assertion_line: 68 expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), baseline.uplc, pretty(after), candidate.uplc,\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -17,16 +16,16 @@ f#1 42 (force [[(force (builtin trace)) (con string "failure")] (delay (error))])))]]) --- optimized Core letrec - f#3 : int -> int [static []] = \x#4 : int -> trace "failure" in error + f#3 : @delay int [static []] = \ -> delay (trace "failure" in error) in -f#3 42 +force f#3 --- optimized UPLC (program 1.1.0 - [(lam builtin_9 - [(lam f_8 [f_8 (con integer 42)]) - [(lam self_5 [self_5 self_5]) - (lam self_6 - (lam x_7 (force [[builtin_9 (con string "failure")] (delay (error))])))]]) + [(lam builtin_6 + [(lam f_5 (force f_5)) + [(lam self_2 [self_2 self_2]) + (lam self_4 + (delay (force [[builtin_6 (con string "failure")] (delay (error))])))]]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__transitive.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__transitive.snap index 2c617bdb..ef8d2be2 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__transitive.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__dead_code__recursive__transitive.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/dead_code.rs -assertion_line: 68 expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), baseline.uplc, pretty(after), candidate.uplc,\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -39,11 +38,7 @@ f#9 42 --- optimized UPLC (program 1.1.0 [(lam builtin_25 - [(lam dispatch_20 - [(lam g_22 - [(lam f_24 [f_24 (con integer 42)]) - (lam x_23 [dispatch_20 (constr 1 dispatch_20 x_23)])]) - (lam y_21 [dispatch_20 (constr 0 dispatch_20 y_21)])]) + [(lam dispatch_20 [dispatch_20 (constr 1 dispatch_20 (con integer 42))]) (lam request_15 (case request_15 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__decode_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__decode_failure.snap index 48dd4dc8..42c96377 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__decode_failure.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__decode_failure.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData (unIData 1)) @@ -8,9 +8,13 @@ unIData (iData (unIData 1)) (program 1.1.0 [(builtin unIData) [(builtin iData) [(builtin unIData) (con integer 1)]]]) --- optimized Core -unIData 1 +let anf#1 : int = unIData 1 in +let anf#2 : Data = iData anf#1 in +anf#1 --- optimized UPLC -(program 1.1.0 [(builtin unIData) (con integer 1)]) +(program 1.1.0 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin iData) anf_3]]) + [(builtin unIData) (con integer 1)]]) --- isolated pass --- core before unIData (iData (unIData 1)) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__decoded.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__decoded.snap index a3564075..1b54276b 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__decoded.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__decoded.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData (unIData (con data (I 42)))) @@ -8,9 +8,9 @@ unIData (iData (unIData (con data (I 42)))) (program 1.1.0 [(builtin unIData) [(builtin iData) [(builtin unIData) (con data (I 42))]]]) --- optimized Core -unIData (con data (I 42)) +42 --- optimized UPLC -(program 1.1.0 [(builtin unIData) (con data (I 42))]) +(program 1.1.0 (con integer 42)) --- isolated pass --- core before unIData (iData (unIData (con data (I 42)))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__literal.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__literal.snap index 2475edde..40064868 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__literal.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__literal.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData 42) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__negative.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__negative.snap index f31da4eb..db2d22cf 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__negative.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__negative.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData -42) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__nested.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__nested.snap index 79e7228c..08e7cb07 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__nested.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__nested.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData (unIData (iData 42))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__partial.snap index 27cd4c5c..028076e5 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__partial.snap @@ -1,17 +1,15 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData 42) --- unoptimized UPLC (program 1.1.0 [(builtin unIData) [(builtin iData) (con integer 42)]]) --- optimized Core -let anf#1 : Data = iData 42 in -unIData anf#1 +unIData (con data (I 42)) --- optimized UPLC -(program 1.1.0 - [(lam anf_2 [(builtin unIData) anf_2]) [(builtin iData) (con integer 42)]]) +(program 1.1.0 [(builtin unIData) (con data (I 42))]) --- isolated pass --- core before unIData (iData 42) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_decode_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_decode_failure.snap index f7075f83..30bdc47f 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_decode_failure.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_decode_failure.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unBData (bData (unBData 0)) @@ -8,9 +8,13 @@ unBData (bData (unBData 0)) (program 1.1.0 [(builtin unBData) [(builtin bData) [(builtin unBData) (con integer 0)]]]) --- optimized Core -unBData 0 +let anf#1 : bytes = unBData 0 in +let anf#2 : Data = bData anf#1 in +anf#1 --- optimized UPLC -(program 1.1.0 [(builtin unBData) (con integer 0)]) +(program 1.1.0 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin bData) anf_3]]) + [(builtin unBData) (con integer 0)]]) --- isolated pass --- core before unBData (bData (unBData 0)) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_decoded.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_decoded.snap index eb0ad132..f5c74de8 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_decoded.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_decoded.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unBData (bData (unBData (con data (B #68656c6c6f)))) @@ -9,9 +9,9 @@ unBData (bData (unBData (con data (B #68656c6c6f)))) [(builtin unBData) [(builtin bData) [(builtin unBData) (con data (B #68656c6c6f))]]]) --- optimized Core -unBData (con data (B #68656c6c6f)) +(con bytestring #68656c6c6f) --- optimized UPLC -(program 1.1.0 [(builtin unBData) (con data (B #68656c6c6f))]) +(program 1.1.0 (con bytestring #68656c6c6f)) --- isolated pass --- core before unBData (bData (unBData (con data (B #68656c6c6f)))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_direct.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_direct.snap index 2fdf05d0..48120fda 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_direct.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_direct.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unBData (bData (con bytestring #68656c6c6f)) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_oversaturated.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_oversaturated.snap index 2974680e..2931dd61 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_oversaturated.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_oversaturated.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unBData (bData (con bytestring #68656c6c6f)) 1 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_partial.snap index cb110be4..dd24df51 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_partial.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unBData (bData (con bytestring #68656c6c6f)) @@ -8,12 +8,9 @@ unBData (bData (con bytestring #68656c6c6f)) (program 1.1.0 [(builtin unBData) [(builtin bData) (con bytestring #68656c6c6f)]]) --- optimized Core -let anf#1 : Data = bData (con bytestring #68656c6c6f) in -unBData anf#1 +unBData (con data (B #68656c6c6f)) --- optimized UPLC -(program 1.1.0 - [(lam anf_2 [(builtin unBData) anf_2]) - [(builtin bData) (con bytestring #68656c6c6f)]]) +(program 1.1.0 [(builtin unBData) (con data (B #68656c6c6f))]) --- isolated pass --- core before unBData (bData (con bytestring #68656c6c6f)) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_reverse.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_reverse.snap index a63e7f5a..5c18a5f3 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_reverse.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_reverse.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core bData (unBData (con data (B #68656c6c6f))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_trace.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_trace.snap index dec8a1c0..c61f2a4d 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_trace.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_bytes_trace.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unBData (bData (trace "operand" in (con bytestring #68656c6c6f))) @@ -12,12 +12,15 @@ unBData (bData (trace "operand" in (con bytestring #68656c6c6f))) [[(force (builtin trace)) (con string "operand")] (delay (con bytestring #68656c6c6f))])]]) --- optimized Core -trace "operand" in (con bytestring #68656c6c6f) +let anf#1 : bytes = trace "operand" in (con bytestring #68656c6c6f) in +let anf#2 : Data = bData anf#1 in +anf#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_1 - (force - [[builtin_1 (con string "operand")] (delay (con bytestring #68656c6c6f))])) + [(lam builtin_5 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin bData) anf_3]]) + (force + [[builtin_5 (con string "operand")] (delay (con bytestring #68656c6c6f))])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_bad_fields.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_bad_fields.snap index cf931787..25ebaf64 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_bad_fields.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_bad_fields.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core let tag#22 : int = 0 in @@ -19,11 +19,14 @@ sndPair (unConstrData constructor#23) --- optimized Core let fields#2 : list Data = false in let constructor#3 : Data = constrData 0 fields#2 in +let anf#4 : 'erased = unConstrData constructor#3 in fields#2 --- optimized UPLC (program 1.1.0 [(lam fields_1 - [(lam constructor_4 fields_1) [[(builtin constrData) (con integer 0)] fields_1]]) + [(lam constructor_5 + [(lam anf_6 fields_1) [(builtin unConstrData) constructor_5]]) + [[(builtin constrData) (con integer 0)] fields_1]]) (con bool False)]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_bad_tag.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_bad_tag.snap index 88d7c36c..891686cf 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_bad_tag.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_bad_tag.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core let tag#22 : int = false in @@ -22,15 +22,17 @@ fstPair (unConstrData constructor#23) let tag#1 : int = false in let fields#2 : list Data = trace "fields evaluated" in (con (list data) [(I 7)]) in let constructor#3 : Data = constrData tag#1 fields#2 in +let anf#4 : 'erased = unConstrData constructor#3 in tag#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_7 - [(lam tag_4 - [(lam fields_5 - [(lam constructor_6 tag_4) [[(builtin constrData) tag_4] fields_5]]) + [(lam builtin_9 + [(lam tag_5 + [(lam fields_6 + [(lam constructor_7 [(lam anf_8 tag_5) [(builtin unConstrData) constructor_7]]) + [[(builtin constrData) tag_5] fields_6]]) (force - [[builtin_7 (con string "fields evaluated")] (delay (con (list data) [(I 7)]))])]) + [[builtin_9 (con string "fields evaluated")] (delay (con (list data) [(I 7)]))])]) (con bool False)]) (force (builtin trace))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_fields.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_fields.snap index d16cfee8..1928480c 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_fields.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_fields.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core let tag#22 : int = 0 in @@ -19,17 +19,9 @@ sndPair payload#24 (con (list data) [(I 7)])]) (con integer 0)]) --- optimized Core -let fields#2 : list Data = (con (list data) [(I 7)]) in -let constructor#3 : Data = constrData 0 fields#2 in -let payload#4 : 'erased = unConstrData constructor#3 in -fields#2 +(con (list data) [(I 7)]) --- optimized UPLC -(program 1.1.0 - [(lam fields_1 - [(lam constructor_5 - [(lam payload_6 fields_1) [(builtin unConstrData) constructor_5]]) - [[(builtin constrData) (con integer 0)] fields_1]]) - (con (list data) [(I 7)])]) +(program 1.1.0 (con (list data) [(I 7)])) --- isolated pass --- core before let tag#22 : int = 0 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_known_reverse.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_known_reverse.snap index 83b06f38..bce8cab3 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_known_reverse.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_known_reverse.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core let constructor#23 : Data = (con data (Constr 3 [I 7])) in @@ -18,17 +18,12 @@ trace "after decoding" in constrData (fstPair payload#24) (sndPair payload#24) [(builtin unConstrData) constructor_23]]) (con data (Constr 3 [I 7]))]) --- optimized Core -let constructor#1 : Data = (con data (Constr 3 [I 7])) in -let payload#2 : 'erased = unConstrData constructor#1 in -trace "after decoding" in constructor#1 +trace "after decoding" in (con data (Constr 3 [I 7])) --- optimized UPLC (program 1.1.0 - [(lam builtin_5 - [(lam constructor_3 - [(lam payload_4 - (force [[builtin_5 (con string "after decoding")] (delay constructor_3)])) - [(builtin unConstrData) constructor_3]]) - (con data (Constr 3 [I 7]))]) + [(lam builtin_1 + (force + [[builtin_1 (con string "after decoding")] (delay (con data (Constr 3 [I 7])))])) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_rebuild.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_rebuild.snap index 39e761ee..208b8d13 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_rebuild.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_rebuild.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core let tag#22 : int = 0 in @@ -21,19 +21,9 @@ constrData (fstPair payload#24) (sndPair payload#24) (con (list data) [(I 7)])]) (con integer 0)]) --- optimized Core -let fields#2 : list Data = (con (list data) [(I 7)]) in -let constructor#3 : Data = constrData 0 fields#2 in -let payload#4 : 'erased = unConstrData constructor#3 in -constrData 0 fields#2 +(con data (Constr 0 [I 7])) --- optimized UPLC -(program 1.1.0 - [(lam partial_7 - [(lam fields_1 - [(lam constructor_5 - [(lam payload_6 [partial_7 fields_1]) [(builtin unConstrData) constructor_5]]) - [partial_7 fields_1]]) - (con (list data) [(I 7)])]) - [(builtin constrData) (con integer 0)]]) +(program 1.1.0 (con data (Constr 0 [I 7]))) --- isolated pass --- core before let tag#22 : int = 0 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_tag.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_tag.snap index 1a3113ef..347d4f06 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_tag.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_tag.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core let tag#22 : int = 0 in @@ -19,14 +19,9 @@ fstPair payload#24 (con (list data) [(I 7)])]) (con integer 0)]) --- optimized Core -let constructor#3 : Data = constrData 0 (con (list data) [(I 7)]) in -let payload#4 : 'erased = unConstrData constructor#3 in 0 --- optimized UPLC -(program 1.1.0 - [(lam constructor_1 - [(lam payload_2 (con integer 0)) [(builtin unConstrData) constructor_1]]) - [[(builtin constrData) (con integer 0)] (con (list data) [(I 7)])]]) +(program 1.1.0 (con integer 0)) --- isolated pass --- core before let tag#22 : int = 0 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_wrong_variant.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_wrong_variant.snap index 34037b7e..ea045d7d 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_wrong_variant.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_constructor_wrong_variant.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core let constructor#23 : Data = (con data (I 7)) in @@ -20,16 +20,26 @@ trace "after decoding" in constrData (fstPair payload#24) (sndPair payload#24) --- optimized Core let constructor#1 : Data = (con data (I 7)) in let payload#2 : 'erased = unConstrData constructor#1 in -trace "after decoding" in constructor#1 +trace "after decoding" in let anf#3 : int = fstPair payload#2 in +let anf#4 : list Data = sndPair payload#2 in +constructor#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_5 - [(lam constructor_3 - [(lam payload_4 - (force [[builtin_5 (con string "after decoding")] (delay constructor_3)])) - [(builtin unConstrData) constructor_3]]) - (con data (I 7))]) - (force (builtin trace))]) + [(lam builtin_9 + [(lam builtin_10 + [(lam builtin_11 + [(lam constructor_5 + [(lam payload_6 + (force + [[builtin_11 (con string "after decoding")] + (delay + [(lam anf_7 [(lam anf_8 constructor_5) [builtin_9 payload_6]]) + [builtin_10 payload_6]])])) + [(builtin unConstrData) constructor_5]]) + (con data (I 7))]) + (force (builtin trace))]) + (force (force (builtin fstPair)))]) + (force (force (builtin sndPair)))]) --- isolated pass --- core before let constructor#23 : Data = (con data (I 7)) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_decode_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_decode_failure.snap index 4a72fd21..6fa76a8c 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_decode_failure.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_decode_failure.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData (unIData 0)) @@ -8,9 +8,13 @@ unIData (iData (unIData 0)) (program 1.1.0 [(builtin unIData) [(builtin iData) [(builtin unIData) (con integer 0)]]]) --- optimized Core -unIData 0 +let anf#1 : int = unIData 0 in +let anf#2 : Data = iData anf#1 in +anf#1 --- optimized UPLC -(program 1.1.0 [(builtin unIData) (con integer 0)]) +(program 1.1.0 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin iData) anf_3]]) + [(builtin unIData) (con integer 0)]]) --- isolated pass --- core before unIData (iData (unIData 0)) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_decoded.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_decoded.snap index d4c0f245..0984b99e 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_decoded.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_decoded.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData (unIData (con data (I 7)))) @@ -8,9 +8,9 @@ unIData (iData (unIData (con data (I 7)))) (program 1.1.0 [(builtin unIData) [(builtin iData) [(builtin unIData) (con data (I 7))]]]) --- optimized Core -unIData (con data (I 7)) +7 --- optimized UPLC -(program 1.1.0 [(builtin unIData) (con data (I 7))]) +(program 1.1.0 (con integer 7)) --- isolated pass --- core before unIData (iData (unIData (con data (I 7)))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_direct.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_direct.snap index b3a468cd..135ff014 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_direct.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_direct.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData 7) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_oversaturated.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_oversaturated.snap index 8572d917..43d7fc5c 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_oversaturated.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_oversaturated.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData 7) 1 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_partial.snap index bbb6ca95..7d73db7b 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_partial.snap @@ -1,17 +1,15 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData 7) --- unoptimized UPLC (program 1.1.0 [(builtin unIData) [(builtin iData) (con integer 7)]]) --- optimized Core -let anf#1 : Data = iData 7 in -unIData anf#1 +unIData (con data (I 7)) --- optimized UPLC -(program 1.1.0 - [(lam anf_2 [(builtin unIData) anf_2]) [(builtin iData) (con integer 7)]]) +(program 1.1.0 [(builtin unIData) (con data (I 7))]) --- isolated pass --- core before unIData (iData 7) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_reverse.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_reverse.snap index cfa13fc5..7d039002 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_reverse.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_reverse.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core iData (unIData (con data (I 7))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_trace.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_trace.snap index 323cb955..f22b4803 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_trace.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_integer_trace.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData (trace "operand" in 7)) @@ -11,11 +11,14 @@ unIData (iData (trace "operand" in 7)) (force [[(force (builtin trace)) (con string "operand")] (delay (con integer 7))])]]) --- optimized Core -trace "operand" in 7 +let anf#1 : int = trace "operand" in 7 in +let anf#2 : Data = iData anf#1 in +anf#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_1 - (force [[builtin_1 (con string "operand")] (delay (con integer 7))])) + [(lam builtin_5 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin iData) anf_3]]) + (force [[builtin_5 (con string "operand")] (delay (con integer 7))])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_decode_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_decode_failure.snap index 4d2e0815..6356ad3e 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_decode_failure.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_decode_failure.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unListData (listData (unListData 0)) @@ -9,9 +9,13 @@ unListData (listData (unListData 0)) [(builtin unListData) [(builtin listData) [(builtin unListData) (con integer 0)]]]) --- optimized Core -unListData 0 +let anf#1 : list Data = unListData 0 in +let anf#2 : Data = listData anf#1 in +anf#1 --- optimized UPLC -(program 1.1.0 [(builtin unListData) (con integer 0)]) +(program 1.1.0 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin listData) anf_3]]) + [(builtin unListData) (con integer 0)]]) --- isolated pass --- core before unListData (listData (unListData 0)) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_decoded.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_decoded.snap index f1c64c9a..984cdc08 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_decoded.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_decoded.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unListData (listData (unListData (con data (List [I 7])))) @@ -9,9 +9,9 @@ unListData (listData (unListData (con data (List [I 7])))) [(builtin unListData) [(builtin listData) [(builtin unListData) (con data (List [I 7]))]]]) --- optimized Core -unListData (con data (List [I 7])) +(con (list data) [(I 7)]) --- optimized UPLC -(program 1.1.0 [(builtin unListData) (con data (List [I 7]))]) +(program 1.1.0 (con (list data) [(I 7)])) --- isolated pass --- core before unListData (listData (unListData (con data (List [I 7])))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_direct.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_direct.snap index 0e42a8ec..09276387 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_direct.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_direct.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unListData (listData (con (list data) [(I 7)])) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_oversaturated.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_oversaturated.snap index c6d39ffb..22f9e59e 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_oversaturated.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_oversaturated.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unListData (listData (con (list data) [(I 7)])) 1 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_partial.snap index c82d666e..5748dd8a 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_partial.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unListData (listData (con (list data) [(I 7)])) @@ -8,12 +8,9 @@ unListData (listData (con (list data) [(I 7)])) (program 1.1.0 [(builtin unListData) [(builtin listData) (con (list data) [(I 7)])]]) --- optimized Core -let anf#1 : Data = listData (con (list data) [(I 7)]) in -unListData anf#1 +unListData (con data (List [I 7])) --- optimized UPLC -(program 1.1.0 - [(lam anf_2 [(builtin unListData) anf_2]) - [(builtin listData) (con (list data) [(I 7)])]]) +(program 1.1.0 [(builtin unListData) (con data (List [I 7]))]) --- isolated pass --- core before unListData (listData (con (list data) [(I 7)])) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_reverse.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_reverse.snap index 668b787f..75f25624 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_reverse.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_reverse.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core listData (unListData (con data (List [I 7]))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_trace.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_trace.snap index 18a2b0ce..368e5186 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_trace.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_list_trace.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unListData (listData (trace "operand" in (con (list data) [(I 7)]))) @@ -12,11 +12,14 @@ unListData (listData (trace "operand" in (con (list data) [(I 7)]))) [[(force (builtin trace)) (con string "operand")] (delay (con (list data) [(I 7)]))])]]) --- optimized Core -trace "operand" in (con (list data) [(I 7)]) +let anf#1 : list Data = trace "operand" in (con (list data) [(I 7)]) in +let anf#2 : Data = listData anf#1 in +anf#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_1 - (force [[builtin_1 (con string "operand")] (delay (con (list data) [(I 7)]))])) + [(lam builtin_5 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin listData) anf_3]]) + (force [[builtin_5 (con string "operand")] (delay (con (list data) [(I 7)]))])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_decode_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_decode_failure.snap index 65a757ae..fd194316 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_decode_failure.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_decode_failure.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unMapData (mapData (unMapData 0)) @@ -8,9 +8,13 @@ unMapData (mapData (unMapData 0)) (program 1.1.0 [(builtin unMapData) [(builtin mapData) [(builtin unMapData) (con integer 0)]]]) --- optimized Core -unMapData 0 +let anf#1 : list (pair Data Data) = unMapData 0 in +let anf#2 : Data = mapData anf#1 in +anf#1 --- optimized UPLC -(program 1.1.0 [(builtin unMapData) (con integer 0)]) +(program 1.1.0 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin mapData) anf_3]]) + [(builtin unMapData) (con integer 0)]]) --- isolated pass --- core before unMapData (mapData (unMapData 0)) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_decoded.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_decoded.snap index 399579ad..13b82f5e 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_decoded.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_decoded.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unMapData (mapData (unMapData (con data (Map [(I 7, I 7)])))) @@ -9,9 +9,9 @@ unMapData (mapData (unMapData (con data (Map [(I 7, I 7)])))) [(builtin unMapData) [(builtin mapData) [(builtin unMapData) (con data (Map [(I 7, I 7)]))]]]) --- optimized Core -unMapData (con data (Map [(I 7, I 7)])) +(con (list (pair data data)) [((I 7), (I 7))]) --- optimized UPLC -(program 1.1.0 [(builtin unMapData) (con data (Map [(I 7, I 7)]))]) +(program 1.1.0 (con (list (pair data data)) [((I 7), (I 7))])) --- isolated pass --- core before unMapData (mapData (unMapData (con data (Map [(I 7, I 7)])))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_direct.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_direct.snap index 0ce171af..fab46699 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_direct.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_direct.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unMapData (mapData (con (list (pair data data)) [((I 7), (I 7))])) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_oversaturated.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_oversaturated.snap index ec9e8483..1ed7b89c 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_oversaturated.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_oversaturated.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unMapData (mapData (con (list (pair data data)) [((I 7), (I 7))])) 1 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_partial.snap index 54d20556..408b91fa 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_partial.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unMapData (mapData (con (list (pair data data)) [((I 7), (I 7))])) @@ -9,12 +9,9 @@ unMapData (mapData (con (list (pair data data)) [((I 7), (I 7))])) [(builtin unMapData) [(builtin mapData) (con (list (pair data data)) [((I 7), (I 7))])]]) --- optimized Core -let anf#1 : Data = mapData (con (list (pair data data)) [((I 7), (I 7))]) in -unMapData anf#1 +unMapData (con data (Map [(I 7, I 7)])) --- optimized UPLC -(program 1.1.0 - [(lam anf_2 [(builtin unMapData) anf_2]) - [(builtin mapData) (con (list (pair data data)) [((I 7), (I 7))])]]) +(program 1.1.0 [(builtin unMapData) (con data (Map [(I 7, I 7)]))]) --- isolated pass --- core before unMapData (mapData (con (list (pair data data)) [((I 7), (I 7))])) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_reverse.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_reverse.snap index 02a8b1ed..fd0f5923 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_reverse.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_reverse.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core mapData (unMapData (con data (Map [(I 7, I 7)]))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_trace.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_trace.snap index 69b23b26..b16b6edd 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_trace.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_map_trace.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unMapData (mapData (trace "operand" in (con (list (pair data data)) [((I 7), (I 7))]))) @@ -12,13 +12,16 @@ unMapData (mapData (trace "operand" in (con (list (pair data data)) [((I 7), (I [[(force (builtin trace)) (con string "operand")] (delay (con (list (pair data data)) [((I 7), (I 7))]))])]]) --- optimized Core -trace "operand" in (con (list (pair data data)) [((I 7), (I 7))]) +let anf#1 : list (pair Data Data) = trace "operand" in (con (list (pair data data)) [((I 7), (I 7))]) in +let anf#2 : Data = mapData anf#1 in +anf#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_1 - (force - [[builtin_1 (con string "operand")] - (delay (con (list (pair data data)) [((I 7), (I 7))]))])) + [(lam builtin_5 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin mapData) anf_3]]) + (force + [[builtin_5 (con string "operand")] + (delay (con (list (pair data data)) [((I 7), (I 7))]))])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_decode_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_decode_failure.snap index 00854b4a..fbb51f44 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_decode_failure.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_decode_failure.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core decodeUtf8 (encodeUtf8 (decodeUtf8 0)) @@ -9,9 +9,13 @@ decodeUtf8 (encodeUtf8 (decodeUtf8 0)) [(builtin decodeUtf8) [(builtin encodeUtf8) [(builtin decodeUtf8) (con integer 0)]]]) --- optimized Core -decodeUtf8 0 +let anf#1 : string = decodeUtf8 0 in +let anf#2 : bytes = encodeUtf8 anf#1 in +anf#1 --- optimized UPLC -(program 1.1.0 [(builtin decodeUtf8) (con integer 0)]) +(program 1.1.0 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin encodeUtf8) anf_3]]) + [(builtin decodeUtf8) (con integer 0)]]) --- isolated pass --- core before decodeUtf8 (encodeUtf8 (decodeUtf8 0)) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_decoded.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_decoded.snap index 9e5536bf..2d2fda9b 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_decoded.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_decoded.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core decodeUtf8 (encodeUtf8 (decodeUtf8 (con bytestring #68c3a96c6c6f))) @@ -9,9 +9,9 @@ decodeUtf8 (encodeUtf8 (decodeUtf8 (con bytestring #68c3a96c6c6f))) [(builtin decodeUtf8) [(builtin encodeUtf8) [(builtin decodeUtf8) (con bytestring #68c3a96c6c6f)]]]) --- optimized Core -decodeUtf8 (con bytestring #68c3a96c6c6f) +"héllo" --- optimized UPLC -(program 1.1.0 [(builtin decodeUtf8) (con bytestring #68c3a96c6c6f)]) +(program 1.1.0 (con string "héllo")) --- isolated pass --- core before decodeUtf8 (encodeUtf8 (decodeUtf8 (con bytestring #68c3a96c6c6f))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_direct.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_direct.snap index 053b1f33..55f9bd34 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_direct.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_direct.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core decodeUtf8 (encodeUtf8 "héllo") diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_oversaturated.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_oversaturated.snap index 32d61463..574ac9c8 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_oversaturated.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_oversaturated.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core decodeUtf8 (encodeUtf8 "héllo") 1 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_partial.snap index 93628b26..76c8f207 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_partial.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core decodeUtf8 (encodeUtf8 "héllo") @@ -8,12 +8,9 @@ decodeUtf8 (encodeUtf8 "héllo") (program 1.1.0 [(builtin decodeUtf8) [(builtin encodeUtf8) (con string "héllo")]]) --- optimized Core -let anf#1 : bytes = encodeUtf8 "héllo" in -decodeUtf8 anf#1 +decodeUtf8 (con bytestring #68c3a96c6c6f) --- optimized UPLC -(program 1.1.0 - [(lam anf_2 [(builtin decodeUtf8) anf_2]) - [(builtin encodeUtf8) (con string "héllo")]]) +(program 1.1.0 [(builtin decodeUtf8) (con bytestring #68c3a96c6c6f)]) --- isolated pass --- core before decodeUtf8 (encodeUtf8 "héllo") diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_reverse.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_reverse.snap index 87c80f54..c6c1ec0d 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_reverse.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_reverse.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core encodeUtf8 (decodeUtf8 (con bytestring #68c3a96c6c6f)) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_trace.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_trace.snap index cb0d3f83..426d5028 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_trace.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__representation_utf8_trace.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core decodeUtf8 (encodeUtf8 (trace "operand" in "héllo")) @@ -11,11 +11,14 @@ decodeUtf8 (encodeUtf8 (trace "operand" in "héllo")) (force [[(force (builtin trace)) (con string "operand")] (delay (con string "héllo"))])]]) --- optimized Core -trace "operand" in "héllo" +let anf#1 : string = trace "operand" in "héllo" in +let anf#2 : bytes = encodeUtf8 anf#1 in +anf#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_1 - (force [[builtin_1 (con string "operand")] (delay (con string "héllo"))])) + [(lam builtin_5 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin encodeUtf8) anf_3]]) + (force [[builtin_5 (con string "operand")] (delay (con string "héllo"))])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__reverse_valid.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__reverse_valid.snap index f09355f0..94cb5601 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__reverse_valid.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__reverse_valid.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core iData (unIData (con data (I 42))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__trace.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__trace.snap index 513f1af9..3a6dc389 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__trace.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__trace.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core unIData (iData (trace "before" in 42)) @@ -11,11 +11,14 @@ unIData (iData (trace "before" in 42)) (force [[(force (builtin trace)) (con string "before")] (delay (con integer 42))])]]) --- optimized Core -trace "before" in 42 +let anf#1 : int = trace "before" in 42 in +let anf#2 : Data = iData anf#1 in +anf#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_1 - (force [[builtin_1 (con string "before")] (delay (con integer 42))])) + [(lam builtin_5 + [(lam anf_3 [(lam anf_4 anf_3) [(builtin iData) anf_3]]) + (force [[builtin_5 (con string "before")] (delay (con integer 42))])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__unknown_valid.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__unknown_valid.snap index 7377febb..48361ce3 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__unknown_valid.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__inverse__unknown_valid.snap @@ -1,6 +1,6 @@ --- source: crates/nash-codegen/src/optimizer_tests/inverse.rs -expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" +expression: "format!(\"{}\\n--- isolated pass\\n{}\", fixture.code_snapshot(),\nformat!(\"--- core before\\n{}\\n--- uplc before\\n{}\\n--- core after\\n{}\\n--- uplc after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), left.uplc, pretty(after), right.uplc, right.result,\nright.logs))" --- --- unoptimized Core (\x#1 : int -> unIData (iData x#1)) 42 @@ -8,11 +8,9 @@ expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core (program 1.1.0 [(lam x_1 [(builtin unIData) [(builtin iData) x_1]]) (con integer 42)]) --- optimized Core -let anf#3 : Data = iData 42 in -unIData anf#3 +42 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unIData) anf_1]) [(builtin iData) (con integer 42)]]) +(program 1.1.0 (con integer 42)) --- isolated pass --- core before (\x#1 : int -> unIData (iData x#1)) 42 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__field_order.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__field_order.snap index 2f32fe8b..d93cdb0b 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__field_order.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__field_order.snap @@ -21,16 +21,17 @@ case@Tag constr 1 (trace "first" in 50) (trace "second" in 8) of [[(force (builtin trace)) (con string "body")] (delay [[(builtin subtractInteger) x_1] y_2])]))))) --- optimized Core -let x#3 : int = trace "first" in 50 in -let y#4 : int = trace "second" in 8 in -trace "body" in subtractInteger x#3 y#4 +let anf#5 : int = trace "first" in 50 in +let anf#6 : int = trace "second" in 8 in +trace "body" in subtractInteger anf#5 anf#6 --- optimized UPLC (program 1.1.0 [(lam builtin_3 - [(lam x_1 - [(lam y_2 + [(lam anf_1 + [(lam anf_2 (force - [[builtin_3 (con string "body")] (delay [[(builtin subtractInteger) x_1] y_2])])) + [[builtin_3 (con string "body")] + (delay [[(builtin subtractInteger) anf_1] anf_2])])) (force [[builtin_3 (con string "second")] (delay (con integer 8))])]) (force [[builtin_3 (con string "first")] (delay (con integer 50))])]) (force (builtin trace))]) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__ignored_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__ignored_failure.snap index 69f9f969..7e8bdc82 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__ignored_failure.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__ignored_failure.snap @@ -16,15 +16,14 @@ case@Tag constr 0 (trace "first" in error) (trace "second" in 0) of (lam ignored_2 (force [[(force (builtin trace)) (con string "body")] (delay (con integer 42))]))))) --- optimized Core -let ignored#3 : int = trace "first" in error in -let ignored#4 : int = trace "second" in 0 in +let anf#5 : int = trace "first" in error in +let anf#6 : int = trace "second" in 0 in trace "body" in 42 --- optimized UPLC (program 1.1.0 [(lam builtin_3 - [(lam ignored_1 - [(lam ignored_2 - (force [[builtin_3 (con string "body")] (delay (con integer 42))])) + [(lam anf_1 + [(lam anf_2 (force [[builtin_3 (con string "body")] (delay (con integer 42))])) (force [[builtin_3 (con string "second")] (delay (con integer 0))])]) (force [[builtin_3 (con string "first")] (delay (error))])]) (force (builtin trace))]) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__returned_delay.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__returned_delay.snap index e4bc6101..4d5d97e9 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__returned_delay.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__returned_delay.snap @@ -15,13 +15,13 @@ force (case@Tag constr 0 (trace "field" in 42) of (lam x_3 (delay (force [[(force (builtin trace)) (con string "body")] (delay x_3)])))))) --- optimized Core -let x#1 : int = trace "field" in 42 in -trace "body" in x#1 +let anf#2 : int = trace "field" in 42 in +trace "body" in anf#2 --- optimized UPLC (program 1.1.0 - [(lam builtin_3 - [(lam x_2 (force [[builtin_3 (con string "body")] (delay x_2)])) - (force [[builtin_3 (con string "field")] (delay (con integer 42))])]) + [(lam builtin_2 + [(lam anf_1 (force [[builtin_2 (con string "body")] (delay anf_1)])) + (force [[builtin_2 (con string "field")] (delay (con integer 42))])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__returned_function.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__returned_function.snap index 11afe614..46442770 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__returned_function.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__returned_function.snap @@ -16,14 +16,14 @@ expression: "crate::harness::pass_snapshot(b.arena, before,\nformat!(\"--- core (force [[(force (builtin trace)) (con string "argument")] (delay (con integer 0))])]) --- optimized Core -let x#3 : int = trace "field" in 42 in -let anf#5 : int = trace "argument" in 0 in -trace "body" in x#3 +let anf#5 : int = trace "field" in 42 in +let anf#8 : int = trace "argument" in 0 in +trace "body" in anf#5 --- optimized UPLC (program 1.1.0 [(lam builtin_3 - [(lam x_1 - [(lam anf_2 (force [[builtin_3 (con string "body")] (delay x_1)])) + [(lam anf_1 + [(lam anf_2 (force [[builtin_3 (con string "body")] (delay anf_1)])) (force [[builtin_3 (con string "argument")] (delay (con integer 0))])]) (force [[builtin_3 (con string "field")] (delay (con integer 42))])]) (force (builtin trace))]) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__wildcard_one_field.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__wildcard_one_field.snap index 66ee8c07..3fa00400 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__wildcard_one_field.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__wildcard_one_field.snap @@ -16,13 +16,13 @@ case@Tag constr 1 (trace "field" in 0) of (lam ignored_4 (con integer 42)) (lam ignored_5 (lam ignored_6 (con integer 42))))) --- optimized Core -let ignored#1 : int = trace "field" in 0 in +let anf#4 : int = trace "field" in 0 in 42 --- optimized UPLC (program 1.1.0 - [(lam builtin_3 - [(lam ignored_2 (con integer 42)) - (force [[builtin_3 (con string "field")] (delay (con integer 0))])]) + [(lam builtin_2 + [(lam anf_1 (con integer 42)) + (force [[builtin_2 (con string "field")] (delay (con integer 0))])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__wildcard_two_fields.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__wildcard_two_fields.snap index 5d4e5993..463302e7 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__wildcard_two_fields.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__constructor__wildcard_two_fields.snap @@ -17,17 +17,17 @@ case@Tag constr 2 (trace "field" in 0) (trace "field" in 0) of (lam ignored_7 (con integer 42)) (lam ignored_8 (lam ignored_9 (con integer 42))))) --- optimized Core -let ignored#2 : int = trace "field" in 0 in -let ignored#3 : int = trace "field" in 0 in +let anf#4 : int = trace "field" in 0 in +let anf#5 : int = trace "field" in 0 in 42 --- optimized UPLC (program 1.1.0 - [(lam builtin_5 - [(lam partial_6 - [(lam ignored_1 - [(lam ignored_4 (con integer 42)) (force [partial_6 (delay (con integer 0))])]) - (force [partial_6 (delay (con integer 0))])]) - [builtin_5 (con string "field")]]) + [(lam builtin_3 + [(lam partial_4 + [(lam anf_1 + [(lam anf_2 (con integer 42)) (force [partial_4 (delay (con integer 0))])]) + (force [partial_4 (delay (con integer 0))])]) + [builtin_3 (con string "field")]]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__idata_subject.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__idata_subject.snap index 0e2a957c..b4f76c93 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__idata_subject.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__idata_subject.snap @@ -15,11 +15,9 @@ case@Data iData 42 of (delay (error))])) [(builtin iData) (con integer 42)]]) --- optimized Core -let anf#3 : Data = iData 42 in 42 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 (con integer 42)) [(builtin iData) (con integer 42)]]) +(program 1.1.0 (con integer 42)) --- isolated pass --- isolated ANF input let anf#3 : Data = iData 42 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__returned_function.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__returned_function.snap index 56c42cc1..23109140 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__returned_function.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__returned_function.snap @@ -18,9 +18,9 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso (con data (I 40))] (con integer 2)]) --- optimized Core -addInteger 40 2 +42 --- optimized UPLC -(program 1.1.0 [[(builtin addInteger) (con integer 40)] (con integer 2)]) +(program 1.1.0 (con integer 42)) --- isolated pass --- isolated ANF input let anf#3 : int -> int = case@Data (con data (I 40)) of diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__traced_subject.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__traced_subject.snap index 440c039f..2093b9c0 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__traced_subject.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__traced_subject.snap @@ -26,9 +26,15 @@ case@Data anf#3 of [(lam anf_1 [(lam generated_5 (force - [[[[[[builtin_6 generated_5] (delay (error))] (delay (error))] (delay (error))] - (delay [(lam number_4 number_4) [(builtin unIData) generated_5]])] - (delay (error))])) + (case + (constr 0 + generated_5 + (delay (error)) + (delay (error)) + (delay (error)) + (delay [(builtin unIData) generated_5]) + (delay (error))) + builtin_6))) anf_1]) (force [[builtin_7 (con string "subject")] (delay (con data (I 42)))])]) (force (builtin trace))]) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_overapplied.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_overapplied.snap index bcace917..8c1f8139 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_overapplied.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_overapplied.snap @@ -15,23 +15,26 @@ case@Data bData (con bytestring #6e617368) 0 of (delay [(lam payload_5 payload_5) [(builtin unBData) generated_6]])])) [[(builtin bData) (con bytestring #6e617368)] (con integer 0)]]) --- optimized Core -let anf#2 : Data = bData (con bytestring #6e617368) in -let anf#3 : Data = anf#2 0 in +let anf#3 : Data = (con data (B #6e617368)) 0 in case@Data anf#3 of DataB payload#1 -> payload#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_8 - [(lam anf_4 - [(lam anf_5 - [(lam generated_7 - (force - [[[[[[builtin_8 generated_7] (delay (error))] (delay (error))] (delay (error))] - (delay (error))] - (delay [(lam payload_6 payload_6) [(builtin unBData) generated_7]])])) - anf_5]) - [anf_4 (con integer 0)]]) - [(builtin bData) (con bytestring #6e617368)]]) + [(lam builtin_6 + [(lam anf_2 + [(lam generated_5 + (force + (case + (constr 0 + generated_5 + (delay (error)) + (delay (error)) + (delay (error)) + (delay (error)) + (delay [(builtin unBData) generated_5])) + builtin_6))) + anf_2]) + [(con data (B #6e617368)) (con integer 0)]]) (force (builtin chooseData))]) --- isolated pass --- isolated ANF input diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_parameter_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_parameter_false.snap index 26ab15b7..a4d03c5f 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_parameter_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_parameter_false.snap @@ -18,12 +18,9 @@ case@Data bData (con bytestring #6e617368) of (delay [(lam payload_9 payload_9) [(builtin unBData) generated_10]])])) [(builtin bData) (con bytestring #6e617368)]]) --- optimized Core -let anf#2 : Data = bData (con bytestring #6e617368) in (con bytestring #6e617368) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 (con bytestring #6e617368)) - [(builtin bData) (con bytestring #6e617368)]]) +(program 1.1.0 (con bytestring #6e617368)) --- isolated pass --- isolated ANF input let anf#10 : Data = bData (con bytestring #6e617368) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_parameter_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_parameter_true.snap index 3a146243..4de5d270 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_parameter_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_parameter_true.snap @@ -20,12 +20,9 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso [(builtin bData) input_12]]) (con bytestring #6e617368)]) --- optimized Core -let anf#3 : Data = bData (con bytestring #6e617368) in (con bytestring #6e617368) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 (con bytestring #6e617368)) - [(builtin bData) (con bytestring #6e617368)]]) +(program 1.1.0 (con bytestring #6e617368)) --- isolated pass --- isolated ANF input (\input#12 : bytes -> let anf#14 : Data = bData input#12 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_partial.snap index 34cbb6e8..f453ab10 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_partial.snap @@ -22,9 +22,15 @@ case@Data bData of [(lam builtin_4 [(lam generated_3 (force - [[[[[[builtin_4 generated_3] (delay (error))] (delay (error))] (delay (error))] - (delay (error))] - (delay [(lam payload_2 payload_2) [(builtin unBData) generated_3]])])) + (case + (constr 0 + generated_3 + (delay (error)) + (delay (error)) + (delay (error)) + (delay (error)) + (delay [(builtin unBData) generated_3])) + builtin_4))) (builtin bData)]) (force (builtin chooseData))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_traced.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_traced.snap index f69665b1..dd6e7855 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_traced.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__bytes_traced.snap @@ -17,7 +17,7 @@ case@Data (trace "producer" in bData (con bytestring #6e617368)) of [[(force (builtin trace)) (con string "producer")] (delay [(builtin bData) (con bytestring #6e617368)])])]) --- optimized Core -let anf#2 : Data = trace "producer" in bData (con bytestring #6e617368) in +let anf#2 : Data = trace "producer" in (con data (B #6e617368)) in case@Data anf#2 of DataB payload#1 -> payload#1 --- optimized UPLC @@ -27,13 +27,17 @@ case@Data anf#2 of [(lam anf_3 [(lam generated_5 (force - [[[[[[builtin_6 generated_5] (delay (error))] (delay (error))] (delay (error))] - (delay (error))] - (delay [(lam payload_4 payload_4) [(builtin unBData) generated_5]])])) + (case + (constr 0 + generated_5 + (delay (error)) + (delay (error)) + (delay (error)) + (delay (error)) + (delay [(builtin unBData) generated_5])) + builtin_6))) anf_3]) - (force - [[builtin_7 (con string "producer")] - (delay [(builtin bData) (con bytestring #6e617368)])])]) + (force [[builtin_7 (con string "producer")] (delay (con data (B #6e617368)))])]) (force (builtin trace))]) (force (builtin chooseData))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_bare.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_bare.snap index b2b2614f..78424bbb 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_bare.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_bare.snap @@ -24,12 +24,15 @@ case@Data constrData of [(lam builtin_4 [(lam generated_3 (force - [[[[[[builtin_4 generated_3] - (delay [(lam pair_2 pair_2) [(builtin unConstrData) generated_3]])] - (delay (error))] - (delay (error))] - (delay (error))] - (delay (error))])) + (case + (constr 0 + generated_3 + (delay [(builtin unConstrData) generated_3]) + (delay (error)) + (delay (error)) + (delay (error)) + (delay (error))) + builtin_4))) (builtin constrData)]) (force (builtin chooseData))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_default_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_default_false.snap index 5e6c99d1..f88bbf2b 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_default_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_default_false.snap @@ -15,12 +15,9 @@ case@Data constrData 59 (con (list data) [(I 42)]) of (delay (error))])) [[(builtin constrData) (con integer 59)] (con (list data) [(I 42)])]]) --- optimized Core -let anf#3 : Data = constrData 59 (con (list data) [(I 42)]) in error --- optimized UPLC -(program 1.1.0 - [(lam anf_1 (error)) - [[(builtin constrData) (con integer 59)] (con (list data) [(I 42)])]]) +(program 1.1.0 (error)) --- isolated pass --- isolated ANF input let anf#2 : Data = constrData 59 (con (list data) [(I 42)]) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_default_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_default_true.snap index 1f6844ba..bdda8b3c 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_default_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_default_true.snap @@ -26,13 +26,11 @@ case@Data constrData 59 (con (list data) [(I 42)]) of [[(force (builtin trace)) (con string "default")] (delay (con integer 9))]))])) [[(builtin constrData) (con integer 59)] (con (list data) [(I 42)])]]) --- optimized Core -let anf#2 : Data = constrData 59 (con (list data) [(I 42)]) in trace "default" in 9 --- optimized UPLC (program 1.1.0 - [(lam builtin_2 - [(lam anf_1 (force [[builtin_2 (con string "default")] (delay (con integer 9))])) - [[(builtin constrData) (con integer 59)] (con (list data) [(I 42)])]]) + [(lam builtin_1 + (force [[builtin_1 (con string "default")] (delay (con integer 9))])) (force (builtin trace))]) --- isolated pass --- isolated ANF input diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_overapplied.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_overapplied.snap index 4c1264dc..22769f92 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_overapplied.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_overapplied.snap @@ -18,26 +18,26 @@ case@Data constrData 59 (con (list data) [(I 42)]) 0 of [[[(builtin constrData) (con integer 59)] (con (list data) [(I 42)])] (con integer 0)]]) --- optimized Core -let anf#2 : Data = constrData 59 (con (list data) [(I 42)]) in -let anf#3 : Data = anf#2 0 in +let anf#3 : Data = (con data (Constr 59 [I 42])) 0 in case@Data anf#3 of DataConstr pair#1 -> pair#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_8 - [(lam anf_4 - [(lam anf_5 - [(lam generated_7 - (force - [[[[[[builtin_8 generated_7] - (delay [(lam pair_6 pair_6) [(builtin unConstrData) generated_7]])] - (delay (error))] - (delay (error))] - (delay (error))] - (delay (error))])) - anf_5]) - [anf_4 (con integer 0)]]) - [[(builtin constrData) (con integer 59)] (con (list data) [(I 42)])]]) + [(lam builtin_6 + [(lam anf_2 + [(lam generated_5 + (force + (case + (constr 0 + generated_5 + (delay [(builtin unConstrData) generated_5]) + (delay (error)) + (delay (error)) + (delay (error)) + (delay (error))) + builtin_6))) + anf_2]) + [(con data (Constr 59 [I 42])) (con integer 0)]]) (force (builtin chooseData))]) --- isolated pass --- isolated ANF input diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_partial.snap index e6229c7b..5c313952 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_partial.snap @@ -26,12 +26,15 @@ case@Data anf#2 of [(lam anf_3 [(lam generated_5 (force - [[[[[[builtin_6 generated_5] - (delay [(lam pair_4 pair_4) [(builtin unConstrData) generated_5]])] - (delay (error))] - (delay (error))] - (delay (error))] - (delay (error))])) + (case + (constr 0 + generated_5 + (delay [(builtin unConstrData) generated_5]) + (delay (error)) + (delay (error)) + (delay (error)) + (delay (error))) + builtin_6))) anf_3]) [(builtin constrData) (con integer 59)]]) (force (builtin chooseData))]) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_producer.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_producer.snap index ad0e2674..b6b505ea 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_producer.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_producer.snap @@ -16,12 +16,9 @@ case@Data constrData 0 (con (list data) []) of (delay (con integer 42))])) [[(builtin constrData) (con integer 0)] (con (list data) [])]]) --- optimized Core -let anf#1 : Data = constrData 0 (con (list data) []) in 42 --- optimized UPLC -(program 1.1.0 - [(lam anf_2 (con integer 42)) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) +(program 1.1.0 (con integer 42)) --- isolated pass --- isolated ANF input let anf#5 : Data = constrData 0 (con (list data) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_false_parameter_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_false_parameter_false.snap index db1088f3..db1c9546 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_false_parameter_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_false_parameter_false.snap @@ -18,12 +18,9 @@ case@Data constrData 0 (con (list data) [(I 42)]) of (delay (force [[(force (builtin trace)) (con string "cold")] (delay (error))]))])) [[(builtin constrData) (con integer 0)] (con (list data) [(I 42)])]]) --- optimized Core -let anf#2 : Data = constrData 0 (con (list data) [(I 42)]) in -unConstrData anf#2 +(con (pair integer (list data)) (0, [(I 42)])) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 0)] (con (list data) [(I 42)])]]) +(program 1.1.0 (con (pair integer (list data)) (0, [(I 42)]))) --- isolated pass --- isolated ANF input let anf#4 : Data = constrData 0 (con (list data) [(I 42)]) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_false_parameter_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_false_parameter_true.snap index 0f3d792c..b4cde647 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_false_parameter_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_false_parameter_true.snap @@ -22,12 +22,9 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso (con integer 0)] (con (list data) [(I 42)])]) --- optimized Core -let anf#4 : Data = constrData 0 (con (list data) [(I 42)]) in -unConstrData anf#4 +(con (pair integer (list data)) (0, [(I 42)])) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 0)] (con (list data) [(I 42)])]]) +(program 1.1.0 (con (pair integer (list data)) (0, [(I 42)]))) --- isolated pass --- isolated ANF input (\tag#5 : int fields#6 : list Data -> let anf#8 : Data = constrData tag#5 fields#6 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_true_parameter_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_true_parameter_false.snap index 4db42cd8..e0fb576e 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_true_parameter_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_true_parameter_false.snap @@ -18,12 +18,9 @@ case@Data constrData 0 (con (list data) []) of (delay (force [[(force (builtin trace)) (con string "cold")] (delay (error))]))])) [[(builtin constrData) (con integer 0)] (con (list data) [])]]) --- optimized Core -let anf#2 : Data = constrData 0 (con (list data) []) in -unConstrData anf#2 +(con (pair integer (list data)) (0, [])) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) +(program 1.1.0 (con (pair integer (list data)) (0, []))) --- isolated pass --- isolated ANF input let anf#12 : Data = constrData 0 (con (list data) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_true_parameter_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_true_parameter_true.snap index a049afbf..e888e747 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_true_parameter_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_0_empty_true_parameter_true.snap @@ -22,12 +22,9 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso (con integer 0)] (con (list data) [])]) --- optimized Core -let anf#4 : Data = constrData 0 (con (list data) []) in -unConstrData anf#4 +(con (pair integer (list data)) (0, [])) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 0)] (con (list data) [])]]) +(program 1.1.0 (con (pair integer (list data)) (0, []))) --- isolated pass --- isolated ANF input (\tag#13 : int fields#14 : list Data -> let anf#16 : Data = constrData tag#13 fields#14 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_false_parameter_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_false_parameter_false.snap index 5e51a6cf..c6453c03 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_false_parameter_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_false_parameter_false.snap @@ -19,13 +19,10 @@ case@Data constrData 18446744073709551615 (con (list data) [(I 42)]) of [[(builtin constrData) (con integer 18446744073709551615)] (con (list data) [(I 42)])]]) --- optimized Core -let anf#2 : Data = constrData 18446744073709551615 (con (list data) [(I 42)]) in -unConstrData anf#2 +(con (pair integer (list data)) (18446744073709551615, [(I 42)])) --- optimized UPLC (program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 18446744073709551615)] - (con (list data) [(I 42)])]]) + (con (pair integer (list data)) (18446744073709551615, [(I 42)]))) --- isolated pass --- isolated ANF input let anf#36 : Data = constrData 18446744073709551615 (con (list data) [(I 42)]) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_false_parameter_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_false_parameter_true.snap index c3376a71..b49ace8c 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_false_parameter_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_false_parameter_true.snap @@ -22,13 +22,10 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso (con integer 18446744073709551615)] (con (list data) [(I 42)])]) --- optimized Core -let anf#4 : Data = constrData 18446744073709551615 (con (list data) [(I 42)]) in -unConstrData anf#4 +(con (pair integer (list data)) (18446744073709551615, [(I 42)])) --- optimized UPLC (program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 18446744073709551615)] - (con (list data) [(I 42)])]]) + (con (pair integer (list data)) (18446744073709551615, [(I 42)]))) --- isolated pass --- isolated ANF input (\tag#37 : int fields#38 : list Data -> let anf#40 : Data = constrData tag#37 fields#38 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_true_parameter_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_true_parameter_false.snap index ceed61e7..1d18b90f 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_true_parameter_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_true_parameter_false.snap @@ -18,12 +18,9 @@ case@Data constrData 18446744073709551615 (con (list data) []) of (delay (force [[(force (builtin trace)) (con string "cold")] (delay (error))]))])) [[(builtin constrData) (con integer 18446744073709551615)] (con (list data) [])]]) --- optimized Core -let anf#2 : Data = constrData 18446744073709551615 (con (list data) []) in -unConstrData anf#2 +(con (pair integer (list data)) (18446744073709551615, [])) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 18446744073709551615)] (con (list data) [])]]) +(program 1.1.0 (con (pair integer (list data)) (18446744073709551615, []))) --- isolated pass --- isolated ANF input let anf#44 : Data = constrData 18446744073709551615 (con (list data) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_true_parameter_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_true_parameter_true.snap index 21364a5e..3d2e5915 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_true_parameter_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_18446744073709551615_empty_true_parameter_true.snap @@ -22,12 +22,9 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso (con integer 18446744073709551615)] (con (list data) [])]) --- optimized Core -let anf#4 : Data = constrData 18446744073709551615 (con (list data) []) in -unConstrData anf#4 +(con (pair integer (list data)) (18446744073709551615, [])) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 18446744073709551615)] (con (list data) [])]]) +(program 1.1.0 (con (pair integer (list data)) (18446744073709551615, []))) --- isolated pass --- isolated ANF input (\tag#45 : int fields#46 : list Data -> let anf#48 : Data = constrData tag#45 fields#46 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_false_parameter_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_false_parameter_false.snap index 5b3019db..17afd7c0 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_false_parameter_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_false_parameter_false.snap @@ -18,12 +18,9 @@ case@Data constrData 59 (con (list data) [(I 42)]) of (delay (force [[(force (builtin trace)) (con string "cold")] (delay (error))]))])) [[(builtin constrData) (con integer 59)] (con (list data) [(I 42)])]]) --- optimized Core -let anf#2 : Data = constrData 59 (con (list data) [(I 42)]) in -unConstrData anf#2 +(con (pair integer (list data)) (59, [(I 42)])) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 59)] (con (list data) [(I 42)])]]) +(program 1.1.0 (con (pair integer (list data)) (59, [(I 42)]))) --- isolated pass --- isolated ANF input let anf#20 : Data = constrData 59 (con (list data) [(I 42)]) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_false_parameter_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_false_parameter_true.snap index 8b9f3b53..d45af356 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_false_parameter_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_false_parameter_true.snap @@ -22,12 +22,9 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso (con integer 59)] (con (list data) [(I 42)])]) --- optimized Core -let anf#4 : Data = constrData 59 (con (list data) [(I 42)]) in -unConstrData anf#4 +(con (pair integer (list data)) (59, [(I 42)])) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 59)] (con (list data) [(I 42)])]]) +(program 1.1.0 (con (pair integer (list data)) (59, [(I 42)]))) --- isolated pass --- isolated ANF input (\tag#21 : int fields#22 : list Data -> let anf#24 : Data = constrData tag#21 fields#22 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_true_parameter_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_true_parameter_false.snap index 70eb5b61..3ec76625 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_true_parameter_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_true_parameter_false.snap @@ -18,12 +18,9 @@ case@Data constrData 59 (con (list data) []) of (delay (force [[(force (builtin trace)) (con string "cold")] (delay (error))]))])) [[(builtin constrData) (con integer 59)] (con (list data) [])]]) --- optimized Core -let anf#2 : Data = constrData 59 (con (list data) []) in -unConstrData anf#2 +(con (pair integer (list data)) (59, [])) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 59)] (con (list data) [])]]) +(program 1.1.0 (con (pair integer (list data)) (59, []))) --- isolated pass --- isolated ANF input let anf#28 : Data = constrData 59 (con (list data) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_true_parameter_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_true_parameter_true.snap index 3d74f610..4ae1caff 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_true_parameter_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_tag_59_empty_true_parameter_true.snap @@ -22,12 +22,9 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso (con integer 59)] (con (list data) [])]) --- optimized Core -let anf#4 : Data = constrData 59 (con (list data) []) in -unConstrData anf#4 +(con (pair integer (list data)) (59, [])) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 [(builtin unConstrData) anf_1]) - [[(builtin constrData) (con integer 59)] (con (list data) [])]]) +(program 1.1.0 (con (pair integer (list data)) (59, []))) --- isolated pass --- isolated ANF input (\tag#29 : int fields#30 : list Data -> let anf#32 : Data = constrData tag#29 fields#30 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_traced.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_traced.snap index a09ef4f1..6cdd6968 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_traced.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__constr_traced.snap @@ -19,7 +19,7 @@ case@Data (trace "producer" in constrData 59 (con (list data) [(I 42)])) of [[(force (builtin trace)) (con string "producer")] (delay [[(builtin constrData) (con integer 59)] (con (list data) [(I 42)])])])]) --- optimized Core -let anf#2 : Data = trace "producer" in constrData 59 (con (list data) [(I 42)]) in +let anf#2 : Data = trace "producer" in (con data (Constr 59 [I 42])) in case@Data anf#2 of DataConstr pair#1 -> pair#1 --- optimized UPLC @@ -29,16 +29,18 @@ case@Data anf#2 of [(lam anf_3 [(lam generated_5 (force - [[[[[[builtin_6 generated_5] - (delay [(lam pair_4 pair_4) [(builtin unConstrData) generated_5]])] - (delay (error))] - (delay (error))] - (delay (error))] - (delay (error))])) + (case + (constr 0 + generated_5 + (delay [(builtin unConstrData) generated_5]) + (delay (error)) + (delay (error)) + (delay (error)) + (delay (error))) + builtin_6))) anf_3]) (force - [[builtin_7 (con string "producer")] - (delay [[(builtin constrData) (con integer 59)] (con (list data) [(I 42)])])])]) + [[builtin_7 (con string "producer")] (delay (con data (Constr 59 [I 42])))])]) (force (builtin trace))]) (force (builtin chooseData))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_overapplied.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_overapplied.snap index abb6c013..57cbad5b 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_overapplied.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_overapplied.snap @@ -15,23 +15,26 @@ case@Data iData 42 0 of (delay (error))])) [[(builtin iData) (con integer 42)] (con integer 0)]]) --- optimized Core -let anf#3 : Data = iData 42 in -let anf#4 : Data = anf#3 0 in +let anf#4 : Data = (con data (I 42)) 0 in case@Data anf#4 of DataI payload#2 -> payload#2 --- optimized UPLC (program 1.1.0 - [(lam builtin_8 + [(lam builtin_5 [(lam anf_1 - [(lam anf_5 - [(lam generated_7 - (force - [[[[[[builtin_8 generated_7] (delay (error))] (delay (error))] (delay (error))] - (delay [(lam payload_6 payload_6) [(builtin unIData) generated_7]])] - (delay (error))])) - anf_5]) - [anf_1 (con integer 0)]]) - [(builtin iData) (con integer 42)]]) + [(lam generated_4 + (force + (case + (constr 0 + generated_4 + (delay (error)) + (delay (error)) + (delay (error)) + (delay [(builtin unIData) generated_4]) + (delay (error))) + builtin_5))) + anf_1]) + [(con data (I 42)) (con integer 0)]]) (force (builtin chooseData))]) --- isolated pass --- isolated ANF input diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_parameter_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_parameter_false.snap index 6825f8b1..60b9d941 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_parameter_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_parameter_false.snap @@ -18,11 +18,9 @@ case@Data iData 42 of (delay (force [[(force (builtin trace)) (con string "cold")] (delay (error))]))])) [(builtin iData) (con integer 42)]]) --- optimized Core -let anf#2 : Data = iData 42 in 42 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 (con integer 42)) [(builtin iData) (con integer 42)]]) +(program 1.1.0 (con integer 42)) --- isolated pass --- isolated ANF input let anf#3 : Data = iData 42 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_parameter_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_parameter_true.snap index 55e13f6c..d5951219 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_parameter_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_parameter_true.snap @@ -20,11 +20,9 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso [(builtin iData) input_5]]) (con integer 42)]) --- optimized Core -let anf#3 : Data = iData 42 in 42 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 (con integer 42)) [(builtin iData) (con integer 42)]]) +(program 1.1.0 (con integer 42)) --- isolated pass --- isolated ANF input (\input#5 : int -> let anf#7 : Data = iData input#5 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_partial.snap index 288db772..9869dda2 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_partial.snap @@ -22,9 +22,15 @@ case@Data iData of [(lam builtin_3 [(lam generated_2 (force - [[[[[[builtin_3 generated_2] (delay (error))] (delay (error))] (delay (error))] - (delay [(lam payload_1 payload_1) [(builtin unIData) generated_2]])] - (delay (error))])) + (case + (constr 0 + generated_2 + (delay (error)) + (delay (error)) + (delay (error)) + (delay [(builtin unIData) generated_2]) + (delay (error))) + builtin_3))) (builtin iData)]) (force (builtin chooseData))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_traced.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_traced.snap index df416889..d4d55094 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_traced.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__integer_traced.snap @@ -17,7 +17,7 @@ case@Data (trace "producer" in iData 42) of [[(force (builtin trace)) (con string "producer")] (delay [(builtin iData) (con integer 42)])])]) --- optimized Core -let anf#3 : Data = trace "producer" in iData 42 in +let anf#3 : Data = trace "producer" in (con data (I 42)) in case@Data anf#3 of DataI payload#2 -> payload#2 --- optimized UPLC @@ -27,12 +27,17 @@ case@Data anf#3 of [(lam anf_1 [(lam generated_5 (force - [[[[[[builtin_6 generated_5] (delay (error))] (delay (error))] (delay (error))] - (delay [(lam payload_4 payload_4) [(builtin unIData) generated_5]])] - (delay (error))])) + (case + (constr 0 + generated_5 + (delay (error)) + (delay (error)) + (delay (error)) + (delay [(builtin unIData) generated_5]) + (delay (error))) + builtin_6))) anf_1]) - (force - [[builtin_7 (con string "producer")] (delay [(builtin iData) (con integer 42)])])]) + (force [[builtin_7 (con string "producer")] (delay (con data (I 42)))])]) (force (builtin trace))]) (force (builtin chooseData))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_cons_used_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_cons_used_false.snap index 1a65d42f..b66ff1c8 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_cons_used_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_cons_used_false.snap @@ -16,15 +16,9 @@ case@Data listData (mkCons (con data (I 42)) (con (list data) [])) of [(builtin listData) [[(force (builtin mkCons)) (con data (I 42))] (con (list data) [])]]]) --- optimized Core -let anf#2 : list Data = mkCons (con data (I 42)) (con (list data) []) in -let anf#3 : Data = listData anf#2 in (con (list data) []) --- optimized UPLC -(program 1.1.0 - [(lam builtin_5 - [(lam anf_1 [(lam anf_4 (con (list data) [])) [(builtin listData) anf_1]]) - [[builtin_5 (con data (I 42))] (con (list data) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 (con (list data) [])) --- isolated pass --- isolated ANF input let anf#20 : list Data = mkCons (con data (I 42)) (con (list data) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_cons_used_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_cons_used_true.snap index 68593863..baabf518 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_cons_used_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_cons_used_true.snap @@ -16,15 +16,9 @@ case@Data listData (mkCons (con data (I 42)) (con (list data) [])) of [(builtin listData) [[(force (builtin mkCons)) (con data (I 42))] (con (list data) [])]]]) --- optimized Core -let anf#2 : list Data = mkCons (con data (I 42)) (con (list data) []) in -let anf#3 : Data = listData anf#2 in -anf#2 +(con (list data) [(I 42)]) --- optimized UPLC -(program 1.1.0 - [(lam builtin_5 - [(lam anf_1 [(lam anf_4 anf_1) [(builtin listData) anf_1]]) - [[builtin_5 (con data (I 42))] (con (list data) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 (con (list data) [(I 42)])) --- isolated pass --- isolated ANF input let anf#23 : list Data = mkCons (con data (I 42)) (con (list data) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_empty_used_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_empty_used_false.snap index daab501a..2c21db62 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_empty_used_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_empty_used_false.snap @@ -15,11 +15,9 @@ case@Data listData (con (list data) []) of (delay (error))])) [(builtin listData) (con (list data) [])]]) --- optimized Core -let anf#2 : Data = listData (con (list data) []) in (con (list data) []) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 (con (list data) [])) [(builtin listData) (con (list data) [])]]) +(program 1.1.0 (con (list data) [])) --- isolated pass --- isolated ANF input let anf#14 : Data = listData (con (list data) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_empty_used_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_empty_used_true.snap index ef4f7bde..cfa01348 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_empty_used_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_empty_used_true.snap @@ -15,14 +15,9 @@ case@Data listData (con (list data) []) of (delay (error))])) [(builtin listData) (con (list data) [])]]) --- optimized Core -let data_operand#3 : list Data = (con (list data) []) in -let anf#2 : Data = listData data_operand#3 in -data_operand#3 +(con (list data) []) --- optimized UPLC -(program 1.1.0 - [(lam data_operand_1 - [(lam anf_4 data_operand_1) [(builtin listData) data_operand_1]]) - (con (list data) [])]) +(program 1.1.0 (con (list data) [])) --- isolated pass --- isolated ANF input let anf#17 : Data = listData (con (list data) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_nested_returned_function.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_nested_returned_function.snap index ec44d621..12f86f14 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_nested_returned_function.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_nested_returned_function.snap @@ -28,18 +28,9 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso [(builtin listData) (con (list data) [(I 42)])]] (con integer 7)]) --- optimized Core -let data_operand#10 : list Data = (con (list data) [(I 42)]) in -let anf#7 : Data = listData data_operand#10 in -let anf#8 : Data = listData data_operand#10 in -constr 0 data_operand#10 7 +constr 0 (con (list data) [(I 42)]) 7 --- optimized UPLC -(program 1.1.0 - [(lam data_operand_1 - [(lam anf_2 - [(lam anf_3 (constr 0 data_operand_1 (con integer 7))) - [(builtin listData) data_operand_1]]) - [(builtin listData) data_operand_1]]) - (con (list data) [(I 42)])]) +(program 1.1.0 (constr 0 (con (list data) [(I 42)]) (con integer 7))) --- isolated pass --- isolated ANF input let anf#4 : Data = listData (con (list data) [(I 42)]) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_overapplied.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_overapplied.snap index 5044af77..69466178 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_overapplied.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_overapplied.snap @@ -15,24 +15,26 @@ case@Data listData (con (list data) [(I 42)]) 0 of (delay (error))])) [[(builtin listData) (con (list data) [(I 42)])] (con integer 0)]]) --- optimized Core -let anf#2 : Data = listData (con (list data) [(I 42)]) in -let anf#3 : Data = anf#2 0 in +let anf#3 : Data = (con data (List [I 42])) 0 in case@Data anf#3 of DataList payload#1 -> payload#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_8 - [(lam anf_4 - [(lam anf_5 - [(lam generated_7 - (force - [[[[[[builtin_8 generated_7] (delay (error))] (delay (error))] - (delay [(lam payload_6 payload_6) [(builtin unListData) generated_7]])] - (delay (error))] - (delay (error))])) - anf_5]) - [anf_4 (con integer 0)]]) - [(builtin listData) (con (list data) [(I 42)])]]) + [(lam builtin_6 + [(lam anf_2 + [(lam generated_5 + (force + (case + (constr 0 + generated_5 + (delay (error)) + (delay (error)) + (delay [(builtin unListData) generated_5]) + (delay (error)) + (delay (error))) + builtin_6))) + anf_2]) + [(con data (List [I 42])) (con integer 0)]]) (force (builtin chooseData))]) --- isolated pass --- isolated ANF input diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_parameter_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_parameter_false.snap index eb2faa2f..1d28641a 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_parameter_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_parameter_false.snap @@ -18,14 +18,9 @@ case@Data listData (con (list data) [(I 42)]) of (delay (force [[(force (builtin trace)) (con string "cold")] (delay (error))]))])) [(builtin listData) (con (list data) [(I 42)])]]) --- optimized Core -let data_operand#3 : list Data = (con (list data) [(I 42)]) in -let anf#2 : Data = listData data_operand#3 in -data_operand#3 +(con (list data) [(I 42)]) --- optimized UPLC -(program 1.1.0 - [(lam data_operand_1 - [(lam anf_4 data_operand_1) [(builtin listData) data_operand_1]]) - (con (list data) [(I 42)])]) +(program 1.1.0 (con (list data) [(I 42)])) --- isolated pass --- isolated ANF input let anf#17 : Data = listData (con (list data) [(I 42)]) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_parameter_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_parameter_true.snap index 78f9a656..cf2f9a37 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_parameter_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_parameter_true.snap @@ -20,14 +20,9 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso [(builtin listData) input_19]]) (con (list data) [(I 42)])]) --- optimized Core -let data_operand#4 : list Data = (con (list data) [(I 42)]) in -let anf#3 : Data = listData data_operand#4 in -data_operand#4 +(con (list data) [(I 42)]) --- optimized UPLC -(program 1.1.0 - [(lam data_operand_1 - [(lam anf_2 data_operand_1) [(builtin listData) data_operand_1]]) - (con (list data) [(I 42)])]) +(program 1.1.0 (con (list data) [(I 42)])) --- isolated pass --- isolated ANF input (\input#19 : list Data -> let anf#21 : Data = listData input#19 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_partial.snap index 76b1f306..0ade7bf4 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_partial.snap @@ -22,10 +22,15 @@ case@Data listData of [(lam builtin_4 [(lam generated_3 (force - [[[[[[builtin_4 generated_3] (delay (error))] (delay (error))] - (delay [(lam payload_2 payload_2) [(builtin unListData) generated_3]])] - (delay (error))] - (delay (error))])) + (case + (constr 0 + generated_3 + (delay (error)) + (delay (error)) + (delay [(builtin unListData) generated_3]) + (delay (error)) + (delay (error))) + builtin_4))) (builtin listData)]) (force (builtin chooseData))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_producer.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_producer.snap index 6ad7cfb5..837d6eff 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_producer.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_producer.snap @@ -16,11 +16,9 @@ case@Data listData (con (list data) []) of (delay (con integer 42))])) [(builtin listData) (con (list data) [])]]) --- optimized Core -let anf#1 : Data = listData (con (list data) []) in 42 --- optimized UPLC -(program 1.1.0 - [(lam anf_2 (con integer 42)) [(builtin listData) (con (list data) [])]]) +(program 1.1.0 (con integer 42)) --- isolated pass --- isolated ANF input let anf#1 : Data = listData (con (list data) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_traced.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_traced.snap index 85832c32..d7239dbf 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_traced.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__list_traced.snap @@ -17,7 +17,7 @@ case@Data (trace "producer" in listData (con (list data) [(I 42)])) of [[(force (builtin trace)) (con string "producer")] (delay [(builtin listData) (con (list data) [(I 42)])])])]) --- optimized Core -let anf#2 : Data = trace "producer" in listData (con (list data) [(I 42)]) in +let anf#2 : Data = trace "producer" in (con data (List [I 42])) in case@Data anf#2 of DataList payload#1 -> payload#1 --- optimized UPLC @@ -27,14 +27,17 @@ case@Data anf#2 of [(lam anf_3 [(lam generated_5 (force - [[[[[[builtin_6 generated_5] (delay (error))] (delay (error))] - (delay [(lam payload_4 payload_4) [(builtin unListData) generated_5]])] - (delay (error))] - (delay (error))])) + (case + (constr 0 + generated_5 + (delay (error)) + (delay (error)) + (delay [(builtin unListData) generated_5]) + (delay (error)) + (delay (error))) + builtin_6))) anf_3]) - (force - [[builtin_7 (con string "producer")] - (delay [(builtin listData) (con (list data) [(I 42)])])])]) + (force [[builtin_7 (con string "producer")] (delay (con data (List [I 42])))])]) (force (builtin trace))]) (force (builtin chooseData))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_cons_used_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_cons_used_false.snap index 6234def0..7c9b0245 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_cons_used_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_cons_used_false.snap @@ -18,17 +18,9 @@ case@Data mapData (mkCons (con (pair data data) ((I 42), (I 42))) (con (list (pa [[(force (builtin mkCons)) (con (pair data data) ((I 42), (I 42)))] (con (list (pair data data)) [])]]]) --- optimized Core -let anf#2 : list (pair Data Data) = mkCons (con (pair data data) ((I 42), (I 42))) (con (list (pair data data)) []) in -let anf#3 : Data = mapData anf#2 in (con (list (pair data data)) []) --- optimized UPLC -(program 1.1.0 - [(lam builtin_5 - [(lam anf_1 - [(lam anf_4 (con (list (pair data data)) [])) [(builtin mapData) anf_1]]) - [[builtin_5 (con (pair data data) ((I 42), (I 42)))] - (con (list (pair data data)) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 (con (list (pair data data)) [])) --- isolated pass --- isolated ANF input let anf#68 : list (pair Data Data) = mkCons (con (pair data data) ((I 42), (I 42))) (con (list (pair data data)) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_cons_used_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_cons_used_true.snap index b3d0346b..2f54f328 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_cons_used_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_cons_used_true.snap @@ -18,16 +18,9 @@ case@Data mapData (mkCons (con (pair data data) ((I 42), (I 42))) (con (list (pa [[(force (builtin mkCons)) (con (pair data data) ((I 42), (I 42)))] (con (list (pair data data)) [])]]]) --- optimized Core -let anf#2 : list (pair Data Data) = mkCons (con (pair data data) ((I 42), (I 42))) (con (list (pair data data)) []) in -let anf#3 : Data = mapData anf#2 in -anf#2 +(con (list (pair data data)) [((I 42), (I 42))]) --- optimized UPLC -(program 1.1.0 - [(lam builtin_5 - [(lam anf_1 [(lam anf_4 anf_1) [(builtin mapData) anf_1]]) - [[builtin_5 (con (pair data data) ((I 42), (I 42)))] - (con (list (pair data data)) [])]]) - (force (builtin mkCons))]) +(program 1.1.0 (con (list (pair data data)) [((I 42), (I 42))])) --- isolated pass --- isolated ANF input let anf#71 : list (pair Data Data) = mkCons (con (pair data data) ((I 42), (I 42))) (con (list (pair data data)) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_empty_used_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_empty_used_false.snap index 979f46de..8f16b1a1 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_empty_used_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_empty_used_false.snap @@ -16,12 +16,9 @@ case@Data mapData (con (list (pair data data)) []) of (delay (error))])) [(builtin mapData) (con (list (pair data data)) [])]]) --- optimized Core -let anf#2 : Data = mapData (con (list (pair data data)) []) in (con (list (pair data data)) []) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 (con (list (pair data data)) [])) - [(builtin mapData) (con (list (pair data data)) [])]]) +(program 1.1.0 (con (list (pair data data)) [])) --- isolated pass --- isolated ANF input let anf#62 : Data = mapData (con (list (pair data data)) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_empty_used_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_empty_used_true.snap index 67a6c5ea..b29f429c 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_empty_used_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_empty_used_true.snap @@ -16,14 +16,9 @@ case@Data mapData (con (list (pair data data)) []) of (delay (error))])) [(builtin mapData) (con (list (pair data data)) [])]]) --- optimized Core -let data_operand#3 : list (pair Data Data) = (con (list (pair data data)) []) in -let anf#2 : Data = mapData data_operand#3 in -data_operand#3 +(con (list (pair data data)) []) --- optimized UPLC -(program 1.1.0 - [(lam data_operand_1 - [(lam anf_4 data_operand_1) [(builtin mapData) data_operand_1]]) - (con (list (pair data data)) [])]) +(program 1.1.0 (con (list (pair data data)) [])) --- isolated pass --- isolated ANF input let anf#65 : Data = mapData (con (list (pair data data)) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_nested_returned_function.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_nested_returned_function.snap index 5c5751d5..e94b3dfb 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_nested_returned_function.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_nested_returned_function.snap @@ -31,18 +31,12 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])]] (con integer 7)]) --- optimized Core -let data_operand#7 : list (pair Data Data) = (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))]) in -let anf#4 : Data = mapData data_operand#7 in -let anf#5 : Data = mapData data_operand#7 in -constr 0 data_operand#7 7 +constr 0 (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))]) 7 --- optimized UPLC (program 1.1.0 - [(lam data_operand_1 - [(lam anf_2 - [(lam anf_3 (constr 0 data_operand_1 (con integer 7))) - [(builtin mapData) data_operand_1]]) - [(builtin mapData) data_operand_1]]) - (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])]) + (constr 0 + (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))]) + (con integer 7))) --- isolated pass --- isolated ANF input let anf#11 : Data = mapData (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))]) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_overapplied.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_overapplied.snap index 59d03329..2961c353 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_overapplied.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_overapplied.snap @@ -18,26 +18,26 @@ case@Data mapData (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)) (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])] (con integer 0)]]) --- optimized Core -let anf#2 : Data = mapData (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))]) in -let anf#3 : Data = anf#2 0 in +let anf#3 : Data = (con data (Map [(I 42, I 7), (I 7, I 42), (I 42, I 42)])) 0 in case@Data anf#3 of DataMap payload#1 -> payload#1 --- optimized UPLC (program 1.1.0 - [(lam builtin_8 - [(lam anf_4 - [(lam anf_5 - [(lam generated_7 - (force - [[[[[[builtin_8 generated_7] (delay (error))] - (delay [(lam payload_6 payload_6) [(builtin unMapData) generated_7]])] - (delay (error))] - (delay (error))] - (delay (error))])) - anf_5]) - [anf_4 (con integer 0)]]) - [(builtin mapData) - (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])]]) + [(lam builtin_6 + [(lam anf_2 + [(lam generated_5 + (force + (case + (constr 0 + generated_5 + (delay (error)) + (delay [(builtin unMapData) generated_5]) + (delay (error)) + (delay (error)) + (delay (error))) + builtin_6))) + anf_2]) + [(con data (Map [(I 42, I 7), (I 7, I 42), (I 42, I 42)])) (con integer 0)]]) (force (builtin chooseData))]) --- isolated pass --- isolated ANF input diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_parameter_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_parameter_false.snap index 4330a21c..db7ab150 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_parameter_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_parameter_false.snap @@ -19,14 +19,10 @@ case@Data mapData (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)) [(builtin mapData) (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])]]) --- optimized Core -let data_operand#3 : list (pair Data Data) = (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))]) in -let anf#2 : Data = mapData data_operand#3 in -data_operand#3 +(con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))]) --- optimized UPLC (program 1.1.0 - [(lam data_operand_1 - [(lam anf_4 data_operand_1) [(builtin mapData) data_operand_1]]) - (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])]) + (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])) --- isolated pass --- isolated ANF input let anf#24 : Data = mapData (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))]) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_parameter_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_parameter_true.snap index 7b4e2ce2..4d1667b0 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_parameter_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_parameter_true.snap @@ -20,14 +20,10 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso [(builtin mapData) input_26]]) (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])]) --- optimized Core -let data_operand#4 : list (pair Data Data) = (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))]) in -let anf#3 : Data = mapData data_operand#4 in -data_operand#4 +(con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))]) --- optimized UPLC (program 1.1.0 - [(lam data_operand_1 - [(lam anf_2 data_operand_1) [(builtin mapData) data_operand_1]]) - (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])]) + (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])) --- isolated pass --- isolated ANF input (\input#26 : list (pair Data Data) -> let anf#28 : Data = mapData input#26 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_partial.snap index e157e613..419f9cce 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_partial.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_partial.snap @@ -23,11 +23,15 @@ case@Data mapData of [(lam builtin_4 [(lam generated_3 (force - [[[[[[builtin_4 generated_3] (delay (error))] - (delay [(lam payload_2 payload_2) [(builtin unMapData) generated_3]])] - (delay (error))] - (delay (error))] - (delay (error))])) + (case + (constr 0 + generated_3 + (delay (error)) + (delay [(builtin unMapData) generated_3]) + (delay (error)) + (delay (error)) + (delay (error))) + builtin_4))) (builtin mapData)]) (force (builtin chooseData))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_producer.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_producer.snap index 6bb2bc2f..b05fd212 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_producer.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_producer.snap @@ -16,12 +16,9 @@ case@Data mapData (con (list (pair data data)) []) of (delay (con integer 42))])) [(builtin mapData) (con (list (pair data data)) [])]]) --- optimized Core -let anf#1 : Data = mapData (con (list (pair data data)) []) in 42 --- optimized UPLC -(program 1.1.0 - [(lam anf_2 (con integer 42)) - [(builtin mapData) (con (list (pair data data)) [])]]) +(program 1.1.0 (con integer 42)) --- isolated pass --- isolated ANF input let anf#3 : Data = mapData (con (list (pair data data)) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_traced.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_traced.snap index 30c130e7..8d525aa3 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_traced.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__map_traced.snap @@ -20,7 +20,7 @@ case@Data (trace "producer" in mapData (con (list (pair data data)) [((I 42), (I [(builtin mapData) (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])])])]) --- optimized Core -let anf#2 : Data = trace "producer" in mapData (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))]) in +let anf#2 : Data = trace "producer" in (con data (Map [(I 42, I 7), (I 7, I 42), (I 42, I 42)])) in case@Data anf#2 of DataMap payload#1 -> payload#1 --- optimized UPLC @@ -30,17 +30,19 @@ case@Data anf#2 of [(lam anf_3 [(lam generated_5 (force - [[[[[[builtin_6 generated_5] (delay (error))] - (delay [(lam payload_4 payload_4) [(builtin unMapData) generated_5]])] - (delay (error))] - (delay (error))] - (delay (error))])) + (case + (constr 0 + generated_5 + (delay (error)) + (delay [(builtin unMapData) generated_5]) + (delay (error)) + (delay (error)) + (delay (error))) + builtin_6))) anf_3]) (force [[builtin_7 (con string "producer")] - (delay - [(builtin mapData) - (con (list (pair data data)) [((I 42), (I 7)), ((I 7), (I 42)), ((I 42), (I 42))])])])]) + (delay (con data (Map [(I 42, I 7), (I 7, I 42), (I 42, I 42)])))])]) (force (builtin trace))]) (force (builtin chooseData))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__nested_returned_function.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__nested_returned_function.snap index db2254b6..0c39800e 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__nested_returned_function.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__nested_returned_function.snap @@ -28,15 +28,9 @@ expression: "crate::harness::pass_snapshot(b.arena, original,\nformat!(\"--- iso [(builtin iData) (con integer 40)]] (con integer 2)]) --- optimized Core -let anf#7 : Data = iData 40 in -let anf#8 : Data = iData 40 in -addInteger 40 2 +42 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 - [(lam anf_2 [[(builtin addInteger) (con integer 40)] (con integer 2)]) - [(builtin iData) (con integer 40)]]) - [(builtin iData) (con integer 40)]]) +(program 1.1.0 (con integer 42)) --- isolated pass --- isolated ANF input let anf#4 : Data = iData 40 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__shared_long_bytes.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__shared_long_bytes.snap index ccd663b9..a0b724e7 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__shared_long_bytes.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrappers__shared_long_bytes.snap @@ -37,13 +37,10 @@ constr 0 (case@Data data#1 of (con bytestring #0707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707)]]) --- optimized Core let data_operand#12 : bytes = (con bytestring #0707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707) in -let data#5 : Data = bData data_operand#12 in constr 0 data_operand#12 data_operand#12 data_operand#12 --- optimized UPLC (program 1.1.0 - [(lam data_operand_1 - [(lam data_2 (constr 0 data_operand_1 data_operand_1 data_operand_1)) - [(builtin bData) data_operand_1]]) + [(lam data_operand_1 (constr 0 data_operand_1 data_operand_1 data_operand_1)) (con bytestring #0707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707)]) --- isolated pass --- isolated ANF input diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrong_subject.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrong_subject.snap index 38c38102..018013f3 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrong_subject.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__data__wrong_subject.snap @@ -22,9 +22,15 @@ case@Data 42 of [(lam builtin_3 [(lam generated_2 (force - [[[[[[builtin_3 generated_2] (delay (error))] (delay (error))] (delay (error))] - (delay [(lam number_1 number_1) [(builtin unIData) generated_2]])] - (delay (error))])) + (case + (constr 0 + generated_2 + (delay (error)) + (delay (error)) + (delay (error)) + (delay [(builtin unIData) generated_2]) + (delay (error))) + builtin_3))) (con integer 42)]) (force (builtin chooseData))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__list__bound_literal.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__list__bound_literal.snap index ab853015..75db8f8b 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__list__bound_literal.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__list__bound_literal.snap @@ -23,14 +23,9 @@ mkCons (addInteger (case@List alias2#15 of xs_13]) (con (list integer) [21, 7])]) --- optimized Core -let anf#10 : int = addInteger 21 21 in -mkCons anf#10 (con (list integer) [21, 7]) +(con (list integer) [42, 21, 7]) --- optimized UPLC -(program 1.1.0 - [(lam builtin_2 - [(lam anf_1 [[builtin_2 anf_1] (con (list integer) [21, 7])]) - [[(builtin addInteger) (con integer 21)] (con integer 21)]]) - (force (builtin mkCons))]) +(program 1.1.0 (con (list integer) [42, 21, 7])) --- isolated pass --- isolated ANF input let xs#13 : list int = (con (list integer) [21, 7]) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__list__oversaturated_cons.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__list__oversaturated_cons.snap index 1d09e298..f0cbc4ca 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__list__oversaturated_cons.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__list__oversaturated_cons.snap @@ -13,19 +13,14 @@ case@List mkCons 42 (con (list integer) []) 9 of (lam generated_2 (lam generated_1 (con integer 0))) (con integer 0))) --- optimized Core -let anf#1 : list int = mkCons 42 (con (list integer) []) in -let anf#2 : list int = anf#1 9 in +let anf#2 : list int = (con (list integer) [42]) 9 in case@List anf#2 of _ -> 0 --- optimized UPLC (program 1.1.0 - [(lam builtin_7 - [(lam anf_3 - [(lam anf_4 - (case anf_4 (lam generated_6 (lam generated_5 (con integer 0))) (con integer 0))) - [anf_3 (con integer 9)]]) - [[builtin_7 (con integer 42)] (con (list integer) [])]]) - (force (builtin mkCons))]) + [(lam anf_1 + (case anf_1 (lam generated_3 (lam generated_2 (con integer 0))) (con integer 0))) + [(con (list integer) [42]) (con integer 9)]]) --- isolated pass --- isolated ANF input let anf#2 : list int = mkCons 42 (con (list integer) []) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__effectful_subject.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__effectful_subject.snap index b3c42fbd..36809bef 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__effectful_subject.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__effectful_subject.snap @@ -22,12 +22,10 @@ case@Int anf#1 of (program 1.1.0 [(lam builtin_4 [(lam anf_2 - [(lam generated_3 - (case - [[(builtin equalsInteger) generated_3] (con integer 7)] - (error) - (con integer 42))) - anf_2]) + (case + [[(builtin equalsInteger) anf_2] (con integer 7)] + (error) + (con integer 42))) (force [[builtin_4 (con string "subject")] (delay (con integer 7))])]) (force (builtin trace))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_empty_bytes_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_empty_bytes_false.snap index c666f8a6..0401b242 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_empty_bytes_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_empty_bytes_false.snap @@ -9,7 +9,7 @@ case@Bytes (con bytestring #) of --- optimized Core case@Bytes (con bytestring #) of --- optimized UPLC -(program 1.1.0 [(lam generated_1 (error)) (con bytestring #)]) +(program 1.1.0 (error)) --- isolated pass --- core before case@Bytes (con bytestring #) of diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_negative_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_negative_false.snap index 5079fb85..3415b046 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_negative_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_negative_false.snap @@ -9,7 +9,7 @@ case@Int -7 of --- optimized Core case@Int -7 of --- optimized UPLC -(program 1.1.0 [(lam generated_1 (error)) (con integer -7)]) +(program 1.1.0 (error)) --- isolated pass --- core before case@Int -7 of diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_wrong_runtime_kind_false.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_wrong_runtime_kind_false.snap index 2d13821e..9901feb7 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_wrong_runtime_kind_false.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_wrong_runtime_kind_false.snap @@ -9,7 +9,7 @@ case@Int true of --- optimized Core case@Int true of --- optimized UPLC -(program 1.1.0 [(lam generated_1 (error)) (con bool True)]) +(program 1.1.0 (error)) --- isolated pass --- core before case@Int true of diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_wrong_runtime_kind_true.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_wrong_runtime_kind_true.snap index aaec9661..cfff1e64 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_wrong_runtime_kind_true.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__known_case__literal__empty_wrong_runtime_kind_true.snap @@ -11,7 +11,7 @@ case@Int true of case@Int true of _ -> 42 --- optimized UPLC -(program 1.1.0 [(lam generated_1 (con integer 42)) (con bool True)]) +(program 1.1.0 (con integer 42)) --- isolated pass --- core before case@Int true of diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__bad_decoder_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__bad_decoder_first.snap new file mode 100644 index 00000000..94cde01d --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__bad_decoder_first.snap @@ -0,0 +1,32 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair unConstrData (con data (I 7)) of + Pair x#17 y#18 -> x#17 +--- unoptimized UPLC +(program 1.1.0 + (case [(builtin unConstrData) (con data (I 7))] (lam x_17 (lam y_18 x_17)))) +--- optimized Core +let anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in +case@Pair anf#3 of + Pair x#1 y#2 -> x#1 +--- optimized UPLC +(program 1.1.0 + [(lam anf_4 (case anf_4 (lam x_5 (lam y_6 x_5)))) + [(builtin unConstrData) (con data (I 7))]]) +--- result +error: Runtime(MalFormedData(Integer(7))) +--- logs +[] +--- budget +cpu: 100, memory: 100 +--- isolated Core before +let anf#91 : pair int (list Data) = unConstrData (con data (I 7)) in +case@Pair anf#91 of + Pair x#17 y#18 -> x#17 +--- isolated Core after +let anf#91 : pair int (list Data) = unConstrData (con data (I 7)) in +case@Pair anf#91 of + Pair x#17 y#18 -> x#17 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__bad_decoder_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__bad_decoder_second.snap new file mode 100644 index 00000000..9bc8573d --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__bad_decoder_second.snap @@ -0,0 +1,32 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair unConstrData (con data (I 7)) of + Pair x#19 y#20 -> y#20 +--- unoptimized UPLC +(program 1.1.0 + (case [(builtin unConstrData) (con data (I 7))] (lam x_19 (lam y_20 y_20)))) +--- optimized Core +let anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in +case@Pair anf#3 of + Pair x#1 y#2 -> y#2 +--- optimized UPLC +(program 1.1.0 + [(lam anf_4 (case anf_4 (lam x_5 (lam y_6 y_6)))) + [(builtin unConstrData) (con data (I 7))]]) +--- result +error: Runtime(MalFormedData(Integer(7))) +--- logs +[] +--- budget +cpu: 100, memory: 100 +--- isolated Core before +let anf#92 : pair int (list Data) = unConstrData (con data (I 7)) in +case@Pair anf#92 of + Pair x#19 y#20 -> y#20 +--- isolated Core after +let anf#92 : pair int (list Data) = unConstrData (con data (I 7)) in +case@Pair anf#92 of + Pair x#19 y#20 -> y#20 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__body.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__body.snap new file mode 100644 index 00000000..76acb6d8 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__body.snap @@ -0,0 +1,50 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair (trace "subject" in (con (pair integer integer) (7, 8))) of + Pair x#33 y#34 -> trace "body" in addInteger x#33 1 +--- unoptimized UPLC +(program 1.1.0 + (case + (force + [[(force (builtin trace)) (con string "subject")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_33 + (lam y_34 + (force + [[(force (builtin trace)) (con string "body")] + (delay [[(builtin addInteger) x_33] (con integer 1)])]))))) +--- optimized Core +let anf#3 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#3 of + Pair x#1 y#2 -> trace "body" in addInteger x#1 1 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_7 + [(lam anf_4 + (case + anf_4 + (lam x_5 + (lam y_6 + (force + [[builtin_7 (con string "body")] + (delay [[(builtin addInteger) x_5] (con integer 1)])]))))) + (force + [[builtin_7 (con string "subject")] (delay (con (pair integer integer) (7, 8)))])]) + (force (builtin trace))]) +--- result +(con integer 8) +--- logs +["subject", "body"] +--- budget +cpu: 588304, memory: 2466 +--- isolated Core before +let anf#99 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#99 of + Pair x#33 y#34 -> trace "body" in addInteger x#33 1 +--- isolated Core after +let anf#99 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#99 of + Pair x#33 y#34 -> trace "body" in addInteger x#33 1 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__both.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__both.snap new file mode 100644 index 00000000..6b31e5f7 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__both.snap @@ -0,0 +1,39 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair (trace "subject" in (con (pair integer integer) (7, 8))) of + Pair x#35 y#36 -> addInteger x#35 y#36 +--- unoptimized UPLC +(program 1.1.0 + (case + (force + [[(force (builtin trace)) (con string "subject")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_35 (lam y_36 [[(builtin addInteger) x_35] y_36])))) +--- optimized Core +let anf#3 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#3 of + Pair x#1 y#2 -> addInteger x#1 y#2 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_7 + [(lam anf_4 (case anf_4 (lam x_5 (lam y_6 [[(builtin addInteger) x_5] y_6])))) + (force + [[builtin_7 (con string "subject")] (delay (con (pair integer integer) (7, 8)))])]) + (force (builtin trace))]) +--- result +(con integer 15) +--- logs +["subject"] +--- budget +cpu: 416806, memory: 1734 +--- isolated Core before +let anf#100 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#100 of + Pair x#35 y#36 -> addInteger x#35 y#36 +--- isolated Core after +let anf#100 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#100 of + Pair x#35 y#36 -> addInteger x#35 y#36 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__decoded_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__decoded_first.snap new file mode 100644 index 00000000..7ce07ed0 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__decoded_first.snap @@ -0,0 +1,32 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair unConstrData (con data (Constr 0 [])) of + Pair x#13 y#14 -> x#13 +--- unoptimized UPLC +(program 1.1.0 + (case + [(builtin unConstrData) (con data (Constr 0 []))] + (lam x_13 (lam y_14 x_13)))) +--- optimized Core +case@Pair (con (pair integer (list data)) (0, [])) of + Pair x#1 y#2 -> x#1 +--- optimized UPLC +(program 1.1.0 + (case (con (pair integer (list data)) (0, [])) (lam x_3 (lam y_4 x_3)))) +--- result +(con integer 0) +--- logs +[] +--- budget +cpu: 136688, memory: 832 +--- isolated Core before +let anf#89 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in +case@Pair anf#89 of + Pair x#13 y#14 -> x#13 +--- isolated Core after +let anf#89 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in +case@Pair anf#89 of + Pair x#13 y#14 -> x#13 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__decoded_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__decoded_second.snap new file mode 100644 index 00000000..d38c7584 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__decoded_second.snap @@ -0,0 +1,32 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair unConstrData (con data (Constr 0 [])) of + Pair x#15 y#16 -> y#16 +--- unoptimized UPLC +(program 1.1.0 + (case + [(builtin unConstrData) (con data (Constr 0 []))] + (lam x_15 (lam y_16 y_16)))) +--- optimized Core +case@Pair (con (pair integer (list data)) (0, [])) of + Pair x#1 y#2 -> y#2 +--- optimized UPLC +(program 1.1.0 + (case (con (pair integer (list data)) (0, [])) (lam x_3 (lam y_4 y_4)))) +--- result +(con (list data) []) +--- logs +[] +--- budget +cpu: 136688, memory: 832 +--- isolated Core before +let anf#90 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in +case@Pair anf#90 of + Pair x#15 y#16 -> y#16 +--- isolated Core after +let anf#90 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in +case@Pair anf#90 of + Pair x#15 y#16 -> y#16 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__default.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__default.snap new file mode 100644 index 00000000..c726d924 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__default.snap @@ -0,0 +1,16 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"--- isolated Core before\\n{}\\n--- UPLC before\\n{}\\n--- isolated Core after\\n{}\\n--- UPLC after\\n{}\",\npretty(before), lowered(before), pretty(after), lowered(after))" +--- +--- isolated Core before +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#1 y#2 -> x#1 + _ -> 0 +--- UPLC before +error: invalid Core case: pair branch must bind its two fields +--- isolated Core after +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#1 y#2 -> x#1 + _ -> 0 +--- UPLC after +error: invalid Core case: pair branch must bind its two fields diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__delay.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__delay.snap new file mode 100644 index 00000000..b4f9c81f --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__delay.snap @@ -0,0 +1,44 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +force (case@Pair (trace "subject" in (con (pair integer integer) (7, 8))) of + Pair x#39 y#40 -> delay x#39) +--- unoptimized UPLC +(program 1.1.0 + (force + (case + (force + [[(force (builtin trace)) (con string "subject")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_39 (lam y_40 (delay x_39)))))) +--- optimized Core +let anf#3 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +let anf#4 : @delay int = case@Pair anf#3 of + Pair x#1 y#2 -> delay x#1 in +force anf#4 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_9 + [(lam anf_5 + [(lam anf_8 (force anf_8)) (case anf_5 (lam x_6 (lam y_7 (delay x_6))))]) + (force + [[builtin_9 (con string "subject")] (delay (con (pair integer integer) (7, 8)))])]) + (force (builtin trace))]) +--- result +(con integer 7) +--- logs +["subject"] +--- budget +cpu: 283598, memory: 1532 +--- isolated Core before +let anf#102 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +let anf#103 : @delay int = case@Pair anf#102 of + Pair x#39 y#40 -> delay x#39 in +force anf#103 +--- isolated Core after +let anf#102 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +let anf#103 : @delay int = case@Pair anf#102 of + Pair x#39 y#40 -> delay x#39 in +force anf#103 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__field_type.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__field_type.snap new file mode 100644 index 00000000..d0621ccf --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__field_type.snap @@ -0,0 +1,26 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}--- isolated Core before\\n{}\\n--- UPLC before\\n{}\\n--- isolated Core after\\n{}\\n--- UPLC after\\n{}\",\nif pipeline.is_empty() { pipeline } else { format!(\"{pipeline}\\n\") },\npretty(before), lowered(before), pretty(after), lowered(after))" +--- +--- unoptimized Core +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#13 y#14 -> x#13 +--- unoptimized UPLC +(program 1.1.0 + (case (con (pair integer integer) (7, 8)) (lam x_13 (lam y_14 x_13)))) +--- optimized Core +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#1 y#2 -> x#1 +--- optimized UPLC +(program 1.1.0 + (case (con (pair integer integer) (7, 8)) (lam x_3 (lam y_4 x_3)))) +--- isolated Core before +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#13 y#14 -> x#13 +--- UPLC before +(case (con (pair integer integer) (7, 8)) (lam x_13 (lam y_14 x_13))) +--- isolated Core after +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#13 y#14 -> x#13 +--- UPLC after +(case (con (pair integer integer) (7, 8)) (lam x_13 (lam y_14 x_13))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__ignored_failure_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__ignored_failure_first.snap new file mode 100644 index 00000000..7133ac38 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__ignored_failure_first.snap @@ -0,0 +1,42 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair mkPairData (con data (I 7)) (trace "unused field" in error) of + Pair x#21 y#22 -> x#21 +--- unoptimized UPLC +(program 1.1.0 + (case + [[(builtin mkPairData) (con data (I 7))] + (force [[(force (builtin trace)) (con string "unused field")] (delay (error))])] + (lam x_21 (lam y_22 x_21)))) +--- optimized Core +let anf#3 : Data = trace "unused field" in error in +let anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in +case@Pair anf#4 of + Pair x#1 y#2 -> x#1 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_9 + [(lam anf_5 + [(lam anf_6 (case anf_6 (lam x_7 (lam y_8 x_7)))) + [[(builtin mkPairData) (con data (I 7))] anf_5]]) + (force [[builtin_9 (con string "unused field")] (delay (error))])]) + (force (builtin trace))]) +--- result +error: ExplicitErrorTerm +--- logs +["unused field"] +--- budget +cpu: 59598, memory: 132 +--- isolated Core before +let anf#93 : Data = trace "unused field" in error in +let anf#94 : pair Data Data = mkPairData (con data (I 7)) anf#93 in +case@Pair anf#94 of + Pair x#21 y#22 -> x#21 +--- isolated Core after +let anf#93 : Data = trace "unused field" in error in +let anf#94 : pair Data Data = mkPairData (con data (I 7)) anf#93 in +case@Pair anf#94 of + Pair x#21 y#22 -> x#21 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__ignored_failure_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__ignored_failure_second.snap new file mode 100644 index 00000000..6e4e41e0 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__ignored_failure_second.snap @@ -0,0 +1,42 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair mkPairData (con data (I 7)) (trace "unused field" in error) of + Pair x#23 y#24 -> y#24 +--- unoptimized UPLC +(program 1.1.0 + (case + [[(builtin mkPairData) (con data (I 7))] + (force [[(force (builtin trace)) (con string "unused field")] (delay (error))])] + (lam x_23 (lam y_24 y_24)))) +--- optimized Core +let anf#3 : Data = trace "unused field" in error in +let anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in +case@Pair anf#4 of + Pair x#1 y#2 -> y#2 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_9 + [(lam anf_5 + [(lam anf_6 (case anf_6 (lam x_7 (lam y_8 y_8)))) + [[(builtin mkPairData) (con data (I 7))] anf_5]]) + (force [[builtin_9 (con string "unused field")] (delay (error))])]) + (force (builtin trace))]) +--- result +error: ExplicitErrorTerm +--- logs +["unused field"] +--- budget +cpu: 59598, memory: 132 +--- isolated Core before +let anf#95 : Data = trace "unused field" in error in +let anf#96 : pair Data Data = mkPairData (con data (I 7)) anf#95 in +case@Pair anf#96 of + Pair x#23 y#24 -> y#24 +--- isolated Core after +let anf#95 : Data = trace "unused field" in error in +let anf#96 : pair Data Data = mkPairData (con data (I 7)) anf#95 in +case@Pair anf#96 of + Pair x#23 y#24 -> y#24 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__lambda.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__lambda.snap new file mode 100644 index 00000000..baace636 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__lambda.snap @@ -0,0 +1,52 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +(case@Pair (trace "subject" in (con (pair integer integer) (7, 8))) of + Pair x#41 y#42 -> \unused#43 : int -> x#41) (trace "argument" in 0) +--- unoptimized UPLC +(program 1.1.0 + [(case + (force + [[(force (builtin trace)) (con string "subject")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_41 (lam y_42 (lam unused_43 x_41)))) + (force + [[(force (builtin trace)) (con string "argument")] (delay (con integer 0))])]) +--- optimized Core +let anf#4 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +let anf#5 : int -> int = case@Pair anf#4 of + Pair x#1 y#2 -> \unused#3 : int -> x#1 in +let anf#6 : int = trace "argument" in 0 in +anf#5 anf#6 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_13 + [(lam anf_7 + [(lam anf_11 + [(lam anf_12 [anf_11 anf_12]) + (force [[builtin_13 (con string "argument")] (delay (con integer 0))])]) + (case anf_7 (lam x_8 (lam y_9 (lam unused_10 x_8))))]) + (force + [[builtin_13 (con string "subject")] + (delay (con (pair integer integer) (7, 8)))])]) + (force (builtin trace))]) +--- result +(con integer 7) +--- logs +["subject", "argument"] +--- budget +cpu: 471096, memory: 2364 +--- isolated Core before +let anf#104 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +let anf#105 : int -> int = case@Pair anf#104 of + Pair x#41 y#42 -> \unused#43 : int -> x#41 in +let anf#106 : int = trace "argument" in 0 in +anf#105 anf#106 +--- isolated Core after +let anf#104 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +let anf#105 : int -> int = case@Pair anf#104 of + Pair x#41 y#42 -> \unused#43 : int -> x#41 in +let anf#106 : int = trace "argument" in 0 in +anf#105 anf#106 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__literal_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__literal_first.snap new file mode 100644 index 00000000..e4f684da --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__literal_first.snap @@ -0,0 +1,28 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#1 y#2 -> x#1 +--- unoptimized UPLC +(program 1.1.0 + (case (con (pair integer integer) (7, 8)) (lam x_1 (lam y_2 x_1)))) +--- optimized Core +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#3 y#4 -> x#3 +--- optimized UPLC +(program 1.1.0 + (case (con (pair integer integer) (7, 8)) (lam x_1 (lam y_2 x_1)))) +--- result +(con integer 7) +--- logs +[] +--- budget +cpu: 80100, memory: 600 +--- isolated Core before +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#1 y#2 -> x#1 +--- isolated Core after +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#1 y#2 -> x#1 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__literal_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__literal_second.snap new file mode 100644 index 00000000..5e932a52 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__literal_second.snap @@ -0,0 +1,28 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#3 y#4 -> y#4 +--- unoptimized UPLC +(program 1.1.0 + (case (con (pair integer integer) (7, 8)) (lam x_3 (lam y_4 y_4)))) +--- optimized Core +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#1 y#2 -> y#2 +--- optimized UPLC +(program 1.1.0 + (case (con (pair integer integer) (7, 8)) (lam x_3 (lam y_4 y_4)))) +--- result +(con integer 8) +--- logs +[] +--- budget +cpu: 80100, memory: 600 +--- isolated Core before +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#3 y#4 -> y#4 +--- isolated Core after +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#3 y#4 -> y#4 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__made_data_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__made_data_first.snap new file mode 100644 index 00000000..6f482407 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__made_data_first.snap @@ -0,0 +1,32 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair mkPairData (con data (I 7)) (con data (I 7)) of + Pair x#9 y#10 -> x#9 +--- unoptimized UPLC +(program 1.1.0 + (case + [[(builtin mkPairData) (con data (I 7))] (con data (I 7))] + (lam x_9 (lam y_10 x_9)))) +--- optimized Core +case@Pair (con (pair data data) ((I 7), (I 7))) of + Pair x#1 y#2 -> x#1 +--- optimized UPLC +(program 1.1.0 + (case (con (pair data data) ((I 7), (I 7))) (lam x_3 (lam y_4 x_3)))) +--- result +(con data (I 7)) +--- logs +[] +--- budget +cpu: 155646, memory: 1032 +--- isolated Core before +let anf#87 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in +case@Pair anf#87 of + Pair x#9 y#10 -> x#9 +--- isolated Core after +let anf#87 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in +case@Pair anf#87 of + Pair x#9 y#10 -> x#9 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__made_data_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__made_data_second.snap new file mode 100644 index 00000000..ce61ab82 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__made_data_second.snap @@ -0,0 +1,32 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair mkPairData (con data (I 7)) (con data (I 7)) of + Pair x#11 y#12 -> y#12 +--- unoptimized UPLC +(program 1.1.0 + (case + [[(builtin mkPairData) (con data (I 7))] (con data (I 7))] + (lam x_11 (lam y_12 y_12)))) +--- optimized Core +case@Pair (con (pair data data) ((I 7), (I 7))) of + Pair x#1 y#2 -> y#2 +--- optimized UPLC +(program 1.1.0 + (case (con (pair data data) ((I 7), (I 7))) (lam x_3 (lam y_4 y_4)))) +--- result +(con data (I 7)) +--- logs +[] +--- budget +cpu: 155646, memory: 1032 +--- isolated Core before +let anf#88 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in +case@Pair anf#88 of + Pair x#11 y#12 -> y#12 +--- isolated Core after +let anf#88 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in +case@Pair anf#88 of + Pair x#11 y#12 -> y#12 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__native_constructor_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__native_constructor_first.snap new file mode 100644 index 00000000..8329eb44 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__native_constructor_first.snap @@ -0,0 +1,32 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair constr 0 7 8 of + Pair x#29 y#30 -> x#29 +--- unoptimized UPLC +(program 1.1.0 + (case (constr 0 (con integer 7) (con integer 8)) (lam x_29 (lam y_30 x_29)))) +--- optimized Core +let anf#3 : pair int int = constr 0 7 8 in +case@Pair anf#3 of + Pair x#1 y#2 -> x#1 +--- optimized UPLC +(program 1.1.0 + [(lam anf_4 (case anf_4 (lam x_5 (lam y_6 x_5)))) + (constr 0 (con integer 7) (con integer 8))]) +--- result +(con integer 7) +--- logs +[] +--- budget +cpu: 112100, memory: 800 +--- isolated Core before +let anf#97 : pair int int = constr 0 7 8 in +case@Pair anf#97 of + Pair x#29 y#30 -> x#29 +--- isolated Core after +let anf#97 : pair int int = constr 0 7 8 in +case@Pair anf#97 of + Pair x#29 y#30 -> x#29 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__native_constructor_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__native_constructor_second.snap new file mode 100644 index 00000000..b5ec9dc3 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__native_constructor_second.snap @@ -0,0 +1,32 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair constr 0 7 8 of + Pair x#31 y#32 -> y#32 +--- unoptimized UPLC +(program 1.1.0 + (case (constr 0 (con integer 7) (con integer 8)) (lam x_31 (lam y_32 y_32)))) +--- optimized Core +let anf#3 : pair int int = constr 0 7 8 in +case@Pair anf#3 of + Pair x#1 y#2 -> y#2 +--- optimized UPLC +(program 1.1.0 + [(lam anf_4 (case anf_4 (lam x_5 (lam y_6 y_6)))) + (constr 0 (con integer 7) (con integer 8))]) +--- result +(con integer 8) +--- logs +[] +--- budget +cpu: 112100, memory: 800 +--- isolated Core before +let anf#98 : pair int int = constr 0 7 8 in +case@Pair anf#98 of + Pair x#31 y#32 -> y#32 +--- isolated Core after +let anf#98 : pair int int = constr 0 7 8 in +case@Pair anf#98 of + Pair x#31 y#32 -> y#32 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__neither.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__neither.snap new file mode 100644 index 00000000..86875389 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__neither.snap @@ -0,0 +1,39 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair (trace "subject" in (con (pair integer integer) (7, 8))) of + Pair x#37 y#38 -> 42 +--- unoptimized UPLC +(program 1.1.0 + (case + (force + [[(force (builtin trace)) (con string "subject")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_37 (lam y_38 (con integer 42))))) +--- optimized Core +let anf#3 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#3 of + Pair x#1 y#2 -> 42 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_7 + [(lam anf_4 (case anf_4 (lam x_5 (lam y_6 (con integer 42))))) + (force + [[builtin_7 (con string "subject")] (delay (con (pair integer integer) (7, 8)))])]) + (force (builtin trace))]) +--- result +(con integer 42) +--- logs +["subject"] +--- budget +cpu: 251598, memory: 1332 +--- isolated Core before +let anf#101 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#101 of + Pair x#37 y#38 -> 42 +--- isolated Core after +let anf#101 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#101 of + Pair x#37 y#38 -> 42 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__no_branches.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__no_branches.snap new file mode 100644 index 00000000..6fd5cde3 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__no_branches.snap @@ -0,0 +1,12 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"--- isolated Core before\\n{}\\n--- UPLC before\\n{}\\n--- isolated Core after\\n{}\\n--- UPLC after\\n{}\",\npretty(before), lowered(before), pretty(after), lowered(after))" +--- +--- isolated Core before +case@Pair (con (pair integer integer) (7, 8)) of +--- UPLC before +error: invalid Core case: pair case requires one branch +--- isolated Core after +case@Pair (con (pair integer integer) (7, 8)) of +--- UPLC after +error: invalid Core case: pair case requires one branch diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__one_binder.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__one_binder.snap new file mode 100644 index 00000000..ee7c5b55 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__one_binder.snap @@ -0,0 +1,14 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"--- isolated Core before\\n{}\\n--- UPLC before\\n{}\\n--- isolated Core after\\n{}\\n--- UPLC after\\n{}\",\npretty(before), lowered(before), pretty(after), lowered(after))" +--- +--- isolated Core before +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#7 -> x#7 +--- UPLC before +error: invalid Core case: pair branch must bind its two fields +--- isolated Core after +case@Pair (con (pair integer integer) (7, 8)) of + Pair x#7 -> x#7 +--- UPLC after +error: invalid Core case: pair branch must bind its two fields diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__repeated.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__repeated.snap new file mode 100644 index 00000000..9a7a2ecf --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__repeated.snap @@ -0,0 +1,39 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair (trace "subject" in (con (pair integer integer) (7, 8))) of + Pair x#44 y#45 -> addInteger x#44 x#44 +--- unoptimized UPLC +(program 1.1.0 + (case + (force + [[(force (builtin trace)) (con string "subject")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_44 (lam y_45 [[(builtin addInteger) x_44] x_44])))) +--- optimized Core +let anf#3 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#3 of + Pair x#1 y#2 -> addInteger x#1 x#1 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_7 + [(lam anf_4 (case anf_4 (lam x_5 (lam y_6 [[(builtin addInteger) x_5] x_5])))) + (force + [[builtin_7 (con string "subject")] (delay (con (pair integer integer) (7, 8)))])]) + (force (builtin trace))]) +--- result +(con integer 14) +--- logs +["subject"] +--- budget +cpu: 416806, memory: 1734 +--- isolated Core before +let anf#107 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#107 of + Pair x#44 y#45 -> addInteger x#44 x#44 +--- isolated Core after +let anf#107 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#107 of + Pair x#44 y#45 -> addInteger x#44 x#44 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_bad_tag_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_bad_tag_first.snap new file mode 100644 index 00000000..b72c8dfd --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_bad_tag_first.snap @@ -0,0 +1,74 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +let tag#73 : int = unBData (trace "tag" in (con data (B #626164))) in +let fields#74 : list Data = mkCons (trace "field" in (con data (I 7))) (con (list data) []) in +let encoded#75 : Data = constrData tag#73 fields#74 in +let decoded#76 : pair int (list Data) = unConstrData encoded#75 in +case@Pair decoded#76 of + Pair x#77 y#78 -> x#77 +--- unoptimized UPLC +(program 1.1.0 + [(lam tag_73 + [(lam fields_74 + [(lam encoded_75 + [(lam decoded_76 (case decoded_76 (lam x_77 (lam y_78 x_77)))) + [(builtin unConstrData) encoded_75]]) + [[(builtin constrData) tag_73] fields_74]]) + [[(force (builtin mkCons)) + (force + [[(force (builtin trace)) (con string "field")] (delay (con data (I 7)))])] + (con (list data) [])]]) + [(builtin unBData) + (force + [[(force (builtin trace)) (con string "tag")] (delay (con data (B #626164)))])]]) +--- optimized Core +let anf#7 : Data = trace "tag" in (con data (B #626164)) in +let tag#1 : int = unBData anf#7 in +let anf#8 : Data = trace "field" in (con data (I 7)) in +let fields#2 : list Data = mkCons anf#8 (con (list data) []) in +let encoded#3 : Data = constrData tag#1 fields#2 in +let decoded#4 : pair int (list Data) = unConstrData encoded#3 in +tag#1 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_13 + [(lam builtin_14 + [(lam anf_5 + [(lam tag_6 + [(lam anf_9 + [(lam fields_10 + [(lam encoded_11 [(lam decoded_12 tag_6) [(builtin unConstrData) encoded_11]]) + [[(builtin constrData) tag_6] fields_10]]) + [[builtin_13 anf_9] (con (list data) [])]]) + (force [[builtin_14 (con string "field")] (delay (con data (I 7)))])]) + [(builtin unBData) anf_5]]) + (force [[builtin_14 (con string "tag")] (delay (con data (B #626164)))])]) + (force (builtin trace))]) + (force (builtin mkCons))]) +--- result +error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100]))) +--- logs +["tag", "field"] +--- budget +cpu: 211600, memory: 228 +--- isolated Core before +let anf#124 : Data = trace "tag" in (con data (B #626164)) in +let tag#73 : int = unBData anf#124 in +let anf#125 : Data = trace "field" in (con data (I 7)) in +let fields#74 : list Data = mkCons anf#125 (con (list data) []) in +let encoded#75 : Data = constrData tag#73 fields#74 in +let decoded#76 : pair int (list Data) = unConstrData encoded#75 in +case@Pair decoded#76 of + Pair x#77 y#78 -> x#77 +--- isolated Core after +let anf#124 : Data = trace "tag" in (con data (B #626164)) in +let tag#73 : int = unBData anf#124 in +let anf#125 : Data = trace "field" in (con data (I 7)) in +let fields#74 : list Data = mkCons anf#125 (con (list data) []) in +let encoded#75 : Data = constrData tag#73 fields#74 in +let decoded#76 : pair int (list Data) = unConstrData encoded#75 in +let x#77 : int = fstPair decoded#76 in +x#77 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_bad_tag_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_bad_tag_second.snap new file mode 100644 index 00000000..a927fc4c --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_bad_tag_second.snap @@ -0,0 +1,75 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +let tag#79 : int = unBData (trace "tag" in (con data (B #626164))) in +let fields#80 : list Data = mkCons (trace "field" in (con data (I 7))) (con (list data) []) in +let encoded#81 : Data = constrData tag#79 fields#80 in +let decoded#82 : pair int (list Data) = unConstrData encoded#81 in +case@Pair decoded#82 of + Pair x#83 y#84 -> y#84 +--- unoptimized UPLC +(program 1.1.0 + [(lam tag_79 + [(lam fields_80 + [(lam encoded_81 + [(lam decoded_82 (case decoded_82 (lam x_83 (lam y_84 y_84)))) + [(builtin unConstrData) encoded_81]]) + [[(builtin constrData) tag_79] fields_80]]) + [[(force (builtin mkCons)) + (force + [[(force (builtin trace)) (con string "field")] (delay (con data (I 7)))])] + (con (list data) [])]]) + [(builtin unBData) + (force + [[(force (builtin trace)) (con string "tag")] (delay (con data (B #626164)))])]]) +--- optimized Core +let anf#7 : Data = trace "tag" in (con data (B #626164)) in +let tag#1 : int = unBData anf#7 in +let anf#8 : Data = trace "field" in (con data (I 7)) in +let fields#2 : list Data = mkCons anf#8 (con (list data) []) in +let encoded#3 : Data = constrData tag#1 fields#2 in +let decoded#4 : pair int (list Data) = unConstrData encoded#3 in +fields#2 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_13 + [(lam builtin_14 + [(lam anf_5 + [(lam tag_6 + [(lam anf_9 + [(lam fields_10 + [(lam encoded_11 + [(lam decoded_12 fields_10) [(builtin unConstrData) encoded_11]]) + [[(builtin constrData) tag_6] fields_10]]) + [[builtin_13 anf_9] (con (list data) [])]]) + (force [[builtin_14 (con string "field")] (delay (con data (I 7)))])]) + [(builtin unBData) anf_5]]) + (force [[builtin_14 (con string "tag")] (delay (con data (B #626164)))])]) + (force (builtin trace))]) + (force (builtin mkCons))]) +--- result +error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100]))) +--- logs +["tag", "field"] +--- budget +cpu: 211600, memory: 228 +--- isolated Core before +let anf#126 : Data = trace "tag" in (con data (B #626164)) in +let tag#79 : int = unBData anf#126 in +let anf#127 : Data = trace "field" in (con data (I 7)) in +let fields#80 : list Data = mkCons anf#127 (con (list data) []) in +let encoded#81 : Data = constrData tag#79 fields#80 in +let decoded#82 : pair int (list Data) = unConstrData encoded#81 in +case@Pair decoded#82 of + Pair x#83 y#84 -> y#84 +--- isolated Core after +let anf#126 : Data = trace "tag" in (con data (B #626164)) in +let tag#79 : int = unBData anf#126 in +let anf#127 : Data = trace "field" in (con data (I 7)) in +let fields#80 : list Data = mkCons anf#127 (con (list data) []) in +let encoded#81 : Data = constrData tag#79 fields#80 in +let decoded#82 : pair int (list Data) = unConstrData encoded#81 in +let y#84 : list Data = sndPair decoded#82 in +y#84 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_valid_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_valid_first.snap new file mode 100644 index 00000000..5fbe9802 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_valid_first.snap @@ -0,0 +1,73 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +let tag#61 : int = unIData (trace "tag" in (con data (I 0))) in +let fields#62 : list Data = mkCons (trace "field" in (con data (I 7))) (con (list data) []) in +let encoded#63 : Data = constrData tag#61 fields#62 in +let decoded#64 : pair int (list Data) = unConstrData encoded#63 in +case@Pair decoded#64 of + Pair x#65 y#66 -> x#65 +--- unoptimized UPLC +(program 1.1.0 + [(lam tag_61 + [(lam fields_62 + [(lam encoded_63 + [(lam decoded_64 (case decoded_64 (lam x_65 (lam y_66 x_65)))) + [(builtin unConstrData) encoded_63]]) + [[(builtin constrData) tag_61] fields_62]]) + [[(force (builtin mkCons)) + (force + [[(force (builtin trace)) (con string "field")] (delay (con data (I 7)))])] + (con (list data) [])]]) + [(builtin unIData) + (force [[(force (builtin trace)) (con string "tag")] (delay (con data (I 0)))])]]) +--- optimized Core +let anf#7 : Data = trace "tag" in (con data (I 0)) in +let tag#1 : int = unIData anf#7 in +let anf#8 : Data = trace "field" in (con data (I 7)) in +let fields#2 : list Data = mkCons anf#8 (con (list data) []) in +let encoded#3 : Data = constrData tag#1 fields#2 in +let decoded#4 : pair int (list Data) = unConstrData encoded#3 in +tag#1 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_13 + [(lam builtin_14 + [(lam anf_5 + [(lam tag_6 + [(lam anf_9 + [(lam fields_10 + [(lam encoded_11 [(lam decoded_12 tag_6) [(builtin unConstrData) encoded_11]]) + [[(builtin constrData) tag_6] fields_10]]) + [[builtin_13 anf_9] (con (list data) [])]]) + (force [[builtin_14 (con string "field")] (delay (con data (I 7)))])]) + [(builtin unIData) anf_5]]) + (force [[builtin_14 (con string "tag")] (delay (con data (I 0)))])]) + (force (builtin trace))]) + (force (builtin mkCons))]) +--- result +(con integer 0) +--- logs +["tag", "field"] +--- budget +cpu: 962941, memory: 4692 +--- isolated Core before +let anf#120 : Data = trace "tag" in (con data (I 0)) in +let tag#61 : int = unIData anf#120 in +let anf#121 : Data = trace "field" in (con data (I 7)) in +let fields#62 : list Data = mkCons anf#121 (con (list data) []) in +let encoded#63 : Data = constrData tag#61 fields#62 in +let decoded#64 : pair int (list Data) = unConstrData encoded#63 in +case@Pair decoded#64 of + Pair x#65 y#66 -> x#65 +--- isolated Core after +let anf#120 : Data = trace "tag" in (con data (I 0)) in +let tag#61 : int = unIData anf#120 in +let anf#121 : Data = trace "field" in (con data (I 7)) in +let fields#62 : list Data = mkCons anf#121 (con (list data) []) in +let encoded#63 : Data = constrData tag#61 fields#62 in +let decoded#64 : pair int (list Data) = unConstrData encoded#63 in +let x#65 : int = fstPair decoded#64 in +x#65 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_valid_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_valid_second.snap new file mode 100644 index 00000000..af4e4fe1 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__roundtrip_valid_second.snap @@ -0,0 +1,74 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +let tag#67 : int = unIData (trace "tag" in (con data (I 0))) in +let fields#68 : list Data = mkCons (trace "field" in (con data (I 7))) (con (list data) []) in +let encoded#69 : Data = constrData tag#67 fields#68 in +let decoded#70 : pair int (list Data) = unConstrData encoded#69 in +case@Pair decoded#70 of + Pair x#71 y#72 -> y#72 +--- unoptimized UPLC +(program 1.1.0 + [(lam tag_67 + [(lam fields_68 + [(lam encoded_69 + [(lam decoded_70 (case decoded_70 (lam x_71 (lam y_72 y_72)))) + [(builtin unConstrData) encoded_69]]) + [[(builtin constrData) tag_67] fields_68]]) + [[(force (builtin mkCons)) + (force + [[(force (builtin trace)) (con string "field")] (delay (con data (I 7)))])] + (con (list data) [])]]) + [(builtin unIData) + (force [[(force (builtin trace)) (con string "tag")] (delay (con data (I 0)))])]]) +--- optimized Core +let anf#7 : Data = trace "tag" in (con data (I 0)) in +let tag#1 : int = unIData anf#7 in +let anf#8 : Data = trace "field" in (con data (I 7)) in +let fields#2 : list Data = mkCons anf#8 (con (list data) []) in +let encoded#3 : Data = constrData tag#1 fields#2 in +let decoded#4 : pair int (list Data) = unConstrData encoded#3 in +fields#2 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_13 + [(lam builtin_14 + [(lam anf_5 + [(lam tag_6 + [(lam anf_9 + [(lam fields_10 + [(lam encoded_11 + [(lam decoded_12 fields_10) [(builtin unConstrData) encoded_11]]) + [[(builtin constrData) tag_6] fields_10]]) + [[builtin_13 anf_9] (con (list data) [])]]) + (force [[builtin_14 (con string "field")] (delay (con data (I 7)))])]) + [(builtin unIData) anf_5]]) + (force [[builtin_14 (con string "tag")] (delay (con data (I 0)))])]) + (force (builtin trace))]) + (force (builtin mkCons))]) +--- result +(con (list data) [(I 7)]) +--- logs +["tag", "field"] +--- budget +cpu: 962941, memory: 4692 +--- isolated Core before +let anf#122 : Data = trace "tag" in (con data (I 0)) in +let tag#67 : int = unIData anf#122 in +let anf#123 : Data = trace "field" in (con data (I 7)) in +let fields#68 : list Data = mkCons anf#123 (con (list data) []) in +let encoded#69 : Data = constrData tag#67 fields#68 in +let decoded#70 : pair int (list Data) = unConstrData encoded#69 in +case@Pair decoded#70 of + Pair x#71 y#72 -> y#72 +--- isolated Core after +let anf#122 : Data = trace "tag" in (con data (I 0)) in +let tag#67 : int = unIData anf#122 in +let anf#123 : Data = trace "field" in (con data (I 7)) in +let fields#68 : list Data = mkCons anf#123 (con (list data) []) in +let encoded#69 : Data = constrData tag#67 fields#68 in +let decoded#70 : pair int (list Data) = unConstrData encoded#69 in +let y#72 : list Data = sndPair decoded#70 in +y#72 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__traced_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__traced_first.snap new file mode 100644 index 00000000..1e6313d3 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__traced_first.snap @@ -0,0 +1,39 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair (trace "subject" in (con (pair integer integer) (7, 8))) of + Pair x#5 y#6 -> x#5 +--- unoptimized UPLC +(program 1.1.0 + (case + (force + [[(force (builtin trace)) (con string "subject")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_5 (lam y_6 x_5)))) +--- optimized Core +let anf#3 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#3 of + Pair x#1 y#2 -> x#1 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_7 + [(lam anf_4 (case anf_4 (lam x_5 (lam y_6 x_5)))) + (force + [[builtin_7 (con string "subject")] (delay (con (pair integer integer) (7, 8)))])]) + (force (builtin trace))]) +--- result +(con integer 7) +--- logs +["subject"] +--- budget +cpu: 251598, memory: 1332 +--- isolated Core before +let anf#85 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#85 of + Pair x#5 y#6 -> x#5 +--- isolated Core after +let anf#85 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#85 of + Pair x#5 y#6 -> x#5 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__traced_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__traced_second.snap new file mode 100644 index 00000000..ffcb5dc5 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__traced_second.snap @@ -0,0 +1,39 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair (trace "subject" in (con (pair integer integer) (7, 8))) of + Pair x#7 y#8 -> y#8 +--- unoptimized UPLC +(program 1.1.0 + (case + (force + [[(force (builtin trace)) (con string "subject")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_7 (lam y_8 y_8)))) +--- optimized Core +let anf#3 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#3 of + Pair x#1 y#2 -> y#2 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_7 + [(lam anf_4 (case anf_4 (lam x_5 (lam y_6 y_6)))) + (force + [[builtin_7 (con string "subject")] (delay (con (pair integer integer) (7, 8)))])]) + (force (builtin trace))]) +--- result +(con integer 8) +--- logs +["subject"] +--- budget +cpu: 251598, memory: 1332 +--- isolated Core before +let anf#86 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#86 of + Pair x#7 y#8 -> y#8 +--- isolated Core after +let anf#86 : pair int int = trace "subject" in (con (pair integer integer) (7, 8)) in +case@Pair anf#86 of + Pair x#7 y#8 -> y#8 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__two_projections_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__two_projections_first.snap new file mode 100644 index 00000000..274ce4e7 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__two_projections_first.snap @@ -0,0 +1,65 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +addInteger (case@Pair (trace "first" in (con (pair integer integer) (7, 8))) of + Pair x#46 y#47 -> x#46) (case@Pair (trace "second" in (con (pair integer integer) (7, 8))) of + Pair x#48 y#49 -> x#48) +--- unoptimized UPLC +(program 1.1.0 + [[(builtin addInteger) + (case + (force + [[(force (builtin trace)) (con string "first")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_46 (lam y_47 x_46)))] + (case + (force + [[(force (builtin trace)) (con string "second")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_48 (lam y_49 x_48)))]) +--- optimized Core +let anf#5 : pair int int = trace "first" in (con (pair integer integer) (7, 8)) in +let anf#6 : int = case@Pair anf#5 of + Pair x#1 y#2 -> x#1 in +let anf#7 : pair int int = trace "second" in (con (pair integer integer) (7, 8)) in +let anf#8 : int = case@Pair anf#7 of + Pair x#3 y#4 -> x#3 in +addInteger anf#6 anf#8 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_17 + [(lam anf_9 + [(lam anf_12 + [(lam anf_13 + [(lam anf_16 [[(builtin addInteger) anf_12] anf_16]) + (case anf_13 (lam x_14 (lam y_15 x_14)))]) + (force + [[builtin_17 (con string "second")] (delay (con (pair integer integer) (7, 8)))])]) + (case anf_9 (lam x_10 (lam y_11 x_10)))]) + (force + [[builtin_17 (con string "first")] (delay (con (pair integer integer) (7, 8)))])]) + (force (builtin trace))]) +--- result +(con integer 14) +--- logs +["first", "second"] +--- budget +cpu: 652304, memory: 2866 +--- isolated Core before +let anf#108 : pair int int = trace "first" in (con (pair integer integer) (7, 8)) in +let anf#109 : int = case@Pair anf#108 of + Pair x#46 y#47 -> x#46 in +let anf#110 : pair int int = trace "second" in (con (pair integer integer) (7, 8)) in +let anf#111 : int = case@Pair anf#110 of + Pair x#48 y#49 -> x#48 in +addInteger anf#109 anf#111 +--- isolated Core after +let anf#108 : pair int int = trace "first" in (con (pair integer integer) (7, 8)) in +let anf#109 : int = case@Pair anf#108 of + Pair x#46 y#47 -> x#46 in +let anf#110 : pair int int = trace "second" in (con (pair integer integer) (7, 8)) in +let anf#111 : int = case@Pair anf#110 of + Pair x#48 y#49 -> x#48 in +addInteger anf#109 anf#111 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__two_projections_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__two_projections_second.snap new file mode 100644 index 00000000..7fe61bcc --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__two_projections_second.snap @@ -0,0 +1,65 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +addInteger (case@Pair (trace "first" in (con (pair integer integer) (7, 8))) of + Pair x#50 y#51 -> y#51) (case@Pair (trace "second" in (con (pair integer integer) (7, 8))) of + Pair x#52 y#53 -> y#53) +--- unoptimized UPLC +(program 1.1.0 + [[(builtin addInteger) + (case + (force + [[(force (builtin trace)) (con string "first")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_50 (lam y_51 y_51)))] + (case + (force + [[(force (builtin trace)) (con string "second")] + (delay (con (pair integer integer) (7, 8)))]) + (lam x_52 (lam y_53 y_53)))]) +--- optimized Core +let anf#5 : pair int int = trace "first" in (con (pair integer integer) (7, 8)) in +let anf#6 : int = case@Pair anf#5 of + Pair x#1 y#2 -> y#2 in +let anf#7 : pair int int = trace "second" in (con (pair integer integer) (7, 8)) in +let anf#8 : int = case@Pair anf#7 of + Pair x#3 y#4 -> y#4 in +addInteger anf#6 anf#8 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_17 + [(lam anf_9 + [(lam anf_12 + [(lam anf_13 + [(lam anf_16 [[(builtin addInteger) anf_12] anf_16]) + (case anf_13 (lam x_14 (lam y_15 y_15)))]) + (force + [[builtin_17 (con string "second")] (delay (con (pair integer integer) (7, 8)))])]) + (case anf_9 (lam x_10 (lam y_11 y_11)))]) + (force + [[builtin_17 (con string "first")] (delay (con (pair integer integer) (7, 8)))])]) + (force (builtin trace))]) +--- result +(con integer 16) +--- logs +["first", "second"] +--- budget +cpu: 652304, memory: 2866 +--- isolated Core before +let anf#112 : pair int int = trace "first" in (con (pair integer integer) (7, 8)) in +let anf#113 : int = case@Pair anf#112 of + Pair x#50 y#51 -> y#51 in +let anf#114 : pair int int = trace "second" in (con (pair integer integer) (7, 8)) in +let anf#115 : int = case@Pair anf#114 of + Pair x#52 y#53 -> y#53 in +addInteger anf#113 anf#115 +--- isolated Core after +let anf#112 : pair int int = trace "first" in (con (pair integer integer) (7, 8)) in +let anf#113 : int = case@Pair anf#112 of + Pair x#50 y#51 -> y#51 in +let anf#114 : pair int int = trace "second" in (con (pair integer integer) (7, 8)) in +let anf#115 : int = case@Pair anf#114 of + Pair x#52 y#53 -> y#53 in +addInteger anf#113 anf#115 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__unconsumed_delay_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__unconsumed_delay_failure.snap new file mode 100644 index 00000000..8820b5fe --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__unconsumed_delay_failure.snap @@ -0,0 +1,51 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +let ignored closure#60 : @delay int = case@Pair unConstrData (trace "before failure" in (con data (I 7))) of + Pair x#58 y#59 -> delay x#58 in +0 +--- unoptimized UPLC +(program 1.1.0 + [(lam n69676e6f72656420636c6f73757265_60 (con integer 0)) + (case + [(builtin unConstrData) + (force + [[(force (builtin trace)) (con string "before failure")] + (delay (con data (I 7)))])] + (lam x_58 (lam y_59 (delay x_58))))]) +--- optimized Core +let anf#4 : Data = trace "before failure" in (con data (I 7)) in +let anf#5 : pair int (list Data) = unConstrData anf#4 in +let ignored closure#3 : @delay int = case@Pair anf#5 of + Pair x#1 y#2 -> delay x#1 in +0 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_11 + [(lam anf_6 + [(lam anf_7 + [(lam n69676e6f72656420636c6f73757265_10 (con integer 0)) + (case anf_7 (lam x_8 (lam y_9 (delay x_8))))]) + [(builtin unConstrData) anf_6]]) + (force [[builtin_11 (con string "before failure")] (delay (con data (I 7)))])]) + (force (builtin trace))]) +--- result +error: Runtime(MalFormedData(Integer(7))) +--- logs +["before failure"] +--- budget +cpu: 59598, memory: 132 +--- isolated Core before +let anf#118 : Data = trace "before failure" in (con data (I 7)) in +let anf#119 : pair int (list Data) = unConstrData anf#118 in +let ignored closure#60 : @delay int = case@Pair anf#119 of + Pair x#58 y#59 -> delay x#58 in +0 +--- isolated Core after +let anf#118 : Data = trace "before failure" in (con data (I 7)) in +let anf#119 : pair int (list Data) = unConstrData anf#118 in +let ignored closure#60 : @delay int = case@Pair anf#119 of + Pair x#58 y#59 -> delay x#58 in +0 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__unconsumed_lambda_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__unconsumed_lambda_failure.snap new file mode 100644 index 00000000..ac0dc33c --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__unconsumed_lambda_failure.snap @@ -0,0 +1,51 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +let ignored closure#57 : int -> int = case@Pair unConstrData (trace "before failure" in (con data (I 7))) of + Pair x#54 y#55 -> \arg#56 : int -> x#54 in +0 +--- unoptimized UPLC +(program 1.1.0 + [(lam n69676e6f72656420636c6f73757265_57 (con integer 0)) + (case + [(builtin unConstrData) + (force + [[(force (builtin trace)) (con string "before failure")] + (delay (con data (I 7)))])] + (lam x_54 (lam y_55 (lam arg_56 x_54))))]) +--- optimized Core +let anf#5 : Data = trace "before failure" in (con data (I 7)) in +let anf#6 : pair int (list Data) = unConstrData anf#5 in +let ignored closure#4 : int -> int = case@Pair anf#6 of + Pair x#1 y#2 -> \arg#3 : int -> x#1 in +0 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_13 + [(lam anf_7 + [(lam anf_8 + [(lam n69676e6f72656420636c6f73757265_12 (con integer 0)) + (case anf_8 (lam x_9 (lam y_10 (lam arg_11 x_9))))]) + [(builtin unConstrData) anf_7]]) + (force [[builtin_13 (con string "before failure")] (delay (con data (I 7)))])]) + (force (builtin trace))]) +--- result +error: Runtime(MalFormedData(Integer(7))) +--- logs +["before failure"] +--- budget +cpu: 59598, memory: 132 +--- isolated Core before +let anf#116 : Data = trace "before failure" in (con data (I 7)) in +let anf#117 : pair int (list Data) = unConstrData anf#116 in +let ignored closure#57 : int -> int = case@Pair anf#117 of + Pair x#54 y#55 -> \arg#56 : int -> x#54 in +0 +--- isolated Core after +let anf#116 : Data = trace "before failure" in (con data (I 7)) in +let anf#117 : pair int (list Data) = unConstrData anf#116 in +let ignored closure#57 : int -> int = case@Pair anf#117 of + Pair x#54 y#55 -> \arg#56 : int -> x#54 in +0 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__unknown_parameter.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__unknown_parameter.snap new file mode 100644 index 00000000..b3ca582a --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__unknown_parameter.snap @@ -0,0 +1,24 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}--- isolated Core before\\n{}\\n--- UPLC before\\n{}\\n--- isolated Core after\\n{}\\n--- UPLC after\\n{}\",\nif pipeline.is_empty() { pipeline } else { format!(\"{pipeline}\\n\") },\npretty(before), lowered(before), pretty(after), lowered(after))" +--- +--- unoptimized Core +\p#18 : pair int int -> case@Pair p#18 of + Pair x#16 y#17 -> x#16 +--- unoptimized UPLC +(program 1.1.0 (lam p_18 (case p_18 (lam x_16 (lam y_17 x_16))))) +--- optimized Core +\p#1 : pair int int -> case@Pair p#1 of + Pair x#2 y#3 -> x#2 +--- optimized UPLC +(program 1.1.0 (lam p_4 (case p_4 (lam x_5 (lam y_6 x_5))))) +--- isolated Core before +\p#18 : pair int int -> case@Pair p#18 of + Pair x#16 y#17 -> x#16 +--- UPLC before +(lam p_18 (case p_18 (lam x_16 (lam y_17 x_16)))) +--- isolated Core after +\p#18 : pair int int -> case@Pair p#18 of + Pair x#16 y#17 -> x#16 +--- UPLC after +(lam p_18 (case p_18 (lam x_16 (lam y_17 x_16)))) diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__wrong_subject_first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__wrong_subject_first.snap new file mode 100644 index 00000000..7f131adf --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__wrong_subject_first.snap @@ -0,0 +1,26 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair 1 of + Pair x#25 y#26 -> x#25 +--- unoptimized UPLC +(program 1.1.0 (case (con integer 1) (lam x_25 (lam y_26 x_25)))) +--- optimized Core +case@Pair 1 of + Pair x#1 y#2 -> x#1 +--- optimized UPLC +(program 1.1.0 (case (con integer 1) (lam x_3 (lam y_4 x_3)))) +--- result +error: NonConstrScrutinized(Con(Integer(1))) +--- logs +[] +--- budget +cpu: 100, memory: 100 +--- isolated Core before +case@Pair 1 of + Pair x#25 y#26 -> x#25 +--- isolated Core after +case@Pair 1 of + Pair x#25 y#26 -> x#25 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__wrong_subject_second.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__wrong_subject_second.snap new file mode 100644 index 00000000..e9ed41c8 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__wrong_subject_second.snap @@ -0,0 +1,26 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"{}\\n--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\nfixture.snapshot(), pretty(anf), pretty(isolated))" +--- +--- unoptimized Core +case@Pair 1 of + Pair x#27 y#28 -> y#28 +--- unoptimized UPLC +(program 1.1.0 (case (con integer 1) (lam x_27 (lam y_28 y_28)))) +--- optimized Core +case@Pair 1 of + Pair x#1 y#2 -> y#2 +--- optimized UPLC +(program 1.1.0 (case (con integer 1) (lam x_3 (lam y_4 y_4)))) +--- result +error: NonConstrScrutinized(Con(Integer(1))) +--- logs +[] +--- budget +cpu: 100, memory: 100 +--- isolated Core before +case@Pair 1 of + Pair x#27 y#28 -> y#28 +--- isolated Core after +case@Pair 1 of + Pair x#27 y#28 -> y#28 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__wrong_test.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__wrong_test.snap new file mode 100644 index 00000000..10db68dc --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__pair_projection__wrong_test.snap @@ -0,0 +1,14 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/pair_projection.rs +expression: "format!(\"--- isolated Core before\\n{}\\n--- UPLC before\\n{}\\n--- isolated Core after\\n{}\\n--- UPLC after\\n{}\",\npretty(before), lowered(before), pretty(after), lowered(after))" +--- +--- isolated Core before +case@Pair (con (pair integer integer) (7, 8)) of + 0 x#4 y#5 -> x#4 +--- UPLC before +error: invalid Core case: pair branch must bind its two fields +--- isolated Core after +case@Pair (con (pair integer integer) (7, 8)) of + 0 x#4 y#5 -> x#4 +--- UPLC after +error: invalid Core case: pair branch must bind its two fields diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__propagate__repeated_64_byte_literal.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__propagate__repeated_64_byte_literal.snap index f627c433..6c02a0a8 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__propagate__repeated_64_byte_literal.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__propagate__repeated_64_byte_literal.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/propagate.rs -assertion_line: 40 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline\\n{}\\n--- core after\\n{}\\n--- candidate\\n{}\",\npretty(before), output(&baseline), pretty(after), output(&candidate)))" --- --- unoptimized Core @@ -11,12 +10,10 @@ appendByteString bytes#1 bytes#1 [(lam bytes_1 [[(builtin appendByteString) bytes_1] bytes_1]) (con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a)]) --- optimized Core -appendByteString (con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a) (con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a) +(con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a) --- optimized UPLC (program 1.1.0 - [[(builtin appendByteString) - (con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a)] - (con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a)]) + (con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a)) --- isolated pass --- core before let bytes#1 : bytes = (con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__propagate__shared_string_alias.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__propagate__shared_string_alias.snap index 019d8868..881ceb97 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__propagate__shared_string_alias.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__propagate__shared_string_alias.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/propagate.rs -assertion_line: 40 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline\\n{}\\n--- core after\\n{}\\n--- candidate\\n{}\",\npretty(before), output(&baseline), pretty(after), output(&candidate)))" --- --- unoptimized Core @@ -12,12 +11,9 @@ appendString alias#2 alias#2 [(lam text_1 [(lam alias_2 [[(builtin appendString) alias_2] alias_2]) text_1]) (con string "shared payload")]) --- optimized Core -let text#3 : string = "shared payload" in -appendString text#3 text#3 +"shared payloadshared payload" --- optimized UPLC -(program 1.1.0 - [(lam text_1 [[(builtin appendString) text_1] text_1]) - (con string "shared payload")]) +(program 1.1.0 (con string "shared payloadshared payload")) --- isolated pass --- core before let text#1 : string = "shared payload" in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__all_unused_cold.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__all_unused_cold.snap new file mode 100644 index 00000000..48138e5f --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__all_unused_cold.snap @@ -0,0 +1,126 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#39 : int -> int [static []] = \x#41 : int -> case@Bool true of + True -> trace "body" in 21 + False -> g#40 x#41 + g#40 : int -> int [static []] = \y#42 : int -> f#39 y#42 +in +case@Bool true of + True -> 42 + False -> addInteger (f#39 (trace "entry1" in 0)) (g#40 (trace "entry2" in 1)) +--- unoptimized UPLC +(program 1.1.0 + [(lam dispatch_1 + [(lam f_39 + [(lam g_40 + (case + (con bool True) + [[(builtin addInteger) + [f_39 + (force + [[(force (builtin trace)) (con string "entry1")] (delay (con integer 0))])]] + [g_40 + (force + [[(force (builtin trace)) (con string "entry2")] (delay (con integer 1))])]] + (con integer 42))) + (lam y_9 [dispatch_1 (constr 1 dispatch_1 y_9)])]) + (lam x_10 [dispatch_1 (constr 0 dispatch_1 x_10)])]) + (lam request_2 + (case + request_2 + (lam self_3 + (lam x_41 + (case + (con bool True) + [self_3 (constr 1 self_3 x_41)] + (force [[(force (builtin trace)) (con string "body")] (delay (con integer 21))])))) + (lam self_6 (lam y_42 [self_6 (constr 0 self_6 y_42)]))))]) +--- optimized Core +42 +--- optimized UPLC +(program 1.1.0 (con integer 42)) +--- isolated pass +--- isolated Core before +letrec + f#39 : int -> int [static []] = \x#41 : int -> case@Bool true of + True -> trace "body" in 21 + False -> g#40 x#41 + g#40 : int -> int [static []] = \y#42 : int -> f#39 y#42 +in +case@Bool true of + True -> 42 + False -> addInteger (f#39 (trace "entry1" in 0)) (g#40 (trace "entry2" in 1)) +--- isolated Core after +letrec + f#39 : @delay int [static []] = \ -> delay (case@Bool true of + True -> trace "body" in 21 + False -> force g#40) + g#40 : @delay int [static []] = \ -> delay (force f#39) +in +case@Bool true of + True -> 42 + False -> addInteger (let arg#1 : int = trace "entry1" in 0 in + force f#39) (let arg#2 : int = trace "entry2" in 1 in + force g#40) +--- isolated UPLC before +(program 1.1.0 + [(lam dispatch_213 + [(lam f_39 + [(lam g_40 + (case + (con bool True) + [[(builtin addInteger) + [f_39 + (force + [[(force (builtin trace)) (con string "entry1")] (delay (con integer 0))])]] + [g_40 + (force + [[(force (builtin trace)) (con string "entry2")] (delay (con integer 1))])]] + (con integer 42))) + (lam y_221 [dispatch_213 (constr 1 dispatch_213 y_221)])]) + (lam x_222 [dispatch_213 (constr 0 dispatch_213 x_222)])]) + (lam request_214 + (case + request_214 + (lam self_215 + (lam x_41 + (case + (con bool True) + [self_215 (constr 1 self_215 x_41)] + (force [[(force (builtin trace)) (con string "body")] (delay (con integer 21))])))) + (lam self_218 (lam y_42 [self_218 (constr 0 self_218 y_42)]))))]) +--- isolated UPLC after +(program 1.1.0 + [(lam dispatch_223 + [(lam f_39 + [(lam g_40 + (case + (con bool True) + [(lam arg_1 + [(lam anf_3 + [(lam arg_2 [(lam anf_4 [[(builtin addInteger) anf_3] anf_4]) (force g_40)]) + (force + [[(force (builtin trace)) (con string "entry2")] (delay (con integer 1))])]) + (force f_39)]) + (force + [[(force (builtin trace)) (con string "entry1")] (delay (con integer 0))])] + (con integer 42))) + (delay [dispatch_223 (constr 1 dispatch_223)])]) + (delay [dispatch_223 (constr 0 dispatch_223)])]) + (lam request_224 + (case + request_224 + (lam self_225 + (case + (con bool True) + (force (delay [self_225 (constr 1 self_225)])) + (force [[(force (builtin trace)) (con string "body")] (delay (con integer 21))]))) + (lam self_226 (force (delay [self_226 (constr 0 self_226)])))))]) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__all_unused_mutual.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__all_unused_mutual.snap new file mode 100644 index 00000000..ba64dd09 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__all_unused_mutual.snap @@ -0,0 +1,136 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#35 : int -> int [static []] = \x#37 : int -> case@Bool true of + True -> trace "body" in 21 + False -> g#36 x#37 + g#36 : int -> int [static []] = \y#38 : int -> f#35 y#38 +in +addInteger (f#35 (trace "entry1" in 0)) (g#36 (trace "entry2" in 1)) +--- unoptimized UPLC +(program 1.1.0 + [(lam dispatch_1 + [(lam f_35 + [(lam g_36 + [[(builtin addInteger) + [f_35 + (force + [[(force (builtin trace)) (con string "entry1")] (delay (con integer 0))])]] + [g_36 + (force + [[(force (builtin trace)) (con string "entry2")] (delay (con integer 1))])]]) + (lam y_9 [dispatch_1 (constr 1 dispatch_1 y_9)])]) + (lam x_10 [dispatch_1 (constr 0 dispatch_1 x_10)])]) + (lam request_2 + (case + request_2 + (lam self_3 + (lam x_37 + (case + (con bool True) + [self_3 (constr 1 self_3 x_37)] + (force [[(force (builtin trace)) (con string "body")] (delay (con integer 21))])))) + (lam self_6 (lam y_38 [self_6 (constr 0 self_6 y_38)]))))]) +--- optimized Core +letrec + f#1 : @delay int [static []] = \ -> delay (trace "body" in 21) + g#2 : @delay int [static []] = \ -> delay (force f#1) +in +let arg#5 : int = trace "entry1" in 0 in +let anf#7 : int = force f#1 in +let arg#6 : int = trace "entry2" in 1 in +let anf#8 : int = force g#2 in +addInteger anf#7 anf#8 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_21 + [(lam dispatch_14 + [(lam arg_17 + [(lam anf_18 + [(lam arg_19 + [(lam anf_20 [[(builtin addInteger) anf_18] anf_20]) + [dispatch_14 (constr 1 dispatch_14)]]) + (force [[builtin_21 (con string "entry2")] (delay (con integer 1))])]) + [dispatch_14 (constr 0 dispatch_14)]]) + (force [[builtin_21 (con string "entry1")] (delay (con integer 0))])]) + (lam request_11 + (case + request_11 + (lam self_12 + (force [[builtin_21 (con string "body")] (delay (con integer 21))])) + (lam self_13 [self_13 (constr 0 self_13)])))]) + (force (builtin trace))]) +--- isolated pass +--- isolated Core before +letrec + f#35 : int -> int [static []] = \x#37 : int -> case@Bool true of + True -> trace "body" in 21 + False -> g#36 x#37 + g#36 : int -> int [static []] = \y#38 : int -> f#35 y#38 +in +addInteger (f#35 (trace "entry1" in 0)) (g#36 (trace "entry2" in 1)) +--- isolated Core after +letrec + f#35 : @delay int [static []] = \ -> delay (case@Bool true of + True -> trace "body" in 21 + False -> force g#36) + g#36 : @delay int [static []] = \ -> delay (force f#35) +in +addInteger (let arg#1 : int = trace "entry1" in 0 in +force f#35) (let arg#2 : int = trace "entry2" in 1 in +force g#36) +--- isolated UPLC before +(program 1.1.0 + [(lam dispatch_199 + [(lam f_35 + [(lam g_36 + [[(builtin addInteger) + [f_35 + (force + [[(force (builtin trace)) (con string "entry1")] (delay (con integer 0))])]] + [g_36 + (force + [[(force (builtin trace)) (con string "entry2")] (delay (con integer 1))])]]) + (lam y_207 [dispatch_199 (constr 1 dispatch_199 y_207)])]) + (lam x_208 [dispatch_199 (constr 0 dispatch_199 x_208)])]) + (lam request_200 + (case + request_200 + (lam self_201 + (lam x_37 + (case + (con bool True) + [self_201 (constr 1 self_201 x_37)] + (force [[(force (builtin trace)) (con string "body")] (delay (con integer 21))])))) + (lam self_204 (lam y_38 [self_204 (constr 0 self_204 y_38)]))))]) +--- isolated UPLC after +(program 1.1.0 + [(lam dispatch_209 + [(lam f_35 + [(lam g_36 + [(lam arg_1 + [(lam anf_3 + [(lam arg_2 [(lam anf_4 [[(builtin addInteger) anf_3] anf_4]) (force g_36)]) + (force + [[(force (builtin trace)) (con string "entry2")] (delay (con integer 1))])]) + (force f_35)]) + (force + [[(force (builtin trace)) (con string "entry1")] (delay (con integer 0))])]) + (delay [dispatch_209 (constr 1 dispatch_209)])]) + (delay [dispatch_209 (constr 0 dispatch_209)])]) + (lam request_210 + (case + request_210 + (lam self_211 + (case + (con bool True) + (force (delay [self_211 (constr 1 self_211)])) + (force [[(force (builtin trace)) (con string "body")] (delay (con integer 21))]))) + (lam self_212 (force (delay [self_212 (constr 0 self_212)])))))]) +--- result +(con integer 42) +--- logs +["entry1", "body", "entry2", "body"] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__all_unused_self.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__all_unused_self.snap new file mode 100644 index 00000000..13ad18db --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__all_unused_self.snap @@ -0,0 +1,110 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#31 : int -> int [static []] = \x#33 : int -> case@Bool true of + True -> trace "body" in 21 + False -> f#31 x#33 +in +addInteger (f#31 (trace "entry1" in 0)) (f#31 (trace "entry2" in 1)) +--- unoptimized UPLC +(program 1.1.0 + [(lam f_31 + [[(builtin addInteger) + [f_31 + (force + [[(force (builtin trace)) (con string "entry1")] (delay (con integer 0))])]] + [f_31 + (force + [[(force (builtin trace)) (con string "entry2")] (delay (con integer 1))])]]) + [(lam self_1 [self_1 self_1]) + (lam self_1 + (lam x_33 + (case + (con bool True) + [[self_1 self_1] x_33] + (force [[(force (builtin trace)) (con string "body")] (delay (con integer 21))]))))]]) +--- optimized Core +let f#1 : @delay int = delay (letrec + worker#3 : @delay int [static []] = \ -> delay (trace "body" in 21) +in +force worker#3) in +let arg#4 : int = trace "entry1" in 0 in +let anf#6 : int = force f#1 in +let arg#5 : int = trace "entry2" in 1 in +let anf#7 : int = force f#1 in +addInteger anf#6 anf#7 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_16 + [(lam f_11 + [(lam arg_12 + [(lam anf_13 + [(lam arg_14 [(lam anf_15 [[(builtin addInteger) anf_13] anf_15]) (force f_11)]) + (force [[builtin_16 (con string "entry2")] (delay (con integer 1))])]) + (force f_11)]) + (force [[builtin_16 (con string "entry1")] (delay (con integer 0))])]) + (delay + [(lam worker_10 (force worker_10)) + [(lam self_8 [self_8 self_8]) + (lam self_9 + (delay (force [[builtin_16 (con string "body")] (delay (con integer 21))])))]])]) + (force (builtin trace))]) +--- isolated pass +--- isolated Core before +letrec + f#31 : int -> int [static []] = \x#33 : int -> case@Bool true of + True -> trace "body" in 21 + False -> f#31 x#33 +in +addInteger (f#31 (trace "entry1" in 0)) (f#31 (trace "entry2" in 1)) +--- isolated Core after +letrec + f#31 : @delay int [static []] = \ -> delay (case@Bool true of + True -> trace "body" in 21 + False -> force f#31) +in +addInteger (let arg#1 : int = trace "entry1" in 0 in +force f#31) (let arg#2 : int = trace "entry2" in 1 in +force f#31) +--- isolated UPLC before +(program 1.1.0 + [(lam f_31 + [[(builtin addInteger) + [f_31 + (force + [[(force (builtin trace)) (con string "entry1")] (delay (con integer 0))])]] + [f_31 + (force + [[(force (builtin trace)) (con string "entry2")] (delay (con integer 1))])]]) + [(lam self_196 [self_196 self_196]) + (lam self_196 + (lam x_33 + (case + (con bool True) + [[self_196 self_196] x_33] + (force [[(force (builtin trace)) (con string "body")] (delay (con integer 21))]))))]]) +--- isolated UPLC after +(program 1.1.0 + [(lam f_31 + [(lam arg_1 + [(lam anf_3 + [(lam arg_2 [(lam anf_4 [[(builtin addInteger) anf_3] anf_4]) (force f_31)]) + (force + [[(force (builtin trace)) (con string "entry2")] (delay (con integer 1))])]) + (force f_31)]) + (force + [[(force (builtin trace)) (con string "entry1")] (delay (con integer 0))])]) + [(lam self_198 [self_198 self_198]) + (lam self_198 + (delay + (case + (con bool True) + (force [self_198 self_198]) + (force [[(force (builtin trace)) (con string "body")] (delay (con integer 21))]))))]]) +--- result +(con integer 42) +--- logs +["entry1", "body", "entry2", "body"] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__compound_dependency.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__compound_dependency.snap new file mode 100644 index 00000000..69d2885e --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__compound_dependency.snap @@ -0,0 +1,100 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#69 : int -> int -> int [static []] = \x#71 : int n#72 : int -> case@Bool equalsInteger n#72 0 of + True -> 42 + False -> f#69 (addInteger x#71 1) (subtractInteger n#72 1) +in +f#69 7 2 +--- unoptimized UPLC +(program 1.1.0 + [(lam f_69 [[f_69 (con integer 7)] (con integer 2)]) + [(lam self_1 [self_1 self_1]) + (lam self_1 + (lam x_71 + (lam n_72 + (case + [[(builtin equalsInteger) n_72] (con integer 0)] + [[[self_1 self_1] [[(builtin addInteger) x_71] (con integer 1)]] + [[(builtin subtractInteger) n_72] (con integer 1)]] + (con integer 42)))))]]) +--- optimized Core +letrec + f#1 : int -> int -> int [static []] = \x#2 : int n#3 : int -> let anf#4 : bool = equalsInteger n#3 0 in + case@Bool anf#4 of + True -> 42 + False -> let anf#5 : int = addInteger x#2 1 in + let anf#6 : int -> int = f#1 anf#5 in + let anf#7 : int = subtractInteger n#3 1 in + anf#6 anf#7 +in +f#1 7 2 +--- optimized UPLC +(program 1.1.0 + [(lam f_19 [[f_19 (con integer 7)] (con integer 2)]) + [(lam self_11 [self_11 self_11]) + (lam self_12 + (lam x_13 + (lam n_14 + [(lam anf_15 + (case + anf_15 + [(lam anf_16 + [(lam anf_17 + [(lam anf_18 [anf_17 anf_18]) + [[(builtin subtractInteger) n_14] (con integer 1)]]) + [[self_12 self_12] anf_16]]) + [[(builtin addInteger) x_13] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_14] (con integer 0)]])))]]) +--- isolated pass +--- isolated Core before +letrec + f#69 : int -> int -> int [static []] = \x#71 : int n#72 : int -> case@Bool equalsInteger n#72 0 of + True -> 42 + False -> f#69 (addInteger x#71 1) (subtractInteger n#72 1) +in +f#69 7 2 +--- isolated Core after +letrec + f#69 : int -> int -> int [static []] = \x#71 : int n#72 : int -> case@Bool equalsInteger n#72 0 of + True -> 42 + False -> f#69 (addInteger x#71 1) (subtractInteger n#72 1) +in +f#69 7 2 +--- isolated UPLC before +(program 1.1.0 + [(lam f_69 [[f_69 (con integer 7)] (con integer 2)]) + [(lam self_250 [self_250 self_250]) + (lam self_250 + (lam x_71 + (lam n_72 + (case + [[(builtin equalsInteger) n_72] (con integer 0)] + [[[self_250 self_250] [[(builtin addInteger) x_71] (con integer 1)]] + [[(builtin subtractInteger) n_72] (con integer 1)]] + (con integer 42)))))]]) +--- isolated UPLC after +(program 1.1.0 + [(lam f_69 [[f_69 (con integer 7)] (con integer 2)]) + [(lam self_253 [self_253 self_253]) + (lam self_253 + (lam x_71 + (lam n_72 + [(lam anf_1 + (case + anf_1 + [(lam anf_2 + [(lam anf_3 + [(lam anf_4 [anf_3 anf_4]) [[(builtin subtractInteger) n_72] (con integer 1)]]) + [[self_253 self_253] anf_2]]) + [[(builtin addInteger) x_71] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_72] (con integer 0)]])))]]) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__delayed_mutual_worker_returns_captured_closure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__delayed_mutual_worker_returns_captured_closure.snap new file mode 100644 index 00000000..c18d5bf3 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__delayed_mutual_worker_returns_captured_closure.snap @@ -0,0 +1,85 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), result.uplc, result.result, result.logs))" +--- +--- unoptimized Core +let captured#1 : int = 40 in +letrec + f#2 : int -> int -> int [static []] = \x#4 : int -> \z#6 : int -> addInteger captured#1 z#6 + g#3 : int -> int -> int [static []] = \y#5 : int -> trace "worker" in f#2 y#5 +in +g#3 7 2 +--- unoptimized UPLC +(program 1.1.0 + [(lam captured_1 + [(lam dispatch_7 + [(lam f_2 + [(lam g_3 [[g_3 (con integer 7)] (con integer 2)]) + (lam y_15 [dispatch_7 (constr 1 dispatch_7 y_15)])]) + (lam x_16 [dispatch_7 (constr 0 dispatch_7 x_16)])]) + (lam request_8 + (case + request_8 + (lam self_9 (lam x_4 (lam z_6 [[(builtin addInteger) captured_1] z_6]))) + (lam self_12 + (lam y_5 + (force + [[(force (builtin trace)) (con string "worker")] + (delay [self_12 (constr 0 self_12 y_5)])])))))]) + (con integer 40)]) +--- optimized Core +letrec + f#8 : @delay (int -> int) [static []] = \ -> delay (\z#11 : int -> addInteger 40 z#11) + g#9 : @delay (int -> int) [static []] = \ -> delay (trace "worker" in force f#8) +in +let anf#13 : int -> int = force g#9 in +anf#13 2 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_17 + [(lam dispatch_12 + [(lam anf_16 [anf_16 (con integer 2)]) [dispatch_12 (constr 1 dispatch_12)]]) + (lam request_5 + (case + request_5 + (lam self_6 (lam z_7 [[(builtin addInteger) (con integer 40)] z_7])) + (lam self_10 + (force + [[builtin_17 (con string "worker")] (delay [self_10 (constr 0 self_10)])]))))]) + (force (builtin trace))]) +--- isolated pass +--- isolated Core before +let captured#1 : int = 40 in +letrec + f#2 : int -> int -> int [static []] = \x#4 : int -> \z#6 : int -> addInteger captured#1 z#6 + g#3 : int -> int -> int [static []] = \y#5 : int -> trace "worker" in f#2 y#5 +in +g#3 7 2 +--- isolated Core after +let captured#1 : int = 40 in +letrec + f#2 : @delay (int -> int) [static []] = \ -> delay (\z#6 : int -> addInteger captured#1 z#6) + g#3 : @delay (int -> int) [static []] = \ -> delay (trace "worker" in force f#2) +in +force g#3 2 +--- isolated UPLC after +(program 1.1.0 + [(lam captured_1 + [(lam dispatch_17 + [(lam f_2 + [(lam g_3 [(force g_3) (con integer 2)]) + (delay [dispatch_17 (constr 1 dispatch_17)])]) + (delay [dispatch_17 (constr 0 dispatch_17)])]) + (lam request_18 + (case + request_18 + (lam self_19 (lam z_6 [[(builtin addInteger) captured_1] z_6])) + (lam self_20 + (force + [[(force (builtin trace)) (con string "worker")] + (delay (force (delay [self_20 (constr 0 self_20)])))]))))]) + (con integer 40)]) +--- result +(con integer 42) +--- logs +["worker"] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__entry_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__entry_failure.snap new file mode 100644 index 00000000..acbb2f64 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__entry_failure.snap @@ -0,0 +1,106 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#43 : int -> int -> int [static []] = \x#45 : int n#46 : int -> case@Bool equalsInteger n#46 0 of + True -> 42 + False -> f#43 x#45 (subtractInteger n#46 1) +in +f#43 (trace "first" in error) (trace "later" in 2) +--- unoptimized UPLC +(program 1.1.0 + [(lam f_43 + [[f_43 (force [[(force (builtin trace)) (con string "first")] (delay (error))])] + (force [[(force (builtin trace)) (con string "later")] (delay (con integer 2))])]) + [(lam self_1 [self_1 self_1]) + (lam self_1 + (lam x_45 + (lam n_46 + (case + [[(builtin equalsInteger) n_46] (con integer 0)] + [[[self_1 self_1] x_45] [[(builtin subtractInteger) n_46] (con integer 1)]] + (con integer 42)))))]]) +--- optimized Core +let arg#6 : int = trace "first" in error in +let arg#7 : int = trace "later" in 2 in +letrec + worker#5 : int -> int [static []] = \n#4 : int -> let anf#8 : bool = equalsInteger n#4 0 in + case@Bool anf#8 of + True -> 42 + False -> let anf#9 : int = subtractInteger n#4 1 in + worker#5 anf#9 +in +worker#5 arg#7 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_17 + [(lam arg_3 + [(lam arg_10 + [(lam worker_16 [worker_16 arg_10]) + [(lam self_11 [self_11 self_11]) + (lam self_12 + (lam n_13 + [(lam anf_14 + (case + anf_14 + [(lam anf_15 [[self_12 self_12] anf_15]) + [[(builtin subtractInteger) n_13] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_13] (con integer 0)]]))]]) + (force [[builtin_17 (con string "later")] (delay (con integer 2))])]) + (force [[builtin_17 (con string "first")] (delay (error))])]) + (force (builtin trace))]) +--- isolated pass +--- isolated Core before +letrec + f#43 : int -> int -> int [static []] = \x#45 : int n#46 : int -> case@Bool equalsInteger n#46 0 of + True -> 42 + False -> f#43 x#45 (subtractInteger n#46 1) +in +f#43 (trace "first" in error) (trace "later" in 2) +--- isolated Core after +letrec + f#43 : int -> int [static []] = \n#46 : int -> case@Bool equalsInteger n#46 0 of + True -> 42 + False -> let arg#1 : int = subtractInteger n#46 1 in + f#43 arg#1 +in +let arg#2 : int = trace "first" in error in +let arg#3 : int = trace "later" in 2 in +f#43 arg#3 +--- isolated UPLC before +(program 1.1.0 + [(lam f_43 + [[f_43 (force [[(force (builtin trace)) (con string "first")] (delay (error))])] + (force [[(force (builtin trace)) (con string "later")] (delay (con integer 2))])]) + [(lam self_227 [self_227 self_227]) + (lam self_227 + (lam x_45 + (lam n_46 + (case + [[(builtin equalsInteger) n_46] (con integer 0)] + [[[self_227 self_227] x_45] [[(builtin subtractInteger) n_46] (con integer 1)]] + (con integer 42)))))]]) +--- isolated UPLC after +(program 1.1.0 + [(lam f_43 + [(lam arg_2 + [(lam arg_3 [f_43 arg_3]) + (force [[(force (builtin trace)) (con string "later")] (delay (con integer 2))])]) + (force [[(force (builtin trace)) (con string "first")] (delay (error))])]) + [(lam self_230 [self_230 self_230]) + (lam self_230 + (lam n_46 + [(lam anf_4 + (case + anf_4 + [(lam arg_1 [[self_230 self_230] arg_1]) + [[(builtin subtractInteger) n_46] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_46] (con integer 0)]]))]]) +--- result +error: ExplicitErrorTerm +--- logs +["first"] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__escaping.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__escaping.snap new file mode 100644 index 00000000..86f08335 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__escaping.snap @@ -0,0 +1,92 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#55 : int -> int -> int [static []] = \x#57 : int n#58 : int -> case@Bool equalsInteger n#58 0 of + True -> 42 + False -> f#55 x#57 (subtractInteger n#58 1) +in +let alias#61 : int -> int -> int = f#55 in +alias#61 7 2 +--- unoptimized UPLC +(program 1.1.0 + [(lam f_55 [(lam alias_61 [[alias_61 (con integer 7)] (con integer 2)]) f_55]) + [(lam self_1 [self_1 self_1]) + (lam self_1 + (lam x_57 + (lam n_58 + (case + [[(builtin equalsInteger) n_58] (con integer 0)] + [[[self_1 self_1] x_57] [[(builtin subtractInteger) n_58] (con integer 1)]] + (con integer 42)))))]]) +--- optimized Core +letrec + worker#6 : int -> int [static []] = \n#5 : int -> let anf#7 : bool = equalsInteger n#5 0 in + case@Bool anf#7 of + True -> 42 + False -> let anf#8 : int = subtractInteger n#5 1 in + worker#6 anf#8 +in +worker#6 2 +--- optimized UPLC +(program 1.1.0 + [(lam worker_12 [worker_12 (con integer 2)]) + [(lam self_3 [self_3 self_3]) + (lam self_4 + (lam n_9 + [(lam anf_10 + (case + anf_10 + [(lam anf_11 [[self_4 self_4] anf_11]) + [[(builtin subtractInteger) n_9] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_9] (con integer 0)]]))]]) +--- isolated pass +--- isolated Core before +letrec + f#55 : int -> int -> int [static []] = \x#57 : int n#58 : int -> case@Bool equalsInteger n#58 0 of + True -> 42 + False -> f#55 x#57 (subtractInteger n#58 1) +in +let alias#61 : int -> int -> int = f#55 in +alias#61 7 2 +--- isolated Core after +letrec + f#55 : int -> int -> int [static []] = \x#57 : int n#58 : int -> case@Bool equalsInteger n#58 0 of + True -> 42 + False -> f#55 x#57 (subtractInteger n#58 1) +in +let alias#61 : int -> int -> int = f#55 in +alias#61 7 2 +--- isolated UPLC before +(program 1.1.0 + [(lam f_55 [(lam alias_61 [[alias_61 (con integer 7)] (con integer 2)]) f_55]) + [(lam self_238 [self_238 self_238]) + (lam self_238 + (lam x_57 + (lam n_58 + (case + [[(builtin equalsInteger) n_58] (con integer 0)] + [[[self_238 self_238] x_57] [[(builtin subtractInteger) n_58] (con integer 1)]] + (con integer 42)))))]]) +--- isolated UPLC after +(program 1.1.0 + [(lam f_55 [(lam alias_61 [[alias_61 (con integer 7)] (con integer 2)]) f_55]) + [(lam self_241 [self_241 self_241]) + (lam self_241 + (lam x_57 + (lam n_58 + [(lam anf_1 + (case + anf_1 + [(lam anf_2 + [(lam anf_3 [anf_2 anf_3]) [[(builtin subtractInteger) n_58] (con integer 1)]]) + [[self_241 self_241] x_57]] + (con integer 42))) + [[(builtin equalsInteger) n_58] (con integer 0)]])))]]) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__forwarding_divergence_remains_delayed_and_strict.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__forwarding_divergence_remains_delayed_and_strict.snap new file mode 100644 index 00000000..38f24cbb --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__forwarding_divergence_remains_delayed_and_strict.snap @@ -0,0 +1,50 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\npretty(before), pretty(after)))" +--- +--- unoptimized Core +letrec + f#1 : int -> int [static []] = \x#3 : int -> g#2 x#3 + g#2 : int -> int [static []] = \y#4 : int -> f#1 y#4 +in +f#1 (addInteger 1 2) +--- unoptimized UPLC +(program 1.1.0 + [(lam dispatch_5 + [(lam f_1 + [(lam g_2 [f_1 [[(builtin addInteger) (con integer 1)] (con integer 2)]]) + (lam y_13 [dispatch_5 (constr 1 dispatch_5 y_13)])]) + (lam x_14 [dispatch_5 (constr 0 dispatch_5 x_14)])]) + (lam request_6 + (case + request_6 + (lam self_7 (lam x_3 [self_7 (constr 1 self_7 x_3)])) + (lam self_10 (lam y_4 [self_10 (constr 0 self_10 y_4)]))))]) +--- optimized Core +letrec + f#5 : @delay int [static []] = \ -> delay (force g#6) + g#6 : @delay int [static []] = \ -> delay (force f#5) +in +force f#5 +--- optimized UPLC +(program 1.1.0 + [(lam dispatch_10 [dispatch_10 (constr 0 dispatch_10)]) + (lam request_7 + (case + request_7 + (lam self_8 [self_8 (constr 1 self_8)]) + (lam self_9 [self_9 (constr 0 self_9)])))]) +--- isolated pass +--- isolated Core before +letrec + f#1 : int -> int [static []] = \x#3 : int -> g#2 x#3 + g#2 : int -> int [static []] = \y#4 : int -> f#1 y#4 +in +f#1 (addInteger 1 2) +--- isolated Core after +letrec + f#1 : @delay int [static []] = \ -> delay (force g#2) + g#2 : @delay int [static []] = \ -> delay (force f#1) +in +let arg#5 : int = addInteger 1 2 in +force f#1 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mixed_delayed.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mixed_delayed.snap new file mode 100644 index 00000000..29ed740f --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mixed_delayed.snap @@ -0,0 +1,148 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#75 : int -> int -> int [static []] = \x#77 : int n#78 : int -> case@Bool equalsInteger n#78 0 of + True -> 42 + False -> f#75 x#77 (subtractInteger n#78 1) + g#76 : int -> int -> int [static []] = \y#79 : int m#80 : int -> trace "delayed" in f#75 7 2 +in +addInteger (f#75 7 2) (g#76 0 0) +--- unoptimized UPLC +(program 1.1.0 + [(lam dispatch_1 + [(lam f_75 + [(lam g_76 + [[(builtin addInteger) [[f_75 (con integer 7)] (con integer 2)]] + [[g_76 (con integer 0)] (con integer 0)]]) + (lam y_13 (lam m_14 [dispatch_1 (constr 1 dispatch_1 y_13 m_14)]))]) + (lam x_15 (lam n_16 [dispatch_1 (constr 0 dispatch_1 x_15 n_16)]))]) + (lam request_2 + (case + request_2 + (lam self_3 + (lam x_77 + (lam n_78 + (case + [[(builtin equalsInteger) n_78] (con integer 0)] + [self_3 + (constr 0 self_3 x_77 [[(builtin subtractInteger) n_78] (con integer 1)])] + (con integer 42))))) + (lam self_8 + (lam y_79 + (lam m_80 + (force + [[(force (builtin trace)) (con string "delayed")] + (delay [self_8 (constr 0 self_8 (con integer 7) (con integer 2))])]))))))]) +--- optimized Core +letrec + f#1 : int -> int [static []] = \n#4 : int -> let anf#8 : bool = equalsInteger n#4 0 in + case@Bool anf#8 of + True -> 42 + False -> let arg#7 : int = subtractInteger n#4 1 in + f#1 arg#7 + g#2 : @delay int [static []] = \ -> delay (trace "delayed" in f#1 2) +in +let anf#9 : int = f#1 2 in +let anf#10 : int = force g#2 in +addInteger anf#9 anf#10 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_27 + [(lam dispatch_21 + [(lam anf_25 + [(lam anf_26 [[(builtin addInteger) anf_25] anf_26]) + [dispatch_21 (constr 1 dispatch_21)]]) + [dispatch_21 (constr 0 dispatch_21 (con integer 2))]]) + (lam request_15 + (case + request_15 + (lam self_16 + (lam n_17 + [(lam anf_18 + (case + anf_18 + [(lam arg_19 [self_16 (constr 0 self_16 arg_19)]) + [[(builtin subtractInteger) n_17] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_17] (con integer 0)]])) + (lam self_20 + (force + [[builtin_27 (con string "delayed")] + (delay [self_20 (constr 0 self_20 (con integer 2))])]))))]) + (force (builtin trace))]) +--- isolated pass +--- isolated Core before +letrec + f#75 : int -> int -> int [static []] = \x#77 : int n#78 : int -> case@Bool equalsInteger n#78 0 of + True -> 42 + False -> f#75 x#77 (subtractInteger n#78 1) + g#76 : int -> int -> int [static []] = \y#79 : int m#80 : int -> trace "delayed" in f#75 7 2 +in +addInteger (f#75 7 2) (g#76 0 0) +--- isolated Core after +letrec + f#75 : int -> int [static []] = \n#78 : int -> case@Bool equalsInteger n#78 0 of + True -> 42 + False -> let arg#1 : int = subtractInteger n#78 1 in + f#75 arg#1 + g#76 : @delay int [static []] = \ -> delay (trace "delayed" in f#75 2) +in +addInteger (f#75 2) (force g#76) +--- isolated UPLC before +(program 1.1.0 + [(lam dispatch_256 + [(lam f_75 + [(lam g_76 + [[(builtin addInteger) [[f_75 (con integer 7)] (con integer 2)]] + [[g_76 (con integer 0)] (con integer 0)]]) + (lam y_268 (lam m_269 [dispatch_256 (constr 1 dispatch_256 y_268 m_269)]))]) + (lam x_270 (lam n_271 [dispatch_256 (constr 0 dispatch_256 x_270 n_271)]))]) + (lam request_257 + (case + request_257 + (lam self_258 + (lam x_77 + (lam n_78 + (case + [[(builtin equalsInteger) n_78] (con integer 0)] + [self_258 + (constr 0 self_258 x_77 [[(builtin subtractInteger) n_78] (con integer 1)])] + (con integer 42))))) + (lam self_263 + (lam y_79 + (lam m_80 + (force + [[(force (builtin trace)) (con string "delayed")] + (delay [self_263 (constr 0 self_263 (con integer 7) (con integer 2))])]))))))]) +--- isolated UPLC after +(program 1.1.0 + [(lam dispatch_272 + [(lam f_75 + [(lam g_76 + [(lam anf_3 [(lam anf_4 [[(builtin addInteger) anf_3] anf_4]) (force g_76)]) + [f_75 (con integer 2)]]) + (delay [dispatch_272 (constr 1 dispatch_272)])]) + (lam n_278 [dispatch_272 (constr 0 dispatch_272 n_278)])]) + (lam request_273 + (case + request_273 + (lam self_274 + (lam n_78 + [(lam anf_2 + (case + anf_2 + [(lam arg_1 [self_274 (constr 0 self_274 arg_1)]) + [[(builtin subtractInteger) n_78] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_78] (con integer 0)]])) + (lam self_276 + (force + [[(force (builtin trace)) (con string "delayed")] + (delay [self_276 (constr 0 self_276 (con integer 2))])]))))]) +--- result +(con integer 84) +--- logs +["delayed"] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mixed_group_prunes_to_single_delayed_worker.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mixed_group_prunes_to_single_delayed_worker.snap new file mode 100644 index 00000000..dfd3737c --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mixed_group_prunes_to_single_delayed_worker.snap @@ -0,0 +1,60 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- reduced mixed group\\n{}\\n--- pruned group\\n{}\\n--- lowered\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(reduced), pretty(after), result.uplc, result.result, result.logs))" +--- +--- unoptimized Core +letrec + delayed#1 : int -> int [static []] = \x#3 : int -> trace "body" in 42 + unusedFunction#2 : int -> int [static []] = \y#4 : int -> y#4 +in +delayed#1 0 +--- unoptimized UPLC +(program 1.1.0 + [(lam dispatch_5 + [(lam delayed_1 + [(lam unusedFunction_2 [delayed_1 (con integer 0)]) + (lam y_13 [dispatch_5 (constr 1 dispatch_5 y_13)])]) + (lam x_14 [dispatch_5 (constr 0 dispatch_5 x_14)])]) + (lam request_6 + (case + request_6 + (lam self_7 + (lam x_3 + (force [[(force (builtin trace)) (con string "body")] (delay (con integer 42))]))) + (lam self_10 (lam y_4 y_4))))]) +--- optimized Core +letrec + delayed#5 : @delay int [static []] = \ -> delay (trace "body" in 42) +in +force delayed#5 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_5 + [(lam delayed_4 (force delayed_4)) + [(lam self_2 [self_2 self_2]) + (lam self_3 + (delay (force [[builtin_5 (con string "body")] (delay (con integer 42))])))]]) + (force (builtin trace))]) +--- isolated pass +--- reduced mixed group +letrec + delayed#1 : @delay int [static []] = \ -> delay (trace "body" in 42) + unusedFunction#2 : int -> int [static []] = \y#4 : int -> y#4 +in +force delayed#1 +--- pruned group +letrec + delayed#1 : @delay int [static []] = \ -> delay (trace "body" in 42) +in +force delayed#1 +--- lowered +(program 1.1.0 + [(lam delayed_1 (force delayed_1)) + [(lam self_15 [self_15 self_15]) + (lam self_15 + (delay + (force [[(force (builtin trace)) (con string "body")] (delay (con integer 42))])))]]) +--- result +(con integer 42) +--- logs +["body"] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mutual_consumed.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mutual_consumed.snap new file mode 100644 index 00000000..20c2af17 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mutual_consumed.snap @@ -0,0 +1,164 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#13 : int -> int -> int [static []] = \x#15 : int n#16 : int -> case@Bool equalsInteger n#16 0 of + True -> x#15 + False -> g#14 (subtractInteger n#16 1) x#15 + g#14 : int -> int -> int [static []] = \m#17 : int y#18 : int -> case@Bool equalsInteger m#17 0 of + True -> y#18 + False -> f#13 y#18 (subtractInteger m#17 1) +in +f#13 7 3 +--- unoptimized UPLC +(program 1.1.0 + [(lam dispatch_1 + [(lam f_13 + [(lam g_14 [[f_13 (con integer 7)] (con integer 3)]) + (lam m_19 (lam y_20 [dispatch_1 (constr 1 dispatch_1 m_19 y_20)]))]) + (lam x_21 (lam n_22 [dispatch_1 (constr 0 dispatch_1 x_21 n_22)]))]) + (lam request_2 + (case + request_2 + (lam self_3 + (lam x_15 + (lam n_16 + (case + [[(builtin equalsInteger) n_16] (con integer 0)] + [self_3 + (constr 1 self_3 [[(builtin subtractInteger) n_16] (con integer 1)] x_15)] + x_15)))) + (lam self_8 + (lam m_17 + (lam y_18 + (case + [[(builtin equalsInteger) m_17] (con integer 0)] + [self_8 + (constr 0 self_8 y_18 [[(builtin subtractInteger) m_17] (con integer 1)])] + y_18))))))]) +--- optimized Core +letrec + f#1 : int -> int -> int [static []] = \x#3 : int n#4 : int -> let anf#7 : bool = equalsInteger n#4 0 in + case@Bool anf#7 of + True -> x#3 + False -> let anf#8 : int = subtractInteger n#4 1 in + g#2 anf#8 x#3 + g#2 : int -> int -> int [static []] = \m#5 : int y#6 : int -> let anf#9 : bool = equalsInteger m#5 0 in + case@Bool anf#9 of + True -> y#6 + False -> let anf#10 : int -> int = f#1 y#6 in + let anf#11 : int = subtractInteger m#5 1 in + anf#10 anf#11 +in +f#1 7 3 +--- optimized UPLC +(program 1.1.0 + [(lam dispatch_42 + [dispatch_42 (constr 0 dispatch_42 (con integer 7) (con integer 3))]) + (lam request_28 + (case + request_28 + (lam self_29 + (lam x_30 + (lam n_31 + [(lam anf_32 + (case + anf_32 + [(lam anf_33 [self_29 (constr 1 self_29 anf_33 x_30)]) + [[(builtin subtractInteger) n_31] (con integer 1)]] + x_30)) + [[(builtin equalsInteger) n_31] (con integer 0)]]))) + (lam self_34 + (lam m_35 + (lam y_36 + [(lam anf_37 + (case + anf_37 + [(lam anf_41 [self_34 (constr 0 self_34 y_36 anf_41)]) + [[(builtin subtractInteger) m_35] (con integer 1)]] + y_36)) + [[(builtin equalsInteger) m_35] (con integer 0)]])))))]) +--- isolated pass +--- isolated Core before +letrec + f#13 : int -> int -> int [static []] = \x#15 : int n#16 : int -> case@Bool equalsInteger n#16 0 of + True -> x#15 + False -> g#14 (subtractInteger n#16 1) x#15 + g#14 : int -> int -> int [static []] = \m#17 : int y#18 : int -> case@Bool equalsInteger m#17 0 of + True -> y#18 + False -> f#13 y#18 (subtractInteger m#17 1) +in +f#13 7 3 +--- isolated Core after +letrec + f#13 : int -> int -> int [static []] = \x#15 : int n#16 : int -> case@Bool equalsInteger n#16 0 of + True -> x#15 + False -> g#14 (subtractInteger n#16 1) x#15 + g#14 : int -> int -> int [static []] = \m#17 : int y#18 : int -> case@Bool equalsInteger m#17 0 of + True -> y#18 + False -> f#13 y#18 (subtractInteger m#17 1) +in +f#13 7 3 +--- isolated UPLC before +(program 1.1.0 + [(lam dispatch_112 + [(lam f_13 + [(lam g_14 [[f_13 (con integer 7)] (con integer 3)]) + (lam m_124 (lam y_125 [dispatch_112 (constr 1 dispatch_112 m_124 y_125)]))]) + (lam x_126 (lam n_127 [dispatch_112 (constr 0 dispatch_112 x_126 n_127)]))]) + (lam request_113 + (case + request_113 + (lam self_114 + (lam x_15 + (lam n_16 + (case + [[(builtin equalsInteger) n_16] (con integer 0)] + [self_114 + (constr 1 self_114 [[(builtin subtractInteger) n_16] (con integer 1)] x_15)] + x_15)))) + (lam self_119 + (lam m_17 + (lam y_18 + (case + [[(builtin equalsInteger) m_17] (con integer 0)] + [self_119 + (constr 0 self_119 y_18 [[(builtin subtractInteger) m_17] (con integer 1)])] + y_18))))))]) +--- isolated UPLC after +(program 1.1.0 + [(lam dispatch_128 + [(lam f_13 + [(lam g_14 [[f_13 (con integer 7)] (con integer 3)]) + (lam m_140 (lam y_141 [dispatch_128 (constr 1 dispatch_128 m_140 y_141)]))]) + (lam x_142 (lam n_143 [dispatch_128 (constr 0 dispatch_128 x_142 n_143)]))]) + (lam request_129 + (case + request_129 + (lam self_130 + (lam x_15 + (lam n_16 + [(lam anf_1 + (case + anf_1 + [(lam anf_2 [self_130 (constr 1 self_130 anf_2 x_15)]) + [[(builtin subtractInteger) n_16] (con integer 1)]] + x_15)) + [[(builtin equalsInteger) n_16] (con integer 0)]]))) + (lam self_135 + (lam m_17 + (lam y_18 + [(lam anf_3 + (case + anf_3 + [(lam anf_4 + [(lam anf_5 [anf_4 anf_5]) [[(builtin subtractInteger) m_17] (con integer 1)]]) + [(lam x_136 (lam n_137 [self_135 (constr 0 self_135 x_136 n_137)])) y_18]] + y_18)) + [[(builtin equalsInteger) m_17] (con integer 0)]])))))]) +--- result +(con integer 7) +--- logs +[] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mutual_forwarding.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mutual_forwarding.snap new file mode 100644 index 00000000..833eec7a --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__mutual_forwarding.snap @@ -0,0 +1,159 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#7 : int -> int -> int [static []] = \x#9 : int n#10 : int -> case@Bool equalsInteger n#10 0 of + True -> 42 + False -> g#8 (subtractInteger n#10 1) x#9 + g#8 : int -> int -> int [static []] = \m#11 : int y#12 : int -> case@Bool equalsInteger m#11 0 of + True -> 42 + False -> f#7 y#12 (subtractInteger m#11 1) +in +f#7 7 3 +--- unoptimized UPLC +(program 1.1.0 + [(lam dispatch_1 + [(lam f_7 + [(lam g_8 [[f_7 (con integer 7)] (con integer 3)]) + (lam m_19 (lam y_20 [dispatch_1 (constr 1 dispatch_1 m_19 y_20)]))]) + (lam x_21 (lam n_22 [dispatch_1 (constr 0 dispatch_1 x_21 n_22)]))]) + (lam request_2 + (case + request_2 + (lam self_3 + (lam x_9 + (lam n_10 + (case + [[(builtin equalsInteger) n_10] (con integer 0)] + [self_3 + (constr 1 self_3 [[(builtin subtractInteger) n_10] (con integer 1)] x_9)] + (con integer 42))))) + (lam self_14 + (lam m_11 + (lam y_12 + (case + [[(builtin equalsInteger) m_11] (con integer 0)] + [self_14 + (constr 0 self_14 y_12 [[(builtin subtractInteger) m_11] (con integer 1)])] + (con integer 42)))))))]) +--- optimized Core +letrec + f#1 : int -> int [static []] = \n#4 : int -> let anf#9 : bool = equalsInteger n#4 0 in + case@Bool anf#9 of + True -> 42 + False -> let arg#7 : int = subtractInteger n#4 1 in + g#2 arg#7 + g#2 : int -> int [static []] = \m#5 : int -> let anf#10 : bool = equalsInteger m#5 0 in + case@Bool anf#10 of + True -> 42 + False -> let arg#8 : int = subtractInteger m#5 1 in + f#1 arg#8 +in +f#1 3 +--- optimized UPLC +(program 1.1.0 + [(lam dispatch_28 [dispatch_28 (constr 0 dispatch_28 (con integer 3))]) + (lam request_19 + (case + request_19 + (lam self_20 + (lam n_21 + [(lam anf_22 + (case + anf_22 + [(lam arg_23 [self_20 (constr 1 self_20 arg_23)]) + [[(builtin subtractInteger) n_21] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_21] (con integer 0)]])) + (lam self_24 + (lam m_25 + [(lam anf_26 + (case + anf_26 + [(lam arg_27 [self_24 (constr 0 self_24 arg_27)]) + [[(builtin subtractInteger) m_25] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) m_25] (con integer 0)]]))))]) +--- isolated pass +--- isolated Core before +letrec + f#7 : int -> int -> int [static []] = \x#9 : int n#10 : int -> case@Bool equalsInteger n#10 0 of + True -> 42 + False -> g#8 (subtractInteger n#10 1) x#9 + g#8 : int -> int -> int [static []] = \m#11 : int y#12 : int -> case@Bool equalsInteger m#11 0 of + True -> 42 + False -> f#7 y#12 (subtractInteger m#11 1) +in +f#7 7 3 +--- isolated Core after +letrec + f#7 : int -> int [static []] = \n#10 : int -> case@Bool equalsInteger n#10 0 of + True -> 42 + False -> let arg#1 : int = subtractInteger n#10 1 in + g#8 arg#1 + g#8 : int -> int [static []] = \m#11 : int -> case@Bool equalsInteger m#11 0 of + True -> 42 + False -> let arg#2 : int = subtractInteger m#11 1 in + f#7 arg#2 +in +f#7 3 +--- isolated UPLC before +(program 1.1.0 + [(lam dispatch_86 + [(lam f_7 + [(lam g_8 [[f_7 (con integer 7)] (con integer 3)]) + (lam m_98 (lam y_99 [dispatch_86 (constr 1 dispatch_86 m_98 y_99)]))]) + (lam x_100 (lam n_101 [dispatch_86 (constr 0 dispatch_86 x_100 n_101)]))]) + (lam request_87 + (case + request_87 + (lam self_88 + (lam x_9 + (lam n_10 + (case + [[(builtin equalsInteger) n_10] (con integer 0)] + [self_88 + (constr 1 self_88 [[(builtin subtractInteger) n_10] (con integer 1)] x_9)] + (con integer 42))))) + (lam self_93 + (lam m_11 + (lam y_12 + (case + [[(builtin equalsInteger) m_11] (con integer 0)] + [self_93 + (constr 0 self_93 y_12 [[(builtin subtractInteger) m_11] (con integer 1)])] + (con integer 42)))))))]) +--- isolated UPLC after +(program 1.1.0 + [(lam dispatch_102 + [(lam f_7 + [(lam g_8 [f_7 (con integer 3)]) + (lam m_110 [dispatch_102 (constr 1 dispatch_102 m_110)])]) + (lam n_111 [dispatch_102 (constr 0 dispatch_102 n_111)])]) + (lam request_103 + (case + request_103 + (lam self_104 + (lam n_10 + [(lam anf_3 + (case + anf_3 + [(lam arg_1 [self_104 (constr 1 self_104 arg_1)]) + [[(builtin subtractInteger) n_10] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_10] (con integer 0)]])) + (lam self_107 + (lam m_11 + [(lam anf_4 + (case + anf_4 + [(lam arg_2 [self_107 (constr 0 self_107 arg_2)]) + [[(builtin subtractInteger) m_11] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) m_11] (con integer 0)]]))))]) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__oversaturated.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__oversaturated.snap new file mode 100644 index 00000000..a2c159ce --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__oversaturated.snap @@ -0,0 +1,50 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#62 : int -> int -> int -> int [static []] = \x#64 : int n#65 : int -> \z#68 : int -> z#68 +in +f#62 0 0 42 +--- unoptimized UPLC +(program 1.1.0 + [(lam f_62 [[[f_62 (con integer 0)] (con integer 0)] (con integer 42)]) + [(lam self_1 [self_1 self_1]) + (lam self_1 (lam x_64 (lam n_65 (lam z_68 z_68))))]]) +--- optimized Core +letrec + f#1 : int -> int -> int -> int [static []] = \x#2 : int n#3 : int -> \z#4 : int -> z#4 +in +f#1 0 0 42 +--- optimized UPLC +(program 1.1.0 + [(lam f_13 + (case (constr 0 (con integer 0) (con integer 0) (con integer 42)) f_13)) + [(lam self_8 [self_8 self_8]) + (lam self_9 (lam x_10 (lam n_11 (lam z_12 z_12))))]]) +--- isolated pass +--- isolated Core before +letrec + f#62 : int -> int -> int -> int [static []] = \x#64 : int n#65 : int -> \z#68 : int -> z#68 +in +f#62 0 0 42 +--- isolated Core after +letrec + f#62 : int -> int -> int -> int [static []] = \x#64 : int n#65 : int -> \z#68 : int -> z#68 +in +f#62 0 0 42 +--- isolated UPLC before +(program 1.1.0 + [(lam f_62 [[[f_62 (con integer 0)] (con integer 0)] (con integer 42)]) + [(lam self_244 [self_244 self_244]) + (lam self_244 (lam x_64 (lam n_65 (lam z_68 z_68))))]]) +--- isolated UPLC after +(program 1.1.0 + [(lam f_62 [[[f_62 (con integer 0)] (con integer 0)] (con integer 42)]) + [(lam self_247 [self_247 self_247]) + (lam self_247 (lam x_64 (lam n_65 (lam z_68 z_68))))]]) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__partial.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__partial.snap new file mode 100644 index 00000000..7696b2bb --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__partial.snap @@ -0,0 +1,89 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#49 : int -> int -> int [static []] = \x#51 : int n#52 : int -> case@Bool equalsInteger n#52 0 of + True -> 42 + False -> f#49 x#51 (subtractInteger n#52 1) +in +f#49 7 2 +--- unoptimized UPLC +(program 1.1.0 + [(lam f_49 [[f_49 (con integer 7)] (con integer 2)]) + [(lam self_1 [self_1 self_1]) + (lam self_1 + (lam x_51 + (lam n_52 + (case + [[(builtin equalsInteger) n_52] (con integer 0)] + [[[self_1 self_1] x_51] [[(builtin subtractInteger) n_52] (con integer 1)]] + (con integer 42)))))]]) +--- optimized Core +letrec + worker#5 : int -> int [static []] = \n#4 : int -> let anf#6 : bool = equalsInteger n#4 0 in + case@Bool anf#6 of + True -> 42 + False -> let anf#7 : int = subtractInteger n#4 1 in + worker#5 anf#7 +in +worker#5 2 +--- optimized UPLC +(program 1.1.0 + [(lam worker_12 [worker_12 (con integer 2)]) + [(lam self_3 [self_3 self_3]) + (lam self_8 + (lam n_9 + [(lam anf_10 + (case + anf_10 + [(lam anf_11 [[self_8 self_8] anf_11]) + [[(builtin subtractInteger) n_9] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_9] (con integer 0)]]))]]) +--- isolated pass +--- isolated Core before +letrec + f#49 : int -> int -> int [static []] = \x#51 : int n#52 : int -> case@Bool equalsInteger n#52 0 of + True -> 42 + False -> f#49 x#51 (subtractInteger n#52 1) +in +f#49 7 2 +--- isolated Core after +letrec + f#49 : int -> int -> int [static []] = \x#51 : int n#52 : int -> case@Bool equalsInteger n#52 0 of + True -> 42 + False -> f#49 x#51 (subtractInteger n#52 1) +in +f#49 7 2 +--- isolated UPLC before +(program 1.1.0 + [(lam f_49 [[f_49 (con integer 7)] (con integer 2)]) + [(lam self_232 [self_232 self_232]) + (lam self_232 + (lam x_51 + (lam n_52 + (case + [[(builtin equalsInteger) n_52] (con integer 0)] + [[[self_232 self_232] x_51] [[(builtin subtractInteger) n_52] (con integer 1)]] + (con integer 42)))))]]) +--- isolated UPLC after +(program 1.1.0 + [(lam f_49 [(lam anf_4 [anf_4 (con integer 2)]) [f_49 (con integer 7)]]) + [(lam self_235 [self_235 self_235]) + (lam self_235 + (lam x_51 + (lam n_52 + [(lam anf_1 + (case + anf_1 + [(lam anf_2 + [(lam anf_3 [anf_2 anf_3]) [[(builtin subtractInteger) n_52] (con integer 1)]]) + [[self_235 self_235] x_51]] + (con integer 42))) + [[(builtin equalsInteger) n_52] (con integer 0)]])))]]) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__recursive_failure_order.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__recursive_failure_order.snap new file mode 100644 index 00000000..003699c8 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__recursive_failure_order.snap @@ -0,0 +1,201 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#25 : int -> int -> int [static []] = \x#27 : int n#28 : int -> case@Bool equalsInteger n#28 0 of + True -> 42 + False -> g#26 (trace "retained" in subtractInteger n#28 1) (trace "discarded" in error) + g#26 : int -> int -> int [static []] = \m#29 : int y#30 : int -> case@Bool equalsInteger m#29 0 of + True -> 42 + False -> f#25 (trace "discarded" in error) (trace "retained" in subtractInteger m#29 1) +in +f#25 7 3 +--- unoptimized UPLC +(program 1.1.0 + [(lam dispatch_1 + [(lam f_25 + [(lam g_26 [[f_25 (con integer 7)] (con integer 3)]) + (lam m_13 (lam y_14 [dispatch_1 (constr 1 dispatch_1 m_13 y_14)]))]) + (lam x_15 (lam n_16 [dispatch_1 (constr 0 dispatch_1 x_15 n_16)]))]) + (lam request_2 + (case + request_2 + (lam self_3 + (lam x_27 + (lam n_28 + (case + [[(builtin equalsInteger) n_28] (con integer 0)] + [self_3 + (constr 1 + self_3 + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) n_28] (con integer 1)])]) + (force [[(force (builtin trace)) (con string "discarded")] (delay (error))]))] + (con integer 42))))) + (lam self_8 + (lam m_29 + (lam y_30 + (case + [[(builtin equalsInteger) m_29] (con integer 0)] + [self_8 + (constr 0 + self_8 + (force [[(force (builtin trace)) (con string "discarded")] (delay (error))]) + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) m_29] (con integer 1)])]))] + (con integer 42)))))))]) +--- optimized Core +letrec + f#1 : int -> int [static []] = \n#4 : int -> let anf#11 : bool = equalsInteger n#4 0 in + case@Bool anf#11 of + True -> 42 + False -> let arg#7 : int = trace "retained" in subtractInteger n#4 1 in + let arg#8 : int = trace "discarded" in error in + g#2 arg#7 + g#2 : int -> int [static []] = \m#5 : int -> let anf#12 : bool = equalsInteger m#5 0 in + case@Bool anf#12 of + True -> 42 + False -> let arg#9 : int = trace "discarded" in error in + let arg#10 : int = trace "retained" in subtractInteger m#5 1 in + f#1 arg#10 +in +f#1 3 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_37 + [(lam partial_38 + [(lam partial_39 + [(lam dispatch_32 [dispatch_32 (constr 0 dispatch_32 (con integer 3))]) + (lam request_21 + (case + request_21 + (lam self_22 + (lam n_23 + [(lam anf_24 + (case + anf_24 + [(lam arg_25 + [(lam arg_26 [self_22 (constr 1 self_22 arg_25)]) + (force [partial_38 (delay (error))])]) + (force [partial_39 (delay [[(builtin subtractInteger) n_23] (con integer 1)])])] + (con integer 42))) + [[(builtin equalsInteger) n_23] (con integer 0)]])) + (lam self_27 + (lam m_28 + [(lam anf_29 + (case + anf_29 + [(lam arg_30 + [(lam arg_31 [self_27 (constr 0 self_27 arg_31)]) + (force [partial_39 (delay [[(builtin subtractInteger) m_28] (con integer 1)])])]) + (force [partial_38 (delay (error))])] + (con integer 42))) + [[(builtin equalsInteger) m_28] (con integer 0)]]))))]) + [builtin_37 (con string "retained")]]) + [builtin_37 (con string "discarded")]]) + (force (builtin trace))]) +--- isolated pass +--- isolated Core before +letrec + f#25 : int -> int -> int [static []] = \x#27 : int n#28 : int -> case@Bool equalsInteger n#28 0 of + True -> 42 + False -> g#26 (trace "retained" in subtractInteger n#28 1) (trace "discarded" in error) + g#26 : int -> int -> int [static []] = \m#29 : int y#30 : int -> case@Bool equalsInteger m#29 0 of + True -> 42 + False -> f#25 (trace "discarded" in error) (trace "retained" in subtractInteger m#29 1) +in +f#25 7 3 +--- isolated Core after +letrec + f#25 : int -> int [static []] = \n#28 : int -> case@Bool equalsInteger n#28 0 of + True -> 42 + False -> let arg#1 : int = trace "retained" in subtractInteger n#28 1 in + let arg#2 : int = trace "discarded" in error in + g#26 arg#1 + g#26 : int -> int [static []] = \m#29 : int -> case@Bool equalsInteger m#29 0 of + True -> 42 + False -> let arg#3 : int = trace "discarded" in error in + let arg#4 : int = trace "retained" in subtractInteger m#29 1 in + f#25 arg#4 +in +f#25 3 +--- isolated UPLC before +(program 1.1.0 + [(lam dispatch_170 + [(lam f_25 + [(lam g_26 [[f_25 (con integer 7)] (con integer 3)]) + (lam m_182 (lam y_183 [dispatch_170 (constr 1 dispatch_170 m_182 y_183)]))]) + (lam x_184 (lam n_185 [dispatch_170 (constr 0 dispatch_170 x_184 n_185)]))]) + (lam request_171 + (case + request_171 + (lam self_172 + (lam x_27 + (lam n_28 + (case + [[(builtin equalsInteger) n_28] (con integer 0)] + [self_172 + (constr 1 + self_172 + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) n_28] (con integer 1)])]) + (force [[(force (builtin trace)) (con string "discarded")] (delay (error))]))] + (con integer 42))))) + (lam self_177 + (lam m_29 + (lam y_30 + (case + [[(builtin equalsInteger) m_29] (con integer 0)] + [self_177 + (constr 0 + self_177 + (force [[(force (builtin trace)) (con string "discarded")] (delay (error))]) + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) m_29] (con integer 1)])]))] + (con integer 42)))))))]) +--- isolated UPLC after +(program 1.1.0 + [(lam dispatch_186 + [(lam f_25 + [(lam g_26 [f_25 (con integer 3)]) + (lam m_194 [dispatch_186 (constr 1 dispatch_186 m_194)])]) + (lam n_195 [dispatch_186 (constr 0 dispatch_186 n_195)])]) + (lam request_187 + (case + request_187 + (lam self_188 + (lam n_28 + [(lam anf_5 + (case + anf_5 + [(lam arg_1 + [(lam arg_2 [self_188 (constr 1 self_188 arg_1)]) + (force [[(force (builtin trace)) (con string "discarded")] (delay (error))])]) + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) n_28] (con integer 1)])])] + (con integer 42))) + [[(builtin equalsInteger) n_28] (con integer 0)]])) + (lam self_191 + (lam m_29 + [(lam anf_6 + (case + anf_6 + [(lam arg_3 + [(lam arg_4 [self_191 (constr 0 self_191 arg_4)]) + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) m_29] (con integer 1)])])]) + (force [[(force (builtin trace)) (con string "discarded")] (delay (error))])] + (con integer 42))) + [[(builtin equalsInteger) m_29] (con integer 0)]]))))]) +--- result +error: ExplicitErrorTerm +--- logs +["retained", "discarded"] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__recursive_trace_order.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__recursive_trace_order.snap new file mode 100644 index 00000000..f837ffd6 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__recursive_trace_order.snap @@ -0,0 +1,207 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#19 : int -> int -> int [static []] = \x#21 : int n#22 : int -> case@Bool equalsInteger n#22 0 of + True -> 42 + False -> g#20 (trace "retained" in subtractInteger n#22 1) (trace "discarded" in 7) + g#20 : int -> int -> int [static []] = \m#23 : int y#24 : int -> case@Bool equalsInteger m#23 0 of + True -> 42 + False -> f#19 (trace "discarded" in 7) (trace "retained" in subtractInteger m#23 1) +in +f#19 7 3 +--- unoptimized UPLC +(program 1.1.0 + [(lam dispatch_1 + [(lam f_19 + [(lam g_20 [[f_19 (con integer 7)] (con integer 3)]) + (lam m_13 (lam y_14 [dispatch_1 (constr 1 dispatch_1 m_13 y_14)]))]) + (lam x_15 (lam n_16 [dispatch_1 (constr 0 dispatch_1 x_15 n_16)]))]) + (lam request_2 + (case + request_2 + (lam self_3 + (lam x_21 + (lam n_22 + (case + [[(builtin equalsInteger) n_22] (con integer 0)] + [self_3 + (constr 1 + self_3 + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) n_22] (con integer 1)])]) + (force + [[(force (builtin trace)) (con string "discarded")] (delay (con integer 7))]))] + (con integer 42))))) + (lam self_8 + (lam m_23 + (lam y_24 + (case + [[(builtin equalsInteger) m_23] (con integer 0)] + [self_8 + (constr 0 + self_8 + (force + [[(force (builtin trace)) (con string "discarded")] (delay (con integer 7))]) + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) m_23] (con integer 1)])]))] + (con integer 42)))))))]) +--- optimized Core +letrec + f#1 : int -> int [static []] = \n#4 : int -> let anf#11 : bool = equalsInteger n#4 0 in + case@Bool anf#11 of + True -> 42 + False -> let arg#7 : int = trace "retained" in subtractInteger n#4 1 in + let arg#8 : int = trace "discarded" in 7 in + g#2 arg#7 + g#2 : int -> int [static []] = \m#5 : int -> let anf#12 : bool = equalsInteger m#5 0 in + case@Bool anf#12 of + True -> 42 + False -> let arg#9 : int = trace "discarded" in 7 in + let arg#10 : int = trace "retained" in subtractInteger m#5 1 in + f#1 arg#10 +in +f#1 3 +--- optimized UPLC +(program 1.1.0 + [(lam builtin_37 + [(lam partial_38 + [(lam partial_39 + [(lam dispatch_32 [dispatch_32 (constr 0 dispatch_32 (con integer 3))]) + (lam request_21 + (case + request_21 + (lam self_22 + (lam n_23 + [(lam anf_24 + (case + anf_24 + [(lam arg_25 + [(lam arg_26 [self_22 (constr 1 self_22 arg_25)]) + (force [partial_38 (delay (con integer 7))])]) + (force [partial_39 (delay [[(builtin subtractInteger) n_23] (con integer 1)])])] + (con integer 42))) + [[(builtin equalsInteger) n_23] (con integer 0)]])) + (lam self_27 + (lam m_28 + [(lam anf_29 + (case + anf_29 + [(lam arg_30 + [(lam arg_31 [self_27 (constr 0 self_27 arg_31)]) + (force [partial_39 (delay [[(builtin subtractInteger) m_28] (con integer 1)])])]) + (force [partial_38 (delay (con integer 7))])] + (con integer 42))) + [[(builtin equalsInteger) m_28] (con integer 0)]]))))]) + [builtin_37 (con string "retained")]]) + [builtin_37 (con string "discarded")]]) + (force (builtin trace))]) +--- isolated pass +--- isolated Core before +letrec + f#19 : int -> int -> int [static []] = \x#21 : int n#22 : int -> case@Bool equalsInteger n#22 0 of + True -> 42 + False -> g#20 (trace "retained" in subtractInteger n#22 1) (trace "discarded" in 7) + g#20 : int -> int -> int [static []] = \m#23 : int y#24 : int -> case@Bool equalsInteger m#23 0 of + True -> 42 + False -> f#19 (trace "discarded" in 7) (trace "retained" in subtractInteger m#23 1) +in +f#19 7 3 +--- isolated Core after +letrec + f#19 : int -> int [static []] = \n#22 : int -> case@Bool equalsInteger n#22 0 of + True -> 42 + False -> let arg#1 : int = trace "retained" in subtractInteger n#22 1 in + let arg#2 : int = trace "discarded" in 7 in + g#20 arg#1 + g#20 : int -> int [static []] = \m#23 : int -> case@Bool equalsInteger m#23 0 of + True -> 42 + False -> let arg#3 : int = trace "discarded" in 7 in + let arg#4 : int = trace "retained" in subtractInteger m#23 1 in + f#19 arg#4 +in +f#19 3 +--- isolated UPLC before +(program 1.1.0 + [(lam dispatch_144 + [(lam f_19 + [(lam g_20 [[f_19 (con integer 7)] (con integer 3)]) + (lam m_156 (lam y_157 [dispatch_144 (constr 1 dispatch_144 m_156 y_157)]))]) + (lam x_158 (lam n_159 [dispatch_144 (constr 0 dispatch_144 x_158 n_159)]))]) + (lam request_145 + (case + request_145 + (lam self_146 + (lam x_21 + (lam n_22 + (case + [[(builtin equalsInteger) n_22] (con integer 0)] + [self_146 + (constr 1 + self_146 + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) n_22] (con integer 1)])]) + (force + [[(force (builtin trace)) (con string "discarded")] (delay (con integer 7))]))] + (con integer 42))))) + (lam self_151 + (lam m_23 + (lam y_24 + (case + [[(builtin equalsInteger) m_23] (con integer 0)] + [self_151 + (constr 0 + self_151 + (force + [[(force (builtin trace)) (con string "discarded")] (delay (con integer 7))]) + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) m_23] (con integer 1)])]))] + (con integer 42)))))))]) +--- isolated UPLC after +(program 1.1.0 + [(lam dispatch_160 + [(lam f_19 + [(lam g_20 [f_19 (con integer 3)]) + (lam m_168 [dispatch_160 (constr 1 dispatch_160 m_168)])]) + (lam n_169 [dispatch_160 (constr 0 dispatch_160 n_169)])]) + (lam request_161 + (case + request_161 + (lam self_162 + (lam n_22 + [(lam anf_5 + (case + anf_5 + [(lam arg_1 + [(lam arg_2 [self_162 (constr 1 self_162 arg_1)]) + (force + [[(force (builtin trace)) (con string "discarded")] (delay (con integer 7))])]) + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) n_22] (con integer 1)])])] + (con integer 42))) + [[(builtin equalsInteger) n_22] (con integer 0)]])) + (lam self_165 + (lam m_23 + [(lam anf_6 + (case + anf_6 + [(lam arg_3 + [(lam arg_4 [self_165 (constr 0 self_165 arg_4)]) + (force + [[(force (builtin trace)) (con string "retained")] + (delay [[(builtin subtractInteger) m_23] (con integer 1)])])]) + (force + [[(force (builtin trace)) (con string "discarded")] (delay (con integer 7))])] + (con integer 42))) + [[(builtin equalsInteger) m_23] (con integer 0)]]))))]) +--- result +(con integer 42) +--- logs +["retained", "discarded", "discarded", "retained", "retained", "discarded"] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__self_forwarding.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__self_forwarding.snap new file mode 100644 index 00000000..5d4f6138 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__self_forwarding.snap @@ -0,0 +1,88 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\\n--- isolated UPLC before\\n{}\\n--- isolated UPLC after\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), pretty(after), original.uplc, result.uplc, result.result,\nresult.logs))" +--- +--- unoptimized Core +letrec + f#1 : int -> int -> int [static []] = \x#3 : int n#4 : int -> case@Bool equalsInteger n#4 0 of + True -> 42 + False -> f#1 x#3 (subtractInteger n#4 1) +in +f#1 7 3 +--- unoptimized UPLC +(program 1.1.0 + [(lam f_1 [[f_1 (con integer 7)] (con integer 3)]) + [(lam self_2 [self_2 self_2]) + (lam self_2 + (lam x_3 + (lam n_4 + (case + [[(builtin equalsInteger) n_4] (con integer 0)] + [[[self_2 self_2] x_3] [[(builtin subtractInteger) n_4] (con integer 1)]] + (con integer 42)))))]]) +--- optimized Core +letrec + worker#8 : int -> int [static []] = \n#7 : int -> let anf#9 : bool = equalsInteger n#7 0 in + case@Bool anf#9 of + True -> 42 + False -> let anf#10 : int = subtractInteger n#7 1 in + worker#8 anf#10 +in +worker#8 3 +--- optimized UPLC +(program 1.1.0 + [(lam worker_12 [worker_12 (con integer 3)]) + [(lam self_3 [self_3 self_3]) + (lam self_4 + (lam n_5 + [(lam anf_6 + (case + anf_6 + [(lam anf_11 [[self_4 self_4] anf_11]) + [[(builtin subtractInteger) n_5] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_5] (con integer 0)]]))]]) +--- isolated pass +--- isolated Core before +letrec + f#1 : int -> int -> int [static []] = \x#3 : int n#4 : int -> case@Bool equalsInteger n#4 0 of + True -> 42 + False -> f#1 x#3 (subtractInteger n#4 1) +in +f#1 7 3 +--- isolated Core after +letrec + f#1 : int -> int [static []] = \n#4 : int -> case@Bool equalsInteger n#4 0 of + True -> 42 + False -> let arg#2 : int = subtractInteger n#4 1 in + f#1 arg#2 +in +f#1 3 +--- isolated UPLC before +(program 1.1.0 + [(lam f_1 [[f_1 (con integer 7)] (con integer 3)]) + [(lam self_81 [self_81 self_81]) + (lam self_81 + (lam x_3 + (lam n_4 + (case + [[(builtin equalsInteger) n_4] (con integer 0)] + [[[self_81 self_81] x_3] [[(builtin subtractInteger) n_4] (con integer 1)]] + (con integer 42)))))]]) +--- isolated UPLC after +(program 1.1.0 + [(lam f_1 [f_1 (con integer 3)]) + [(lam self_84 [self_84 self_84]) + (lam self_84 + (lam n_4 + [(lam anf_3 + (case + anf_3 + [(lam arg_2 [[self_84 self_84] arg_2]) + [[(builtin subtractInteger) n_4] (con integer 1)]] + (con integer 42))) + [[(builtin equalsInteger) n_4] (con integer 0)]]))]]) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__static_indices_and_call_type_views_survive.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__static_indices_and_call_type_views_survive.snap new file mode 100644 index 00000000..04956840 --- /dev/null +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__recursive_params__static_indices_and_call_type_views_survive.snap @@ -0,0 +1,33 @@ +--- +source: crates/nash-codegen/src/optimizer_tests/recursive_params.rs +expression: "crate::harness::pass_snapshot(&arena, before,\nformat!(\"--- isolated Core before\\n{}\\n--- isolated Core after\\n{}\",\npretty(before), pretty(after)))" +--- +--- unoptimized Core +letrec + f#1 : int -> int -> int [static [1]] = \unused#2 : int used#3 : int -> used#3 +in +f#1 0 42 +--- unoptimized UPLC +(program 1.1.0 + [(lam f_1 [[f_1 (con integer 0)] (con integer 42)]) + [(lam self_4 [self_4 self_4]) (lam self_4 (lam unused_2 (lam used_3 used_3)))]]) +--- optimized Core +letrec + f#4 : int -> int [static [0]] = \used#6 : int -> used#6 +in +f#4 42 +--- optimized UPLC +(program 1.1.0 + [(lam f_8 [f_8 (con integer 42)]) + [(lam self_3 [self_3 self_3]) (lam self_5 (lam used_7 used_7))]]) +--- isolated pass +--- isolated Core before +letrec + f#1 : int -> int -> int [static [1]] = \unused#2 : int used#3 : int -> used#3 +in +f#1 0 42 +--- isolated Core after +letrec + f#1 : int -> int [static [0]] = \used#3 : int -> used#3 +in +f#1 42 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__single_use__builtin_inside_repeated_function.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__single_use__builtin_inside_repeated_function.snap index b604d0c7..97a9056b 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__single_use__builtin_inside_repeated_function.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__single_use__builtin_inside_repeated_function.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/single_use.rs -assertion_line: 40 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline\\n{}\\n--- core after\\n{}\\n--- candidate\\n{}\",\npretty(before), output(&baseline), pretty(after), output(&candidate)))" --- --- unoptimized Core @@ -23,11 +22,9 @@ repeated#7 42 --- optimized UPLC (program 1.1.0 [(lam builtin_5 - [(lam tracer_1 - [(lam repeated_3 - [(lam unused_4 [repeated_3 (con integer 42)]) [repeated_3 (con integer 1)]]) - (lam x_2 [[tracer_1 (con string "tick")] x_2])]) - builtin_5]) + [(lam repeated_3 + [(lam unused_4 [repeated_3 (con integer 42)]) [repeated_3 (con integer 1)]]) + (lam x_2 [[builtin_5 (con string "tick")] x_2])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__single_use__computed_tail.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__single_use__computed_tail.snap index 8fb8f30d..6ef28752 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__single_use__computed_tail.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__single_use__computed_tail.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/single_use.rs -assertion_line: 40 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline\\n{}\\n--- core after\\n{}\\n--- candidate\\n{}\",\npretty(before), output(&baseline), pretty(after), output(&candidate)))" --- --- unoptimized Core @@ -11,9 +10,9 @@ result#1 [(lam result_1 result_1) [[(builtin addInteger) (con integer 40)] (con integer 2)]]) --- optimized Core -addInteger 40 2 +42 --- optimized UPLC -(program 1.1.0 [[(builtin addInteger) (con integer 40)] (con integer 2)]) +(program 1.1.0 (con integer 42)) --- isolated pass --- core before let result#1 : int = addInteger 40 2 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__argument_order.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__argument_order.snap index 9c691fad..8576ac0f 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__argument_order.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__argument_order.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/small_inline.rs -assertion_line: 37 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline uplc\\n{}\\n--- core after\\n{}\\n--- optimized uplc\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), baseline.uplc, pretty(after), candidate.uplc,\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -27,34 +26,28 @@ addInteger (subtract#3 (trace "first" in 2) (trace "second" in 5)) (addInteger ( let anf#11 : int = trace "first" in 2 in let anf#13 : int = trace "second" in 5 in let anf#14 : int = subtractInteger anf#13 anf#11 in -let anf#15 : int = subtractInteger 4 1 in let anf#16 : int = trace "once" in 10 in let anf#17 : int = addInteger anf#16 anf#16 in -let anf#18 : int = addInteger 11 11 in -let anf#19 : int = addInteger anf#17 anf#18 in -let anf#20 : int = addInteger anf#15 anf#19 in +let anf#19 : int = addInteger anf#17 22 in +let anf#20 : int = addInteger 3 anf#19 in addInteger anf#14 anf#20 --- optimized UPLC (program 1.1.0 - [(lam builtin_10 + [(lam builtin_8 [(lam anf_1 [(lam anf_2 [(lam anf_3 [(lam anf_4 [(lam anf_5 [(lam anf_6 - [(lam anf_7 - [(lam anf_8 - [(lam anf_9 [[(builtin addInteger) anf_3] anf_9]) - [[(builtin addInteger) anf_4] anf_8]]) - [[(builtin addInteger) anf_6] anf_7]]) - [[(builtin addInteger) (con integer 11)] (con integer 11)]]) - [[(builtin addInteger) anf_5] anf_5]]) - (force [[builtin_10 (con string "once")] (delay (con integer 10))])]) - [[(builtin subtractInteger) (con integer 4)] (con integer 1)]]) + [(lam anf_7 [[(builtin addInteger) anf_3] anf_7]) + [[(builtin addInteger) (con integer 3)] anf_6]]) + [[(builtin addInteger) anf_5] (con integer 22)]]) + [[(builtin addInteger) anf_4] anf_4]]) + (force [[builtin_8 (con string "once")] (delay (con integer 10))])]) [[(builtin subtractInteger) anf_2] anf_1]]) - (force [[builtin_10 (con string "second")] (delay (con integer 5))])]) - (force [[builtin_10 (con string "first")] (delay (con integer 2))])]) + (force [[builtin_8 (con string "second")] (delay (con integer 5))])]) + (force [[builtin_8 (con string "first")] (delay (con integer 2))])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__escaping.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__escaping.snap index 0dd2f726..da8c6474 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__escaping.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__escaping.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/small_inline.rs -assertion_line: 37 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline uplc\\n{}\\n--- core after\\n{}\\n--- optimized uplc\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), baseline.uplc, pretty(after), candidate.uplc,\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -16,9 +15,9 @@ addInteger ((case@Bool true of [identity_2 (con integer 22)]]) (lam x_1 x_1)]) --- optimized Core -addInteger 20 22 +42 --- optimized UPLC -(program 1.1.0 [[(builtin addInteger) (con integer 20)] (con integer 22)]) +(program 1.1.0 (con integer 42)) --- isolated pass --- core before let identity#2 : int -> int = \x#1 : int -> x#1 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__identity.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__identity.snap index 9cd3ec79..b3914397 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__identity.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__identity.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/small_inline.rs -assertion_line: 37 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline uplc\\n{}\\n--- core after\\n{}\\n--- optimized uplc\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), baseline.uplc, pretty(after), candidate.uplc,\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -13,9 +12,9 @@ addInteger (identity#2 20) (identity#2 22) [identity_2 (con integer 22)]]) (lam x_1 x_1)]) --- optimized Core -addInteger 20 22 +42 --- optimized UPLC -(program 1.1.0 [[(builtin addInteger) (con integer 20)] (con integer 22)]) +(program 1.1.0 (con integer 42)) --- isolated pass --- core before let identity#2 : int -> int = \x#1 : int -> x#1 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__known_conditional_becomes_identity.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__known_conditional_becomes_identity.snap index 5247c41d..ec5bc8a7 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__known_conditional_becomes_identity.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__known_conditional_becomes_identity.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/small_inline.rs -assertion_line: 37 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline uplc\\n{}\\n--- core after\\n{}\\n--- optimized uplc\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), baseline.uplc, pretty(after), candidate.uplc,\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -15,9 +14,9 @@ addInteger (conditional#2 20) (conditional#2 22) [conditional_2 (con integer 22)]]) (lam x_1 (case (con bool True) (con integer 0) x_1))]) --- optimized Core -addInteger 20 22 +42 --- optimized UPLC -(program 1.1.0 [[(builtin addInteger) (con integer 20)] (con integer 22)]) +(program 1.1.0 (con integer 42)) --- isolated pass --- core before let conditional#2 : int -> int = \x#1 : int -> case@Bool true of diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__literal_64.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__literal_64.snap index 3b1e7722..417afc36 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__literal_64.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__literal_64.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/small_inline.rs -assertion_line: 37 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline uplc\\n{}\\n--- core after\\n{}\\n--- optimized uplc\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), baseline.uplc, pretty(after), candidate.uplc,\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -18,7 +17,7 @@ addInteger (length#2 (con bytestring #070707070707070707070707070707070707070707 [(builtin lengthOfByteString) (con bytestring #07070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707)])]) --- optimized Core -let length#4 : @delay int = delay (lengthOfByteString (con bytestring #07070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707)) in +let length#4 : @delay int = delay 64 in let anf#5 : int = force length#4 in let anf#6 : int = force length#4 in addInteger anf#5 anf#6 @@ -27,9 +26,7 @@ addInteger anf#5 anf#6 [(lam length_1 [(lam anf_2 [(lam anf_3 [[(builtin addInteger) anf_2] anf_3]) (force length_1)]) (force length_1)]) - (delay - [(builtin lengthOfByteString) - (con bytestring #07070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707)])]) + (delay (con integer 64))]) --- isolated pass --- core before let length#2 : bytes -> int = \x#1 : bytes -> lengthOfByteString (con bytestring #07070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__literal_65.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__literal_65.snap index 97eacaaf..073db706 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__literal_65.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__literal_65.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/small_inline.rs -assertion_line: 37 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline uplc\\n{}\\n--- core after\\n{}\\n--- optimized uplc\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), baseline.uplc, pretty(after), candidate.uplc,\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -18,7 +17,7 @@ addInteger (length#2 (con bytestring #070707070707070707070707070707070707070707 [(builtin lengthOfByteString) (con bytestring #0707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707)])]) --- optimized Core -let length#4 : @delay int = delay (lengthOfByteString (con bytestring #0707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707)) in +let length#4 : @delay int = delay 65 in let anf#5 : int = force length#4 in let anf#6 : int = force length#4 in addInteger anf#5 anf#6 @@ -27,9 +26,7 @@ addInteger anf#5 anf#6 [(lam length_1 [(lam anf_2 [(lam anf_3 [[(builtin addInteger) anf_2] anf_3]) (force length_1)]) (force length_1)]) - (delay - [(builtin lengthOfByteString) - (con bytestring #0707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707)])]) + (delay (con integer 65))]) --- isolated pass --- core before let length#2 : bytes -> int = \x#1 : bytes -> lengthOfByteString (con bytestring #0707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707) in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__partial_calls.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__partial_calls.snap index fd828963..10d428ef 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__partial_calls.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__partial_calls.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/small_inline.rs -assertion_line: 37 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline uplc\\n{}\\n--- core after\\n{}\\n--- optimized uplc\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), baseline.uplc, pretty(after), candidate.uplc,\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -19,23 +18,20 @@ let anf#7 : int -> int = add#6 10 in let anf#8 : int = anf#7 1 in let anf#9 : int -> int = add#6 20 in let anf#10 : int = anf#9 1 in -let anf#11 : int = addInteger 3 4 in -let anf#12 : int = addInteger anf#10 anf#11 in +let anf#12 : int = addInteger anf#10 7 in addInteger anf#8 anf#12 --- optimized UPLC (program 1.1.0 [(lam add_3 - [(lam anf_13 - [(lam anf_14 - [(lam anf_15 - [(lam anf_16 - [(lam anf_17 - [(lam anf_18 [[(builtin addInteger) anf_14] anf_18]) - [[(builtin addInteger) anf_16] anf_17]]) - [[(builtin addInteger) (con integer 3)] (con integer 4)]]) - [anf_15 (con integer 1)]]) + [(lam anf_11 + [(lam anf_13 + [(lam anf_14 + [(lam anf_15 + [(lam anf_16 [[(builtin addInteger) anf_13] anf_16]) + [[(builtin addInteger) anf_15] (con integer 7)]]) + [anf_14 (con integer 1)]]) [add_3 (con integer 20)]]) - [anf_13 (con integer 1)]]) + [anf_11 (con integer 1)]]) [add_3 (con integer 10)]]) (lam x_1 (lam y_2 [[(builtin addInteger) x_1] y_2]))]) --- isolated pass diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__unused_failure.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__unused_failure.snap index 127e98b7..114f4c8b 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__unused_failure.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__small_inline__unused_failure.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/small_inline.rs -assertion_line: 37 expression: "crate::harness::pass_snapshot(b.arena, core,\nformat!(\"--- core before\\n{}\\n--- baseline uplc\\n{}\\n--- core after\\n{}\\n--- optimized uplc\\n{}\\n--- result\\n{}\\n--- logs\\n{:?}\",\npretty(before), baseline.uplc, pretty(after), candidate.uplc,\ncandidate.result, candidate.logs))" --- --- unoptimized Core @@ -19,21 +18,18 @@ addInteger (increment#3 1 (trace "failure" in error)) (increment#3 (trace "unrea (lam x_1 (lam unused_2 [[(builtin addInteger) x_1] (con integer 1)]))]) --- optimized Core let arg#7 : int = trace "failure" in error in -let anf#9 : int = addInteger 1 1 in let arg#8 : int = trace "unreached" in 1 in let anf#10 : int = addInteger arg#8 1 in -addInteger anf#9 anf#10 +addInteger 2 anf#10 --- optimized UPLC (program 1.1.0 - [(lam builtin_5 + [(lam builtin_4 [(lam arg_1 - [(lam anf_2 - [(lam arg_3 - [(lam anf_4 [[(builtin addInteger) anf_2] anf_4]) - [[(builtin addInteger) arg_3] (con integer 1)]]) - (force [[builtin_5 (con string "unreached")] (delay (con integer 1))])]) - [[(builtin addInteger) (con integer 1)] (con integer 1)]]) - (force [[builtin_5 (con string "failure")] (delay (error))])]) + [(lam arg_2 + [(lam anf_3 [[(builtin addInteger) (con integer 2)] anf_3]) + [[(builtin addInteger) arg_2] (con integer 1)]]) + (force [[builtin_4 (con string "unreached")] (delay (con integer 1))])]) + (force [[builtin_4 (con string "failure")] (delay (error))])]) (force (builtin trace))]) --- isolated pass --- core before diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__divergent_argument.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__divergent_argument.snap index d80a66e1..8da87e5d 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__divergent_argument.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__divergent_argument.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/optimizer_tests/unused_params.rs -assertion_line: 261 expression: "crate::harness::pass_snapshot(b.arena, root,\nformat!(\"--- core before\\n{}\\n--- core after\\n{}\", pretty(root),\npretty(after)))" --- --- unoptimized Core @@ -36,7 +35,7 @@ loop#4 0) --- core after let helper#2 : @delay int = delay 42 in let arg#5 : int = letrec - loop#4 : int -> int [static []] = \n#3 : int -> loop#4 n#3 + loop#4 : @delay int [static []] = \ -> delay (force loop#4) in -loop#4 0 in +force loop#4 in force helper#2 diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__escaping_blocks_all_calls.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__escaping_blocks_all_calls.snap index bdaf77b3..9e9e9b07 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__escaping_blocks_all_calls.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__escaping_blocks_all_calls.snap @@ -15,18 +15,9 @@ addInteger (helper#3 0 21) (alias#4 0 21) helper_3]) (lam unused_1 (lam used_2 used_2))]) --- optimized Core -let helper#7 : int -> int -> int = \unused#5 : int used#6 : int -> used#6 in -let anf#9 : int = helper#7 0 21 in -let anf#10 : int = helper#7 0 21 in -addInteger anf#9 anf#10 +42 --- optimized UPLC -(program 1.1.0 - [(lam helper_3 - [(lam anf_4 - [(lam anf_8 [[(builtin addInteger) anf_4] anf_8]) - [[helper_3 (con integer 0)] (con integer 21)]]) - [[helper_3 (con integer 0)] (con integer 21)]]) - (lam unused_1 (lam used_2 used_2))]) +(program 1.1.0 (con integer 42)) --- isolated pass --- core before let helper#3 : int -> int -> int = \unused#1 : int used#2 : int -> used#2 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__first.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__first.snap index 1b60941a..5cf96c8d 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__first.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__first.snap @@ -13,16 +13,9 @@ addInteger (helper#4 10 20 30) (helper#4 10 20 30) [[[helper_4 (con integer 10)] (con integer 20)] (con integer 30)]]) (lam x_1 (lam y_2 (lam z_3 [[(builtin addInteger) y_2] z_3])))]) --- optimized Core -let anf#9 : int = addInteger 20 30 in -let anf#10 : int = addInteger 20 30 in -addInteger anf#9 anf#10 +100 --- optimized UPLC -(program 1.1.0 - [(lam partial_3 - [(lam anf_1 - [(lam anf_2 [[(builtin addInteger) anf_1] anf_2]) [partial_3 (con integer 30)]]) - [partial_3 (con integer 30)]]) - [(builtin addInteger) (con integer 20)]]) +(program 1.1.0 (con integer 100)) --- isolated pass --- core before let helper#4 : int -> int -> int -> int = \x#1 : int y#2 : int z#3 : int -> addInteger y#2 z#3 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__last.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__last.snap index 4fadcc6e..d93f20f8 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__last.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__last.snap @@ -13,16 +13,9 @@ addInteger (helper#12 10 20 30) (helper#12 10 20 30) [[[helper_12 (con integer 10)] (con integer 20)] (con integer 30)]]) (lam x_9 (lam y_10 (lam z_11 [[(builtin addInteger) x_9] y_10])))]) --- optimized Core -let anf#5 : int = addInteger 10 20 in -let anf#6 : int = addInteger 10 20 in -addInteger anf#5 anf#6 +60 --- optimized UPLC -(program 1.1.0 - [(lam partial_3 - [(lam anf_1 - [(lam anf_2 [[(builtin addInteger) anf_1] anf_2]) [partial_3 (con integer 20)]]) - [partial_3 (con integer 20)]]) - [(builtin addInteger) (con integer 10)]]) +(program 1.1.0 (con integer 60)) --- isolated pass --- core before let helper#12 : int -> int -> int -> int = \x#9 : int y#10 : int z#11 : int -> addInteger x#9 y#10 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__middle.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__middle.snap index 05c580e0..ba8241a1 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__middle.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__middle.snap @@ -13,16 +13,9 @@ addInteger (helper#8 10 20 30) (helper#8 10 20 30) [[[helper_8 (con integer 10)] (con integer 20)] (con integer 30)]]) (lam x_5 (lam y_6 (lam z_7 [[(builtin addInteger) x_5] z_7])))]) --- optimized Core -let anf#5 : int = addInteger 10 30 in -let anf#6 : int = addInteger 10 30 in -addInteger anf#5 anf#6 +80 --- optimized UPLC -(program 1.1.0 - [(lam partial_3 - [(lam anf_1 - [(lam anf_2 [[(builtin addInteger) anf_1] anf_2]) [partial_3 (con integer 30)]]) - [partial_3 (con integer 30)]]) - [(builtin addInteger) (con integer 10)]]) +(program 1.1.0 (con integer 80)) --- isolated pass --- core before let helper#8 : int -> int -> int -> int = \x#5 : int y#6 : int z#7 : int -> addInteger x#5 z#7 in diff --git a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__recursive_unchanged.snap b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__recursive_signature_reduced.snap similarity index 67% rename from crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__recursive_unchanged.snap rename to crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__recursive_signature_reduced.snap index 235ca488..a98e070b 100644 --- a/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__recursive_unchanged.snap +++ b/crates/nash-codegen/src/optimizer_tests/snapshots/nash_codegen__optimizer_tests__unused_params__recursive_signature_reduced.snap @@ -13,13 +13,13 @@ helper#3 0 42 [(lam self_4 [self_4 self_4]) (lam self_4 (lam unused_1 (lam used_2 used_2)))]]) --- optimized Core letrec - helper#4 : int -> int -> int [static []] = \unused#5 : int used#6 : int -> used#6 + helper#4 : int -> int [static []] = \used#6 : int -> used#6 in -helper#4 0 42 +helper#4 42 --- optimized UPLC (program 1.1.0 - [(lam helper_11 [[helper_11 (con integer 0)] (con integer 42)]) - [(lam self_7 [self_7 self_7]) (lam self_8 (lam unused_9 (lam used_10 used_10)))]]) + [(lam helper_8 [helper_8 (con integer 42)]) + [(lam self_3 [self_3 self_3]) (lam self_5 (lam used_7 used_7))]]) --- isolated pass --- core before letrec @@ -28,22 +28,22 @@ in helper#3 0 42 --- core early letrec - helper#3 : int -> int -> int [static []] = \unused#1 : int used#2 : int -> used#2 + helper#3 : int -> int [static []] = \used#2 : int -> used#2 in -helper#3 0 42 +helper#3 42 --- core after ANF letrec - helper#3 : int -> int -> int [static []] = \unused#1 : int used#2 : int -> used#2 + helper#3 : int -> int [static []] = \used#2 : int -> used#2 in -helper#3 0 42 +helper#3 42 --- uplc before (program 1.1.0 [(lam helper_3 [[helper_3 (con integer 0)] (con integer 42)]) [(lam self_4 [self_4 self_4]) (lam self_4 (lam unused_1 (lam used_2 used_2)))]]) --- uplc after (program 1.1.0 - [(lam helper_3 [[helper_3 (con integer 0)] (con integer 42)]) - [(lam self_7 [self_7 self_7]) (lam self_7 (lam unused_1 (lam used_2 used_2)))]]) + [(lam helper_3 [helper_3 (con integer 42)]) + [(lam self_7 [self_7 self_7]) (lam self_7 (lam used_2 used_2))]]) --- result (con integer 42) --- logs diff --git a/crates/nash-codegen/src/optimizer_tests/unused_params.rs b/crates/nash-codegen/src/optimizer_tests/unused_params.rs index b507686f..11894c2a 100644 --- a/crates/nash-codegen/src/optimizer_tests/unused_params.rs +++ b/crates/nash-codegen/src/optimizer_tests/unused_params.rs @@ -271,7 +271,7 @@ fn explicit_function_views_keep_their_result_annotations() { } #[test] -fn recursive_signatures_and_unsupported_views_are_unchanged() { +fn recursive_signatures_reduce_but_unsupported_views_are_unchanged() { let a = Arena::new(); let b = Builder::new(&a); let x = bind(&b, "unused", INT); @@ -287,7 +287,7 @@ fn recursive_signatures_and_unsupported_views_are_unchanged() { }], call(&b, f, &[b.int(0), b.int(42)]), ); - check("recursive_unchanged", &b, recursive, false, false); + check("recursive_signature_reduced", &b, recursive, true, false); let opaque = b.let_( f, value, @@ -575,6 +575,8 @@ fn diverging_discarded_argument_is_still_a_strict_binding() { let CoreKind::Let { value, .. } = body.kind else { panic!("strict argument") }; - assert!(std::ptr::eq(value, diverge)); + // Recursive signature reduction can now rewrite the divergent argument. + // It must still be an unsafe-to-discard computation in the strict binding. + assert!(!nash_ir::analysis::safe_to_discard(value)); hygiene::validate(after, &[]).unwrap(); } diff --git a/crates/nash-codegen/src/program.rs b/crates/nash-codegen/src/program.rs index ff874b76..49a65782 100644 --- a/crates/nash-codegen/src/program.rs +++ b/crates/nash-codegen/src/program.rs @@ -34,6 +34,8 @@ pub enum Error<'a> { #[error("{0}")] DeBruijn(debruijn::FreeVariable<'a>), #[error("{0}")] + Silent(#[from] crate::silent::Error), + #[error("{0}")] Target(#[from] script::TargetError), } @@ -58,23 +60,13 @@ pub fn assemble<'a>(arena: &'a Arena, module: &Module<'a>) -> Result(arena: &'a Arena, core: &'a Core<'a>) -> Result, Error<'a>> { - assemble_core_for_version(arena, core, PlutusVersion::V3) -} - -/// Assemble and validate for the selected ledger language at the PV11 baseline. -pub fn assemble_core_for_version<'a>( - arena: &'a Arena, - core: &'a Core<'a>, - version: PlutusVersion, -) -> Result, Error<'a>> { - assemble_core_with_options(arena, core, version, nash_config::OptimizationLevel::O0) + assemble_core_with_options(arena, core, nash_config::OptimizationLevel::O0) } -/// Assemble at the selected optimization level without changing trace policy. +/// Assemble at the selected level. O2 removes all logging before O1 optimization. pub fn assemble_core_with_options<'a>( arena: &'a Arena, core: &'a Core<'a>, - version: PlutusVersion, optimize: nash_config::OptimizationLevel, ) -> Result, Error<'a>> { if let Some(name) = free_variables(core).first() { @@ -83,20 +75,21 @@ pub fn assemble_core_with_options<'a>( let core = match optimize { nash_config::OptimizationLevel::O0 => core, nash_config::OptimizationLevel::O1 => crate::optimizer::optimize(arena, core), + nash_config::OptimizationLevel::O2 => crate::optimizer::optimize_silent(arena, core)?, }; let build = Builder::new(arena); let core = crate::recursion::rewrite(&build, core)?; let named = match optimize { nash_config::OptimizationLevel::O0 => crate::lower::lower(arena, core)?, - nash_config::OptimizationLevel::O1 => { + nash_config::OptimizationLevel::O1 | nash_config::OptimizationLevel::O2 => { let core = nash_ir::hygiene::freshen(&build, core); - crate::lower::lower_with_constant_sharing(arena, core)? + crate::lower::lower_optimized(arena, core)? } }; let term = debruijn::to_debruijn(arena, named).map_err(Error::DeBruijn)?; let uplc_version = Version::plutus_v3(arena); let program = Program::new(arena, uplc_version, term); - script::validate_program(program, version)?; + script::validate_program(program, PlutusVersion::V3)?; Ok(Compiled { program, named }) } diff --git a/crates/nash-codegen/src/program/snapshots/nash_codegen__program__tests__optimizer_substitution_preserves_free_names_at_runtime.snap b/crates/nash-codegen/src/program/snapshots/nash_codegen__program__tests__optimizer_substitution_preserves_free_names_at_runtime.snap index 4d5777ea..2f5bfce4 100644 --- a/crates/nash-codegen/src/program/snapshots/nash_codegen__program__tests__optimizer_substitution_preserves_free_names_at_runtime.snap +++ b/crates/nash-codegen/src/program/snapshots/nash_codegen__program__tests__optimizer_substitution_preserves_free_names_at_runtime.snap @@ -1,7 +1,6 @@ --- source: crates/nash-codegen/src/program/tests.rs -assertion_line: 32 -expression: "crate::harness::pass_snapshot(&arena, reference,\nformat!(\"--- Core before substitution\\n{}\\n--- UPLC before substitution\\n{}\\n--- Core after substitution\\n{}\\n--- UPLC after substitution\\n{}\",\nnash_ir::pretty::pretty(reference), pretty::term(original_program.named),\nnash_ir::pretty::pretty(candidate), pretty::term(changed_program.named),))" +expression: "format!(\"{}\\n--- isolated pass\\n--- Core before substitution\\n{}\\n--- UPLC before substitution\\n{}\\n--- Core after substitution\\n{}\\n--- UPLC after substitution\\n{}\",\nprepared.snapshot(), nash_ir::pretty::pretty(reference),\npretty::term(original_program.named), nash_ir::pretty::pretty(candidate),\npretty::term(changed_program.named),)" --- --- unoptimized Core let y#1 : int = 20 in @@ -16,9 +15,9 @@ addInteger target#2 y#1 y_1]) (con integer 20)]) --- optimized Core -addInteger 20 10 +30 --- optimized UPLC -(program 1.1.0 [[(builtin addInteger) (con integer 20)] (con integer 10)]) +(program 1.1.0 (con integer 30)) --- isolated pass --- Core before substitution let y#1 : int = 20 in diff --git a/crates/nash-codegen/src/program/tests.rs b/crates/nash-codegen/src/program/tests.rs index d2b60be8..c0e74a30 100644 --- a/crates/nash-codegen/src/program/tests.rs +++ b/crates/nash-codegen/src/program/tests.rs @@ -464,34 +464,36 @@ fn comptime_infinite_recursion_exhausts_default_budget() { } #[test] -fn assemble_selected_ledger_language() { +fn assemble_targets_plutus_v3() { let a = Arena::new(); let b = Builder::new(&a); - for version in [PlutusVersion::V1, PlutusVersion::V2, PlutusVersion::V3] { - let compiled = assemble_core_for_version(&a, b.int(42), version).unwrap(); - assert!(compiled.program.version.is_v1_1_0()); - assert_eq!( - pretty::term(compiled.program.eval_version(&a, version).term.unwrap()), - "(con integer 42)" - ); - } - for version in [PlutusVersion::V1, PlutusVersion::V2, PlutusVersion::V3] { - let constr = b.constr( - 0, - &[b.int(1)], - Ty::Runtime(b.arena.alloc(nash_ir::ty::RuntimeTy::Constr { - tag: 0, - fields: b.arena.alloc_slice_copy(&[Ty::Const(&ConstTy::Int)]), - })), - ); - assert!(assemble_core_for_version(&a, constr, version).is_ok()); - let newer = b.builtin( - F::ExpModInteger, - &[b.int(2), b.int(3), b.int(5)], - Ty::Const(&ConstTy::Int), - ); - assert!(assemble_core_for_version(&a, newer, version).is_ok()); - } + let compiled = assemble_core(&a, b.int(42)).unwrap(); + assert!(compiled.program.version.is_v1_1_0()); + assert_eq!( + pretty::term( + compiled + .program + .eval_version(&a, PlutusVersion::V3) + .term + .unwrap() + ), + "(con integer 42)" + ); + let constr = b.constr( + 0, + &[b.int(1)], + Ty::Runtime(b.arena.alloc(nash_ir::ty::RuntimeTy::Constr { + tag: 0, + fields: b.arena.alloc_slice_copy(&[Ty::Const(&ConstTy::Int)]), + })), + ); + assert!(assemble_core(&a, constr).is_ok()); + let newer = b.builtin( + F::ExpModInteger, + &[b.int(2), b.int(3), b.int(5)], + Ty::Const(&ConstTy::Int), + ); + assert!(assemble_core(&a, newer).is_ok()); } #[test] @@ -508,8 +510,7 @@ fn o1_assembly_matches_snapshot_pipeline_and_preserves_traces() { if fails { b.error(int) } else { value }, ); let prepared = crate::snapshot_optimizer::prepare(&arena, root); - let o1 = assemble_core_with_options(&arena, root, PlutusVersion::V3, OptimizationLevel::O1) - .unwrap(); + let o1 = assemble_core_with_options(&arena, root, OptimizationLevel::O1).unwrap(); let before = prepared.before.program.eval(&arena); let after = o1.program.eval(&arena); insta::assert_snapshot!( @@ -560,8 +561,7 @@ fn deep_assembly_uses_heap_work_lists() { nash_config::OptimizationLevel::O0, nash_config::OptimizationLevel::O1, ] { - let compiled = - assemble_core_with_options(&arena, core, PlutusVersion::V3, level).unwrap(); + let compiled = assemble_core_with_options(&arena, core, level).unwrap(); nash_plutus::flat::encode(compiled.program).unwrap(); let result = compiled.program.eval(&arena); outcomes.push((pretty::term(result.term.unwrap()), result.info.logs)); diff --git a/crates/nash-codegen/src/recursion.rs b/crates/nash-codegen/src/recursion.rs index a7363579..704e1b54 100644 --- a/crates/nash-codegen/src/recursion.rs +++ b/crates/nash-codegen/src/recursion.rs @@ -373,7 +373,10 @@ impl<'a> Rewriter<'_, 'a> { tasks.push(Task::Visit(single.body, inner_env)); return Ok(()); } - if binders.iter().any(|r| r.params.is_empty()) { + if binders + .iter() + .any(|r| r.params.is_empty() && !matches!(r.body.kind, CoreKind::Delay(_))) + { return Err(Error::RecursiveValue); } let names: HashSet<_> = binders.iter().map(|r| r.binder.name).collect(); @@ -502,7 +505,11 @@ impl<'a> Rewriter<'_, 'a> { let params = rb.params.iter().map(|p| p.ty).collect::>(); DispatchArm { params: b.arena.alloc_slice_copy(¶ms), - result: rb.body.ty, + result: if let ([], CoreKind::Delay(body)) = (rb.params, rb.body.kind) { + body.ty + } else { + rb.body.ty + }, } }) .collect::>(); @@ -554,7 +561,12 @@ impl<'a> Rewriter<'_, 'a> { this.mutual(state, tasks)?; Ok(None) }))); - tasks.push(Task::Visit(rb.body, env)); + let body = if let ([], CoreKind::Delay(body)) = (rb.params, rb.body.kind) { + body + } else { + rb.body + }; + tasks.push(Task::Visit(body, env)); } else { let results_ty = Ty::Runtime(b.arena.alloc(RuntimeTy::Results(state.arms))); let dispatch = b.lam( @@ -598,14 +610,16 @@ impl<'a> Rewriter<'_, 'a> { let mut fields = vec![b.var(dispatcher.name, dispatcher.ty)]; fields.extend(params.iter().map(|p| b.var(p.name, p.ty))); let packet_ty = Ty::Runtime(b.arena.alloc(RuntimeTy::Packet { arms, tag })); - b.lam( - ¶ms, - b.app( - b.var(dispatcher.name, dispatcher.ty), - &[b.constr(tag, &fields, packet_ty)], - arms[usize::from(tag)].result, - ), - ) + let call = b.app( + b.var(dispatcher.name, dispatcher.ty), + &[b.constr(tag, &fields, packet_ty)], + arms[usize::from(tag)].result, + ); + if params.is_empty() { + b.delay(call) + } else { + b.lam(¶ms, call) + } } } fn without<'a>( diff --git a/crates/nash-codegen/src/silent.rs b/crates/nash-codegen/src/silent.rs new file mode 100644 index 00000000..0d12f51e --- /dev/null +++ b/crates/nash-codegen/src/silent.rs @@ -0,0 +1,139 @@ +//! O2 removes trace operations and their message computations. +use nash_ir::{ + build::Builder, + core::*, + hygiene, + ty::{TermTy, Ty}, +}; +use nash_plutus::{arena::Arena, builtin::DefaultFunction}; +use std::collections::HashMap; + +#[derive(Debug, thiserror::Error)] +#[error("trace erasure requires a well-typed trace with at most two arguments")] +pub struct Error; + +/// Source trace syntax has already obeyed its silent source policy. Prebuilt +/// Core traces and builtin message expressions are discarded even if they fail +/// or diverge. Returned values retain their ordinary evaluation. +pub fn erase<'a>(arena: &'a Arena, core: &'a Core<'a>) -> Result<&'a Core<'a>, Error> { + let b = Builder::new(arena); + let core = hygiene::freshen(&b, core); + // Expose direct calls through builtin aliases before removing the builtin + // itself. This also discards a failing message passed to a first-class alias. + let mut bindings = HashMap::new(); + core.walk(&mut |node| { + if let CoreKind::Let { binder, value, .. } = node.kind { + bindings.insert(binder.name.unique, value); + } + }); + let core = core.map(&b, &mut |node| { + let CoreKind::App { func, args } = node.kind else { + return None; + }; + let mut trace_args = trace_prefix(func, &bindings)?; + trace_args.extend_from_slice(args); + if trace_args.len() <= 2 { + Some(b.builtin(DefaultFunction::Trace, &trace_args, node.ty)) + } else { + Some(b.app(trace_args[1], &trace_args[2..], node.ty)) + } + }); + let mut invalid = false; + let result = core.map(&b, &mut |node| { + let replacement = match node.kind { + CoreKind::Trace { body, .. } => body, + CoreKind::Builtin { + func: DefaultFunction::Trace, + args, + } => { + let value = match args { + [_, value] => *value, + [] | [_] => { + let value_ty = if args.is_empty() { + peel(&b, node.ty).and_then(|(_, rest)| peel(&b, rest)) + } else { + peel(&b, node.ty) + }; + let Some((param, result)) = value_ty else { + invalid = true; + return None; + }; + let value = Binder { + name: b.fresh("trace_value"), + ty: param, + }; + b.with_type( + b.lam(&[value], b.var(value.name, result)), + if args.is_empty() { + peel(&b, node.ty).unwrap().1 + } else { + node.ty + }, + ) + } + _ => { + invalid = true; + return None; + } + }; + if !args.is_empty() { + value + } else { + let message = Binder { + name: b.fresh("trace_message"), + ty: peel(&b, node.ty).unwrap().0, + }; + b.lam(&[message], value) + } + } + _ => return None, + }; + Some(b.with_type(replacement, node.ty)) + }); + if invalid { Err(Error) } else { Ok(result) } +} + +// Only unsaturated trace references are aliases. A saturated trace returning a +// function may compute that function and must not be copied to its call sites. +fn trace_prefix<'a>( + mut core: &'a Core<'a>, + bindings: &HashMap>, +) -> Option>> { + let mut suffix: Vec<&'a Core<'a>> = Vec::new(); + loop { + match core.kind { + CoreKind::Var(name) => core = bindings.get(&name.unique)?, + CoreKind::App { func, args } => { + suffix.extend(args.iter().rev().copied()); + core = func; + } + CoreKind::Builtin { + func: DefaultFunction::Trace, + args, + } if args.len() + suffix.len() < 2 => { + let mut result = args.to_vec(); + result.extend(suffix.into_iter().rev()); + return Some(result); + } + _ => return None, + } + } +} + +fn peel<'a>(b: &Builder<'a>, ty: Ty<'a>) -> Option<(Ty<'a>, Ty<'a>)> { + let Ty::Term(TermTy::Fun(params, result)) = ty else { + return None; + }; + let (first, rest) = params.split_first()?; + Some(( + *first, + if rest.is_empty() { + *result + } else { + Ty::Term(b.arena.alloc(TermTy::Fun(rest, *result))) + }, + )) +} + +#[cfg(test)] +mod tests; diff --git a/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_one.snap b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_one.snap new file mode 100644 index 00000000..c950db65 --- /dev/null +++ b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_one.snap @@ -0,0 +1,21 @@ +--- +source: crates/nash-codegen/src/silent/tests.rs +description: Hand-built Core +--- +--- unoptimized Core +trace "direct" 42 +--- unoptimized UPLC +(program 1.1.0 + [[(force (builtin trace)) (con string "direct")] (con integer 42)]) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +(con integer 42) +--- O0 logs +["direct"] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_two.snap b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_two.snap new file mode 100644 index 00000000..c950db65 --- /dev/null +++ b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_two.snap @@ -0,0 +1,21 @@ +--- +source: crates/nash-codegen/src/silent/tests.rs +description: Hand-built Core +--- +--- unoptimized Core +trace "direct" 42 +--- unoptimized UPLC +(program 1.1.0 + [[(force (builtin trace)) (con string "direct")] (con integer 42)]) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +(con integer 42) +--- O0 logs +["direct"] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_unused_failing_partial.snap b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_unused_failing_partial.snap new file mode 100644 index 00000000..6056b2bb --- /dev/null +++ b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_unused_failing_partial.snap @@ -0,0 +1,22 @@ +--- +source: crates/nash-codegen/src/silent/tests.rs +description: Hand-built Core +--- +--- unoptimized Core +let unused#1 : int -> int = trace error in +42 +--- unoptimized UPLC +(program 1.1.0 + [(lam unused_1 (con integer 42)) [(force (builtin trace)) (error)]]) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +error: ExplicitErrorTerm +--- O0 logs +[] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_zero.snap b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_zero.snap new file mode 100644 index 00000000..c950db65 --- /dev/null +++ b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__builtin_zero.snap @@ -0,0 +1,21 @@ +--- +source: crates/nash-codegen/src/silent/tests.rs +description: Hand-built Core +--- +--- unoptimized Core +trace "direct" 42 +--- unoptimized UPLC +(program 1.1.0 + [[(force (builtin trace)) (con string "direct")] (con integer 42)]) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +(con integer 42) +--- O0 logs +["direct"] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__core_trace.snap b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__core_trace.snap new file mode 100644 index 00000000..4b0c6280 --- /dev/null +++ b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__core_trace.snap @@ -0,0 +1,22 @@ +--- +source: crates/nash-codegen/src/silent/tests.rs +description: Hand-built Core +--- +--- unoptimized Core +trace "message" in 42 +--- unoptimized UPLC +(program 1.1.0 + (force + [[(force (builtin trace)) (con string "message")] (delay (con integer 42))])) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +(con integer 42) +--- O0 logs +["message"] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__core_trace_failing_message.snap b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__core_trace_failing_message.snap new file mode 100644 index 00000000..d03495e8 --- /dev/null +++ b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__core_trace_failing_message.snap @@ -0,0 +1,21 @@ +--- +source: crates/nash-codegen/src/silent/tests.rs +description: Hand-built Core +--- +--- unoptimized Core +trace error in 42 +--- unoptimized UPLC +(program 1.1.0 + (force [[(force (builtin trace)) (error)] (delay (con integer 42))])) +--- optimized Core (O2) +42 +--- optimized UPLC (O2) +(program 1.1.0 (con integer 42)) +--- O0 result +error: ExplicitErrorTerm +--- O0 logs +[] +--- O2 result +(con integer 42) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__trace_inside_delay.snap b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__trace_inside_delay.snap new file mode 100644 index 00000000..670bb7d4 --- /dev/null +++ b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__trace_inside_delay.snap @@ -0,0 +1,23 @@ +--- +source: crates/nash-codegen/src/silent/tests.rs +description: Hand-built Core +--- +--- unoptimized Core +delay (trace "message" in error) +--- unoptimized UPLC +(program 1.1.0 + (delay + (force [[(force (builtin trace)) (con string "message")] (delay (error))]))) +--- optimized Core (O2) +delay error +--- optimized UPLC (O2) +(program 1.1.0 (delay (error))) +--- O0 result +(delay + (force [[(force (builtin trace)) (con string "message")] (delay (error))])) +--- O0 logs +[] +--- O2 result +(delay (error)) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__trace_inside_lambda.snap b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__trace_inside_lambda.snap new file mode 100644 index 00000000..28273c19 --- /dev/null +++ b/crates/nash-codegen/src/silent/snapshots/nash_codegen__silent__tests__trace_inside_lambda.snap @@ -0,0 +1,22 @@ +--- +source: crates/nash-codegen/src/silent/tests.rs +description: Hand-built Core +--- +--- unoptimized Core +\value#1 : int -> trace "message" in value#1 +--- unoptimized UPLC +(program 1.1.0 + (lam value_1 + (force [[(force (builtin trace)) (con string "message")] (delay value_1)]))) +--- optimized Core (O2) +\value#1 : int -> value#1 +--- optimized UPLC (O2) +(program 1.1.0 (lam value_2 value_2)) +--- O0 result +(lam i0 (force [[(force (builtin trace)) (con string "message")] (delay i0)])) +--- O0 logs +[] +--- O2 result +(lam i0 i0) +--- O2 logs +[] diff --git a/crates/nash-codegen/src/silent/tests.rs b/crates/nash-codegen/src/silent/tests.rs new file mode 100644 index 00000000..dd9a4b3c --- /dev/null +++ b/crates/nash-codegen/src/silent/tests.rs @@ -0,0 +1,125 @@ +use super::*; +use nash_config::OptimizationLevel; +use nash_ir::{ + pretty::pretty, + ty::{ConstTy, TermTy}, +}; +use nash_plutus::{builtin::DefaultFunction as F, constant::Constant, term::Term}; + +fn check(arena: &Arena, name: &str, core: &Core<'_>, fails: bool) { + let after = crate::optimizer::optimize_silent(arena, core).unwrap(); + let before_program = crate::program::assemble_core(arena, core).unwrap(); + let after_program = + crate::program::assemble_core_with_options(arena, core, OptimizationLevel::O2).unwrap(); + let baseline = crate::harness::eval_named(arena, before_program.named); + let optimized = crate::harness::eval_named(arena, after_program.named); + assert_eq!(optimized.result.starts_with("error:"), fails); + insta::with_settings!({description => "Hand-built Core", omit_expression => true}, { + insta::assert_snapshot!(name, format!("--- unoptimized Core\n{}\n--- unoptimized UPLC\n{}\n--- optimized Core (O2)\n{}\n--- optimized UPLC (O2)\n{}\n--- O0 result\n{}\n--- O0 logs\n{:?}\n--- O2 result\n{}\n--- O2 logs\n{:?}", pretty(core), baseline.uplc, pretty(after), optimized.uplc, baseline.result, baseline.logs, optimized.result, optimized.logs)); + }); + // O2 intentionally drops failures in trace messages. Value failures remain + // covered by the success/error guard and the evaluated snapshot. + assert_eq!(core.ty, after.ty); + nash_ir::hygiene::validate(after, &[]).unwrap(); + nash_ir::anf::validate(after).unwrap(); + assert_silent(after_program.named); + let twice = + crate::program::assemble_core_with_options(arena, after, OptimizationLevel::O2).unwrap(); + assert_eq!( + nash_plutus::flat::encode(after_program.program).unwrap(), + nash_plutus::flat::encode(twice.program).unwrap() + ); +} +fn assert_silent(root: &Term<'_, nash_plutus::binder::Name<'_>>) { + let mut pending = vec![root]; + while let Some(term) = pending.pop() { + match term { + Term::Builtin(F::Trace) => panic!("O2 emitted a trace builtin"), + Term::Lambda { body, .. } | Term::Delay(body) | Term::Force(body) => pending.push(body), + Term::Apply { function, argument } => pending.extend([*function, *argument]), + Term::Constr { fields, .. } => pending.extend(fields.iter().copied()), + Term::Case { constr, branches } => { + pending.push(constr); + pending.extend(branches.iter().copied()); + } + _ => {} + } + } +} +#[test] +fn prebuilt_core_trace_and_delayed_body() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let message = b.lit(Constant::string(&arena, "message")); + check(&arena, "core_trace", b.trace(message, b.int(42)), false); + check( + &arena, + "core_trace_failing_message", + b.trace(b.error(message.ty), b.int(42)), + false, + ); + check( + &arena, + "trace_inside_delay", + b.delay(b.trace(message, b.error(Ty::Const(&ConstTy::Int)))), + false, + ); + let value = Binder { + name: b.fresh("value"), + ty: Ty::Const(&ConstTy::Int), + }; + check( + &arena, + "trace_inside_lambda", + b.lam(&[value], b.trace(message, b.var(value.name, value.ty))), + false, + ); +} +#[test] +fn builtin_trace_all_saturations() { + let arena = Arena::new(); + let b = Builder::new(&arena); + let string = Ty::Const(&ConstTy::String); + let int = Ty::Const(&ConstTy::Int); + let partial_ty = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[int]), int))); + let full_ty = Ty::Term(arena.alloc(TermTy::Fun(arena.alloc_slice_copy(&[string]), partial_ty))); + let message = b.lit(Constant::string(&arena, "direct")); + for (name, trace) in [ + ( + "builtin_zero", + b.app( + b.builtin(F::Trace, &[], full_ty), + &[message, b.int(42)], + int, + ), + ), + ( + "builtin_one", + b.app( + b.builtin(F::Trace, &[message], partial_ty), + &[b.int(42)], + int, + ), + ), + ( + "builtin_two", + b.builtin(F::Trace, &[message, b.int(42)], int), + ), + ] { + check(&arena, name, trace, false); + } + let unused = Binder { + name: b.fresh("unused"), + ty: partial_ty, + }; + check( + &arena, + "builtin_unused_failing_partial", + b.let_( + unused, + b.builtin(F::Trace, &[b.error(string)], partial_ty), + b.int(42), + ), + false, + ); +} diff --git a/crates/nash-codegen/src/snapshots/nash_codegen__decision_tree__tests__big_list_tail_binding_is_only_reconstructed_when_used@ignored.snap b/crates/nash-codegen/src/snapshots/nash_codegen__decision_tree__tests__big_list_tail_binding_is_only_reconstructed_when_used@ignored.snap index 39d1f9c5..7353a584 100644 --- a/crates/nash-codegen/src/snapshots/nash_codegen__decision_tree__tests__big_list_tail_binding_is_only_reconstructed_when_used@ignored.snap +++ b/crates/nash-codegen/src/snapshots/nash_codegen__decision_tree__tests__big_list_tail_binding_is_only_reconstructed_when_used@ignored.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/decision_tree_tests.rs -assertion_line: 858 description: "let match#1 : List Int = (con data (List [I 1, I 2])) in\ncase@List unListData match#1 of\n Nil -> error\n Cons field#2 listTail#4 -> 42" --- --- unoptimized Core @@ -17,14 +16,9 @@ case@List unListData match#1 of (error))) (con data (List [I 1, I 2]))]) --- optimized Core -let anf#7 : list Int = unListData (con data (List [I 1, I 2])) in -case@List anf#7 of - Nil -> error - Cons field#5 listTail#6 -> 42 +42 --- optimized UPLC -(program 1.1.0 - [(lam anf_1 (case anf_1 (lam field_2 (lam listTail_3 (con integer 42))) (error))) - [(builtin unListData) (con data (List [I 1, I 2]))]]) +(program 1.1.0 (con integer 42)) --- result (con integer 42) --- logs diff --git a/crates/nash-codegen/src/snapshots/nash_codegen__decision_tree__tests__big_list_tail_binding_is_only_reconstructed_when_used@used.snap b/crates/nash-codegen/src/snapshots/nash_codegen__decision_tree__tests__big_list_tail_binding_is_only_reconstructed_when_used@used.snap index 62fcdb71..c11ce6c8 100644 --- a/crates/nash-codegen/src/snapshots/nash_codegen__decision_tree__tests__big_list_tail_binding_is_only_reconstructed_when_used@used.snap +++ b/crates/nash-codegen/src/snapshots/nash_codegen__decision_tree__tests__big_list_tail_binding_is_only_reconstructed_when_used@used.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/decision_tree_tests.rs -assertion_line: 858 description: "let match#2 : List Int = (con data (List [I 1, I 2])) in\ncase@List unListData match#2 of\n Nil -> error\n Cons field#3 listTail#5 -> let field#4 : List Int = listData listTail#5 in\n let tail#1 : List Int = field#4 in\n tail#1" --- --- unoptimized Core @@ -21,18 +20,9 @@ case@List unListData match#2 of (error))) (con data (List [I 1, I 2]))]) --- optimized Core -let anf#11 : list Int = unListData (con data (List [I 1, I 2])) in -case@List anf#11 of - Nil -> error - Cons field#7 listTail#8 -> listData listTail#8 +(con data (List [I 2])) --- optimized UPLC -(program 1.1.0 - [(lam anf_1 - (case - anf_1 - (lam field_2 (lam listTail_3 [(builtin listData) listTail_3])) - (error))) - [(builtin unListData) (con data (List [I 1, I 2]))]]) +(program 1.1.0 (con data (List [I 2]))) --- result (con data (List [I 2])) --- logs diff --git a/crates/nash-codegen/src/tests.rs b/crates/nash-codegen/src/tests.rs index beee2eba..9a8b075d 100644 --- a/crates/nash-codegen/src/tests.rs +++ b/crates/nash-codegen/src/tests.rs @@ -21,6 +21,8 @@ pub enum Error<'a> { #[error("unknown test module {0:?}")] UnknownModule(ModuleName<'a>), #[error("{0}")] + Settings(#[from] nash_config::BuildConflict), + #[error("{0}")] Build(crate::build::Error<'a>), #[error("{0}")] Program(crate::program::Error<'a>), @@ -47,22 +49,19 @@ pub fn compile_tests<'a>( module: ModuleName<'a>, source: &str, path: &Path, - version: nash_config::PlutusVersion, trace: TraceConfig, ) -> Result, Error<'a>> { - compile_tests_matching(arena, build, module, source, path, version, trace, |_| true) + compile_tests_matching(arena, build, module, source, path, trace, |_| true) } /// Select declarations before code generation: an unselected property must not /// impose its native-constructor target requirements on selected unit tests. -#[allow(clippy::too_many_arguments)] pub fn compile_tests_matching<'a>( arena: &'a Arena, build: &Build<'a, '_>, module: ModuleName<'a>, source: &str, path: &Path, - version: nash_config::PlutusVersion, trace: TraceConfig, include: impl FnMut(&nash_ast::Test<'a>) -> bool, ) -> Result, Error<'a>> { @@ -72,7 +71,6 @@ pub fn compile_tests_matching<'a>( module, source, path, - version, trace, nash_config::OptimizationLevel::O0, include, @@ -86,11 +84,21 @@ pub fn compile_tests_matching_optimized<'a>( module: ModuleName<'a>, source: &str, path: &Path, - version: nash_config::PlutusVersion, trace: TraceConfig, optimize: nash_config::OptimizationLevel, mut include: impl FnMut(&nash_ast::Test<'a>) -> bool, ) -> Result, Error<'a>> { + nash_config::Build { + optimize, + trace_level: match trace.user { + crate::build::TraceLevel::Silent => nash_config::TraceLevel::Silent, + crate::build::TraceLevel::Compact => nash_config::TraceLevel::Compact, + crate::build::TraceLevel::Verbose => nash_config::TraceLevel::Verbose, + }, + compiler_traces: trace.compiler, + ..Default::default() + } + .validate()?; let input = build .inputs .iter() @@ -106,12 +114,12 @@ pub fn compile_tests_matching_optimized<'a>( let programs = if test.binders.is_empty() { let root = engine.expr(test.body, &ctx)?; Programs::Unit { - run: encode(&mut engine, root, version, optimize)?, + run: encode(&mut engine, root, optimize)?, } } else { let prepare = engine.property(test, &ctx)?; Programs::Prop { - prepare: encode(&mut engine, prepare, version, optimize)?, + prepare: encode(&mut engine, prepare, optimize)?, } }; result.push(TestProgram { @@ -127,7 +135,6 @@ pub fn compile_tests_matching_optimized<'a>( .iter() .map(|b| source_region(source, b.pattern.region)) .collect(), - plutus_version: version, source: source.to_owned(), source_path: path.to_owned(), }); @@ -138,17 +145,10 @@ pub fn compile_tests_matching_optimized<'a>( fn encode<'a>( engine: &mut Engine<'a, '_, '_>, root: &'a Core<'a>, - version: nash_config::PlutusVersion, optimize: nash_config::OptimizationLevel, ) -> Result, Error<'a>> { let core = engine.finish_root(root)?; - let version = match version { - nash_config::PlutusVersion::V1 => nash_plutus::machine::PlutusVersion::V1, - nash_config::PlutusVersion::V2 => nash_plutus::machine::PlutusVersion::V2, - nash_config::PlutusVersion::V3 => nash_plutus::machine::PlutusVersion::V3, - }; - let program = - crate::program::assemble_core_with_options(engine.ir.arena, core, version, optimize)?; + let program = crate::program::assemble_core_with_options(engine.ir.arena, core, optimize)?; flat::encode(program.program).map_err(|e| Error::Encoding(e.to_string())) } diff --git a/crates/nash-codegen/src/tests/integration.rs b/crates/nash-codegen/src/tests/integration.rs index d240375b..c690c8ac 100644 --- a/crates/nash-codegen/src/tests/integration.rs +++ b/crates/nash-codegen/src/tests/integration.rs @@ -3,23 +3,20 @@ use std::collections::BTreeMap; use super::*; use crate::build::{Input, TraceLevel}; use nash_ast::primitives; -use nash_config::PlutusVersion; use nash_plutus::machine::PlutusVersion as MachineVersion; use nash_test::{eval, prng::Prng}; fn compile( snapshot_name: &str, source: &str, - version: PlutusVersion, trace: TraceLevel, ) -> Result, String> { - compile_selected(snapshot_name, source, version, trace, None) + compile_selected(snapshot_name, source, trace, None) } fn compile_selected( snapshot_name: &str, source: &str, - version: PlutusVersion, trace: TraceLevel, name: Option<&str>, ) -> Result, String> { @@ -143,7 +140,6 @@ fn compile_selected( modules.last().unwrap().0.module.name, source, Path::new("Main.nash"), - version, TraceConfig { user: trace, compiler: false, @@ -193,7 +189,7 @@ fn compile_selected( output.push('\n'); } insta::with_settings!({description => source, omit_expression => true}, { - insta::assert_snapshot!(format!("{snapshot_name}_{version:?}_{trace:?}"), output); + insta::assert_snapshot!(format!("{snapshot_name}_{trace:?}"), output); }); Ok(programs) } @@ -229,7 +225,6 @@ fn unit_roots_and_power_assert_payloads() { let programs = compile( "unit_roots_and_power_assert_payloads_1", source, - PlutusVersion::V3, TraceLevel::Silent, ) .unwrap(); @@ -277,7 +272,6 @@ fn captures_preserve_partial_application_order_and_lazy_branches() { let programs = compile( "captures_preserve_partial_application_order_and_lazy_branches_1", source, - PlutusVersion::V3, TraceLevel::Verbose, ) .unwrap(); @@ -325,7 +319,6 @@ fn custom_show_runs_only_on_failure_and_test_local_native_layouts_specialize() { let programs = compile( "custom_show_runs_only_on_failure_and_test_local_native_layouts_specialize_1", source, - PlutusVersion::V3, TraceLevel::Verbose, ) .unwrap(); @@ -373,7 +366,6 @@ fn assertion_json_preserves_nested_call_delimiters_and_string_parentheses() { let programs = compile( "assertion_json_preserves_nested_call_delimiters_and_string_parentheses_1", source, - PlutusVersion::V3, TraceLevel::Silent, ) .unwrap(); @@ -418,7 +410,6 @@ fn properties_thread_prng_bind_patterns_and_draw_without_running_body() { let programs = compile( "properties_thread_prng_bind_patterns_and_draw_without_running_body_1", source, - PlutusVersion::V3, TraceLevel::Verbose, ) .unwrap(); @@ -455,7 +446,7 @@ fn properties_thread_prng_bind_patterns_and_draw_without_running_body() { } #[test] -fn rejected_generator_skips_body_and_selected_target_is_enforced() { +fn rejected_generator_skips_body_and_selection_precedes_codegen() { let source = indoc::indoc!( r#" module Main exposing (..) @@ -472,9 +463,8 @@ fn rejected_generator_skips_body_and_selected_target_is_enforced() { "# ); let programs = compile( - "rejected_generator_skips_body_and_selected_target_is_enforced_3", + "rejected_generator_skips_body_and_selection_precedes_codegen_all", source, - PlutusVersion::V3, TraceLevel::Silent, ) .unwrap(); @@ -493,28 +483,15 @@ fn rejected_generator_skips_body_and_selected_target_is_enforced() { .unwrap() .is_none() ); - for version in [PlutusVersion::V1, PlutusVersion::V2] { - let all = compile( - "rejected_generator_skips_body_and_selected_target_is_enforced_2", - source, - version, - TraceLevel::Silent, - ) - .unwrap(); - assert_eq!(all.len(), 2); - assert_eq!(all[0].plutus_version, version); - assert_eq!(all[1].plutus_version, version); - let selected = compile_selected( - "rejected_generator_skips_body_and_selected_target_is_enforced_1", - source, - version, - TraceLevel::Silent, - Some("plain"), - ) - .unwrap(); - assert_eq!(selected.len(), 1); - assert_eq!(unit(&selected[0]), (true, vec![])); - } + let selected = compile_selected( + "rejected_generator_skips_body_and_selection_precedes_codegen_plain", + source, + TraceLevel::Silent, + Some("plain"), + ) + .unwrap(); + assert_eq!(selected.len(), 1); + assert_eq!(unit(&selected[0]), (true, vec![])); } #[test] @@ -537,7 +514,6 @@ fn rejected_generator_does_not_initialize_later_generators() { let programs = compile( "rejected_generator_does_not_initialize_later_generators", source, - PlutusVersion::V3, TraceLevel::Verbose, ) .unwrap(); @@ -557,3 +533,40 @@ fn rejected_generator_does_not_initialize_later_generators() { )); assert_eq!(evaluated.logs, ["first"]); } + +#[test] +fn o2_test_compilation_rejects_trace_settings() { + let arena = Arena::new(); + let build = Build::new(std::iter::empty()); + let mut rows = Vec::new(); + for trace in [ + TraceConfig { + user: TraceLevel::Compact, + compiler: false, + }, + TraceConfig { + user: TraceLevel::Verbose, + compiler: false, + }, + TraceConfig { + user: TraceLevel::Silent, + compiler: true, + }, + ] { + let result = compile_tests_matching_optimized( + &arena, + &build, + primitives::primitive_home(), + "", + Path::new("Main.nash"), + trace, + nash_config::OptimizationLevel::O2, + |_| true, + ); + let Err(error) = result else { + panic!("conflicting settings must fail before compilation"); + }; + rows.push(format!("{trace:?}: {error}")); + } + insta::with_settings!({omit_expression => true}, { insta::assert_snapshot!(rows.join("\n")); }); +} diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__assertion_json_preserves_nested_call_delimiters_and_string_parentheses_1_V3_Silent.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__assertion_json_preserves_nested_call_delimiters_and_string_parentheses_1_Silent.snap similarity index 82% rename from crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__assertion_json_preserves_nested_call_delimiters_and_string_parentheses_1_V3_Silent.snap rename to crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__assertion_json_preserves_nested_call_delimiters_and_string_parentheses_1_Silent.snap index 021f98fa..b7fdbb94 100644 --- a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__assertion_json_preserves_nested_call_delimiters_and_string_parentheses_1_V3_Silent.snap +++ b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__assertion_json_preserves_nested_call_delimiters_and_string_parentheses_1_Silent.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/tests/integration.rs -assertion_line: 196 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal\nimport TestLogic exposing ((==))\none : int\none = 1\ntests\n test \"nested infix call\" = do\n assert (one == Builtin.addInteger one (Builtin.addInteger one one))\n test \"parentheses inside strings\" = do\n assert (Builtin.equalsString \"(\" (Builtin.appendString \")\" (\"(\")))\n test \"grouped operands\" = do\n assert ((Builtin.addInteger one one) == (Builtin.addInteger one (Builtin.addInteger one one)))\n test \"grouped callee\" = do\n assert ((\\x -> x) False)\n" --- --- nested infix call @@ -455,18 +454,8 @@ case@Bool anf#252 of let anf#267 : bytes = consByteString anf#265 (con bytestring #) in appendByteString anf#261 anf#267 in - let anf#269 : bool = lessThanInteger 1 0 in - let anf#280 : string = case@Bool anf#269 of - True -> let anf#270 : (int -> int) -> int = applyForward#162 1 in - let anf#272 : int -> int = subtractInteger 0 in - let anf#273 : int = anf#270 anf#272 in - let anf#274 : bytes = applyForward#162 anf#273 decimal#167 in - let anf#275 : string = applyForward#162 anf#274 decodeUtf8 in - let anf#276 : (string -> string) -> string = applyForward#162 anf#275 in - let anf#278 : string -> string = appendString message#126 in - anf#276 anf#278 - False -> let anf#279 : bytes = applyForward#162 1 decimal#167 in - applyForward#162 anf#279 decodeUtf8 in + let anf#279 : bytes = applyForward#162 1 decimal#167 in + let anf#280 : string = applyForward#162 anf#279 decodeUtf8 in anf#253 anf#280 (\unit#173 : unit -> let applyForward#177 : 'erased -> ('erased -> 'erased) -> 'erased = \x#175 : 'erased (f#176 : 'erased -> 'erased) -> f#176 x#175 in let anf#281 : string -> (unit -> unit) -> unit = assertCapture#145 "\0assert\00\01\0" in letrec @@ -507,18 +496,8 @@ case@Bool anf#252 of let anf#323 : bytes = consByteString anf#321 (con bytestring #) in appendByteString anf#317 anf#323 in - let anf#325 : bool = lessThanInteger 1 0 in - let anf#336 : string = case@Bool anf#325 of - True -> let anf#326 : (int -> int) -> int = applyForward#192 1 in - let anf#328 : int -> int = subtractInteger 0 in - let anf#329 : int = anf#326 anf#328 in - let anf#330 : bytes = applyForward#192 anf#329 decimal#197 in - let anf#331 : string = applyForward#192 anf#330 decodeUtf8 in - let anf#332 : (string -> string) -> string = applyForward#192 anf#331 in - let anf#334 : string -> string = appendString message#126 in - anf#332 anf#334 - False -> let anf#335 : bytes = applyForward#192 1 decimal#197 in - applyForward#192 anf#335 decodeUtf8 in + let anf#335 : bytes = applyForward#192 1 decimal#197 in + let anf#336 : string = applyForward#192 anf#335 decodeUtf8 in anf#309 anf#336 (\unit#203 : unit -> let applyForward#207 : 'erased -> ('erased -> 'erased) -> 'erased = \x#205 : 'erased (f#206 : 'erased -> 'erased) -> f#206 x#205 in let anf#337 : string -> (unit -> unit) -> unit = assertCapture#145 "\0assert\00\04\0" in letrec @@ -559,18 +538,8 @@ case@Bool anf#252 of let anf#379 : bytes = consByteString anf#377 (con bytestring #) in appendByteString anf#373 anf#379 in - let anf#381 : bool = lessThanInteger 1 0 in - let anf#392 : string = case@Bool anf#381 of - True -> let anf#382 : (int -> int) -> int = applyForward#222 1 in - let anf#384 : int -> int = subtractInteger 0 in - let anf#385 : int = anf#382 anf#384 in - let anf#386 : bytes = applyForward#222 anf#385 decimal#227 in - let anf#387 : string = applyForward#222 anf#386 decodeUtf8 in - let anf#388 : (string -> string) -> string = applyForward#222 anf#387 in - let anf#390 : string -> string = appendString message#126 in - anf#388 anf#390 - False -> let anf#391 : bytes = applyForward#222 1 decimal#227 in - applyForward#222 anf#391 decodeUtf8 in + let anf#391 : bytes = applyForward#222 1 decimal#227 in + let anf#392 : string = applyForward#222 anf#391 decodeUtf8 in anf#365 anf#392 (\unit#233 : unit -> let applyForward#237 : 'erased -> ('erased -> 'erased) -> 'erased = \x#235 : 'erased (f#236 : 'erased -> 'erased) -> f#236 x#235 in let anf#393 : string -> (unit -> unit) -> unit = assertCapture#145 "\0assert\00\07\0" in letrec @@ -585,331 +554,248 @@ case@Bool anf#252 of let anf#407 : bytes = consByteString anf#405 (con bytestring #) in appendByteString anf#401 anf#407 in - let anf#409 : bool = lessThanInteger 1 0 in - let anf#420 : string = case@Bool anf#409 of - True -> let anf#410 : (int -> int) -> int = applyForward#237 1 in - let anf#412 : int -> int = subtractInteger 0 in - let anf#413 : int = anf#410 anf#412 in - let anf#414 : bytes = applyForward#237 anf#413 decimal#242 in - let anf#415 : string = applyForward#237 anf#414 decodeUtf8 in - let anf#416 : (string -> string) -> string = applyForward#237 anf#415 in - let anf#418 : string -> string = appendString message#126 in - anf#416 anf#418 - False -> let anf#419 : bytes = applyForward#237 1 decimal#242 in - applyForward#237 anf#419 decodeUtf8 in + let anf#419 : bytes = applyForward#237 1 decimal#242 in + let anf#420 : string = applyForward#237 anf#419 decodeUtf8 in anf#393 anf#420 (\unit#248 : unit -> error))))))) --- optimized UPLC (program 1.1.0 - [(lam builtin_227 - [(lam partial_228 - [(lam partial_229 - [(lam partial_230 - [(lam partial_231 - [(lam message_13 - [(lam assertAt_17 - [(lam assertCapture_22 - [(lam apply_23 - [(lam apply_24 - [(lam apply_25 - [(lam assert_value_26 - [(lam assert_value_27 - [(lam anf_28 - (case - anf_28 - [[assertAt_17 (con string "\0assert\0\48")] - (lam unit_29 - [(lam applyForward_32 - [(lam anf_33 - [(lam decimal_44 - [(lam anf_45 - [(lam anf_54 - [[anf_33 anf_54] - (lam unit_55 - [(lam applyForward_58 - [(lam anf_59 - [(lam decimal_70 - [(lam anf_71 - [(lam anf_80 - [[anf_59 anf_80] - (lam unit_81 - [(lam applyForward_84 - [(lam anf_85 - [(lam decimal_96 - [(lam anf_97 - [(lam anf_106 - [[anf_85 anf_106] - (lam unit_107 - [(lam applyForward_110 - [(lam anf_111 - [(lam decimal_122 - [(lam anf_123 - [(lam anf_133 - [[anf_111 anf_133] - (lam unit_134 - [(lam applyForward_137 - [(lam anf_138 - [(lam decimal_165 - [(lam anf_166 - [(lam anf_181 - [[anf_138 anf_181] - (lam unit_184 - [(lam applyForward_187 - [(lam anf_189 - [(lam decimal_209 - [(lam anf_210 - [(lam anf_225 [[anf_189 anf_225] (lam unit_226 (error))]) - (case - anf_210 - [(lam anf_224 [[applyForward_187 anf_224] (builtin decodeUtf8)]) - [[applyForward_187 (con integer 1)] decimal_209]] - [(lam anf_211 - [(lam anf_214 - [(lam anf_215 - [(lam anf_216 - [(lam anf_217 - [(lam anf_219 - [(lam anf_223 [anf_219 anf_223]) [(builtin appendString) message_13]]) - [applyForward_187 anf_217]]) - [[applyForward_187 anf_216] (builtin decodeUtf8)]]) - [[applyForward_187 anf_215] decimal_209]]) - [anf_211 anf_214]]) - partial_228]) - [applyForward_187 (con integer 1)]])]) - [partial_229 (con integer 0)]]) - [(lam self_193 [self_193 self_193]) - (lam self_194 - (lam n_195 - [(lam anf_196 - (case - anf_196 - [(lam anf_200 - [(lam anf_201 - [(lam anf_202 - [(lam anf_204 - [(lam anf_208 [[(builtin appendByteString) anf_201] anf_208]) - [[(builtin consByteString) anf_204] (con bytestring #)]]) - [partial_230 anf_202]]) - [[(builtin remainderInteger) n_195] (con integer 10)]]) - [[self_194 self_194] anf_200]]) - [[(builtin quotientInteger) n_195] (con integer 10)]] - [(lam anf_199 [[(builtin consByteString) anf_199] (con bytestring #)]) - [partial_230 n_195]])) - [[(builtin lessThanInteger) n_195] (con integer 10)]]))]]) - [assertCapture_22 (con string "\0assert\0\48\0\55\0")]]) - (lam x_185 (lam f_186 [f_186 x_185]))])]) - (case - anf_166 - [(lam anf_180 [[applyForward_137 anf_180] (builtin decodeUtf8)]) - [[applyForward_137 (con integer 1)] decimal_165]] - [(lam anf_169 + [(lam builtin_173 + [(lam partial_174 + [(lam partial_175 + [(lam partial_176 + [(lam message_13 + [(lam assertAt_17 + [(lam assertCapture_22 + [(lam apply_23 + [(lam assert_value_26 + [(lam assert_value_27 + [(lam anf_28 + (case + anf_28 + [[assertAt_17 (con string "\0assert\0\48")] + (lam unit_29 + [(lam applyForward_32 + [(lam anf_33 + [(lam decimal_44 + [(lam anf_45 + [(lam anf_46 + [[anf_33 anf_46] + (lam unit_47 + [(lam applyForward_50 + [(lam anf_51 + [(lam decimal_62 + [(lam anf_63 + [(lam anf_72 + [[anf_51 anf_72] + (lam unit_73 + [(lam applyForward_76 + [(lam anf_77 + [(lam decimal_88 + [(lam anf_89 + [(lam anf_90 + [[anf_77 anf_90] + (lam unit_91 + [(lam applyForward_94 + [(lam anf_95 + [(lam decimal_106 + [(lam anf_107 + [(lam anf_116 + [[anf_95 anf_116] + (lam unit_117 + [(lam applyForward_120 + [(lam anf_121 + [(lam decimal_133 + [(lam anf_134 + [(lam anf_135 + [[anf_121 anf_135] + (lam unit_136 + [(lam applyForward_146 + [(lam anf_147 + [(lam decimal_169 [(lam anf_170 - [(lam anf_171 - [(lam anf_172 - [(lam anf_174 - [(lam anf_178 - [(lam anf_179 [anf_178 anf_179]) [(builtin appendString) message_13]]) - [applyForward_137 anf_174]]) - [[applyForward_137 anf_172] (builtin decodeUtf8)]]) - [[applyForward_137 anf_171] decimal_165]]) - [anf_169 anf_170]]) - partial_228]) - [applyForward_137 (con integer 1)]])]) - [partial_229 (con integer 0)]]) - [(lam self_146 [self_146 self_146]) - (lam self_147 - (lam n_149 - [(lam anf_150 - (case - anf_150 - [(lam anf_153 - [(lam anf_155 - [(lam anf_159 - [(lam anf_163 - [(lam anf_164 [[(builtin appendByteString) anf_155] anf_164]) - [[(builtin consByteString) anf_163] (con bytestring #)]]) - [partial_230 anf_159]]) - [[(builtin remainderInteger) n_149] (con integer 10)]]) - [[self_147 self_147] anf_153]]) - [[(builtin quotientInteger) n_149] (con integer 10)]] - [(lam anf_152 [[(builtin consByteString) anf_152] (con bytestring #)]) - [partial_230 n_149]])) - [[(builtin lessThanInteger) n_149] (con integer 10)]]))]]) - [assertCapture_22 (con string "\0assert\0\48\0\54\0")]]) - (lam x_135 (lam f_136 [f_136 x_135]))])]) - (case - anf_123 - [(lam anf_132 [[applyForward_110 anf_132] (builtin decodeUtf8)]) - [[applyForward_110 assert_value_26] decimal_122]] - [(lam anf_124 - [(lam anf_125 - [(lam anf_127 - [(lam anf_128 - [(lam anf_129 - [(lam anf_130 - [(lam anf_131 [anf_130 anf_131]) [(builtin appendString) message_13]]) - [applyForward_110 anf_129]]) - [[applyForward_110 anf_128] (builtin decodeUtf8)]]) - [[applyForward_110 anf_127] decimal_122]]) - [anf_124 anf_125]]) - partial_228]) - [applyForward_110 assert_value_26]])]) - [[(builtin lessThanInteger) assert_value_26] (con integer 0)]]) - [(lam self_112 [self_112 self_112]) - (lam self_113 - (lam n_114 - [(lam anf_115 - (case - anf_115 - [(lam anf_117 - [(lam anf_118 - [(lam anf_119 - [(lam anf_120 - [(lam anf_121 [[(builtin appendByteString) anf_118] anf_121]) - [[(builtin consByteString) anf_120] (con bytestring #)]]) - [partial_230 anf_119]]) - [[(builtin remainderInteger) n_114] (con integer 10)]]) - [[self_113 self_113] anf_117]]) - [[(builtin quotientInteger) n_114] (con integer 10)]] - [(lam anf_116 [[(builtin consByteString) anf_116] (con bytestring #)]) - [partial_230 n_114]])) - [[(builtin lessThanInteger) n_114] (con integer 10)]]))]]) - [assertCapture_22 (con string "\0assert\0\48\0\52\0")]]) - (lam x_108 (lam f_109 [f_109 x_108]))])]) - (case - anf_97 - [(lam anf_105 [[applyForward_84 anf_105] (builtin decodeUtf8)]) - [[applyForward_84 (con integer 1)] decimal_96]] - [(lam anf_98 - [(lam anf_99 - [(lam anf_100 - [(lam anf_101 - [(lam anf_102 - [(lam anf_103 - [(lam anf_104 [anf_103 anf_104]) [(builtin appendString) message_13]]) - [applyForward_84 anf_102]]) - [[applyForward_84 anf_101] (builtin decodeUtf8)]]) - [[applyForward_84 anf_100] decimal_96]]) - [anf_98 anf_99]]) - partial_228]) - [applyForward_84 (con integer 1)]])]) - [partial_229 (con integer 0)]]) - [(lam self_86 [self_86 self_86]) - (lam self_87 - (lam n_88 - [(lam anf_89 - (case - anf_89 - [(lam anf_91 - [(lam anf_92 - [(lam anf_93 - [(lam anf_94 - [(lam anf_95 [[(builtin appendByteString) anf_92] anf_95]) - [[(builtin consByteString) anf_94] (con bytestring #)]]) - [partial_230 anf_93]]) - [[(builtin remainderInteger) n_88] (con integer 10)]]) - [[self_87 self_87] anf_91]]) - [[(builtin quotientInteger) n_88] (con integer 10)]] - [(lam anf_90 [[(builtin consByteString) anf_90] (con bytestring #)]) - [partial_230 n_88]])) - [[(builtin lessThanInteger) n_88] (con integer 10)]]))]]) - [assertCapture_22 (con string "\0assert\0\48\0\51\0")]]) - (lam x_82 (lam f_83 [f_83 x_82]))])]) - (case - anf_71 - [(lam anf_79 [[applyForward_58 anf_79] (builtin decodeUtf8)]) - [[applyForward_58 assert_value_27] decimal_70]] - [(lam anf_72 - [(lam anf_73 - [(lam anf_74 - [(lam anf_75 - [(lam anf_76 - [(lam anf_77 [(lam anf_78 [anf_77 anf_78]) [(builtin appendString) message_13]]) - [applyForward_58 anf_76]]) - [[applyForward_58 anf_75] (builtin decodeUtf8)]]) - [[applyForward_58 anf_74] decimal_70]]) - [anf_72 anf_73]]) - partial_228]) - [applyForward_58 assert_value_27]])]) - [[(builtin lessThanInteger) assert_value_27] (con integer 0)]]) - [(lam self_60 [self_60 self_60]) - (lam self_61 - (lam n_62 - [(lam anf_63 - (case - anf_63 - [(lam anf_65 - [(lam anf_66 - [(lam anf_67 - [(lam anf_68 - [(lam anf_69 [[(builtin appendByteString) anf_66] anf_69]) - [[(builtin consByteString) anf_68] (con bytestring #)]]) - [partial_230 anf_67]]) - [[(builtin remainderInteger) n_62] (con integer 10)]]) - [[self_61 self_61] anf_65]]) - [[(builtin quotientInteger) n_62] (con integer 10)]] - [(lam anf_64 [[(builtin consByteString) anf_64] (con bytestring #)]) - [partial_230 n_62]])) - [[(builtin lessThanInteger) n_62] (con integer 10)]]))]]) - [assertCapture_22 (con string "\0assert\0\48\0\49\0")]]) - (lam x_56 (lam f_57 [f_57 x_56]))])]) - (case - anf_45 - [(lam anf_53 [[applyForward_32 anf_53] (builtin decodeUtf8)]) - [[applyForward_32 (con integer 1)] decimal_44]] - [(lam anf_46 - [(lam anf_47 - [(lam anf_48 - [(lam anf_49 - [(lam anf_50 - [(lam anf_51 [(lam anf_52 [anf_51 anf_52]) [(builtin appendString) message_13]]) - [applyForward_32 anf_50]]) - [[applyForward_32 anf_49] (builtin decodeUtf8)]]) - [[applyForward_32 anf_48] decimal_44]]) - [anf_46 anf_47]]) - partial_228]) - [applyForward_32 (con integer 1)]])]) - [partial_229 (con integer 0)]]) - [(lam self_34 [self_34 self_34]) - (lam self_35 - (lam n_36 - [(lam anf_37 - (case - anf_37 - [(lam anf_39 - [(lam anf_40 - [(lam anf_41 - [(lam anf_42 - [(lam anf_43 [[(builtin appendByteString) anf_40] anf_43]) - [[(builtin consByteString) anf_42] (con bytestring #)]]) - [partial_230 anf_41]]) - [[(builtin remainderInteger) n_36] (con integer 10)]]) - [[self_35 self_35] anf_39]]) - [[(builtin quotientInteger) n_36] (con integer 10)]] - [(lam anf_38 [[(builtin consByteString) anf_38] (con bytestring #)]) - [partial_230 n_36]])) - [[(builtin lessThanInteger) n_36] (con integer 10)]]))]]) - [assertCapture_22 (con string "\0assert\0\48\0\48\0")]]) - (lam x_30 (lam f_31 [f_31 x_30]))])] - (con unit ()))) - [apply_23 assert_value_27]]) - [apply_24 assert_value_26]]) - [apply_25 (con integer 1)]]) - partial_231]) - partial_231]) - [(builtin equalsInteger) (con integer 1)]]) - (lam prefix_18 - (lam value_19 - (lam rest_20 - [(lam anf_21 [[assertAt_17 anf_21] rest_20]) - [[(builtin appendString) prefix_18] value_19]])))]) - (lam marker_14 - (lam rest_15 - [(lam anf_16 [anf_16 (con unit ())]) [[builtin_227 marker_14] rest_15]]))]) - (con string "-")]) - [(builtin addInteger) (con integer 1)]]) - [(builtin addInteger) (con integer 48)]]) - [(builtin lessThanInteger) (con integer 1)]]) - [(builtin subtractInteger) (con integer 0)]]) + [(lam anf_171 [[anf_147 anf_171] (lam unit_172 (error))]) + [[applyForward_146 anf_170] (builtin decodeUtf8)]]) + [[applyForward_146 (con integer 1)] decimal_169]]) + [(lam self_149 [self_149 self_149]) + (lam self_150 + (lam n_152 + [(lam anf_153 + (case + anf_153 + [(lam anf_159 + [(lam anf_163 + [(lam anf_164 + [(lam anf_165 + [(lam anf_166 [[(builtin appendByteString) anf_163] anf_166]) + [[(builtin consByteString) anf_165] (con bytestring #)]]) + [partial_174 anf_164]]) + [[(builtin remainderInteger) n_152] (con integer 10)]]) + [[self_150 self_150] anf_159]]) + [[(builtin quotientInteger) n_152] (con integer 10)]] + [(lam anf_155 [[(builtin consByteString) anf_155] (con bytestring #)]) + [partial_174 n_152]])) + [[(builtin lessThanInteger) n_152] (con integer 10)]]))]]) + [assertCapture_22 (con string "\0assert\0\48\0\55\0")]]) + (lam x_137 (lam f_138 [f_138 x_137]))])]) + [[applyForward_120 anf_134] (builtin decodeUtf8)]]) + [[applyForward_120 (con integer 1)] decimal_133]]) + [(lam self_122 [self_122 self_122]) + (lam self_123 + (lam n_124 + [(lam anf_125 + (case + anf_125 + [(lam anf_128 + [(lam anf_129 + [(lam anf_130 + [(lam anf_131 + [(lam anf_132 [[(builtin appendByteString) anf_129] anf_132]) + [[(builtin consByteString) anf_131] (con bytestring #)]]) + [partial_174 anf_130]]) + [[(builtin remainderInteger) n_124] (con integer 10)]]) + [[self_123 self_123] anf_128]]) + [[(builtin quotientInteger) n_124] (con integer 10)]] + [(lam anf_127 [[(builtin consByteString) anf_127] (con bytestring #)]) + [partial_174 n_124]])) + [[(builtin lessThanInteger) n_124] (con integer 10)]]))]]) + [assertCapture_22 (con string "\0assert\0\48\0\54\0")]]) + (lam x_118 (lam f_119 [f_119 x_118]))])]) + (case + anf_107 + [(lam anf_115 [[applyForward_94 anf_115] (builtin decodeUtf8)]) + [[applyForward_94 assert_value_26] decimal_106]] + [(lam anf_108 + [(lam anf_110 + [(lam anf_111 + [(lam anf_112 + [(lam anf_113 + [(lam anf_114 [anf_113 anf_114]) [(builtin appendString) message_13]]) + [applyForward_94 anf_112]]) + [[applyForward_94 anf_111] (builtin decodeUtf8)]]) + [[applyForward_94 anf_110] decimal_106]]) + [anf_108 partial_175]]) + [applyForward_94 assert_value_26]])]) + [[(builtin lessThanInteger) assert_value_26] (con integer 0)]]) + [(lam self_96 [self_96 self_96]) + (lam self_97 + (lam n_98 + [(lam anf_99 + (case + anf_99 + [(lam anf_101 + [(lam anf_102 + [(lam anf_103 + [(lam anf_104 + [(lam anf_105 [[(builtin appendByteString) anf_102] anf_105]) + [[(builtin consByteString) anf_104] (con bytestring #)]]) + [partial_174 anf_103]]) + [[(builtin remainderInteger) n_98] (con integer 10)]]) + [[self_97 self_97] anf_101]]) + [[(builtin quotientInteger) n_98] (con integer 10)]] + [(lam anf_100 [[(builtin consByteString) anf_100] (con bytestring #)]) + [partial_174 n_98]])) + [[(builtin lessThanInteger) n_98] (con integer 10)]]))]]) + [assertCapture_22 (con string "\0assert\0\48\0\52\0")]]) + (lam x_92 (lam f_93 [f_93 x_92]))])]) + [[applyForward_76 anf_89] (builtin decodeUtf8)]]) + [[applyForward_76 (con integer 1)] decimal_88]]) + [(lam self_78 [self_78 self_78]) + (lam self_79 + (lam n_80 + [(lam anf_81 + (case + anf_81 + [(lam anf_83 + [(lam anf_84 + [(lam anf_85 + [(lam anf_86 + [(lam anf_87 [[(builtin appendByteString) anf_84] anf_87]) + [[(builtin consByteString) anf_86] (con bytestring #)]]) + [partial_174 anf_85]]) + [[(builtin remainderInteger) n_80] (con integer 10)]]) + [[self_79 self_79] anf_83]]) + [[(builtin quotientInteger) n_80] (con integer 10)]] + [(lam anf_82 [[(builtin consByteString) anf_82] (con bytestring #)]) + [partial_174 n_80]])) + [[(builtin lessThanInteger) n_80] (con integer 10)]]))]]) + [assertCapture_22 (con string "\0assert\0\48\0\51\0")]]) + (lam x_74 (lam f_75 [f_75 x_74]))])]) + (case + anf_63 + [(lam anf_71 [[applyForward_50 anf_71] (builtin decodeUtf8)]) + [[applyForward_50 assert_value_27] decimal_62]] + [(lam anf_64 + [(lam anf_66 + [(lam anf_67 + [(lam anf_68 + [(lam anf_69 [(lam anf_70 [anf_69 anf_70]) [(builtin appendString) message_13]]) + [applyForward_50 anf_68]]) + [[applyForward_50 anf_67] (builtin decodeUtf8)]]) + [[applyForward_50 anf_66] decimal_62]]) + [anf_64 partial_175]]) + [applyForward_50 assert_value_27]])]) + [[(builtin lessThanInteger) assert_value_27] (con integer 0)]]) + [(lam self_52 [self_52 self_52]) + (lam self_53 + (lam n_54 + [(lam anf_55 + (case + anf_55 + [(lam anf_57 + [(lam anf_58 + [(lam anf_59 + [(lam anf_60 + [(lam anf_61 [[(builtin appendByteString) anf_58] anf_61]) + [[(builtin consByteString) anf_60] (con bytestring #)]]) + [partial_174 anf_59]]) + [[(builtin remainderInteger) n_54] (con integer 10)]]) + [[self_53 self_53] anf_57]]) + [[(builtin quotientInteger) n_54] (con integer 10)]] + [(lam anf_56 [[(builtin consByteString) anf_56] (con bytestring #)]) + [partial_174 n_54]])) + [[(builtin lessThanInteger) n_54] (con integer 10)]]))]]) + [assertCapture_22 (con string "\0assert\0\48\0\49\0")]]) + (lam x_48 (lam f_49 [f_49 x_48]))])]) + [[applyForward_32 anf_45] (builtin decodeUtf8)]]) + [[applyForward_32 (con integer 1)] decimal_44]]) + [(lam self_34 [self_34 self_34]) + (lam self_35 + (lam n_36 + [(lam anf_37 + (case + anf_37 + [(lam anf_39 + [(lam anf_40 + [(lam anf_41 + [(lam anf_42 + [(lam anf_43 [[(builtin appendByteString) anf_40] anf_43]) + [[(builtin consByteString) anf_42] (con bytestring #)]]) + [partial_174 anf_41]]) + [[(builtin remainderInteger) n_36] (con integer 10)]]) + [[self_35 self_35] anf_39]]) + [[(builtin quotientInteger) n_36] (con integer 10)]] + [(lam anf_38 [[(builtin consByteString) anf_38] (con bytestring #)]) + [partial_174 n_36]])) + [[(builtin lessThanInteger) n_36] (con integer 10)]]))]]) + [assertCapture_22 (con string "\0assert\0\48\0\48\0")]]) + (lam x_30 (lam f_31 [f_31 x_30]))])] + (con unit ()))) + [apply_23 assert_value_27]]) + [partial_176 assert_value_26]]) + [partial_176 (con integer 1)]]) + [(builtin equalsInteger) (con integer 1)]]) + (lam prefix_18 + (lam value_19 + (lam rest_20 + [(lam anf_21 [[assertAt_17 anf_21] rest_20]) + [[(builtin appendString) prefix_18] value_19]])))]) + (lam marker_14 + (lam rest_15 + [(lam anf_16 [anf_16 (con unit ())]) [[builtin_173 marker_14] rest_15]]))]) + (con string "-")]) + [(builtin addInteger) (con integer 1)]]) + [(builtin subtractInteger) (con integer 0)]]) + [(builtin addInteger) (con integer 48)]]) (force (builtin trace))]) --- encoded target UPLC (program 1.1.0 @@ -2200,18 +2086,8 @@ case@Bool anf#324 of let anf#367 : bytes = consByteString anf#365 (con bytestring #) in appendByteString anf#361 anf#367 in - let anf#369 : bool = lessThanInteger 1 0 in - let anf#380 : string = case@Bool anf#369 of - True -> let anf#370 : (int -> int) -> int = applyForward#219 1 in - let anf#372 : int -> int = subtractInteger 0 in - let anf#373 : int = anf#370 anf#372 in - let anf#374 : bytes = applyForward#219 anf#373 decimal#224 in - let anf#375 : string = applyForward#219 anf#374 decodeUtf8 in - let anf#376 : (string -> string) -> string = applyForward#219 anf#375 in - let anf#378 : string -> string = appendString message#162 in - anf#376 anf#378 - False -> let anf#379 : bytes = applyForward#219 1 decimal#224 in - applyForward#219 anf#379 decodeUtf8 in + let anf#379 : bytes = applyForward#219 1 decimal#224 in + let anf#380 : string = applyForward#219 anf#379 decodeUtf8 in anf#353 anf#380 (\unit#230 : unit -> let applyForward#234 : 'erased -> ('erased -> 'erased) -> 'erased = \x#232 : 'erased (f#233 : 'erased -> 'erased) -> f#233 x#232 in let anf#381 : string -> (unit -> unit) -> unit = assertCapture#183 "\0assert\00\03\0" in letrec @@ -2226,18 +2102,8 @@ case@Bool anf#324 of let anf#395 : bytes = consByteString anf#393 (con bytestring #) in appendByteString anf#389 anf#395 in - let anf#397 : bool = lessThanInteger 1 0 in - let anf#408 : string = case@Bool anf#397 of - True -> let anf#398 : (int -> int) -> int = applyForward#234 1 in - let anf#400 : int -> int = subtractInteger 0 in - let anf#401 : int = anf#398 anf#400 in - let anf#402 : bytes = applyForward#234 anf#401 decimal#239 in - let anf#403 : string = applyForward#234 anf#402 decodeUtf8 in - let anf#404 : (string -> string) -> string = applyForward#234 anf#403 in - let anf#406 : string -> string = appendString message#162 in - anf#404 anf#406 - False -> let anf#407 : bytes = applyForward#234 1 decimal#239 in - applyForward#234 anf#407 decodeUtf8 in + let anf#407 : bytes = applyForward#234 1 decimal#239 in + let anf#408 : string = applyForward#234 anf#407 decodeUtf8 in anf#381 anf#408 (\unit#245 : unit -> let applyForward#249 : 'erased -> ('erased -> 'erased) -> 'erased = \x#247 : 'erased (f#248 : 'erased -> 'erased) -> f#248 x#247 in let anf#409 : string -> (unit -> unit) -> unit = assertCapture#183 "\0assert\00\04\0" in letrec @@ -2278,18 +2144,8 @@ case@Bool anf#324 of let anf#451 : bytes = consByteString anf#449 (con bytestring #) in appendByteString anf#445 anf#451 in - let anf#453 : bool = lessThanInteger 1 0 in - let anf#464 : string = case@Bool anf#453 of - True -> let anf#454 : (int -> int) -> int = applyForward#264 1 in - let anf#456 : int -> int = subtractInteger 0 in - let anf#457 : int = anf#454 anf#456 in - let anf#458 : bytes = applyForward#264 anf#457 decimal#269 in - let anf#459 : string = applyForward#264 anf#458 decodeUtf8 in - let anf#460 : (string -> string) -> string = applyForward#264 anf#459 in - let anf#462 : string -> string = appendString message#162 in - anf#460 anf#462 - False -> let anf#463 : bytes = applyForward#264 1 decimal#269 in - applyForward#264 anf#463 decodeUtf8 in + let anf#463 : bytes = applyForward#264 1 decimal#269 in + let anf#464 : string = applyForward#264 anf#463 decodeUtf8 in anf#437 anf#464 (\unit#275 : unit -> let applyForward#279 : 'erased -> ('erased -> 'erased) -> 'erased = \x#277 : 'erased (f#278 : 'erased -> 'erased) -> f#278 x#277 in let anf#465 : string -> (unit -> unit) -> unit = assertCapture#183 "\0assert\00\07\0" in letrec @@ -2330,18 +2186,8 @@ case@Bool anf#324 of let anf#507 : bytes = consByteString anf#505 (con bytestring #) in appendByteString anf#501 anf#507 in - let anf#509 : bool = lessThanInteger 1 0 in - let anf#520 : string = case@Bool anf#509 of - True -> let anf#510 : (int -> int) -> int = applyForward#294 1 in - let anf#512 : int -> int = subtractInteger 0 in - let anf#513 : int = anf#510 anf#512 in - let anf#514 : bytes = applyForward#294 anf#513 decimal#299 in - let anf#515 : string = applyForward#294 anf#514 decodeUtf8 in - let anf#516 : (string -> string) -> string = applyForward#294 anf#515 in - let anf#518 : string -> string = appendString message#162 in - anf#516 anf#518 - False -> let anf#519 : bytes = applyForward#294 1 decimal#299 in - applyForward#294 anf#519 decodeUtf8 in + let anf#519 : bytes = applyForward#294 1 decimal#299 in + let anf#520 : string = applyForward#294 anf#519 decodeUtf8 in anf#493 anf#520 (\unit#305 : unit -> let applyForward#309 : 'erased -> ('erased -> 'erased) -> 'erased = \x#307 : 'erased (f#308 : 'erased -> 'erased) -> f#308 x#307 in let anf#521 : string -> (unit -> unit) -> unit = assertCapture#183 "\0assert\00\010\0" in letrec @@ -2356,427 +2202,324 @@ case@Bool anf#324 of let anf#535 : bytes = consByteString anf#533 (con bytestring #) in appendByteString anf#529 anf#535 in - let anf#537 : bool = lessThanInteger 1 0 in - let anf#548 : string = case@Bool anf#537 of - True -> let anf#538 : (int -> int) -> int = applyForward#309 1 in - let anf#540 : int -> int = subtractInteger 0 in - let anf#541 : int = anf#538 anf#540 in - let anf#542 : bytes = applyForward#309 anf#541 decimal#314 in - let anf#543 : string = applyForward#309 anf#542 decodeUtf8 in - let anf#544 : (string -> string) -> string = applyForward#309 anf#543 in - let anf#546 : string -> string = appendString message#162 in - anf#544 anf#546 - False -> let anf#547 : bytes = applyForward#309 1 decimal#314 in - applyForward#309 anf#547 decodeUtf8 in + let anf#547 : bytes = applyForward#309 1 decimal#314 in + let anf#548 : string = applyForward#309 anf#547 decodeUtf8 in anf#521 anf#548 (\unit#320 : unit -> error))))))))) --- optimized UPLC (program 1.1.0 - [(lam builtin_299 - [(lam partial_300 - [(lam partial_301 - [(lam partial_302 - [(lam partial_303 - [(lam message_17 - [(lam assertAt_21 - [(lam assertCapture_26 - [(lam apply_27 - [(lam assert_value_28 - [(lam apply_29 - [(lam apply_30 - [(lam apply_31 - [(lam assert_value_32 - [(lam assert_value_33 - [(lam anf_34 - (case - anf_34 - [[assertAt_21 (con string "\0assert\0\48")] - (lam unit_35 - [(lam applyForward_38 - [(lam anf_39 - [(lam decimal_50 - [(lam anf_51 - [(lam anf_60 - [[anf_39 anf_60] - (lam unit_61 - [(lam applyForward_64 - [(lam anf_65 - [(lam decimal_76 - [(lam anf_77 - [(lam anf_86 - [[anf_65 anf_86] - (lam unit_87 - [(lam applyForward_90 - [(lam anf_91 - [(lam decimal_102 - [(lam anf_103 - [(lam anf_112 - [[anf_91 anf_112] - (lam unit_113 - [(lam applyForward_116 - [(lam anf_117 - [(lam decimal_128 - [(lam anf_129 - [(lam anf_138 - [[anf_117 anf_138] - (lam unit_139 - [(lam applyForward_142 - [(lam anf_143 - [(lam decimal_154 - [(lam anf_155 - [(lam anf_165 - [[anf_143 anf_165] - (lam unit_166 - [(lam applyForward_169 - [(lam anf_170 - [(lam decimal_191 - [(lam anf_192 - [(lam anf_211 - [[anf_170 anf_211] - (lam unit_212 - [(lam applyForward_216 - [(lam anf_220 - [(lam decimal_237 - [(lam anf_238 - [(lam anf_253 - [[anf_220 anf_253] - (lam unit_256 - [(lam applyForward_259 - [(lam anf_261 - [(lam decimal_281 - [(lam anf_282 - [(lam anf_297 [[anf_261 anf_297] (lam unit_298 (error))]) - (case - anf_282 - [(lam anf_296 [[applyForward_259 anf_296] (builtin decodeUtf8)]) - [[applyForward_259 (con integer 1)] decimal_281]] - [(lam anf_283 - [(lam anf_286 - [(lam anf_287 - [(lam anf_288 - [(lam anf_289 - [(lam anf_291 - [(lam anf_295 [anf_291 anf_295]) [(builtin appendString) message_17]]) - [applyForward_259 anf_289]]) - [[applyForward_259 anf_288] (builtin decodeUtf8)]]) - [[applyForward_259 anf_287] decimal_281]]) - [anf_283 anf_286]]) - partial_300]) - [applyForward_259 (con integer 1)]])]) - [partial_301 (con integer 0)]]) - [(lam self_265 [self_265 self_265]) - (lam self_266 - (lam n_267 - [(lam anf_268 - (case - anf_268 - [(lam anf_272 - [(lam anf_273 - [(lam anf_274 - [(lam anf_276 - [(lam anf_280 [[(builtin appendByteString) anf_273] anf_280]) - [[(builtin consByteString) anf_276] (con bytestring #)]]) - [partial_302 anf_274]]) - [[(builtin remainderInteger) n_267] (con integer 10)]]) - [[self_266 self_266] anf_272]]) - [[(builtin quotientInteger) n_267] (con integer 10)]] - [(lam anf_271 [[(builtin consByteString) anf_271] (con bytestring #)]) - [partial_302 n_267]])) - [[(builtin lessThanInteger) n_267] (con integer 10)]]))]]) - [assertCapture_26 (con string "\0assert\0\48\0\49\48\0")]]) - (lam x_257 (lam f_258 [f_258 x_257]))])]) - (case - anf_238 - [(lam anf_252 [[applyForward_216 anf_252] (builtin decodeUtf8)]) - [[applyForward_216 (con integer 1)] decimal_237]] - [(lam anf_241 - [(lam anf_242 - [(lam anf_243 - [(lam anf_244 - [(lam anf_246 - [(lam anf_250 - [(lam anf_251 [anf_250 anf_251]) [(builtin appendString) message_17]]) - [applyForward_216 anf_246]]) - [[applyForward_216 anf_244] (builtin decodeUtf8)]]) - [[applyForward_216 anf_243] decimal_237]]) - [anf_241 anf_242]]) - partial_300]) - [applyForward_216 (con integer 1)]])]) - [partial_301 (con integer 0)]]) - [(lam self_221 [self_221 self_221]) - (lam self_222 - (lam n_223 - [(lam anf_226 - (case - anf_226 - [(lam anf_228 - [(lam anf_229 - [(lam anf_231 - [(lam anf_235 - [(lam anf_236 [[(builtin appendByteString) anf_229] anf_236]) - [[(builtin consByteString) anf_235] (con bytestring #)]]) - [partial_302 anf_231]]) - [[(builtin remainderInteger) n_223] (con integer 10)]]) - [[self_222 self_222] anf_228]]) - [[(builtin quotientInteger) n_223] (con integer 10)]] - [(lam anf_227 [[(builtin consByteString) anf_227] (con bytestring #)]) - [partial_302 n_223]])) - [[(builtin lessThanInteger) n_223] (con integer 10)]]))]]) - [assertCapture_26 (con string "\0assert\0\48\0\57\0")]]) - (lam x_213 (lam f_214 [f_214 x_213]))])]) - (case - anf_192 - [(lam anf_208 [[applyForward_169 anf_208] (builtin decodeUtf8)]) - [[applyForward_169 assert_value_32] decimal_191]] - [(lam anf_194 - [(lam anf_195 - [(lam anf_197 - [(lam anf_201 - [(lam anf_205 - [(lam anf_206 - [(lam anf_207 [anf_206 anf_207]) [(builtin appendString) message_17]]) - [applyForward_169 anf_205]]) - [[applyForward_169 anf_201] (builtin decodeUtf8)]]) - [[applyForward_169 anf_197] decimal_191]]) - [anf_194 anf_195]]) - partial_300]) - [applyForward_169 assert_value_32]])]) - [[(builtin lessThanInteger) assert_value_32] (con integer 0)]]) - [(lam self_171 [self_171 self_171]) - (lam self_172 - (lam n_173 - [(lam anf_174 - (case - anf_174 - [(lam anf_176 - [(lam anf_184 - [(lam anf_185 - [(lam anf_186 - [(lam anf_188 [[(builtin appendByteString) anf_184] anf_188]) - [[(builtin consByteString) anf_186] (con bytestring #)]]) - [partial_302 anf_185]]) - [[(builtin remainderInteger) n_173] (con integer 10)]]) - [[self_172 self_172] anf_176]]) - [[(builtin quotientInteger) n_173] (con integer 10)]] - [(lam anf_175 [[(builtin consByteString) anf_175] (con bytestring #)]) - [partial_302 n_173]])) - [[(builtin lessThanInteger) n_173] (con integer 10)]]))]]) - [assertCapture_26 (con string "\0assert\0\48\0\55\0")]]) - (lam x_167 (lam f_168 [f_168 x_167]))])]) - (case - anf_155 - [(lam anf_164 [[applyForward_142 anf_164] (builtin decodeUtf8)]) - [[applyForward_142 (con integer 1)] decimal_154]] - [(lam anf_156 - [(lam anf_157 - [(lam anf_158 - [(lam anf_159 + [(lam builtin_232 + [(lam partial_233 + [(lam partial_234 + [(lam partial_235 + [(lam message_17 + [(lam assertAt_21 + [(lam assertCapture_26 + [(lam assert_value_28 + [(lam apply_29 + [(lam assert_value_32 + [(lam assert_value_33 + [(lam anf_34 + (case + anf_34 + [[assertAt_21 (con string "\0assert\0\48")] + (lam unit_35 + [(lam applyForward_38 + [(lam anf_39 + [(lam decimal_50 + [(lam anf_51 + [(lam anf_60 + [[anf_39 anf_60] + (lam unit_61 + [(lam applyForward_64 + [(lam anf_65 + [(lam decimal_76 + [(lam anf_77 + [(lam anf_78 + [[anf_65 anf_78] + (lam unit_79 + [(lam applyForward_82 + [(lam anf_83 + [(lam decimal_94 + [(lam anf_95 + [(lam anf_96 + [[anf_83 anf_96] + (lam unit_97 + [(lam applyForward_100 + [(lam anf_101 + [(lam decimal_112 + [(lam anf_113 + [(lam anf_122 + [[anf_101 anf_122] + (lam unit_123 + [(lam applyForward_126 + [(lam anf_127 + [(lam decimal_138 + [(lam anf_139 + [(lam anf_140 + [[anf_127 anf_140] + (lam unit_141 + [(lam applyForward_144 + [(lam anf_145 + [(lam decimal_156 + [(lam anf_157 + [(lam anf_167 + [[anf_145 anf_167] + (lam unit_168 + [(lam applyForward_171 + [(lam anf_172 + [(lam decimal_194 + [(lam anf_195 + [(lam anf_197 + [[anf_172 anf_197] + (lam unit_201 + [(lam applyForward_207 + [(lam anf_208 + [(lam decimal_227 + [(lam anf_228 + [(lam anf_229 [[anf_208 anf_229] (lam unit_231 (error))]) + [[applyForward_207 anf_228] (builtin decodeUtf8)]]) + [[applyForward_207 (con integer 1)] decimal_227]]) + [(lam self_211 [self_211 self_211]) + (lam self_212 + (lam n_213 + [(lam anf_214 + (case + anf_214 + [(lam anf_220 + [(lam anf_221 + [(lam anf_222 + [(lam anf_223 + [(lam anf_226 [[(builtin appendByteString) anf_221] anf_226]) + [[(builtin consByteString) anf_223] (con bytestring #)]]) + [partial_233 anf_222]]) + [[(builtin remainderInteger) n_213] (con integer 10)]]) + [[self_212 self_212] anf_220]]) + [[(builtin quotientInteger) n_213] (con integer 10)]] + [(lam anf_216 [[(builtin consByteString) anf_216] (con bytestring #)]) + [partial_233 n_213]])) + [[(builtin lessThanInteger) n_213] (con integer 10)]]))]]) + [assertCapture_26 (con string "\0assert\0\48\0\49\48\0")]]) + (lam x_205 (lam f_206 [f_206 x_205]))])]) + [[applyForward_171 anf_195] (builtin decodeUtf8)]]) + [[applyForward_171 (con integer 1)] decimal_194]]) + [(lam self_173 [self_173 self_173]) + (lam self_174 + (lam n_175 + [(lam anf_176 + (case + anf_176 + [(lam anf_185 + [(lam anf_186 + [(lam anf_188 + [(lam anf_191 + [(lam anf_192 [[(builtin appendByteString) anf_186] anf_192]) + [[(builtin consByteString) anf_191] (con bytestring #)]]) + [partial_233 anf_188]]) + [[(builtin remainderInteger) n_175] (con integer 10)]]) + [[self_174 self_174] anf_185]]) + [[(builtin quotientInteger) n_175] (con integer 10)]] + [(lam anf_184 [[(builtin consByteString) anf_184] (con bytestring #)]) + [partial_233 n_175]])) + [[(builtin lessThanInteger) n_175] (con integer 10)]]))]]) + [assertCapture_26 (con string "\0assert\0\48\0\57\0")]]) + (lam x_169 (lam f_170 [f_170 x_169]))])]) + (case + anf_157 + [(lam anf_166 [[applyForward_144 anf_166] (builtin decodeUtf8)]) + [[applyForward_144 assert_value_32] decimal_156]] + [(lam anf_158 [(lam anf_160 [(lam anf_161 - [(lam anf_163 [anf_161 anf_163]) [(builtin appendString) message_17]]) - [applyForward_142 anf_160]]) - [[applyForward_142 anf_159] (builtin decodeUtf8)]]) - [[applyForward_142 anf_158] decimal_154]]) - [anf_156 anf_157]]) - partial_300]) - [applyForward_142 (con integer 1)]])]) - [partial_301 (con integer 0)]]) - [(lam self_144 [self_144 self_144]) - (lam self_145 - (lam n_146 - [(lam anf_147 - (case - anf_147 - [(lam anf_149 - [(lam anf_150 - [(lam anf_151 - [(lam anf_152 - [(lam anf_153 [[(builtin appendByteString) anf_150] anf_153]) - [[(builtin consByteString) anf_152] (con bytestring #)]]) - [partial_302 anf_151]]) - [[(builtin remainderInteger) n_146] (con integer 10)]]) - [[self_145 self_145] anf_149]]) - [[(builtin quotientInteger) n_146] (con integer 10)]] - [(lam anf_148 [[(builtin consByteString) anf_148] (con bytestring #)]) - [partial_302 n_146]])) - [[(builtin lessThanInteger) n_146] (con integer 10)]]))]]) - [assertCapture_26 (con string "\0assert\0\48\0\54\0")]]) - (lam x_140 (lam f_141 [f_141 x_140]))])]) - (case - anf_129 - [(lam anf_137 [[applyForward_116 anf_137] (builtin decodeUtf8)]) - [[applyForward_116 assert_value_33] decimal_128]] - [(lam anf_130 - [(lam anf_131 - [(lam anf_132 - [(lam anf_133 - [(lam anf_134 - [(lam anf_135 - [(lam anf_136 [anf_135 anf_136]) [(builtin appendString) message_17]]) - [applyForward_116 anf_134]]) - [[applyForward_116 anf_133] (builtin decodeUtf8)]]) - [[applyForward_116 anf_132] decimal_128]]) - [anf_130 anf_131]]) - partial_300]) - [applyForward_116 assert_value_33]])]) - [[(builtin lessThanInteger) assert_value_33] (con integer 0)]]) - [(lam self_118 [self_118 self_118]) - (lam self_119 - (lam n_120 - [(lam anf_121 - (case - anf_121 - [(lam anf_123 - [(lam anf_124 - [(lam anf_125 - [(lam anf_126 - [(lam anf_127 [[(builtin appendByteString) anf_124] anf_127]) - [[(builtin consByteString) anf_126] (con bytestring #)]]) - [partial_302 anf_125]]) - [[(builtin remainderInteger) n_120] (con integer 10)]]) - [[self_119 self_119] anf_123]]) - [[(builtin quotientInteger) n_120] (con integer 10)]] - [(lam anf_122 [[(builtin consByteString) anf_122] (con bytestring #)]) - [partial_302 n_120]])) - [[(builtin lessThanInteger) n_120] (con integer 10)]]))]]) - [assertCapture_26 (con string "\0assert\0\48\0\52\0")]]) - (lam x_114 (lam f_115 [f_115 x_114]))])]) - (case - anf_103 - [(lam anf_111 [[applyForward_90 anf_111] (builtin decodeUtf8)]) - [[applyForward_90 (con integer 1)] decimal_102]] - [(lam anf_104 - [(lam anf_105 - [(lam anf_106 - [(lam anf_107 - [(lam anf_108 - [(lam anf_109 - [(lam anf_110 [anf_109 anf_110]) [(builtin appendString) message_17]]) - [applyForward_90 anf_108]]) - [[applyForward_90 anf_107] (builtin decodeUtf8)]]) - [[applyForward_90 anf_106] decimal_102]]) - [anf_104 anf_105]]) - partial_300]) - [applyForward_90 (con integer 1)]])]) - [partial_301 (con integer 0)]]) - [(lam self_92 [self_92 self_92]) - (lam self_93 - (lam n_94 - [(lam anf_95 - (case - anf_95 - [(lam anf_97 - [(lam anf_98 - [(lam anf_99 - [(lam anf_100 - [(lam anf_101 [[(builtin appendByteString) anf_98] anf_101]) - [[(builtin consByteString) anf_100] (con bytestring #)]]) - [partial_302 anf_99]]) - [[(builtin remainderInteger) n_94] (con integer 10)]]) - [[self_93 self_93] anf_97]]) - [[(builtin quotientInteger) n_94] (con integer 10)]] - [(lam anf_96 [[(builtin consByteString) anf_96] (con bytestring #)]) - [partial_302 n_94]])) - [[(builtin lessThanInteger) n_94] (con integer 10)]]))]]) - [assertCapture_26 (con string "\0assert\0\48\0\51\0")]]) - (lam x_88 (lam f_89 [f_89 x_88]))])]) - (case - anf_77 - [(lam anf_85 [[applyForward_64 anf_85] (builtin decodeUtf8)]) - [[applyForward_64 (con integer 1)] decimal_76]] - [(lam anf_78 - [(lam anf_79 - [(lam anf_80 - [(lam anf_81 - [(lam anf_82 - [(lam anf_83 [(lam anf_84 [anf_83 anf_84]) [(builtin appendString) message_17]]) - [applyForward_64 anf_82]]) - [[applyForward_64 anf_81] (builtin decodeUtf8)]]) - [[applyForward_64 anf_80] decimal_76]]) - [anf_78 anf_79]]) - partial_300]) - [applyForward_64 (con integer 1)]])]) - [partial_301 (con integer 0)]]) - [(lam self_66 [self_66 self_66]) - (lam self_67 - (lam n_68 - [(lam anf_69 - (case - anf_69 - [(lam anf_71 - [(lam anf_72 - [(lam anf_73 - [(lam anf_74 - [(lam anf_75 [[(builtin appendByteString) anf_72] anf_75]) - [[(builtin consByteString) anf_74] (con bytestring #)]]) - [partial_302 anf_73]]) - [[(builtin remainderInteger) n_68] (con integer 10)]]) - [[self_67 self_67] anf_71]]) - [[(builtin quotientInteger) n_68] (con integer 10)]] - [(lam anf_70 [[(builtin consByteString) anf_70] (con bytestring #)]) - [partial_302 n_68]])) - [[(builtin lessThanInteger) n_68] (con integer 10)]]))]]) - [assertCapture_26 (con string "\0assert\0\48\0\50\0")]]) - (lam x_62 (lam f_63 [f_63 x_62]))])]) - (case - anf_51 - [(lam anf_59 [[applyForward_38 anf_59] (builtin decodeUtf8)]) - [[applyForward_38 assert_value_28] decimal_50]] - [(lam anf_52 - [(lam anf_53 - [(lam anf_54 - [(lam anf_55 - [(lam anf_56 - [(lam anf_57 [(lam anf_58 [anf_57 anf_58]) [(builtin appendString) message_17]]) - [applyForward_38 anf_56]]) - [[applyForward_38 anf_55] (builtin decodeUtf8)]]) - [[applyForward_38 anf_54] decimal_50]]) - [anf_52 anf_53]]) - partial_300]) - [applyForward_38 assert_value_28]])]) - [[(builtin lessThanInteger) assert_value_28] (con integer 0)]]) - [(lam self_40 [self_40 self_40]) - (lam self_41 - (lam n_42 - [(lam anf_43 - (case - anf_43 - [(lam anf_45 - [(lam anf_46 - [(lam anf_47 - [(lam anf_48 - [(lam anf_49 [[(builtin appendByteString) anf_46] anf_49]) - [[(builtin consByteString) anf_48] (con bytestring #)]]) - [partial_302 anf_47]]) - [[(builtin remainderInteger) n_42] (con integer 10)]]) - [[self_41 self_41] anf_45]]) - [[(builtin quotientInteger) n_42] (con integer 10)]] - [(lam anf_44 [[(builtin consByteString) anf_44] (con bytestring #)]) - [partial_302 n_42]])) - [[(builtin lessThanInteger) n_42] (con integer 10)]]))]]) - [assertCapture_26 (con string "\0assert\0\48\0\48\0")]]) - (lam x_36 (lam f_37 [f_37 x_36]))])] - (con unit ()))) - [apply_29 assert_value_33]]) - [apply_30 assert_value_32]]) - [apply_31 (con integer 1)]]) - partial_303]) - partial_303]) - [(builtin equalsInteger) assert_value_28]]) - [apply_27 (con integer 1)]]) - partial_303]) - (lam prefix_22 - (lam value_23 - (lam rest_24 - [(lam anf_25 [[assertAt_21 anf_25] rest_24]) - [[(builtin appendString) prefix_22] value_23]])))]) - (lam marker_18 - (lam rest_19 - [(lam anf_20 [anf_20 (con unit ())]) [[builtin_299 marker_18] rest_19]]))]) - (con string "-")]) - [(builtin addInteger) (con integer 1)]]) - [(builtin addInteger) (con integer 48)]]) - [(builtin lessThanInteger) (con integer 1)]]) - [(builtin subtractInteger) (con integer 0)]]) + [(lam anf_163 + [(lam anf_164 + [(lam anf_165 [anf_164 anf_165]) [(builtin appendString) message_17]]) + [applyForward_144 anf_163]]) + [[applyForward_144 anf_161] (builtin decodeUtf8)]]) + [[applyForward_144 anf_160] decimal_156]]) + [anf_158 partial_234]]) + [applyForward_144 assert_value_32]])]) + [[(builtin lessThanInteger) assert_value_32] (con integer 0)]]) + [(lam self_146 [self_146 self_146]) + (lam self_147 + (lam n_148 + [(lam anf_149 + (case + anf_149 + [(lam anf_151 + [(lam anf_152 + [(lam anf_153 + [(lam anf_154 + [(lam anf_155 [[(builtin appendByteString) anf_152] anf_155]) + [[(builtin consByteString) anf_154] (con bytestring #)]]) + [partial_233 anf_153]]) + [[(builtin remainderInteger) n_148] (con integer 10)]]) + [[self_147 self_147] anf_151]]) + [[(builtin quotientInteger) n_148] (con integer 10)]] + [(lam anf_150 [[(builtin consByteString) anf_150] (con bytestring #)]) + [partial_233 n_148]])) + [[(builtin lessThanInteger) n_148] (con integer 10)]]))]]) + [assertCapture_26 (con string "\0assert\0\48\0\55\0")]]) + (lam x_142 (lam f_143 [f_143 x_142]))])]) + [[applyForward_126 anf_139] (builtin decodeUtf8)]]) + [[applyForward_126 (con integer 1)] decimal_138]]) + [(lam self_128 [self_128 self_128]) + (lam self_129 + (lam n_130 + [(lam anf_131 + (case + anf_131 + [(lam anf_133 + [(lam anf_134 + [(lam anf_135 + [(lam anf_136 + [(lam anf_137 [[(builtin appendByteString) anf_134] anf_137]) + [[(builtin consByteString) anf_136] (con bytestring #)]]) + [partial_233 anf_135]]) + [[(builtin remainderInteger) n_130] (con integer 10)]]) + [[self_129 self_129] anf_133]]) + [[(builtin quotientInteger) n_130] (con integer 10)]] + [(lam anf_132 [[(builtin consByteString) anf_132] (con bytestring #)]) + [partial_233 n_130]])) + [[(builtin lessThanInteger) n_130] (con integer 10)]]))]]) + [assertCapture_26 (con string "\0assert\0\48\0\54\0")]]) + (lam x_124 (lam f_125 [f_125 x_124]))])]) + (case + anf_113 + [(lam anf_121 [[applyForward_100 anf_121] (builtin decodeUtf8)]) + [[applyForward_100 assert_value_33] decimal_112]] + [(lam anf_114 + [(lam anf_116 + [(lam anf_117 + [(lam anf_118 + [(lam anf_119 + [(lam anf_120 [anf_119 anf_120]) [(builtin appendString) message_17]]) + [applyForward_100 anf_118]]) + [[applyForward_100 anf_117] (builtin decodeUtf8)]]) + [[applyForward_100 anf_116] decimal_112]]) + [anf_114 partial_234]]) + [applyForward_100 assert_value_33]])]) + [[(builtin lessThanInteger) assert_value_33] (con integer 0)]]) + [(lam self_102 [self_102 self_102]) + (lam self_103 + (lam n_104 + [(lam anf_105 + (case + anf_105 + [(lam anf_107 + [(lam anf_108 + [(lam anf_109 + [(lam anf_110 + [(lam anf_111 [[(builtin appendByteString) anf_108] anf_111]) + [[(builtin consByteString) anf_110] (con bytestring #)]]) + [partial_233 anf_109]]) + [[(builtin remainderInteger) n_104] (con integer 10)]]) + [[self_103 self_103] anf_107]]) + [[(builtin quotientInteger) n_104] (con integer 10)]] + [(lam anf_106 [[(builtin consByteString) anf_106] (con bytestring #)]) + [partial_233 n_104]])) + [[(builtin lessThanInteger) n_104] (con integer 10)]]))]]) + [assertCapture_26 (con string "\0assert\0\48\0\52\0")]]) + (lam x_98 (lam f_99 [f_99 x_98]))])]) + [[applyForward_82 anf_95] (builtin decodeUtf8)]]) + [[applyForward_82 (con integer 1)] decimal_94]]) + [(lam self_84 [self_84 self_84]) + (lam self_85 + (lam n_86 + [(lam anf_87 + (case + anf_87 + [(lam anf_89 + [(lam anf_90 + [(lam anf_91 + [(lam anf_92 + [(lam anf_93 [[(builtin appendByteString) anf_90] anf_93]) + [[(builtin consByteString) anf_92] (con bytestring #)]]) + [partial_233 anf_91]]) + [[(builtin remainderInteger) n_86] (con integer 10)]]) + [[self_85 self_85] anf_89]]) + [[(builtin quotientInteger) n_86] (con integer 10)]] + [(lam anf_88 [[(builtin consByteString) anf_88] (con bytestring #)]) + [partial_233 n_86]])) + [[(builtin lessThanInteger) n_86] (con integer 10)]]))]]) + [assertCapture_26 (con string "\0assert\0\48\0\51\0")]]) + (lam x_80 (lam f_81 [f_81 x_80]))])]) + [[applyForward_64 anf_77] (builtin decodeUtf8)]]) + [[applyForward_64 (con integer 1)] decimal_76]]) + [(lam self_66 [self_66 self_66]) + (lam self_67 + (lam n_68 + [(lam anf_69 + (case + anf_69 + [(lam anf_71 + [(lam anf_72 + [(lam anf_73 + [(lam anf_74 + [(lam anf_75 [[(builtin appendByteString) anf_72] anf_75]) + [[(builtin consByteString) anf_74] (con bytestring #)]]) + [partial_233 anf_73]]) + [[(builtin remainderInteger) n_68] (con integer 10)]]) + [[self_67 self_67] anf_71]]) + [[(builtin quotientInteger) n_68] (con integer 10)]] + [(lam anf_70 [[(builtin consByteString) anf_70] (con bytestring #)]) + [partial_233 n_68]])) + [[(builtin lessThanInteger) n_68] (con integer 10)]]))]]) + [assertCapture_26 (con string "\0assert\0\48\0\50\0")]]) + (lam x_62 (lam f_63 [f_63 x_62]))])]) + (case + anf_51 + [(lam anf_59 [[applyForward_38 anf_59] (builtin decodeUtf8)]) + [[applyForward_38 assert_value_28] decimal_50]] + [(lam anf_52 + [(lam anf_54 + [(lam anf_55 + [(lam anf_56 + [(lam anf_57 [(lam anf_58 [anf_57 anf_58]) [(builtin appendString) message_17]]) + [applyForward_38 anf_56]]) + [[applyForward_38 anf_55] (builtin decodeUtf8)]]) + [[applyForward_38 anf_54] decimal_50]]) + [anf_52 partial_234]]) + [applyForward_38 assert_value_28]])]) + [[(builtin lessThanInteger) assert_value_28] (con integer 0)]]) + [(lam self_40 [self_40 self_40]) + (lam self_41 + (lam n_42 + [(lam anf_43 + (case + anf_43 + [(lam anf_45 + [(lam anf_46 + [(lam anf_47 + [(lam anf_48 + [(lam anf_49 [[(builtin appendByteString) anf_46] anf_49]) + [[(builtin consByteString) anf_48] (con bytestring #)]]) + [partial_233 anf_47]]) + [[(builtin remainderInteger) n_42] (con integer 10)]]) + [[self_41 self_41] anf_45]]) + [[(builtin quotientInteger) n_42] (con integer 10)]] + [(lam anf_44 [[(builtin consByteString) anf_44] (con bytestring #)]) + [partial_233 n_42]])) + [[(builtin lessThanInteger) n_42] (con integer 10)]]))]]) + [assertCapture_26 (con string "\0assert\0\48\0\48\0")]]) + (lam x_36 (lam f_37 [f_37 x_36]))])] + (con unit ()))) + [apply_29 assert_value_33]]) + [partial_235 assert_value_32]]) + [partial_235 (con integer 1)]]) + [(builtin equalsInteger) assert_value_28]]) + [partial_235 (con integer 1)]]) + (lam prefix_22 + (lam value_23 + (lam rest_24 + [(lam anf_25 [[assertAt_21 anf_25] rest_24]) + [[(builtin appendString) prefix_22] value_23]])))]) + (lam marker_18 + (lam rest_19 + [(lam anf_20 [anf_20 (con unit ())]) [[builtin_232 marker_18] rest_19]]))]) + (con string "-")]) + [(builtin addInteger) (con integer 1)]]) + [(builtin subtractInteger) (con integer 0)]]) + [(builtin addInteger) (con integer 48)]]) (force (builtin trace))]) --- encoded target UPLC (program 1.1.0 diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__captures_preserve_partial_application_order_and_lazy_branches_1_V3_Verbose.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__captures_preserve_partial_application_order_and_lazy_branches_1_Verbose.snap similarity index 93% rename from crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__captures_preserve_partial_application_order_and_lazy_branches_1_V3_Verbose.snap rename to crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__captures_preserve_partial_application_order_and_lazy_branches_1_Verbose.snap index ae24fddd..e7673232 100644 --- a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__captures_preserve_partial_application_order_and_lazy_branches_1_V3_Verbose.snap +++ b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__captures_preserve_partial_application_order_and_lazy_branches_1_Verbose.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/tests/integration.rs -assertion_line: 196 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal\nimport Logic exposing (..)\nimport TestLogic exposing ((==))\ncompare : int -> int -> bool\ncompare x = trace \"partial\" (\\y -> Builtin.equalsInteger x y)\none : int\none = 1\nbadBool : unit -> bool\nbadBool _ = fail \"unselected\"\nordinary : unit\nordinary = if True || (badBool ()) then () else (fail \"wrong\")\ntests\n test \"ordered\" = do\n assert (compare (trace \"left\" one) (trace \"right\" 2))\n test \"lazy\" = do\n assert (if False then (fail \"unselected\") else True)\n test \"lazy or\" = do\n assert (True || (badBool ()))\n test \"lazy and\" = do\n assert (if False && (badBool ()) then False else True)\n test \"ordinary lowering is lazy\" = do\n ordinary\n" --- --- ordered @@ -168,30 +167,20 @@ case@Bool anf#103 of let anf#118 : bytes = consByteString anf#116 (con bytestring #) in appendByteString anf#112 anf#118 in - let anf#120 : bool = lessThanInteger 1 0 in - let anf#131 : string = case@Bool anf#120 of - True -> let anf#121 : (int -> int) -> int = applyForward#87 1 in - let anf#123 : int -> int = subtractInteger 0 in - let anf#124 : int = anf#121 anf#123 in - let anf#125 : bytes = applyForward#87 anf#124 decimal#92 in - let anf#126 : string = applyForward#87 anf#125 decodeUtf8 in - let anf#127 : (string -> string) -> string = applyForward#87 anf#126 in - let anf#129 : string -> string = appendString "-" in - anf#127 anf#129 - False -> let anf#130 : bytes = applyForward#87 1 decimal#92 in - applyForward#87 anf#130 decodeUtf8 in + let anf#130 : bytes = applyForward#87 1 decimal#92 in + let anf#131 : string = applyForward#87 anf#130 decodeUtf8 in let anf#102 : string = appendString "\0assert\00\01\0" anf#131 in assertAt#68 anf#102 (\unit#98 : unit -> error)) --- optimized UPLC (program 1.1.0 - [(lam builtin_39 - [(lam partial_40 + [(lam builtin_31 + [(lam partial_32 [(lam assertAt_6 (case - (force [[builtin_39 (con string "left")] (delay (con unit ()))]) + (force [[builtin_31 (con string "left")] (delay (con unit ()))]) [(lam apply_9 (case - (force [[builtin_39 (con string "right")] (delay (con unit ()))]) + (force [[builtin_31 (con string "right")] (delay (con unit ()))]) [(lam anf_11 (case anf_11 @@ -200,27 +189,11 @@ case@Bool anf#103 of [(lam applyForward_15 [(lam decimal_26 [(lam anf_27 - [(lam anf_36 - [(lam anf_37 [[assertAt_6 anf_37] (lam unit_38 (error))]) - [[(builtin appendString) (con string "\0assert\0\48\0\49\0")] anf_36]]) - (case - anf_27 - [(lam anf_35 [[applyForward_15 anf_35] (builtin decodeUtf8)]) - [[applyForward_15 (con integer 1)] decimal_26]] - [(lam anf_28 - [(lam anf_29 - [(lam anf_30 - [(lam anf_31 - [(lam anf_32 - [(lam anf_33 - [(lam anf_34 [anf_33 anf_34]) [(builtin appendString) (con string "-")]]) - [applyForward_15 anf_32]]) - [[applyForward_15 anf_31] (builtin decodeUtf8)]]) - [[applyForward_15 anf_30] decimal_26]]) - [anf_28 anf_29]]) - [(builtin subtractInteger) (con integer 0)]]) - [applyForward_15 (con integer 1)]])]) - [[(builtin lessThanInteger) (con integer 1)] (con integer 0)]]) + [(lam anf_28 + [(lam anf_29 [[assertAt_6 anf_29] (lam unit_30 (error))]) + [[(builtin appendString) (con string "\0assert\0\48\0\49\0")] anf_28]]) + [[applyForward_15 anf_27] (builtin decodeUtf8)]]) + [[applyForward_15 (con integer 1)] decimal_26]]) [(lam self_16 [self_16 self_16]) (lam self_17 (lam n_18 @@ -233,21 +206,21 @@ case@Bool anf#103 of [(lam anf_24 [(lam anf_25 [[(builtin appendByteString) anf_22] anf_25]) [[(builtin consByteString) anf_24] (con bytestring #)]]) - [partial_40 anf_23]]) + [partial_32 anf_23]]) [[(builtin remainderInteger) n_18] (con integer 10)]]) [[self_17 self_17] anf_21]]) [[(builtin quotientInteger) n_18] (con integer 10)]] [(lam anf_20 [[(builtin consByteString) anf_20] (con bytestring #)]) - [partial_40 n_18]])) + [partial_32 n_18]])) [[(builtin lessThanInteger) n_18] (con integer 10)]]))]]) (lam x_13 (lam f_14 [f_14 x_13]))])] (con unit ()))) [apply_9 (con integer 2)]])) (force - [[builtin_39 (con string "partial")] + [[builtin_31 (con string "partial")] (delay (lam y_8 [[(builtin equalsInteger) (con integer 1)] y_8]))])])) (lam marker_3 - (lam rest_4 [(lam anf_5 [anf_5 (con unit ())]) [[builtin_39 marker_3] rest_4]]))]) + (lam rest_4 [(lam anf_5 [anf_5 (con unit ())]) [[builtin_31 marker_3] rest_4]]))]) [(builtin addInteger) (con integer 48)]]) (force (builtin trace))]) --- encoded target UPLC diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__custom_show_runs_only_on_failure_and_test_local_native_layouts_specialize_1_V3_Verbose.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__custom_show_runs_only_on_failure_and_test_local_native_layouts_specialize_1_Verbose.snap similarity index 88% rename from crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__custom_show_runs_only_on_failure_and_test_local_native_layouts_specialize_1_V3_Verbose.snap rename to crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__custom_show_runs_only_on_failure_and_test_local_native_layouts_specialize_1_Verbose.snap index 4194e536..87087da2 100644 --- a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__custom_show_runs_only_on_failure_and_test_local_native_layouts_specialize_1_V3_Verbose.snap +++ b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__custom_show_runs_only_on_failure_and_test_local_native_layouts_specialize_1_Verbose.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/tests/integration.rs -assertion_line: 196 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal\nimport Show exposing (Show)\ntype boxed = Box int\nimpl Show boxed where\n show = trace \"show init\" (\\_ -> trace \"show\" \"Box\")\nisZero : boxed -> bool\nisZero (Box value) = Builtin.equalsInteger value 0\nordinary : unit\nordinary = assert False\ntests\n test \"passing show is lazy\" = do\n value <- trace \"value\" (Box 0)\n assert (isZero value)\n test \"failing show executes\" = do\n value <- trace \"value\" (Box 1)\n assert (isZero value)\n test \"native local specialization\" = do\n values <- let singleton x = [x] in singleton 1\n assert (Builtin.equalsInteger (Builtin.headList values) 1)\n test \"ordinary assertion unchanged\" = do\n ordinary\n" --- --- passing show is lazy @@ -671,7 +670,7 @@ let assertAt#93 : string -> (unit -> unit) -> unit = \marker#91 : string (rest#9 anf#157 () in let assertCapture#97 : string -> string -> (unit -> unit) -> unit = \prefix#94 : string value#95 : string (rest#96 : unit -> unit) -> let anf#159 : string = appendString prefix#94 value#95 in assertAt#93 anf#159 rest#96 in -let destruct#100 : list int = mkCons 1 (con (list integer) []) in +let destruct#100 : list int = (con (list integer) [1]) in let assert_value#102 : list int -> int = headList in let assert_value#106 : int = assert_value#102 destruct#100 in let apply#107 : int -> bool = equalsInteger assert_value#106 in @@ -747,152 +746,144 @@ case@Bool anf#161 of (program 1.1.0 [(lam builtin_89 [(lam builtin_90 - [(lam builtin_91 + [(lam partial_91 [(lam partial_92 - [(lam partial_93 - [(lam message_7 - [(lam assertAt_11 - [(lam assertCapture_16 - [(lam destruct_17 - [(lam assert_value_18 - [(lam assert_value_19 - [(lam apply_20 - [(lam anf_21 - (case - anf_21 - [[assertAt_11 (con string "\0assert\0\48")] - (lam unit_22 - [(lam applyForward_25 - [(lam anf_26 - [(lam decimal_37 - [(lam anf_38 - [(lam anf_47 - [[anf_26 anf_47] - (lam unit_48 - [(lam applyForward_51 - [(lam anf_52 - [(lam decimal_63 - [(lam showItems_84 - [(lam anf_85 - [(lam anf_86 - [(lam anf_87 [[anf_52 anf_87] (lam unit_88 (error))]) - [[(builtin appendString) (con string "[")] anf_86]]) - [[(builtin appendString) anf_85] (con string "]")]]) - [showItems_84 destruct_17]]) - [(lam self_64 [self_64 self_64]) - (lam self_65 - (lam values_66 - (case - values_66 - (lam field_67 - (lam field_68 - [(lam anf_69 - [(lam first_78 - (case - field_68 - (lam field_79 - (lam field_81 - [(lam anf_82 - [(lam anf_83 [[(builtin appendString) first_78] anf_83]) - [[(builtin appendString) (con string ", ")] anf_82]]) - [[self_65 self_65] field_68]])) - first_78)) - (case - anf_69 - [(lam anf_77 [[applyForward_51 anf_77] (builtin decodeUtf8)]) - [[applyForward_51 field_67] decimal_63]] - [(lam anf_70 - [(lam anf_71 - [(lam anf_72 - [(lam anf_73 - [(lam anf_74 - [(lam anf_75 [(lam anf_76 [anf_75 anf_76]) [(builtin appendString) message_7]]) - [applyForward_51 anf_74]]) - [[applyForward_51 anf_73] (builtin decodeUtf8)]]) - [[applyForward_51 anf_72] decimal_63]]) - [anf_70 anf_71]]) - partial_92]) - [applyForward_51 field_67]])]) - [[(builtin lessThanInteger) field_67] (con integer 0)]])) - (con string ""))))]]) - [(lam self_53 [self_53 self_53]) - (lam self_54 - (lam n_55 - [(lam anf_56 - (case - anf_56 - [(lam anf_58 - [(lam anf_59 - [(lam anf_60 - [(lam anf_61 - [(lam anf_62 [[(builtin appendByteString) anf_59] anf_62]) - [[(builtin consByteString) anf_61] (con bytestring #)]]) - [partial_93 anf_60]]) - [[(builtin remainderInteger) n_55] (con integer 10)]]) - [[self_54 self_54] anf_58]]) - [[(builtin quotientInteger) n_55] (con integer 10)]] - [(lam anf_57 [[(builtin consByteString) anf_57] (con bytestring #)]) - [partial_93 n_55]])) - [[(builtin lessThanInteger) n_55] (con integer 10)]]))]]) - [assertCapture_16 (con string "\0assert\0\48\0\51\0")]]) - (lam x_49 (lam f_50 [f_50 x_49]))])]) + [(lam message_7 + [(lam assertAt_11 + [(lam assertCapture_16 + [(lam destruct_17 + [(lam assert_value_19 + [(lam apply_20 + [(lam anf_21 + (case + anf_21 + [[assertAt_11 (con string "\0assert\0\48")] + (lam unit_22 + [(lam applyForward_25 + [(lam anf_26 + [(lam decimal_37 + [(lam anf_38 + [(lam anf_47 + [[anf_26 anf_47] + (lam unit_48 + [(lam applyForward_51 + [(lam anf_52 + [(lam decimal_63 + [(lam showItems_84 + [(lam anf_85 + [(lam anf_86 + [(lam anf_87 [[anf_52 anf_87] (lam unit_88 (error))]) + [[(builtin appendString) (con string "[")] anf_86]]) + [[(builtin appendString) anf_85] (con string "]")]]) + [showItems_84 destruct_17]]) + [(lam self_64 [self_64 self_64]) + (lam self_65 + (lam values_66 + (case + values_66 + (lam field_67 + (lam field_68 + [(lam anf_69 + [(lam first_78 + (case + field_68 + (lam field_79 + (lam field_81 + [(lam anf_82 + [(lam anf_83 [[(builtin appendString) first_78] anf_83]) + [[(builtin appendString) (con string ", ")] anf_82]]) + [[self_65 self_65] field_68]])) + first_78)) + (case + anf_69 + [(lam anf_77 [[applyForward_51 anf_77] (builtin decodeUtf8)]) + [[applyForward_51 field_67] decimal_63]] + [(lam anf_70 + [(lam anf_72 + [(lam anf_73 + [(lam anf_74 + [(lam anf_75 [(lam anf_76 [anf_75 anf_76]) [(builtin appendString) message_7]]) + [applyForward_51 anf_74]]) + [[applyForward_51 anf_73] (builtin decodeUtf8)]]) + [[applyForward_51 anf_72] decimal_63]]) + [anf_70 partial_91]]) + [applyForward_51 field_67]])]) + [[(builtin lessThanInteger) field_67] (con integer 0)]])) + (con string ""))))]]) + [(lam self_53 [self_53 self_53]) + (lam self_54 + (lam n_55 + [(lam anf_56 + (case + anf_56 + [(lam anf_58 + [(lam anf_59 + [(lam anf_60 + [(lam anf_61 + [(lam anf_62 [[(builtin appendByteString) anf_59] anf_62]) + [[(builtin consByteString) anf_61] (con bytestring #)]]) + [partial_92 anf_60]]) + [[(builtin remainderInteger) n_55] (con integer 10)]]) + [[self_54 self_54] anf_58]]) + [[(builtin quotientInteger) n_55] (con integer 10)]] + [(lam anf_57 [[(builtin consByteString) anf_57] (con bytestring #)]) + [partial_92 n_55]])) + [[(builtin lessThanInteger) n_55] (con integer 10)]]))]]) + [assertCapture_16 (con string "\0assert\0\48\0\51\0")]]) + (lam x_49 (lam f_50 [f_50 x_49]))])]) + (case + anf_38 + [(lam anf_46 [[applyForward_25 anf_46] (builtin decodeUtf8)]) + [[applyForward_25 assert_value_19] decimal_37]] + [(lam anf_39 + [(lam anf_41 + [(lam anf_42 + [(lam anf_43 + [(lam anf_44 [(lam anf_45 [anf_44 anf_45]) [(builtin appendString) message_7]]) + [applyForward_25 anf_43]]) + [[applyForward_25 anf_42] (builtin decodeUtf8)]]) + [[applyForward_25 anf_41] decimal_37]]) + [anf_39 partial_91]]) + [applyForward_25 assert_value_19]])]) + [[(builtin lessThanInteger) assert_value_19] (con integer 0)]]) + [(lam self_27 [self_27 self_27]) + (lam self_28 + (lam n_29 + [(lam anf_30 (case - anf_38 - [(lam anf_46 [[applyForward_25 anf_46] (builtin decodeUtf8)]) - [[applyForward_25 assert_value_19] decimal_37]] - [(lam anf_39 - [(lam anf_40 - [(lam anf_41 - [(lam anf_42 - [(lam anf_43 - [(lam anf_44 [(lam anf_45 [anf_44 anf_45]) [(builtin appendString) message_7]]) - [applyForward_25 anf_43]]) - [[applyForward_25 anf_42] (builtin decodeUtf8)]]) - [[applyForward_25 anf_41] decimal_37]]) - [anf_39 anf_40]]) - partial_92]) - [applyForward_25 assert_value_19]])]) - [[(builtin lessThanInteger) assert_value_19] (con integer 0)]]) - [(lam self_27 [self_27 self_27]) - (lam self_28 - (lam n_29 - [(lam anf_30 - (case - anf_30 - [(lam anf_32 - [(lam anf_33 - [(lam anf_34 - [(lam anf_35 - [(lam anf_36 [[(builtin appendByteString) anf_33] anf_36]) - [[(builtin consByteString) anf_35] (con bytestring #)]]) - [partial_93 anf_34]]) - [[(builtin remainderInteger) n_29] (con integer 10)]]) - [[self_28 self_28] anf_32]]) - [[(builtin quotientInteger) n_29] (con integer 10)]] - [(lam anf_31 [[(builtin consByteString) anf_31] (con bytestring #)]) - [partial_93 n_29]])) - [[(builtin lessThanInteger) n_29] (con integer 10)]]))]]) - [assertCapture_16 (con string "\0assert\0\48\0\49\0")]]) - (lam x_23 (lam f_24 [f_24 x_23]))])] - (con unit ()))) - [apply_20 (con integer 1)]]) - [(builtin equalsInteger) assert_value_19]]) - [assert_value_18 destruct_17]]) - builtin_89]) - [[builtin_90 (con integer 1)] (con (list integer) [])]]) - (lam prefix_12 - (lam value_13 - (lam rest_14 - [(lam anf_15 [[assertAt_11 anf_15] rest_14]) - [[(builtin appendString) prefix_12] value_13]])))]) - (lam marker_8 - (lam rest_9 - [(lam anf_10 [anf_10 (con unit ())]) [[builtin_91 marker_8] rest_9]]))]) - (con string "-")]) - [(builtin addInteger) (con integer 48)]]) - [(builtin subtractInteger) (con integer 0)]]) - (force (builtin trace))]) - (force (builtin mkCons))]) + anf_30 + [(lam anf_32 + [(lam anf_33 + [(lam anf_34 + [(lam anf_35 + [(lam anf_36 [[(builtin appendByteString) anf_33] anf_36]) + [[(builtin consByteString) anf_35] (con bytestring #)]]) + [partial_92 anf_34]]) + [[(builtin remainderInteger) n_29] (con integer 10)]]) + [[self_28 self_28] anf_32]]) + [[(builtin quotientInteger) n_29] (con integer 10)]] + [(lam anf_31 [[(builtin consByteString) anf_31] (con bytestring #)]) + [partial_92 n_29]])) + [[(builtin lessThanInteger) n_29] (con integer 10)]]))]]) + [assertCapture_16 (con string "\0assert\0\48\0\49\0")]]) + (lam x_23 (lam f_24 [f_24 x_23]))])] + (con unit ()))) + [apply_20 (con integer 1)]]) + [(builtin equalsInteger) assert_value_19]]) + [builtin_89 destruct_17]]) + (con (list integer) [1])]) + (lam prefix_12 + (lam value_13 + (lam rest_14 + [(lam anf_15 [[assertAt_11 anf_15] rest_14]) + [[(builtin appendString) prefix_12] value_13]])))]) + (lam marker_8 + (lam rest_9 + [(lam anf_10 [anf_10 (con unit ())]) [[builtin_90 marker_8] rest_9]]))]) + (con string "-")]) + [(builtin addInteger) (con integer 48)]]) + [(builtin subtractInteger) (con integer 0)]]) + (force (builtin trace))]) (force (builtin headList))]) --- encoded target UPLC (program 1.1.0 diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__o2_test_compilation_rejects_trace_settings.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__o2_test_compilation_rejects_trace_settings.snap new file mode 100644 index 00000000..1b6be2de --- /dev/null +++ b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__o2_test_compilation_rejects_trace_settings.snap @@ -0,0 +1,6 @@ +--- +source: crates/nash-codegen/src/tests/integration.rs +--- +TraceConfig { user: Compact, compiler: false }: O2 requires silent tracing; compact and verbose tracing are not supported +TraceConfig { user: Verbose, compiler: false }: O2 requires silent tracing; compact and verbose tracing are not supported +TraceConfig { user: Silent, compiler: true }: O2 does not support compiler traces diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__properties_thread_prng_bind_patterns_and_draw_without_running_body_1_V3_Verbose.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__properties_thread_prng_bind_patterns_and_draw_without_running_body_1_Verbose.snap similarity index 98% rename from crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__properties_thread_prng_bind_patterns_and_draw_without_running_body_1_V3_Verbose.snap rename to crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__properties_thread_prng_bind_patterns_and_draw_without_running_body_1_Verbose.snap index 8799c95a..7cdfc01e 100644 --- a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__properties_thread_prng_bind_patterns_and_draw_without_running_body_1_V3_Verbose.snap +++ b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__properties_thread_prng_bind_patterns_and_draw_without_running_body_1_Verbose.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/tests/integration.rs -assertion_line: 196 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal\nimport Prop exposing (constant)\ntests\n prop \"patterns\" =\n let\n x via trace \"first\" (constant 7)\n (y, z) via trace \"second\" (constant (8, True))\n in\n do\n trace \"body\" ()\n assert (if z then Builtin.equalsInteger y (Builtin.addInteger x 1) else False)\n" --- --- patterns @@ -376,15 +375,14 @@ case@Tag match#166 of anf#271 anf#273 False -> let anf#274 : bytes = applyForward#216 projection#202 decimal#221 in applyForward#216 anf#274 decodeUtf8 in - let anf#276 : list string = mkCons "?" (con (list string) []) in - mkCons anf#275 anf#276) in + mkCons anf#275 (con (list string) ["?"])) in constr 0 anf#234 1 -> constr 1 --- optimized UPLC (program 1.1.0 - [(lam builtin_72 - [(lam builtin_77 - [(lam partial_82 + [(lam builtin_71 + [(lam builtin_76 + [(lam partial_81 [(lam constant_6 [(lam assertAt_10 [(lam anf_11 @@ -398,7 +396,7 @@ case@Tag match#166 of field_26 (lam field_27 (lam field_28 - [(lam anf_71 (constr 0 anf_71)) + [(lam anf_70 (constr 0 anf_70)) (constr 0 field_28 (lam arg_29 @@ -409,7 +407,7 @@ case@Tag match#166 of (lam field_32 (lam field_33 (case - (force [[builtin_72 (con string "body")] (delay (con unit ()))]) + (force [[builtin_71 (con string "body")] (delay (con unit ()))]) [(lam anf_36 (case anf_36 @@ -425,8 +423,8 @@ case@Tag match#166 of (con bool False) [(lam anf_35 [[(builtin equalsInteger) field_32] anf_35]) [[(builtin addInteger) projection_30] (con integer 1)]])]))))) - (case field_27 (lam generated_73 (lam generated_74 generated_74)))]) - (case field_27 (lam generated_75 (lam generated_76 generated_75)))]) + (case field_27 (lam generated_72 (lam generated_73 generated_73)))]) + (case field_27 (lam generated_74 (lam generated_75 generated_74)))]) (lam arg_41 [(lam projection_42 [(lam projection_43 @@ -437,9 +435,7 @@ case@Tag match#166 of [(lam applyForward_48 [(lam decimal_59 [(lam anf_60 - [(lam anf_69 - [(lam anf_70 [[builtin_77 anf_69] anf_70]) - [[builtin_77 (con string "?")] (con (list string) [])]]) + [(lam anf_69 [[builtin_76 anf_69] (con (list string) ["?"])]) (case anf_60 [(lam anf_68 [[applyForward_48 anf_68] (builtin decodeUtf8)]) @@ -470,16 +466,16 @@ case@Tag match#166 of [(lam anf_57 [(lam anf_58 [[(builtin appendByteString) anf_55] anf_58]) [[(builtin consByteString) anf_57] (con bytestring #)]]) - [partial_82 anf_56]]) + [partial_81 anf_56]]) [[(builtin remainderInteger) n_51] (con integer 10)]]) [[self_50 self_50] anf_54]]) [[(builtin quotientInteger) n_51] (con integer 10)]] [(lam anf_53 [[(builtin consByteString) anf_53] (con bytestring #)]) - [partial_82 n_51]])) + [partial_81 n_51]])) [[(builtin lessThanInteger) n_51] (con integer 10)]]))]]) (lam x_46 (lam f_47 [f_47 x_46]))])))) - (case field_27 (lam generated_78 (lam generated_79 generated_79)))]) - (case field_27 (lam generated_80 (lam generated_81 generated_80)))]))])))) + (case field_27 (lam generated_77 (lam generated_78 generated_78)))]) + (case field_27 (lam generated_79 (lam generated_80 generated_79)))]))])))) (constr 1))) (case match_13 @@ -502,14 +498,14 @@ case@Tag match#166 of (constr 1))) [beta_18 field_16]]) (force - [[builtin_72 (con string "second")] + [[builtin_71 (con string "second")] (delay [(lam anf_17 [constant_6 anf_17]) (constr 0 (con integer 8) (con bool True))])])])))) (constr 1))]) [anf_11 state_12]])) - (force [[builtin_72 (con string "first")] (delay [constant_6 (con integer 7)])])]) + (force [[builtin_71 (con string "first")] (delay [constant_6 (con integer 7)])])]) (lam marker_7 - (lam rest_8 [(lam anf_9 [anf_9 (con unit ())]) [[builtin_72 marker_7] rest_8]]))]) + (lam rest_8 [(lam anf_9 [anf_9 (con unit ())]) [[builtin_71 marker_7] rest_8]]))]) (lam value_3 (lam prng_4 [(lam anf_5 (constr 0 anf_5)) (constr 0 value_3 prng_4)]))]) [(builtin addInteger) (con integer 48)]]) diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_does_not_initialize_later_generators_V3_Verbose.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_does_not_initialize_later_generators_Verbose.snap similarity index 97% rename from crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_does_not_initialize_later_generators_V3_Verbose.snap rename to crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_does_not_initialize_later_generators_Verbose.snap index fa6fac21..7ac29489 100644 --- a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_does_not_initialize_later_generators_V3_Verbose.snap +++ b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_does_not_initialize_later_generators_Verbose.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/tests/integration.rs -assertion_line: 196 description: "module Main exposing (..)\nimport Builtin\nimport Prop exposing (reject)\ntests\n prop \"reject before later generator\" =\n let\n x via trace \"first\" reject\n y via fail\n in\n do\n assert (Builtin.equalsInteger x y)\n" --- --- reject before later generator @@ -604,16 +603,14 @@ case@Tag match#182 of [(lam anf_92 [[applyForward_71 anf_92] (builtin decodeUtf8)]) [[applyForward_71 projection_39] decimal_83]] [(lam anf_85 - [(lam anf_86 - [(lam anf_87 - [(lam anf_88 - [(lam anf_89 - [(lam anf_90 [(lam anf_91 [anf_90 anf_91]) [(builtin appendString) message_9]]) - [applyForward_71 anf_89]]) - [[applyForward_71 anf_88] (builtin decodeUtf8)]]) - [[applyForward_71 anf_87] decimal_83]]) - [anf_85 anf_86]]) - partial_160]) + [(lam anf_87 + [(lam anf_88 + [(lam anf_89 + [(lam anf_90 [(lam anf_91 [anf_90 anf_91]) [(builtin appendString) message_9]]) + [applyForward_71 anf_89]]) + [[applyForward_71 anf_88] (builtin decodeUtf8)]]) + [[applyForward_71 anf_87] decimal_83]]) + [anf_85 partial_160]]) [applyForward_71 projection_39]])]) [[(builtin lessThanInteger) projection_39] (con integer 0)]]) [(lam self_73 [self_73 self_73]) @@ -642,16 +639,14 @@ case@Tag match#182 of [(lam anf_66 [[applyForward_45 anf_66] (builtin decodeUtf8)]) [[applyForward_45 projection_38] decimal_57]] [(lam anf_59 - [(lam anf_60 - [(lam anf_61 - [(lam anf_62 - [(lam anf_63 - [(lam anf_64 [(lam anf_65 [anf_64 anf_65]) [(builtin appendString) message_9]]) - [applyForward_45 anf_63]]) - [[applyForward_45 anf_62] (builtin decodeUtf8)]]) - [[applyForward_45 anf_61] decimal_57]]) - [anf_59 anf_60]]) - partial_160]) + [(lam anf_61 + [(lam anf_62 + [(lam anf_63 + [(lam anf_64 [(lam anf_65 [anf_64 anf_65]) [(builtin appendString) message_9]]) + [applyForward_45 anf_63]]) + [[applyForward_45 anf_62] (builtin decodeUtf8)]]) + [[applyForward_45 anf_61] decimal_57]]) + [anf_59 partial_160]]) [applyForward_45 projection_38]])]) [[(builtin lessThanInteger) projection_38] (con integer 0)]]) [(lam self_47 [self_47 self_47]) @@ -698,17 +693,15 @@ case@Tag match#182 of [(lam anf_146 [[applyForward_124 anf_146] (builtin decodeUtf8)]) [[applyForward_124 projection_97] decimal_135]] [(lam anf_137 - [(lam anf_138 - [(lam anf_139 - [(lam anf_140 - [(lam anf_142 - [(lam anf_143 - [(lam anf_145 [anf_143 anf_145]) [(builtin appendString) message_9]]) - [applyForward_124 anf_142]]) - [[applyForward_124 anf_140] (builtin decodeUtf8)]]) - [[applyForward_124 anf_139] decimal_135]]) - [anf_137 anf_138]]) - partial_160]) + [(lam anf_139 + [(lam anf_140 + [(lam anf_142 + [(lam anf_143 + [(lam anf_145 [anf_143 anf_145]) [(builtin appendString) message_9]]) + [applyForward_124 anf_142]]) + [[applyForward_124 anf_140] (builtin decodeUtf8)]]) + [[applyForward_124 anf_139] decimal_135]]) + [anf_137 partial_160]]) [applyForward_124 projection_97]])]) [[(builtin lessThanInteger) projection_97] (con integer 0)]]) [(lam self_125 [self_125 self_125]) @@ -736,17 +729,15 @@ case@Tag match#182 of [(lam anf_120 [[applyForward_100 anf_120] (builtin decodeUtf8)]) [[applyForward_100 projection_96] decimal_111]] [(lam anf_113 - [(lam anf_114 - [(lam anf_115 - [(lam anf_116 - [(lam anf_117 - [(lam anf_118 - [(lam anf_119 [anf_118 anf_119]) [(builtin appendString) message_9]]) - [applyForward_100 anf_117]]) - [[applyForward_100 anf_116] (builtin decodeUtf8)]]) - [[applyForward_100 anf_115] decimal_111]]) - [anf_113 anf_114]]) - partial_160]) + [(lam anf_115 + [(lam anf_116 + [(lam anf_117 + [(lam anf_118 + [(lam anf_119 [anf_118 anf_119]) [(builtin appendString) message_9]]) + [applyForward_100 anf_117]]) + [[applyForward_100 anf_116] (builtin decodeUtf8)]]) + [[applyForward_100 anf_115] decimal_111]]) + [anf_113 partial_160]]) [applyForward_100 projection_96]])]) [[(builtin lessThanInteger) projection_96] (con integer 0)]]) [(lam self_101 [self_101 self_101]) diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_1_V2_Silent.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_1_V2_Silent.snap deleted file mode 100644 index e85e6a6d..00000000 --- a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_1_V2_Silent.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/nash-codegen/src/tests/integration.rs -assertion_line: 196 -description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Prop exposing (reject)\ntests\n test \"plain\" = do\n assert True\n prop \"invalid\" =\n let x via reject in\n do\n assert (Builtin.equalsInteger x x)\n" ---- ---- plain ---- unoptimized Core -let message#9 : string = "\0assert\00" in -let fromBool#1 : bool -> bool = \value#4 : bool -> value#4 in -let fromUnit#7 : unit -> unit = \value#8 : unit -> value#8 in -let assertAt#3 : string -> (unit -> unit) -> unit = \marker#5 : string (rest#6 : unit -> unit) -> trace marker#5 rest#6 (fromUnit#7 ()) in -case@Bool fromBool#1 true of - True -> () - False -> assertAt#3 message#9 (\unit#2 : unit -> error) ---- unoptimized UPLC -(program 1.1.0 - [(lam message_9 - [(lam fromBool_1 - [(lam fromUnit_7 - [(lam assertAt_3 - (case - [fromBool_1 (con bool True)] - [[assertAt_3 message_9] (lam unit_2 (error))] - (con unit ()))) - (lam marker_5 - (lam rest_6 - [[[(force (builtin trace)) marker_5] rest_6] [fromUnit_7 (con unit ())]]))]) - (lam value_8 value_8)]) - (lam value_4 value_4)]) - (con string "\0assert\0\48")]) ---- optimized Core -() ---- optimized UPLC -(program 1.1.0 (con unit ())) ---- encoded target UPLC -(program 1.1.0 - [(lam i0 - [(lam i1 - [(lam i2 - [(lam i3 (case [i1 (con bool True)] [[i3 i0] (lam i4 (error))] (con unit ()))) - (lam i3 (lam i4 [[[(force (builtin trace)) i3] i4] [i2 (con unit ())]]))]) - (lam i2 i2)]) - (lam i1 i1)]) - (con string "\0assert\0\48")]) diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_2_V2_Silent.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_2_V2_Silent.snap deleted file mode 100644 index 97b10313..00000000 --- a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_2_V2_Silent.snap +++ /dev/null @@ -1,495 +0,0 @@ ---- -source: crates/nash-codegen/src/tests/integration.rs -description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Prop exposing (reject)\ntests\n test \"plain\" = do\n assert True\n prop \"invalid\" =\n let x via reject in\n do\n assert (Builtin.equalsInteger x x)\n" ---- ---- plain ---- unoptimized Core -let message#9 : string = "\0assert\00" in -let fromBool#1 : bool -> bool = \value#4 : bool -> value#4 in -let fromUnit#7 : unit -> unit = \value#8 : unit -> value#8 in -let assertAt#3 : string -> (unit -> unit) -> unit = \marker#5 : string (rest#6 : unit -> unit) -> trace marker#5 rest#6 (fromUnit#7 ()) in -case@Bool fromBool#1 true of - True -> () - False -> assertAt#3 message#9 (\unit#2 : unit -> error) ---- unoptimized UPLC -(program 1.1.0 - [(lam message_9 - [(lam fromBool_1 - [(lam fromUnit_7 - [(lam assertAt_3 - (case - [fromBool_1 (con bool True)] - [[assertAt_3 message_9] (lam unit_2 (error))] - (con unit ()))) - (lam marker_5 - (lam rest_6 - [[[(force (builtin trace)) marker_5] rest_6] [fromUnit_7 (con unit ())]]))]) - (lam value_8 value_8)]) - (lam value_4 value_4)]) - (con string "\0assert\0\48")]) ---- optimized Core -() ---- optimized UPLC -(program 1.1.0 (con unit ())) ---- encoded target UPLC -(program 1.1.0 - [(lam i0 - [(lam i1 - [(lam i2 - [(lam i3 (case [i1 (con bool True)] [[i3 i0] (lam i4 (error))] (con unit ()))) - (lam i3 (lam i4 [[[(force (builtin trace)) i3] i4] [i2 (con unit ())]]))]) - (lam i2 i2)]) - (lam i1 i1)]) - (con string "\0assert\0\48")]) ---- invalid ---- unoptimized Core -let message#86 : string = "\0assert\00" in -let message#87 : string = "-" in -let message#88 : string = "\0assert\00\01\0" in -let message#89 : string = "\0assert\00\02\0" in -let reject#1 : nash/base:Prop.prng -> nash/base:Option.option ('erased, nash/base:Prop.prng) = \arg#62 : nash/base:Prop.prng -> let match#63 : nash/base:Prop.prng = arg#62 in -constr 1 in -let fromUnit#69 : unit -> unit = \value#85 : unit -> value#85 in -let assertAt#41 : string -> (unit -> unit) -> unit = \marker#67 : string (rest#68 : unit -> unit) -> trace marker#67 rest#68 (fromUnit#69 ()) in -let assertCapture#38 : string -> string -> (unit -> unit) -> unit = \prefix#64 : string value#65 : string (rest#66 : unit -> unit) -> assertAt#41 (appendString prefix#64 value#65) rest#66 in -let prepare#61 : (nash/base:Prop.prng -> nash/base:Option.option ('erased, nash/base:Prop.prng)) -> ('erased -> unit) -> ('erased -> list string) -> nash/base:Prop.prng -> nash/base:Option.option (nash/base:Prop.prng, unit -> unit, unit -> list string) = \(generator#70 : nash/base:Prop.prng -> nash/base:Option.option ('erased, nash/base:Prop.prng)) (property#71 : 'erased -> unit) (display#72 : 'erased -> list string) state#73 : nash/base:Prop.prng -> let match#81 : nash/base:Option.option ('erased, nash/base:Prop.prng) = generator#70 state#73 in -case@Tag match#81 of - 0 field#82 -> case@Tag field#82 of - 0 field#83 field#84 -> let value#74 : 'erased = field#83 in - let next#75 : nash/base:Prop.prng = field#84 in - (\field#76 : (nash/base:Prop.prng, unit -> unit, unit -> list string) -> constr 0 field#76) (constr 0 next#75 (\arg#77 : unit -> let match#78 : unit = arg#77 in - property#71 value#74) (\arg#79 : unit -> let match#80 : unit = arg#79 in - display#72 value#74)) - 1 -> constr 1 in -prepare#61 reject#1 (\values#2 : int -> let generated#3 : int = values#2 in -let match#42 : int = generated#3 in -let x#4 : int = match#42 in -let assert_value#5 : int -> int -> bool = equalsInteger in -let assert_value#6 : int = x#4 in -let apply#21 : int -> bool = assert_value#5 assert_value#6 in -let assert_value#22 : int = x#4 in -case@Bool apply#21 assert_value#22 of - True -> () - False -> assertAt#41 message#86 (\unit#40 : unit -> let message#20 : string = message#87 in - let applyForward#9 : 'erased -> ('erased -> 'erased) -> 'erased = \x#13 : 'erased (f#14 : 'erased -> 'erased) -> f#14 x#13 in - let fromInt#11 : int -> int = \x#17 : int -> x#17 in - let fromBytes#16 : bytes -> bytes = \x#19 : bytes -> x#19 in - assertCapture#38 message#88 ((letrec - decimal#10 : int -> bytes [static []] = \n#15 : int -> case@Bool lessThanInteger n#15 (fromInt#11 10) of - True -> consByteString (addInteger (fromInt#11 48) n#15) (fromBytes#16 (con bytestring #)) - False -> appendByteString (decimal#10 (quotientInteger n#15 (fromInt#11 10))) (consByteString (addInteger (fromInt#11 48) (remainderInteger n#15 (fromInt#11 10))) (fromBytes#16 (con bytestring #))) - in - let fromString#12 : string -> string = \x#18 : string -> x#18 in - let show#7 : int -> string = \n#8 : int -> case@Bool lessThanInteger n#8 (fromInt#11 0) of - True -> applyForward#9 (applyForward#9 (applyForward#9 (applyForward#9 n#8 (subtractInteger (fromInt#11 0))) decimal#10) decodeUtf8) (appendString (fromString#12 message#20)) - False -> applyForward#9 (applyForward#9 n#8 decimal#10) decodeUtf8 in - show#7) assert_value#6) (\unit#39 : unit -> let message#36 : string = message#87 in - let applyForward#25 : 'erased -> ('erased -> 'erased) -> 'erased = \x#29 : 'erased (f#30 : 'erased -> 'erased) -> f#30 x#29 in - let fromInt#27 : int -> int = \x#33 : int -> x#33 in - let fromBytes#32 : bytes -> bytes = \x#35 : bytes -> x#35 in - assertCapture#38 message#89 ((letrec - decimal#26 : int -> bytes [static []] = \n#31 : int -> case@Bool lessThanInteger n#31 (fromInt#27 10) of - True -> consByteString (addInteger (fromInt#27 48) n#31) (fromBytes#32 (con bytestring #)) - False -> appendByteString (decimal#26 (quotientInteger n#31 (fromInt#27 10))) (consByteString (addInteger (fromInt#27 48) (remainderInteger n#31 (fromInt#27 10))) (fromBytes#32 (con bytestring #))) - in - let fromString#28 : string -> string = \x#34 : string -> x#34 in - let show#23 : int -> string = \n#24 : int -> case@Bool lessThanInteger n#24 (fromInt#27 0) of - True -> applyForward#25 (applyForward#25 (applyForward#25 (applyForward#25 n#24 (subtractInteger (fromInt#27 0))) decimal#26) decodeUtf8) (appendString (fromString#28 message#36)) - False -> applyForward#25 (applyForward#25 n#24 decimal#26) decodeUtf8 in - show#23) assert_value#22) (\unit#37 : unit -> error)))) (\values#43 : int -> let generated#44 : int = values#43 in -let match#60 : int = generated#44 in -let x#45 : int = match#60 in -let message#59 : string = message#87 in -let applyForward#48 : 'erased -> ('erased -> 'erased) -> 'erased = \x#52 : 'erased (f#53 : 'erased -> 'erased) -> f#53 x#52 in -let fromInt#50 : int -> int = \x#56 : int -> x#56 in -let fromBytes#55 : bytes -> bytes = \x#58 : bytes -> x#58 in -mkCons ((letrec - decimal#49 : int -> bytes [static []] = \n#54 : int -> case@Bool lessThanInteger n#54 (fromInt#50 10) of - True -> consByteString (addInteger (fromInt#50 48) n#54) (fromBytes#55 (con bytestring #)) - False -> appendByteString (decimal#49 (quotientInteger n#54 (fromInt#50 10))) (consByteString (addInteger (fromInt#50 48) (remainderInteger n#54 (fromInt#50 10))) (fromBytes#55 (con bytestring #))) -in -let fromString#51 : string -> string = \x#57 : string -> x#57 in -let show#46 : int -> string = \n#47 : int -> case@Bool lessThanInteger n#47 (fromInt#50 0) of - True -> applyForward#48 (applyForward#48 (applyForward#48 (applyForward#48 n#47 (subtractInteger (fromInt#50 0))) decimal#49) decodeUtf8) (appendString (fromString#51 message#59)) - False -> applyForward#48 (applyForward#48 n#47 decimal#49) decodeUtf8 in -show#46) generated#44) (con (list string) [])) ---- unoptimized UPLC -(program 1.1.0 - [(lam message_86 - [(lam message_87 - [(lam message_88 - [(lam message_89 - [(lam reject_1 - [(lam fromUnit_69 - [(lam assertAt_41 - [(lam assertCapture_38 - [(lam prepare_61 - [[[prepare_61 reject_1] - (lam values_2 - [(lam generated_3 - [(lam match_42 - [(lam x_4 - [(lam assert_value_5 - [(lam assert_value_6 - [(lam apply_21 - [(lam assert_value_22 - (case - [apply_21 assert_value_22] - [[assertAt_41 message_86] - (lam unit_40 - [(lam message_20 - [(lam applyForward_9 - [(lam fromInt_11 - [(lam fromBytes_16 - [[[assertCapture_38 message_88] - [[(lam decimal_10 - [(lam fromString_12 - [(lam show_7 show_7) - (lam n_8 - (case - [[(builtin lessThanInteger) n_8] [fromInt_11 (con integer 0)]] - [[applyForward_9 [[applyForward_9 n_8] decimal_10]] (builtin decodeUtf8)] - [[applyForward_9 - [[applyForward_9 - [[applyForward_9 - [[applyForward_9 n_8] [(builtin subtractInteger) [fromInt_11 (con integer 0)]]]] - decimal_10]] - (builtin decodeUtf8)]] - [(builtin appendString) [fromString_12 message_20]]]))]) - (lam x_18 x_18)]) - [(lam self_90 [self_90 self_90]) - (lam self_90 - (lam n_15 - (case - [[(builtin lessThanInteger) n_15] [fromInt_11 (con integer 10)]] - [[(builtin appendByteString) - [[self_90 self_90] - [[(builtin quotientInteger) n_15] [fromInt_11 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_11 (con integer 48)]] - [[(builtin remainderInteger) n_15] [fromInt_11 (con integer 10)]]]] - [fromBytes_16 (con bytestring #)]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_11 (con integer 48)]] n_15]] - [fromBytes_16 (con bytestring #)]])))]] - assert_value_6]] - (lam unit_39 - [(lam message_36 - [(lam applyForward_25 - [(lam fromInt_27 - [(lam fromBytes_32 - [[[assertCapture_38 message_89] - [[(lam decimal_26 - [(lam fromString_28 - [(lam show_23 show_23) - (lam n_24 - (case - [[(builtin lessThanInteger) n_24] [fromInt_27 (con integer 0)]] - [[applyForward_25 [[applyForward_25 n_24] decimal_26]] (builtin decodeUtf8)] - [[applyForward_25 - [[applyForward_25 - [[applyForward_25 - [[applyForward_25 n_24] - [(builtin subtractInteger) [fromInt_27 (con integer 0)]]]] - decimal_26]] - (builtin decodeUtf8)]] - [(builtin appendString) [fromString_28 message_36]]]))]) - (lam x_34 x_34)]) - [(lam self_92 [self_92 self_92]) - (lam self_92 - (lam n_31 - (case - [[(builtin lessThanInteger) n_31] [fromInt_27 (con integer 10)]] - [[(builtin appendByteString) - [[self_92 self_92] - [[(builtin quotientInteger) n_31] [fromInt_27 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_27 (con integer 48)]] - [[(builtin remainderInteger) n_31] [fromInt_27 (con integer 10)]]]] - [fromBytes_32 (con bytestring #)]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_27 (con integer 48)]] n_31]] - [fromBytes_32 (con bytestring #)]])))]] - assert_value_22]] - (lam unit_37 (error))]) - (lam x_35 x_35)]) - (lam x_33 x_33)]) - (lam x_29 (lam f_30 [f_30 x_29]))]) - message_87])]) - (lam x_19 x_19)]) - (lam x_17 x_17)]) - (lam x_13 (lam f_14 [f_14 x_13]))]) - message_87])] - (con unit ()))) - x_4]) - [assert_value_5 assert_value_6]]) - x_4]) - (builtin equalsInteger)]) - match_42]) - generated_3]) - values_2])] - (lam values_43 - [(lam generated_44 - [(lam match_60 - [(lam x_45 - [(lam message_59 - [(lam applyForward_48 - [(lam fromInt_50 - [(lam fromBytes_55 - [[(force (builtin mkCons)) - [[(lam decimal_49 - [(lam fromString_51 - [(lam show_46 show_46) - (lam n_47 - (case - [[(builtin lessThanInteger) n_47] [fromInt_50 (con integer 0)]] - [[applyForward_48 [[applyForward_48 n_47] decimal_49]] (builtin decodeUtf8)] - [[applyForward_48 - [[applyForward_48 - [[applyForward_48 - [[applyForward_48 n_47] - [(builtin subtractInteger) [fromInt_50 (con integer 0)]]]] - decimal_49]] - (builtin decodeUtf8)]] - [(builtin appendString) [fromString_51 message_59]]]))]) - (lam x_57 x_57)]) - [(lam self_94 [self_94 self_94]) - (lam self_94 - (lam n_54 - (case - [[(builtin lessThanInteger) n_54] [fromInt_50 (con integer 10)]] - [[(builtin appendByteString) - [[self_94 self_94] - [[(builtin quotientInteger) n_54] [fromInt_50 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_50 (con integer 48)]] - [[(builtin remainderInteger) n_54] [fromInt_50 (con integer 10)]]]] - [fromBytes_55 (con bytestring #)]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_50 (con integer 48)]] n_54]] - [fromBytes_55 (con bytestring #)]])))]] - generated_44]] - (con (list string) [])]) - (lam x_58 x_58)]) - (lam x_56 x_56)]) - (lam x_52 (lam f_53 [f_53 x_52]))]) - message_87]) - match_60]) - generated_44]) - values_43])]) - (lam generator_70 - (lam property_71 - (lam display_72 - (lam state_73 - [(lam match_81 - (case - match_81 - (lam field_82 - (case - field_82 - (lam field_83 - (lam field_84 - [(lam value_74 - [(lam next_75 - [(lam field_76 (constr 0 field_76)) - (constr 0 - next_75 - (lam arg_77 (case arg_77 [property_71 value_74])) - (lam arg_79 (case arg_79 [display_72 value_74])))]) - field_84]) - field_83])))) - (constr 1))) - [generator_70 state_73]]))))]) - (lam prefix_64 - (lam value_65 - (lam rest_66 - [[assertAt_41 [[(builtin appendString) prefix_64] value_65]] rest_66])))]) - (lam marker_67 - (lam rest_68 - [[[(force (builtin trace)) marker_67] rest_68] [fromUnit_69 (con unit ())]]))]) - (lam value_85 value_85)]) - (lam arg_62 [(lam match_63 (constr 1)) arg_62])]) - (con string "\0assert\0\48\0\50\0")]) - (con string "\0assert\0\48\0\49\0")]) - (con string "-")]) - (con string "\0assert\0\48")]) ---- optimized Core -\state#109 : nash/base:Prop.prng -> constr 1 ---- optimized UPLC -(program 1.1.0 (lam state_1 (constr 1))) ---- encoded target UPLC ---- prepare -(program 1.1.0 - [(lam i0 - [(lam i1 - [(lam i2 - [(lam i3 - [(lam i4 - [(lam i5 - [(lam i6 - [(lam i7 - [(lam i8 - [[[i8 i4] - (lam i9 - [(lam i10 - [(lam i11 - [(lam i12 - [(lam i13 - [(lam i14 - [(lam i15 - [(lam i16 - (case - [i15 i16] - [[i6 i0] - (lam i17 - [(lam i18 - [(lam i19 - [(lam i20 - [(lam i21 - [[[i7 i2] - [[(lam i22 - [(lam i23 - [(lam i24 i24) - (lam i24 - (case - [[(builtin lessThanInteger) i24] [i20 (con integer 0)]] - [[i19 [[i19 i24] i22]] (builtin decodeUtf8)] - [[i19 - [[i19 [[i19 [[i19 i24] [(builtin subtractInteger) [i20 (con integer 0)]]]] i22]] - (builtin decodeUtf8)]] - [(builtin appendString) [i23 i18]]]))]) - (lam i23 i23)]) - [(lam i22 [i22 i22]) - (lam i22 - (lam i23 - (case - [[(builtin lessThanInteger) i23] [i20 (con integer 10)]] - [[(builtin appendByteString) - [[i22 i22] [[(builtin quotientInteger) i23] [i20 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [i20 (con integer 48)]] - [[(builtin remainderInteger) i23] [i20 (con integer 10)]]]] - [i21 (con bytestring #)]]] - [[(builtin consByteString) [[(builtin addInteger) [i20 (con integer 48)]] i23]] - [i21 (con bytestring #)]])))]] - i14]] - (lam i22 - [(lam i23 - [(lam i24 - [(lam i25 - [(lam i26 - [[[i7 i3] - [[(lam i27 - [(lam i28 - [(lam i29 i29) - (lam i29 - (case - [[(builtin lessThanInteger) i29] [i25 (con integer 0)]] - [[i24 [[i24 i29] i27]] (builtin decodeUtf8)] - [[i24 - [[i24 [[i24 [[i24 i29] [(builtin subtractInteger) [i25 (con integer 0)]]]] i27]] - (builtin decodeUtf8)]] - [(builtin appendString) [i28 i23]]]))]) - (lam i28 i28)]) - [(lam i27 [i27 i27]) - (lam i27 - (lam i28 - (case - [[(builtin lessThanInteger) i28] [i25 (con integer 10)]] - [[(builtin appendByteString) - [[i27 i27] [[(builtin quotientInteger) i28] [i25 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [i25 (con integer 48)]] - [[(builtin remainderInteger) i28] [i25 (con integer 10)]]]] - [i26 (con bytestring #)]]] - [[(builtin consByteString) [[(builtin addInteger) [i25 (con integer 48)]] i28]] - [i26 (con bytestring #)]])))]] - i16]] - (lam i27 (error))]) - (lam i26 i26)]) - (lam i25 i25)]) - (lam i24 (lam i25 [i25 i24]))]) - i1])]) - (lam i21 i21)]) - (lam i20 i20)]) - (lam i19 (lam i20 [i20 i19]))]) - i1])] - (con unit ()))) - i12]) - [i13 i14]]) - i12]) - (builtin equalsInteger)]) - i11]) - i10]) - i9])] - (lam i9 - [(lam i10 - [(lam i11 - [(lam i12 - [(lam i13 - [(lam i14 - [(lam i15 - [(lam i16 - [[(force (builtin mkCons)) - [[(lam i17 - [(lam i18 - [(lam i19 i19) - (lam i19 - (case - [[(builtin lessThanInteger) i19] [i15 (con integer 0)]] - [[i14 [[i14 i19] i17]] (builtin decodeUtf8)] - [[i14 - [[i14 [[i14 [[i14 i19] [(builtin subtractInteger) [i15 (con integer 0)]]]] i17]] - (builtin decodeUtf8)]] - [(builtin appendString) [i18 i13]]]))]) - (lam i18 i18)]) - [(lam i17 [i17 i17]) - (lam i17 - (lam i18 - (case - [[(builtin lessThanInteger) i18] [i15 (con integer 10)]] - [[(builtin appendByteString) - [[i17 i17] [[(builtin quotientInteger) i18] [i15 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [i15 (con integer 48)]] - [[(builtin remainderInteger) i18] [i15 (con integer 10)]]]] - [i16 (con bytestring #)]]] - [[(builtin consByteString) [[(builtin addInteger) [i15 (con integer 48)]] i18]] - [i16 (con bytestring #)]])))]] - i10]] - (con (list string) [])]) - (lam i16 i16)]) - (lam i15 i15)]) - (lam i14 (lam i15 [i15 i14]))]) - i1]) - i11]) - i10]) - i9])]) - (lam i8 - (lam i9 - (lam i10 - (lam i11 - [(lam i12 - (case - i12 - (lam i13 - (case - i13 - (lam i14 - (lam i15 - [(lam i16 - [(lam i17 - [(lam i18 (constr 0 i18)) - (constr 0 i17 (lam i18 (case i18 [i9 i16])) (lam i18 (case i18 [i10 i16])))]) - i15]) - i14])))) - (constr 1))) - [i8 i11]]))))]) - (lam i7 (lam i8 (lam i9 [[i6 [[(builtin appendString) i7] i8]] i9])))]) - (lam i6 (lam i7 [[[(force (builtin trace)) i6] i7] [i5 (con unit ())]]))]) - (lam i5 i5)]) - (lam i4 [(lam i5 (constr 1)) i4])]) - (con string "\0assert\0\48\0\50\0")]) - (con string "\0assert\0\48\0\49\0")]) - (con string "-")]) - (con string "\0assert\0\48")]) diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_3_V3_Silent.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_3_V3_Silent.snap deleted file mode 100644 index 97b10313..00000000 --- a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_3_V3_Silent.snap +++ /dev/null @@ -1,495 +0,0 @@ ---- -source: crates/nash-codegen/src/tests/integration.rs -description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Prop exposing (reject)\ntests\n test \"plain\" = do\n assert True\n prop \"invalid\" =\n let x via reject in\n do\n assert (Builtin.equalsInteger x x)\n" ---- ---- plain ---- unoptimized Core -let message#9 : string = "\0assert\00" in -let fromBool#1 : bool -> bool = \value#4 : bool -> value#4 in -let fromUnit#7 : unit -> unit = \value#8 : unit -> value#8 in -let assertAt#3 : string -> (unit -> unit) -> unit = \marker#5 : string (rest#6 : unit -> unit) -> trace marker#5 rest#6 (fromUnit#7 ()) in -case@Bool fromBool#1 true of - True -> () - False -> assertAt#3 message#9 (\unit#2 : unit -> error) ---- unoptimized UPLC -(program 1.1.0 - [(lam message_9 - [(lam fromBool_1 - [(lam fromUnit_7 - [(lam assertAt_3 - (case - [fromBool_1 (con bool True)] - [[assertAt_3 message_9] (lam unit_2 (error))] - (con unit ()))) - (lam marker_5 - (lam rest_6 - [[[(force (builtin trace)) marker_5] rest_6] [fromUnit_7 (con unit ())]]))]) - (lam value_8 value_8)]) - (lam value_4 value_4)]) - (con string "\0assert\0\48")]) ---- optimized Core -() ---- optimized UPLC -(program 1.1.0 (con unit ())) ---- encoded target UPLC -(program 1.1.0 - [(lam i0 - [(lam i1 - [(lam i2 - [(lam i3 (case [i1 (con bool True)] [[i3 i0] (lam i4 (error))] (con unit ()))) - (lam i3 (lam i4 [[[(force (builtin trace)) i3] i4] [i2 (con unit ())]]))]) - (lam i2 i2)]) - (lam i1 i1)]) - (con string "\0assert\0\48")]) ---- invalid ---- unoptimized Core -let message#86 : string = "\0assert\00" in -let message#87 : string = "-" in -let message#88 : string = "\0assert\00\01\0" in -let message#89 : string = "\0assert\00\02\0" in -let reject#1 : nash/base:Prop.prng -> nash/base:Option.option ('erased, nash/base:Prop.prng) = \arg#62 : nash/base:Prop.prng -> let match#63 : nash/base:Prop.prng = arg#62 in -constr 1 in -let fromUnit#69 : unit -> unit = \value#85 : unit -> value#85 in -let assertAt#41 : string -> (unit -> unit) -> unit = \marker#67 : string (rest#68 : unit -> unit) -> trace marker#67 rest#68 (fromUnit#69 ()) in -let assertCapture#38 : string -> string -> (unit -> unit) -> unit = \prefix#64 : string value#65 : string (rest#66 : unit -> unit) -> assertAt#41 (appendString prefix#64 value#65) rest#66 in -let prepare#61 : (nash/base:Prop.prng -> nash/base:Option.option ('erased, nash/base:Prop.prng)) -> ('erased -> unit) -> ('erased -> list string) -> nash/base:Prop.prng -> nash/base:Option.option (nash/base:Prop.prng, unit -> unit, unit -> list string) = \(generator#70 : nash/base:Prop.prng -> nash/base:Option.option ('erased, nash/base:Prop.prng)) (property#71 : 'erased -> unit) (display#72 : 'erased -> list string) state#73 : nash/base:Prop.prng -> let match#81 : nash/base:Option.option ('erased, nash/base:Prop.prng) = generator#70 state#73 in -case@Tag match#81 of - 0 field#82 -> case@Tag field#82 of - 0 field#83 field#84 -> let value#74 : 'erased = field#83 in - let next#75 : nash/base:Prop.prng = field#84 in - (\field#76 : (nash/base:Prop.prng, unit -> unit, unit -> list string) -> constr 0 field#76) (constr 0 next#75 (\arg#77 : unit -> let match#78 : unit = arg#77 in - property#71 value#74) (\arg#79 : unit -> let match#80 : unit = arg#79 in - display#72 value#74)) - 1 -> constr 1 in -prepare#61 reject#1 (\values#2 : int -> let generated#3 : int = values#2 in -let match#42 : int = generated#3 in -let x#4 : int = match#42 in -let assert_value#5 : int -> int -> bool = equalsInteger in -let assert_value#6 : int = x#4 in -let apply#21 : int -> bool = assert_value#5 assert_value#6 in -let assert_value#22 : int = x#4 in -case@Bool apply#21 assert_value#22 of - True -> () - False -> assertAt#41 message#86 (\unit#40 : unit -> let message#20 : string = message#87 in - let applyForward#9 : 'erased -> ('erased -> 'erased) -> 'erased = \x#13 : 'erased (f#14 : 'erased -> 'erased) -> f#14 x#13 in - let fromInt#11 : int -> int = \x#17 : int -> x#17 in - let fromBytes#16 : bytes -> bytes = \x#19 : bytes -> x#19 in - assertCapture#38 message#88 ((letrec - decimal#10 : int -> bytes [static []] = \n#15 : int -> case@Bool lessThanInteger n#15 (fromInt#11 10) of - True -> consByteString (addInteger (fromInt#11 48) n#15) (fromBytes#16 (con bytestring #)) - False -> appendByteString (decimal#10 (quotientInteger n#15 (fromInt#11 10))) (consByteString (addInteger (fromInt#11 48) (remainderInteger n#15 (fromInt#11 10))) (fromBytes#16 (con bytestring #))) - in - let fromString#12 : string -> string = \x#18 : string -> x#18 in - let show#7 : int -> string = \n#8 : int -> case@Bool lessThanInteger n#8 (fromInt#11 0) of - True -> applyForward#9 (applyForward#9 (applyForward#9 (applyForward#9 n#8 (subtractInteger (fromInt#11 0))) decimal#10) decodeUtf8) (appendString (fromString#12 message#20)) - False -> applyForward#9 (applyForward#9 n#8 decimal#10) decodeUtf8 in - show#7) assert_value#6) (\unit#39 : unit -> let message#36 : string = message#87 in - let applyForward#25 : 'erased -> ('erased -> 'erased) -> 'erased = \x#29 : 'erased (f#30 : 'erased -> 'erased) -> f#30 x#29 in - let fromInt#27 : int -> int = \x#33 : int -> x#33 in - let fromBytes#32 : bytes -> bytes = \x#35 : bytes -> x#35 in - assertCapture#38 message#89 ((letrec - decimal#26 : int -> bytes [static []] = \n#31 : int -> case@Bool lessThanInteger n#31 (fromInt#27 10) of - True -> consByteString (addInteger (fromInt#27 48) n#31) (fromBytes#32 (con bytestring #)) - False -> appendByteString (decimal#26 (quotientInteger n#31 (fromInt#27 10))) (consByteString (addInteger (fromInt#27 48) (remainderInteger n#31 (fromInt#27 10))) (fromBytes#32 (con bytestring #))) - in - let fromString#28 : string -> string = \x#34 : string -> x#34 in - let show#23 : int -> string = \n#24 : int -> case@Bool lessThanInteger n#24 (fromInt#27 0) of - True -> applyForward#25 (applyForward#25 (applyForward#25 (applyForward#25 n#24 (subtractInteger (fromInt#27 0))) decimal#26) decodeUtf8) (appendString (fromString#28 message#36)) - False -> applyForward#25 (applyForward#25 n#24 decimal#26) decodeUtf8 in - show#23) assert_value#22) (\unit#37 : unit -> error)))) (\values#43 : int -> let generated#44 : int = values#43 in -let match#60 : int = generated#44 in -let x#45 : int = match#60 in -let message#59 : string = message#87 in -let applyForward#48 : 'erased -> ('erased -> 'erased) -> 'erased = \x#52 : 'erased (f#53 : 'erased -> 'erased) -> f#53 x#52 in -let fromInt#50 : int -> int = \x#56 : int -> x#56 in -let fromBytes#55 : bytes -> bytes = \x#58 : bytes -> x#58 in -mkCons ((letrec - decimal#49 : int -> bytes [static []] = \n#54 : int -> case@Bool lessThanInteger n#54 (fromInt#50 10) of - True -> consByteString (addInteger (fromInt#50 48) n#54) (fromBytes#55 (con bytestring #)) - False -> appendByteString (decimal#49 (quotientInteger n#54 (fromInt#50 10))) (consByteString (addInteger (fromInt#50 48) (remainderInteger n#54 (fromInt#50 10))) (fromBytes#55 (con bytestring #))) -in -let fromString#51 : string -> string = \x#57 : string -> x#57 in -let show#46 : int -> string = \n#47 : int -> case@Bool lessThanInteger n#47 (fromInt#50 0) of - True -> applyForward#48 (applyForward#48 (applyForward#48 (applyForward#48 n#47 (subtractInteger (fromInt#50 0))) decimal#49) decodeUtf8) (appendString (fromString#51 message#59)) - False -> applyForward#48 (applyForward#48 n#47 decimal#49) decodeUtf8 in -show#46) generated#44) (con (list string) [])) ---- unoptimized UPLC -(program 1.1.0 - [(lam message_86 - [(lam message_87 - [(lam message_88 - [(lam message_89 - [(lam reject_1 - [(lam fromUnit_69 - [(lam assertAt_41 - [(lam assertCapture_38 - [(lam prepare_61 - [[[prepare_61 reject_1] - (lam values_2 - [(lam generated_3 - [(lam match_42 - [(lam x_4 - [(lam assert_value_5 - [(lam assert_value_6 - [(lam apply_21 - [(lam assert_value_22 - (case - [apply_21 assert_value_22] - [[assertAt_41 message_86] - (lam unit_40 - [(lam message_20 - [(lam applyForward_9 - [(lam fromInt_11 - [(lam fromBytes_16 - [[[assertCapture_38 message_88] - [[(lam decimal_10 - [(lam fromString_12 - [(lam show_7 show_7) - (lam n_8 - (case - [[(builtin lessThanInteger) n_8] [fromInt_11 (con integer 0)]] - [[applyForward_9 [[applyForward_9 n_8] decimal_10]] (builtin decodeUtf8)] - [[applyForward_9 - [[applyForward_9 - [[applyForward_9 - [[applyForward_9 n_8] [(builtin subtractInteger) [fromInt_11 (con integer 0)]]]] - decimal_10]] - (builtin decodeUtf8)]] - [(builtin appendString) [fromString_12 message_20]]]))]) - (lam x_18 x_18)]) - [(lam self_90 [self_90 self_90]) - (lam self_90 - (lam n_15 - (case - [[(builtin lessThanInteger) n_15] [fromInt_11 (con integer 10)]] - [[(builtin appendByteString) - [[self_90 self_90] - [[(builtin quotientInteger) n_15] [fromInt_11 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_11 (con integer 48)]] - [[(builtin remainderInteger) n_15] [fromInt_11 (con integer 10)]]]] - [fromBytes_16 (con bytestring #)]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_11 (con integer 48)]] n_15]] - [fromBytes_16 (con bytestring #)]])))]] - assert_value_6]] - (lam unit_39 - [(lam message_36 - [(lam applyForward_25 - [(lam fromInt_27 - [(lam fromBytes_32 - [[[assertCapture_38 message_89] - [[(lam decimal_26 - [(lam fromString_28 - [(lam show_23 show_23) - (lam n_24 - (case - [[(builtin lessThanInteger) n_24] [fromInt_27 (con integer 0)]] - [[applyForward_25 [[applyForward_25 n_24] decimal_26]] (builtin decodeUtf8)] - [[applyForward_25 - [[applyForward_25 - [[applyForward_25 - [[applyForward_25 n_24] - [(builtin subtractInteger) [fromInt_27 (con integer 0)]]]] - decimal_26]] - (builtin decodeUtf8)]] - [(builtin appendString) [fromString_28 message_36]]]))]) - (lam x_34 x_34)]) - [(lam self_92 [self_92 self_92]) - (lam self_92 - (lam n_31 - (case - [[(builtin lessThanInteger) n_31] [fromInt_27 (con integer 10)]] - [[(builtin appendByteString) - [[self_92 self_92] - [[(builtin quotientInteger) n_31] [fromInt_27 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_27 (con integer 48)]] - [[(builtin remainderInteger) n_31] [fromInt_27 (con integer 10)]]]] - [fromBytes_32 (con bytestring #)]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_27 (con integer 48)]] n_31]] - [fromBytes_32 (con bytestring #)]])))]] - assert_value_22]] - (lam unit_37 (error))]) - (lam x_35 x_35)]) - (lam x_33 x_33)]) - (lam x_29 (lam f_30 [f_30 x_29]))]) - message_87])]) - (lam x_19 x_19)]) - (lam x_17 x_17)]) - (lam x_13 (lam f_14 [f_14 x_13]))]) - message_87])] - (con unit ()))) - x_4]) - [assert_value_5 assert_value_6]]) - x_4]) - (builtin equalsInteger)]) - match_42]) - generated_3]) - values_2])] - (lam values_43 - [(lam generated_44 - [(lam match_60 - [(lam x_45 - [(lam message_59 - [(lam applyForward_48 - [(lam fromInt_50 - [(lam fromBytes_55 - [[(force (builtin mkCons)) - [[(lam decimal_49 - [(lam fromString_51 - [(lam show_46 show_46) - (lam n_47 - (case - [[(builtin lessThanInteger) n_47] [fromInt_50 (con integer 0)]] - [[applyForward_48 [[applyForward_48 n_47] decimal_49]] (builtin decodeUtf8)] - [[applyForward_48 - [[applyForward_48 - [[applyForward_48 - [[applyForward_48 n_47] - [(builtin subtractInteger) [fromInt_50 (con integer 0)]]]] - decimal_49]] - (builtin decodeUtf8)]] - [(builtin appendString) [fromString_51 message_59]]]))]) - (lam x_57 x_57)]) - [(lam self_94 [self_94 self_94]) - (lam self_94 - (lam n_54 - (case - [[(builtin lessThanInteger) n_54] [fromInt_50 (con integer 10)]] - [[(builtin appendByteString) - [[self_94 self_94] - [[(builtin quotientInteger) n_54] [fromInt_50 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_50 (con integer 48)]] - [[(builtin remainderInteger) n_54] [fromInt_50 (con integer 10)]]]] - [fromBytes_55 (con bytestring #)]]] - [[(builtin consByteString) - [[(builtin addInteger) [fromInt_50 (con integer 48)]] n_54]] - [fromBytes_55 (con bytestring #)]])))]] - generated_44]] - (con (list string) [])]) - (lam x_58 x_58)]) - (lam x_56 x_56)]) - (lam x_52 (lam f_53 [f_53 x_52]))]) - message_87]) - match_60]) - generated_44]) - values_43])]) - (lam generator_70 - (lam property_71 - (lam display_72 - (lam state_73 - [(lam match_81 - (case - match_81 - (lam field_82 - (case - field_82 - (lam field_83 - (lam field_84 - [(lam value_74 - [(lam next_75 - [(lam field_76 (constr 0 field_76)) - (constr 0 - next_75 - (lam arg_77 (case arg_77 [property_71 value_74])) - (lam arg_79 (case arg_79 [display_72 value_74])))]) - field_84]) - field_83])))) - (constr 1))) - [generator_70 state_73]]))))]) - (lam prefix_64 - (lam value_65 - (lam rest_66 - [[assertAt_41 [[(builtin appendString) prefix_64] value_65]] rest_66])))]) - (lam marker_67 - (lam rest_68 - [[[(force (builtin trace)) marker_67] rest_68] [fromUnit_69 (con unit ())]]))]) - (lam value_85 value_85)]) - (lam arg_62 [(lam match_63 (constr 1)) arg_62])]) - (con string "\0assert\0\48\0\50\0")]) - (con string "\0assert\0\48\0\49\0")]) - (con string "-")]) - (con string "\0assert\0\48")]) ---- optimized Core -\state#109 : nash/base:Prop.prng -> constr 1 ---- optimized UPLC -(program 1.1.0 (lam state_1 (constr 1))) ---- encoded target UPLC ---- prepare -(program 1.1.0 - [(lam i0 - [(lam i1 - [(lam i2 - [(lam i3 - [(lam i4 - [(lam i5 - [(lam i6 - [(lam i7 - [(lam i8 - [[[i8 i4] - (lam i9 - [(lam i10 - [(lam i11 - [(lam i12 - [(lam i13 - [(lam i14 - [(lam i15 - [(lam i16 - (case - [i15 i16] - [[i6 i0] - (lam i17 - [(lam i18 - [(lam i19 - [(lam i20 - [(lam i21 - [[[i7 i2] - [[(lam i22 - [(lam i23 - [(lam i24 i24) - (lam i24 - (case - [[(builtin lessThanInteger) i24] [i20 (con integer 0)]] - [[i19 [[i19 i24] i22]] (builtin decodeUtf8)] - [[i19 - [[i19 [[i19 [[i19 i24] [(builtin subtractInteger) [i20 (con integer 0)]]]] i22]] - (builtin decodeUtf8)]] - [(builtin appendString) [i23 i18]]]))]) - (lam i23 i23)]) - [(lam i22 [i22 i22]) - (lam i22 - (lam i23 - (case - [[(builtin lessThanInteger) i23] [i20 (con integer 10)]] - [[(builtin appendByteString) - [[i22 i22] [[(builtin quotientInteger) i23] [i20 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [i20 (con integer 48)]] - [[(builtin remainderInteger) i23] [i20 (con integer 10)]]]] - [i21 (con bytestring #)]]] - [[(builtin consByteString) [[(builtin addInteger) [i20 (con integer 48)]] i23]] - [i21 (con bytestring #)]])))]] - i14]] - (lam i22 - [(lam i23 - [(lam i24 - [(lam i25 - [(lam i26 - [[[i7 i3] - [[(lam i27 - [(lam i28 - [(lam i29 i29) - (lam i29 - (case - [[(builtin lessThanInteger) i29] [i25 (con integer 0)]] - [[i24 [[i24 i29] i27]] (builtin decodeUtf8)] - [[i24 - [[i24 [[i24 [[i24 i29] [(builtin subtractInteger) [i25 (con integer 0)]]]] i27]] - (builtin decodeUtf8)]] - [(builtin appendString) [i28 i23]]]))]) - (lam i28 i28)]) - [(lam i27 [i27 i27]) - (lam i27 - (lam i28 - (case - [[(builtin lessThanInteger) i28] [i25 (con integer 10)]] - [[(builtin appendByteString) - [[i27 i27] [[(builtin quotientInteger) i28] [i25 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [i25 (con integer 48)]] - [[(builtin remainderInteger) i28] [i25 (con integer 10)]]]] - [i26 (con bytestring #)]]] - [[(builtin consByteString) [[(builtin addInteger) [i25 (con integer 48)]] i28]] - [i26 (con bytestring #)]])))]] - i16]] - (lam i27 (error))]) - (lam i26 i26)]) - (lam i25 i25)]) - (lam i24 (lam i25 [i25 i24]))]) - i1])]) - (lam i21 i21)]) - (lam i20 i20)]) - (lam i19 (lam i20 [i20 i19]))]) - i1])] - (con unit ()))) - i12]) - [i13 i14]]) - i12]) - (builtin equalsInteger)]) - i11]) - i10]) - i9])] - (lam i9 - [(lam i10 - [(lam i11 - [(lam i12 - [(lam i13 - [(lam i14 - [(lam i15 - [(lam i16 - [[(force (builtin mkCons)) - [[(lam i17 - [(lam i18 - [(lam i19 i19) - (lam i19 - (case - [[(builtin lessThanInteger) i19] [i15 (con integer 0)]] - [[i14 [[i14 i19] i17]] (builtin decodeUtf8)] - [[i14 - [[i14 [[i14 [[i14 i19] [(builtin subtractInteger) [i15 (con integer 0)]]]] i17]] - (builtin decodeUtf8)]] - [(builtin appendString) [i18 i13]]]))]) - (lam i18 i18)]) - [(lam i17 [i17 i17]) - (lam i17 - (lam i18 - (case - [[(builtin lessThanInteger) i18] [i15 (con integer 10)]] - [[(builtin appendByteString) - [[i17 i17] [[(builtin quotientInteger) i18] [i15 (con integer 10)]]]] - [[(builtin consByteString) - [[(builtin addInteger) [i15 (con integer 48)]] - [[(builtin remainderInteger) i18] [i15 (con integer 10)]]]] - [i16 (con bytestring #)]]] - [[(builtin consByteString) [[(builtin addInteger) [i15 (con integer 48)]] i18]] - [i16 (con bytestring #)]])))]] - i10]] - (con (list string) [])]) - (lam i16 i16)]) - (lam i15 i15)]) - (lam i14 (lam i15 [i15 i14]))]) - i1]) - i11]) - i10]) - i9])]) - (lam i8 - (lam i9 - (lam i10 - (lam i11 - [(lam i12 - (case - i12 - (lam i13 - (case - i13 - (lam i14 - (lam i15 - [(lam i16 - [(lam i17 - [(lam i18 (constr 0 i18)) - (constr 0 i17 (lam i18 (case i18 [i9 i16])) (lam i18 (case i18 [i10 i16])))]) - i15]) - i14])))) - (constr 1))) - [i8 i11]]))))]) - (lam i7 (lam i8 (lam i9 [[i6 [[(builtin appendString) i7] i8]] i9])))]) - (lam i6 (lam i7 [[[(force (builtin trace)) i6] i7] [i5 (con unit ())]]))]) - (lam i5 i5)]) - (lam i4 [(lam i5 (constr 1)) i4])]) - (con string "\0assert\0\48\0\50\0")]) - (con string "\0assert\0\48\0\49\0")]) - (con string "-")]) - (con string "\0assert\0\48")]) diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_2_V1_Silent.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selection_precedes_codegen_all_Silent.snap similarity index 100% rename from crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_2_V1_Silent.snap rename to crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selection_precedes_codegen_all_Silent.snap diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_1_V1_Silent.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selection_precedes_codegen_plain_Silent.snap similarity index 100% rename from crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selected_target_is_enforced_1_V1_Silent.snap rename to crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__rejected_generator_skips_body_and_selection_precedes_codegen_plain_Silent.snap diff --git a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__unit_roots_and_power_assert_payloads_1_V3_Silent.snap b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__unit_roots_and_power_assert_payloads_1_Silent.snap similarity index 88% rename from crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__unit_roots_and_power_assert_payloads_1_V3_Silent.snap rename to crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__unit_roots_and_power_assert_payloads_1_Silent.snap index c35bcbf1..8d527361 100644 --- a/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__unit_roots_and_power_assert_payloads_1_V3_Silent.snap +++ b/crates/nash-codegen/src/tests/snapshots/nash_codegen__tests__integration__unit_roots_and_power_assert_payloads_1_Silent.snap @@ -1,6 +1,5 @@ --- source: crates/nash-codegen/src/tests/integration.rs -assertion_line: 196 description: "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal\nprivateValue : int\nprivateValue = 1\ntests\n test \"passes\" = do\n assert True\n test \"fails without captures\" = do\n assert False\n test \"captures private value\" = do\n assert (Builtin.equalsInteger privateValue 2)\n" --- --- passes @@ -213,24 +212,14 @@ case@Bool anf#74 of let anf#89 : bytes = consByteString anf#87 (con bytestring #) in appendByteString anf#83 anf#89 in - let anf#91 : bool = lessThanInteger 1 0 in - let anf#102 : string = case@Bool anf#91 of - True -> let anf#92 : (int -> int) -> int = applyForward#59 1 in - let anf#94 : int -> int = subtractInteger 0 in - let anf#95 : int = anf#92 anf#94 in - let anf#96 : bytes = applyForward#59 anf#95 decimal#64 in - let anf#97 : string = applyForward#59 anf#96 decodeUtf8 in - let anf#98 : (string -> string) -> string = applyForward#59 anf#97 in - let anf#100 : string -> string = appendString "-" in - anf#98 anf#100 - False -> let anf#101 : bytes = applyForward#59 1 decimal#64 in - applyForward#59 anf#101 decodeUtf8 in + let anf#101 : bytes = applyForward#59 1 decimal#64 in + let anf#102 : string = applyForward#59 anf#101 decodeUtf8 in let anf#73 : string = appendString "\0assert\00\01\0" anf#102 in assertAt#46 anf#73 (\unit#70 : unit -> error)) --- optimized UPLC (program 1.1.0 - [(lam builtin_36 - [(lam partial_37 + [(lam builtin_28 + [(lam partial_29 [(lam assertAt_6 [(lam apply_7 [(lam anf_8 @@ -241,27 +230,11 @@ case@Bool anf#74 of [(lam applyForward_12 [(lam decimal_23 [(lam anf_24 - [(lam anf_33 - [(lam anf_34 [[assertAt_6 anf_34] (lam unit_35 (error))]) - [[(builtin appendString) (con string "\0assert\0\48\0\49\0")] anf_33]]) - (case - anf_24 - [(lam anf_32 [[applyForward_12 anf_32] (builtin decodeUtf8)]) - [[applyForward_12 (con integer 1)] decimal_23]] - [(lam anf_25 - [(lam anf_26 - [(lam anf_27 - [(lam anf_28 - [(lam anf_29 - [(lam anf_30 - [(lam anf_31 [anf_30 anf_31]) [(builtin appendString) (con string "-")]]) - [applyForward_12 anf_29]]) - [[applyForward_12 anf_28] (builtin decodeUtf8)]]) - [[applyForward_12 anf_27] decimal_23]]) - [anf_25 anf_26]]) - [(builtin subtractInteger) (con integer 0)]]) - [applyForward_12 (con integer 1)]])]) - [[(builtin lessThanInteger) (con integer 1)] (con integer 0)]]) + [(lam anf_25 + [(lam anf_26 [[assertAt_6 anf_26] (lam unit_27 (error))]) + [[(builtin appendString) (con string "\0assert\0\48\0\49\0")] anf_25]]) + [[applyForward_12 anf_24] (builtin decodeUtf8)]]) + [[applyForward_12 (con integer 1)] decimal_23]]) [(lam self_13 [self_13 self_13]) (lam self_14 (lam n_15 @@ -274,19 +247,19 @@ case@Bool anf#74 of [(lam anf_21 [(lam anf_22 [[(builtin appendByteString) anf_19] anf_22]) [[(builtin consByteString) anf_21] (con bytestring #)]]) - [partial_37 anf_20]]) + [partial_29 anf_20]]) [[(builtin remainderInteger) n_15] (con integer 10)]]) [[self_14 self_14] anf_18]]) [[(builtin quotientInteger) n_15] (con integer 10)]] [(lam anf_17 [[(builtin consByteString) anf_17] (con bytestring #)]) - [partial_37 n_15]])) + [partial_29 n_15]])) [[(builtin lessThanInteger) n_15] (con integer 10)]]))]]) (lam x_10 (lam f_11 [f_11 x_10]))])] (con unit ()))) [apply_7 (con integer 2)]]) [(builtin equalsInteger) (con integer 1)]]) (lam marker_3 - (lam rest_4 [(lam anf_5 [anf_5 (con unit ())]) [[builtin_36 marker_3] rest_4]]))]) + (lam rest_4 [(lam anf_5 [anf_5 (con unit ())]) [[builtin_28 marker_3] rest_4]]))]) [(builtin addInteger) (con integer 48)]]) (force (builtin trace))]) --- encoded target UPLC diff --git a/crates/nash-codegen/src/ty_of.rs b/crates/nash-codegen/src/ty_of.rs index ce320aa4..d76b5093 100644 --- a/crates/nash-codegen/src/ty_of.rs +++ b/crates/nash-codegen/src/ty_of.rs @@ -127,6 +127,17 @@ impl<'a, 'env> TypeEnv<'a, 'env> { } } CanType::Named { reference, args } => { + if reference.home == nash_ast::primitives::primitive_home() + && reference.name == "pair" + { + let [first, second] = *args else { + return Err(TypeError::NoFields); + }; + return Ok(vec![ + ("fst", 0, self.convert(first)?), + ("snd", 1, self.convert(second)?), + ]); + } if let Some(alias) = self.aliases.get(reference).copied() { if args.len() < alias.parameters.len() { return Err(TypeError::NoFields); diff --git a/crates/nash-codegen/src/uplc_optimizer.rs b/crates/nash-codegen/src/uplc_optimizer.rs new file mode 100644 index 00000000..6782bce0 --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer.rs @@ -0,0 +1,203 @@ +//! Late O1 cleanup and native application packing on named UPLC. +//! +//! Cleanup only shrinks terms; in particular it never duplicates a lambda body +//! or unfolds the multiple-use self applications generated by recursion encoding. +use nash_plutus::{arena::Arena, binder::Name, term::Term}; +use std::{ + collections::{HashMap, HashSet}, + ptr, +}; + +type Uplc<'a> = &'a Term<'a, Name<'a>>; + +/// Input must be closed and well-scoped; shadowed names are supported. Preserve +/// strict evaluation, traces and termination. Sharing runs before this pass: +/// forced builtin references and applied prefixes remain computations. +pub fn optimize<'a>(arena: &'a Arena, mut term: Uplc<'a>) -> Uplc<'a> { + loop { + let next = cleanup(arena, term); + let next = rewrite(arena, next, |node| pack(arena, node)); + if ptr::eq(term, next) { + return next; + } + term = next; + } +} + +fn value(term: Uplc<'_>) -> bool { + matches!( + term, + Term::Var(_) | Term::Constant(_) | Term::Builtin(_) | Term::Lambda { .. } | Term::Delay(_) + ) +} + +fn cleanup<'a>(arena: &'a Arena, term: Uplc<'a>) -> Uplc<'a> { + let mut uses = HashMap::::new(); + walk(term, |node| { + if let Term::Var(name) = node { + *uses.entry(name.unique()).or_default() += 1; + } + }); + rewrite(arena, term, |node| { + if let Term::Force(Term::Delay(body)) = node { + return Some(*body); + } + let Term::Apply { + function: Term::Lambda { parameter, body }, + argument, + } = node + else { + return None; + }; + // This retains argument evaluation even for a failing computation. + if matches!(body, Term::Var(name) if name.unique() == parameter.unique()) { + return Some(*argument); + } + if !value(argument) { + return None; + } + match uses.get(¶meter.unique()).copied().unwrap_or(0) { + 0 => Some(*body), + 1 if can_substitute(body, argument, parameter.unique()) => { + Some(rewrite(arena, body, |node| match node { + Term::Var(name) if name.unique() == parameter.unique() => Some(*argument), + _ => None, + })) + } + _ => None, + } + }) +} + +/// Named lowering is normally fresh, but public lowering also accepts shadowed +/// names. Reject any possible capture rather than assume global uniqueness. +/// Including bound argument names is conservative and avoids renaming or copying. +fn can_substitute(body: Uplc<'_>, argument: Uplc<'_>, parameter: usize) -> bool { + let mut names = HashSet::new(); + names.insert(parameter); + walk(argument, |node| { + if let Term::Var(name) = node { + names.insert(name.unique()); + } + }); + let mut safe = true; + walk(body, |node| { + if let Term::Lambda { parameter, .. } = node { + safe &= !names.contains(¶meter.unique()); + } + }); + safe +} + +fn pack<'a>(arena: &'a Arena, node: Uplc<'a>) -> Option> { + if !matches!(node, Term::Apply { .. }) { + return None; + } + let mut head = node; + let mut args = Vec::new(); + while let Term::Apply { function, argument } = head { + args.push(*argument); + head = function; + } + // A child may already have packed a prefix. Extend that same pack rather + // than leave nested packs or expose a new opportunity on the next invocation. + if let Term::Case { + constr: Term::Constr { tag: 0, fields }, + branches: [function], + } = head + { + args.extend(fields.iter().rev().copied()); + head = function; + } + // N Apply nodes become two nodes (Case + Constr). Three is the first arity + // with fewer evaluator steps; this is not an optimizer resource limit. + if args.len() < 3 || !value(head) || !args.iter().all(|arg| value(arg)) { + return None; + } + args.reverse(); + Some(Term::case( + arena, + Term::constr(arena, 0, arena.alloc_slice_copy(&args)), + arena.alloc_slice_copy(&[head]), + )) +} + +fn walk<'a>(root: Uplc<'a>, mut visit: impl FnMut(Uplc<'a>)) { + let mut pending = vec![root]; + while let Some(node) = pending.pop() { + visit(node); + match node { + Term::Apply { function, argument } => pending.extend([*argument, *function]), + Term::Lambda { body, .. } | Term::Force(body) | Term::Delay(body) => pending.push(body), + Term::Case { constr, branches } => { + pending.extend(branches.iter().rev().copied()); + pending.push(constr); + } + Term::Constr { fields, .. } => pending.extend(fields.iter().rev().copied()), + _ => {} + } + } +} + +/// Iterative postorder rewriting, retaining every unchanged parent pointer. +fn rewrite<'a>( + arena: &'a Arena, + root: Uplc<'a>, + mut rule: impl FnMut(Uplc<'a>) -> Option>, +) -> Uplc<'a> { + let mut pending = vec![(root, false, 0)]; + let mut results: Vec> = Vec::new(); + while let Some((node, finish, start)) = pending.pop() { + if !finish { + pending.push((node, true, results.len())); + match node { + Term::Apply { function, argument } => { + pending.push((argument, false, 0)); + pending.push((function, false, 0)); + } + Term::Lambda { body, .. } | Term::Force(body) | Term::Delay(body) => { + pending.push((body, false, 0)) + } + Term::Case { constr, branches } => { + pending.extend(branches.iter().rev().map(|branch| (*branch, false, 0))); + pending.push((constr, false, 0)); + } + Term::Constr { fields, .. } => { + pending.extend(fields.iter().rev().map(|field| (*field, false, 0))) + } + _ => {} + } + continue; + } + let c = &results[start..]; + let mapped = match node { + Term::Apply { function, argument } + if !ptr::eq(*function, c[0]) || !ptr::eq(*argument, c[1]) => + { + c[0].apply(arena, c[1]) + } + Term::Lambda { parameter, body } if !ptr::eq(*body, c[0]) => { + c[0].lambda(arena, parameter) + } + Term::Force(body) if !ptr::eq(*body, c[0]) => c[0].force(arena), + Term::Delay(body) if !ptr::eq(*body, c[0]) => c[0].delay(arena), + Term::Case { constr, branches } + if !ptr::eq(*constr, c[0]) + || !branches.iter().zip(&c[1..]).all(|(l, r)| ptr::eq(*l, *r)) => + { + Term::case(arena, c[0], arena.alloc_slice_copy(&c[1..])) + } + Term::Constr { tag, fields } if !fields.iter().zip(c).all(|(l, r)| ptr::eq(*l, *r)) => { + Term::constr(arena, *tag, arena.alloc_slice_copy(c)) + } + _ => node, + }; + let next = rule(mapped).unwrap_or(mapped); + results.truncate(start); + results.push(next); + } + results.pop().unwrap() +} + +#[cfg(test)] +mod tests; diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__effectful_last_argument.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__effectful_last_argument.snap new file mode 100644 index 00000000..45205fd6 --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__effectful_last_argument.snap @@ -0,0 +1,39 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +(case + [(lam f_3 + (constr 0 + [[[f_3 (con integer 20)] (con integer 20)] + (force [[(force (builtin trace)) (con string "last")] (delay (con integer 2))])] + (delay f_3))) + (lam x_0 + (force + [[(force (builtin trace)) (con string "first")] + (delay + (lam y_1 + (force + [[(force (builtin trace)) (con string "second")] + (delay (lam z_2 [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] z_2]))])))]))] + (lam result_5 (lam unused_4 result_5))) +--- UPLC after +(case + [(lam f_3 + (constr 0 + [[[f_3 (con integer 20)] (con integer 20)] + (force [[(force (builtin trace)) (con string "last")] (delay (con integer 2))])] + (delay f_3))) + (lam x_0 + (force + [[(force (builtin trace)) (con string "first")] + (delay + (lam y_1 + (force + [[(force (builtin trace)) (con string "second")] + (delay (lam z_2 [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] z_2]))])))]))] + (lam result_5 (lam unused_4 result_5))) +--- result +(con integer 42) +--- logs +["first", "second", "last"] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__failing_last_argument.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__failing_last_argument.snap new file mode 100644 index 00000000..9e1221cd --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__failing_last_argument.snap @@ -0,0 +1,39 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +(case + [(lam f_3 + (constr 0 + [[[f_3 (con integer 20)] (con integer 20)] + (force [[(force (builtin trace)) (con string "last")] (delay (error))])] + (delay f_3))) + (lam x_0 + (force + [[(force (builtin trace)) (con string "first")] + (delay + (lam y_1 + (force + [[(force (builtin trace)) (con string "second")] + (delay (lam z_2 [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] z_2]))])))]))] + (lam result_5 (lam unused_4 result_5))) +--- UPLC after +(case + [(lam f_3 + (constr 0 + [[[f_3 (con integer 20)] (con integer 20)] + (force [[(force (builtin trace)) (con string "last")] (delay (error))])] + (delay f_3))) + (lam x_0 + (force + [[(force (builtin trace)) (con string "first")] + (delay + (lam y_1 + (force + [[(force (builtin trace)) (con string "second")] + (delay (lam z_2 [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] z_2]))])))]))] + (lam result_5 (lam unused_4 result_5))) +--- result +error: ExplicitErrorTerm +--- logs +["first", "second", "last"] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__forced_reference.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__forced_reference.snap new file mode 100644 index 00000000..225c616a --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__forced_reference.snap @@ -0,0 +1,11 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +[(lam f_0 [[f_0 (con string "kept")] (con integer 42)]) (force (builtin trace))] +--- UPLC after +[(lam f_0 [[f_0 (con string "kept")] (con integer 42)]) (force (builtin trace))] +--- result +(con integer 42) +--- logs +["kept"] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__four_values.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__four_values.snap new file mode 100644 index 00000000..e6fc29fb --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__four_values.snap @@ -0,0 +1,41 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +(case + [(lam f_4 + (constr 0 + [[[[f_4 (con integer 10)] (con integer 10)] (con integer 20)] (con integer 2)] + (delay f_4))) + (lam x_0 + (lam y_1 + (lam z_2 + (force + [[(force (builtin trace)) (con string "third")] + (delay + (lam w_3 + [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] + [[(builtin addInteger) z_2] w_3]]))]))))] + (lam result_6 (lam unused_5 result_6))) +--- UPLC after +(case + [(lam f_4 + (constr 0 + (case + (constr 0 (con integer 10) (con integer 10) (con integer 20) (con integer 2)) + f_4) + (delay f_4))) + (lam x_0 + (lam y_1 + (lam z_2 + (force + [[(force (builtin trace)) (con string "third")] + (delay + (lam w_3 + [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] + [[(builtin addInteger) z_2] w_3]]))]))))] + (lam result_6 (lam unused_5 result_6))) +--- result +(con integer 42) +--- logs +["third"] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__identity_trace.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__identity_trace.snap new file mode 100644 index 00000000..88098cac --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__identity_trace.snap @@ -0,0 +1,14 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +[(lam x_0 x_0) + (force + [[(force (builtin trace)) (con string "argument")] (delay (con integer 42))])] +--- UPLC after +(force + [[(force (builtin trace)) (con string "argument")] (delay (con integer 42))]) +--- result +(con integer 42) +--- logs +["argument"] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__packed_prefix_then_failure.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__packed_prefix_then_failure.snap new file mode 100644 index 00000000..65285c27 --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__packed_prefix_then_failure.snap @@ -0,0 +1,41 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +(case + [(lam f_4 + (constr 0 + [[[[f_4 (con integer 10)] (con integer 10)] (con integer 20)] + (force [[(force (builtin trace)) (con string "fourth")] (delay (error))])] + (delay f_4))) + (lam x_0 + (lam y_1 + (lam z_2 + (force + [[(force (builtin trace)) (con string "third")] + (delay + (lam w_3 + [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] + [[(builtin addInteger) z_2] w_3]]))]))))] + (lam result_6 (lam unused_5 result_6))) +--- UPLC after +(case + [(lam f_4 + (constr 0 + [(case (constr 0 (con integer 10) (con integer 10) (con integer 20)) f_4) + (force [[(force (builtin trace)) (con string "fourth")] (delay (error))])] + (delay f_4))) + (lam x_0 + (lam y_1 + (lam z_2 + (force + [[(force (builtin trace)) (con string "third")] + (delay + (lam w_3 + [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] + [[(builtin addInteger) z_2] w_3]]))]))))] + (lam result_6 (lam unused_5 result_6))) +--- result +error: ExplicitErrorTerm +--- logs +["third", "fourth"] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__packed_prefix_then_trace.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__packed_prefix_then_trace.snap new file mode 100644 index 00000000..db1f0ddb --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__packed_prefix_then_trace.snap @@ -0,0 +1,43 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +(case + [(lam f_4 + (constr 0 + [[[[f_4 (con integer 10)] (con integer 10)] (con integer 20)] + (force + [[(force (builtin trace)) (con string "fourth")] (delay (con integer 2))])] + (delay f_4))) + (lam x_0 + (lam y_1 + (lam z_2 + (force + [[(force (builtin trace)) (con string "third")] + (delay + (lam w_3 + [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] + [[(builtin addInteger) z_2] w_3]]))]))))] + (lam result_6 (lam unused_5 result_6))) +--- UPLC after +(case + [(lam f_4 + (constr 0 + [(case (constr 0 (con integer 10) (con integer 10) (con integer 20)) f_4) + (force + [[(force (builtin trace)) (con string "fourth")] (delay (con integer 2))])] + (delay f_4))) + (lam x_0 + (lam y_1 + (lam z_2 + (force + [[(force (builtin trace)) (con string "third")] + (delay + (lam w_3 + [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] + [[(builtin addInteger) z_2] w_3]]))]))))] + (lam result_6 (lam unused_5 result_6))) +--- result +(con integer 42) +--- logs +["third", "fourth"] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__packed_values.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__packed_values.snap new file mode 100644 index 00000000..be1d3dae --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__packed_values.snap @@ -0,0 +1,37 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +(case + [(lam f_3 + (constr 0 + [[[f_3 (con integer 20)] (con integer 20)] (con integer 2)] + (delay f_3))) + (lam x_0 + (force + [[(force (builtin trace)) (con string "first")] + (delay + (lam y_1 + (force + [[(force (builtin trace)) (con string "second")] + (delay (lam z_2 [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] z_2]))])))]))] + (lam result_5 (lam unused_4 result_5))) +--- UPLC after +(case + [(lam f_3 + (constr 0 + (case (constr 0 (con integer 20) (con integer 20) (con integer 2)) f_3) + (delay f_3))) + (lam x_0 + (force + [[(force (builtin trace)) (con string "first")] + (delay + (lam y_1 + (force + [[(force (builtin trace)) (con string "second")] + (delay (lam z_2 [[(builtin addInteger) [[(builtin addInteger) x_0] y_1]] z_2]))])))]))] + (lam result_5 (lam unused_4 result_5))) +--- result +(con integer 42) +--- logs +["first", "second"] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__recursive_self_application_is_not_unfolded.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__recursive_self_application_is_not_unfolded.snap new file mode 100644 index 00000000..35767d73 --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__recursive_self_application_is_not_unfolded.snap @@ -0,0 +1,7 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +[(lam x_0 [x_0 x_0]) (lam x_0 [x_0 x_0])] +--- UPLC after +[(lam x_0 [x_0 x_0]) (lam x_0 [x_0 x_0])] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__shadow_capture.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__shadow_capture.snap new file mode 100644 index 00000000..2e556633 --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__shadow_capture.snap @@ -0,0 +1,11 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +[(lam y_1 [[(lam x_0 (lam y_1 x_0)) y_1] (con integer 0)]) (con integer 42)] +--- UPLC after +[(lam y_1 [[(lam x_0 (lam y_1 x_0)) y_1] (con integer 0)]) (con integer 42)] +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__unused_error.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__unused_error.snap new file mode 100644 index 00000000..a99c7da7 --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__unused_error.snap @@ -0,0 +1,13 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +[(lam x_0 (con integer 42)) + (force [[(force (builtin trace)) (con string "argument")] (delay (error))])] +--- UPLC after +[(lam x_0 (con integer 42)) + (force [[(force (builtin trace)) (con string "argument")] (delay (error))])] +--- result +error: ExplicitErrorTerm +--- logs +["argument"] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__unused_value.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__unused_value.snap new file mode 100644 index 00000000..1008caa1 --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__unused_value.snap @@ -0,0 +1,12 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +[(lam x_0 (con integer 42)) + (delay (force [[(force (builtin trace)) (con string "cold")] (delay (error))]))] +--- UPLC after +(con integer 42) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__value_in_delay.snap b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__value_in_delay.snap new file mode 100644 index 00000000..dc526adc --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/snapshots/nash_codegen__uplc_optimizer__tests__value_in_delay.snap @@ -0,0 +1,11 @@ +--- +source: crates/nash-codegen/src/uplc_optimizer/tests.rs +--- +--- UPLC before +(force [(lam x_0 (delay x_0)) (con integer 42)]) +--- UPLC after +(con integer 42) +--- result +(con integer 42) +--- logs +[] diff --git a/crates/nash-codegen/src/uplc_optimizer/tests.rs b/crates/nash-codegen/src/uplc_optimizer/tests.rs new file mode 100644 index 00000000..5ac31d05 --- /dev/null +++ b/crates/nash-codegen/src/uplc_optimizer/tests.rs @@ -0,0 +1,229 @@ +use super::*; +use nash_plutus::{builtin::DefaultFunction as F, pretty}; + +fn check(a: &Arena, name: &str, input: Uplc<'_>, fails: bool) { + let mut settings = insta::Settings::clone_current(); + settings.set_omit_expression(true); + let _settings = settings.bind_to_scope(); + let after = optimize(a, input); + let before_eval = crate::harness::eval_named(a, input); + let after_eval = crate::harness::eval_named(a, after); + assert_eq!(after_eval.result.starts_with("error:"), fails); + insta::assert_snapshot!( + name, + format!( + "--- UPLC before\n{}\n--- UPLC after\n{}\n--- result\n{}\n--- logs\n{:?}", + pretty::term(input), + pretty::term(after), + after_eval.result, + after_eval.logs + ) + ); + assert_eq!(before_eval.observable, after_eval.observable); + assert_eq!(before_eval.logs, after_eval.logs); + assert!(std::ptr::eq(after, optimize(a, after))); +} +fn trace<'a>(a: &'a Arena, message: &'a str, term: Uplc<'a>) -> Uplc<'a> { + Term::trace(a) + .force(a) + .apply(a, Term::string(a, message)) + .apply(a, term.delay(a)) + .force(a) +} +#[test] +fn cleanup_keeps_strict_effects() { + let a = Arena::new(); + let x = Name::new(&a, "x", 0); + check( + &a, + "identity_trace", + Term::var(&a, x) + .lambda(&a, x) + .apply(&a, trace(&a, "argument", Term::integer_from(&a, 42))), + false, + ); + check( + &a, + "unused_error", + Term::integer_from(&a, 42) + .lambda(&a, x) + .apply(&a, trace(&a, "argument", Term::error(&a))), + true, + ); + check( + &a, + "unused_value", + Term::integer_from(&a, 42) + .lambda(&a, x) + .apply(&a, trace(&a, "cold", Term::error(&a)).delay(&a)), + false, + ); + check( + &a, + "value_in_delay", + Term::var(&a, x) + .delay(&a) + .lambda(&a, x) + .apply(&a, Term::integer_from(&a, 42)) + .force(&a), + false, + ); +} +#[test] +fn substitution_does_not_capture_shadowed_names() { + let a = Arena::new(); + let x = Name::new(&a, "x", 0); + let y = Name::new(&a, "y", 1); + // y=42; (lambda x. lambda y. x) y 0. Inner y must not capture outer y. + let root = Term::var(&a, x) + .lambda(&a, y) + .lambda(&a, x) + .apply(&a, Term::var(&a, y)) + .apply(&a, Term::integer_from(&a, 0)) + .lambda(&a, y) + .apply(&a, Term::integer_from(&a, 42)); + check(&a, "shadow_capture", root, false); +} +#[test] +fn packing_retains_stages_and_effectful_arguments() { + let a = Arena::new(); + let x = Name::new(&a, "x", 0); + let y = Name::new(&a, "y", 1); + let z = Name::new(&a, "z", 2); + let f = Name::new(&a, "f", 3); + let sum = Term::add_integer(&a) + .apply(&a, Term::var(&a, x)) + .apply(&a, Term::var(&a, y)); + let body = Term::add_integer(&a) + .apply(&a, sum) + .apply(&a, Term::var(&a, z)); + let func = trace( + &a, + "first", + trace(&a, "second", body.lambda(&a, z)).lambda(&a, y), + ) + .lambda(&a, x); + for (name, last, fails) in [ + ("packed_values", Term::integer_from(&a, 2), false), + ( + "effectful_last_argument", + trace(&a, "last", Term::integer_from(&a, 2)), + false, + ), + ( + "failing_last_argument", + trace(&a, "last", Term::error(&a)), + true, + ), + ] { + // Twice-used f retains an unknown function value at the first call. + let call = Term::var(&a, f) + .apply(&a, Term::integer_from(&a, 20)) + .apply(&a, Term::integer_from(&a, 20)) + .apply(&a, last); + let root = Term::constr( + &a, + 0, + a.alloc_slice_copy(&[call, Term::var(&a, f).delay(&a)]), + ) + .lambda(&a, f) + .apply(&a, func); + // Return the ground call result; the second field is deliberately cold. + let unused = Name::new(&a, "unused", 4); + let result = Name::new(&a, "result", 5); + let select = Term::var(&a, result).lambda(&a, unused).lambda(&a, result); + check( + &a, + name, + Term::case(&a, root, a.alloc_slice_copy(&[select])), + fails, + ); + } +} +#[test] +fn partial_builtin_and_forced_sharing_stay_strict() { + let a = Arena::new(); + let f = Name::new(&a, "f", 0); + let shared = Term::builtin(&a, a.alloc(F::Trace)).force(&a); + let call = Term::var(&a, f) + .apply(&a, Term::string(&a, "kept")) + .apply(&a, Term::integer_from(&a, 42)); + check( + &a, + "forced_reference", + call.lambda(&a, f).apply(&a, shared), + false, + ); +} +#[test] +fn recursive_self_application_is_not_unfolded() { + let mut settings = insta::Settings::clone_current(); + settings.set_omit_expression(true); + let _settings = settings.bind_to_scope(); + let a = Arena::new(); + let x = Name::new(&a, "x", 0); + let worker = Term::var(&a, x).apply(&a, Term::var(&a, x)).lambda(&a, x); + let divergent = worker.apply(&a, worker); + let after = optimize(&a, divergent); + insta::assert_snapshot!(format!( + "--- UPLC before\n{}\n--- UPLC after\n{}", + pretty::term(divergent), + pretty::term(after) + )); + assert!(std::ptr::eq(divergent, after)); + assert!(std::ptr::eq(after, optimize(&a, after))); +} + +#[test] +fn maximal_packing_keeps_a_later_computation_after_the_prefix() { + let a = Arena::new(); + let x = Name::new(&a, "x", 0); + let y = Name::new(&a, "y", 1); + let z = Name::new(&a, "z", 2); + let w = Name::new(&a, "w", 3); + let f = Name::new(&a, "f", 4); + let add = |l, r| Term::add_integer(&a).apply(&a, l).apply(&a, r); + let sum = add( + add(Term::var(&a, x), Term::var(&a, y)), + add(Term::var(&a, z), Term::var(&a, w)), + ); + let func = trace(&a, "third", sum.lambda(&a, w)) + .lambda(&a, z) + .lambda(&a, y) + .lambda(&a, x); + let unused = Name::new(&a, "unused", 5); + let result = Name::new(&a, "result", 6); + let select = Term::var(&a, result).lambda(&a, unused).lambda(&a, result); + for (name, last, fails) in [ + ("four_values", Term::integer_from(&a, 2), false), + ( + "packed_prefix_then_trace", + trace(&a, "fourth", Term::integer_from(&a, 2)), + false, + ), + ( + "packed_prefix_then_failure", + trace(&a, "fourth", Term::error(&a)), + true, + ), + ] { + let call = Term::var(&a, f) + .apply(&a, Term::integer_from(&a, 10)) + .apply(&a, Term::integer_from(&a, 10)) + .apply(&a, Term::integer_from(&a, 20)) + .apply(&a, last); + let root = Term::constr( + &a, + 0, + a.alloc_slice_copy(&[call, Term::var(&a, f).delay(&a)]), + ) + .lambda(&a, f) + .apply(&a, func); + check( + &a, + name, + Term::case(&a, root, a.alloc_slice_copy(&[select])), + fails, + ); + } +} diff --git a/crates/nash-codegen/tests/snapshots/vesting__vesting.snap b/crates/nash-codegen/tests/snapshots/vesting__vesting.snap index 90fc6d08..8811b4d4 100644 --- a/crates/nash-codegen/tests/snapshots/vesting__vesting.snap +++ b/crates/nash-codegen/tests/snapshots/vesting__vesting.snap @@ -1007,507 +1007,544 @@ case@Data ctx#430 of [(lam leaf_6 [(lam generated_367 (force - [[[[[[builtin_376 generated_367] - (delay - [(lam field_7 - (case - field_7 - (lam field_8 - (lam field_9 - [(lam anf_10 - [(lam anf_11 - (case - anf_11 - (force leaf_6) + (case + (constr 0 + generated_367 + (delay + [(lam field_7 + (case + field_7 + (lam field_8 + (lam field_9 + [(lam anf_10 + [(lam anf_11 (case - field_9 - (lam field_12 - (lam field_13 - (case - field_13 - (lam field_14 - (lam field_16 - (case - field_16 - (lam field_17 - (lam field_19 - [(lam generated_368 - (force - [[[[[[builtin_376 generated_368] - (delay - [(lam field_20 - (case - field_20 - (lam field_21 - (lam field_22 - [(lam anf_27 - [(lam anf_47 - (case - anf_47 - (force leaf_6) - (case - field_22 - (lam field_53 - (lam field_54 - (case - field_54 - (lam field_55 - (lam field_56 - [(lam generated_369 - (force - [[[[[[builtin_376 generated_369] - (delay - [(lam field_57 - (case - field_57 - (lam field_58 - (lam field_59 - [(lam anf_60 - [(lam anf_61 - (case - anf_61 - (force leaf_6) - (case - field_59 - (lam field_62 - (lam field_63 + anf_11 + (force leaf_6) + (case + field_9 + (lam field_12 + (lam field_13 + (case + field_13 + (lam field_14 + (lam field_16 + (case + field_16 + (lam field_17 + (lam field_19 + [(lam generated_368 + (force + (case + (constr 0 + generated_368 + (delay + [(lam field_20 + (case + field_20 + (lam field_21 + (lam field_22 + [(lam anf_27 + [(lam anf_47 + (case + anf_47 + (force leaf_6) + (case + field_22 + (lam field_53 + (lam field_54 + (case + field_54 + (lam field_55 + (lam field_56 + [(lam generated_369 + (force + (case + (constr 0 + generated_369 + (delay + [(lam field_57 + (case + field_57 + (lam field_58 + (lam field_59 + [(lam anf_60 + [(lam anf_61 + (case + anf_61 + (force leaf_6) (case - field_63 - (lam field_353 (lam field_354 (force leaf_6))) - (case - field_56 - (lam field_351 (lam field_352 (force leaf_6))) - (case - field_19 - (lam field_349 (lam field_350 (force leaf_6))) - [(lam projection_64 + field_59 + (lam field_62 + (lam field_63 + (case + field_63 + (lam field_353 (lam field_354 (force leaf_6))) (case - projection_64 - (lam tag_65 - (lam fields_66 + field_56 + (lam field_351 (lam field_352 (force leaf_6))) + (case + field_19 + (lam field_349 (lam field_350 (force leaf_6))) + [(lam projection_64 (case - tag_65 - [(lam projection_67 - (case - projection_67 - (lam tag_68 - (lam fields_69 + projection_64 + (lam tag_65 + (lam fields_66 + (case + tag_65 + [(lam projection_67 + (case + projection_67 + (lam tag_68 + (lam fields_69 + (case + fields_69 + (lam head_70 + (lam tail_71 + (case + tail_71 + (lam head_72 + (lam tail_73 + [(lam anf_74 + [(lam leaf_75 + [(lam anf_234 + [(lam anf_235 + (case anf_235 (force [[builtin_370 message_3] (delay (error))]) (con unit ()))) + [[(builtin lessThanInteger) anf_74] anf_234]]) + [(lam generated_371 + (force + (case + (constr 0 + generated_371 + (delay + [(lam field_76 + (case + field_76 + (lam field_77 + (lam field_78 + [(lam anf_79 + [(lam anf_80 + (case + anf_80 + (force leaf_75) + (case + field_78 + (lam field_81 + (lam field_82 + (case + field_82 + (lam field_83 + (lam field_84 + (case + field_84 + (lam field_85 + (lam field_86 + (case + field_86 + (lam field_87 + (lam field_88 + (case + field_88 + (lam field_89 + (lam field_90 + (case + field_90 + (lam field_91 + (lam field_92 + (case + field_92 + (lam field_93 + (lam field_94 + (case + field_94 + (lam field_95 + (lam field_96 + [(lam generated_372 + (force + (case + (constr 0 + generated_372 + (delay + [(lam field_97 + (case + field_97 + (lam field_98 + (lam field_99 + [(lam anf_100 + [(lam anf_101 + (case + anf_101 + (force leaf_75) + (case + field_99 + (lam field_102 + (lam field_103 + [(lam generated_373 + (force + (case + (constr 0 + generated_373 + (delay + [(lam field_104 + (case + field_104 + (lam field_105 + (lam field_106 + [(lam anf_107 + [(lam anf_108 + (case + anf_108 + (force leaf_75) + (case + field_106 + (lam field_109 + (lam field_110 + [(lam generated_374 + (force + (case + (constr 0 + generated_374 + (delay + [(lam field_111 + (case + field_111 + (lam field_112 + (lam field_113 + [(lam anf_114 + [(lam anf_115 + (case + anf_115 + (force leaf_75) + (case + field_113 + (lam field_116 + (lam field_117 + [(lam generated_375 + (force + (case + (constr 0 + generated_375 + (delay (force leaf_75)) + (delay (force leaf_75)) + (delay (force leaf_75)) + (delay + [(lam field_121 + (case + field_117 + (lam field_215 (lam field_216 (force leaf_75))) + (case + field_110 + (lam field_127 + (lam field_154 + (case + field_154 + (lam field_213 (lam field_214 (force leaf_75))) + (case + field_103 + (lam field_180 + (lam field_181 + (case + field_181 + (lam field_211 (lam field_212 (force leaf_75))) + (case + field_96 + (lam field_182 + (lam field_183 + (case + field_183 + (lam field_184 + (lam field_185 + (case + field_185 + (lam field_186 + (lam field_195 + (case + field_195 + (lam field_196 + (lam field_197 + (case + field_197 + (lam field_198 + (lam field_199 + (case + field_199 + (lam field_200 + (lam field_201 + (case + field_201 + (lam field_205 + (lam field_206 + (case + field_206 + (lam field_207 + (lam field_208 + (case field_208 (lam field_209 (lam field_210 (force leaf_75))) field_121))) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75))))) + (force leaf_75))))) + (force leaf_75)))) + [(builtin unIData) generated_375]]) + (delay (force leaf_75))) + builtin_376))) + field_116])) + (force leaf_75)))) + [anf_114 (con integer 1)]]) + [eq_4 field_112]])))) + [(builtin unConstrData) generated_374]]) + (delay (force leaf_75)) + (delay (force leaf_75)) + (delay (force leaf_75)) + (delay (force leaf_75))) + builtin_376))) + field_109])) + (force leaf_75)))) + [anf_107 (con integer 0)]]) + [eq_4 field_105]])))) + [(builtin unConstrData) generated_373]]) + (delay (force leaf_75)) + (delay (force leaf_75)) + (delay (force leaf_75)) + (delay (force leaf_75))) + builtin_376))) + field_102])) + (force leaf_75)))) + [anf_100 (con integer 0)]]) + [eq_4 field_98]])))) + [(builtin unConstrData) generated_372]]) + (delay (force leaf_75)) + (delay (force leaf_75)) + (delay (force leaf_75)) + (delay (force leaf_75))) + builtin_376))) + field_95])) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75)))) + (force leaf_75)))) + [anf_79 (con integer 0)]]) + [eq_4 field_77]])))) + [(builtin unConstrData) generated_371]]) + (delay (force leaf_75)) + (delay (force leaf_75)) + (delay (force leaf_75)) + (delay (force leaf_75))) + builtin_376))) + field_12]]) + (delay (error))]) + [(builtin unIData) head_72]])) + (error)))) + (error)))))) + [(builtin unConstrData) field_62]] + [(lam projection_236 (case - fields_69 - (lam head_70 - (lam tail_71 + projection_236 + (lam tag_237 + (lam fields_238 (case - tail_71 - (lam head_72 - (lam tail_73 - [(lam anf_74 - [(lam leaf_75 - [(lam anf_234 - [(lam anf_235 - (case anf_235 (force [[builtin_370 message_3] (delay (error))]) (con unit ()))) - [[(builtin lessThanInteger) anf_74] anf_234]]) - [(lam generated_371 - (force - [[[[[[builtin_376 generated_371] + fields_238 + (lam head_239 + (lam tail_240 + [(lam leaf_241 + [(lam anf_348 + (case anf_348 (force [[builtin_370 message_3] (delay (error))]) (con unit ()))) + [(lam generated_377 + (force + (case + (constr 0 + generated_377 (delay - [(lam field_76 + [(lam field_242 (case - field_76 - (lam field_77 - (lam field_78 - [(lam anf_79 - [(lam anf_80 + field_242 + (lam field_243 + (lam field_244 + [(lam anf_245 + [(lam anf_246 (case - anf_80 - (force leaf_75) + anf_246 + (force leaf_241) (case - field_78 - (lam field_81 - (lam field_82 + field_244 + (lam field_247 + (lam field_248 (case - field_82 - (lam field_83 - (lam field_84 + field_248 + (lam field_249 + (lam field_250 (case - field_84 - (lam field_85 - (lam field_86 + field_250 + (lam field_251 + (lam field_252 (case - field_86 - (lam field_87 - (lam field_88 + field_252 + (lam field_253 + (lam field_254 (case - field_88 - (lam field_89 - (lam field_90 + field_254 + (lam field_255 + (lam field_256 (case - field_90 - (lam field_91 - (lam field_92 + field_256 + (lam field_257 + (lam field_258 (case - field_92 - (lam field_93 - (lam field_94 + field_258 + (lam field_259 + (lam field_260 (case - field_94 - (lam field_95 - (lam field_96 - [(lam generated_372 - (force - [[[[[[builtin_376 generated_372] - (delay - [(lam field_97 + field_260 + (lam field_261 + (lam field_262 + (case + field_262 + (lam field_263 + (lam field_264 + [(lam generated_378 + (force (case - field_97 - (lam field_98 - (lam field_99 - [(lam anf_100 - [(lam anf_101 - (case - anf_101 - (force leaf_75) - (case - field_99 - (lam field_102 - (lam field_103 - [(lam generated_373 - (force - [[[[[[builtin_376 generated_373] - (delay - [(lam field_104 - (case - field_104 - (lam field_105 - (lam field_106 - [(lam anf_107 - [(lam anf_108 + (constr 0 + generated_378 + (delay (force leaf_241)) + (delay (force leaf_241)) + (delay + [(lam field_267 + (case + field_264 + (lam field_268 + (lam field_269 + (case + field_269 + (lam field_270 + (lam field_271 + (case + field_271 + (lam field_272 + (lam field_273 + (case + field_273 + (lam field_274 + (lam field_275 + (case + field_275 + (lam field_276 + (lam field_277 (case - anf_108 - (force leaf_75) - (case - field_106 - (lam field_109 - (lam field_110 - [(lam generated_374 - (force - [[[[[[builtin_376 generated_374] - (delay - [(lam field_111 - (case - field_111 - (lam field_112 - (lam field_113 - [(lam anf_114 - [(lam anf_115 - (case - anf_115 - (force leaf_75) - (case - field_113 - (lam field_116 - (lam field_117 - [(lam generated_375 - (force - [[[[[[builtin_376 generated_375] (delay (force leaf_75))] (delay (force leaf_75))] - (delay (force leaf_75))] - (delay - [(lam field_121 - (case - field_117 - (lam field_215 (lam field_216 (force leaf_75))) - (case - field_110 - (lam field_127 - (lam field_154 - (case - field_154 - (lam field_213 (lam field_214 (force leaf_75))) - (case - field_103 - (lam field_180 - (lam field_181 - (case - field_181 - (lam field_211 (lam field_212 (force leaf_75))) - (case - field_96 - (lam field_182 - (lam field_183 - (case - field_183 - (lam field_184 - (lam field_185 - (case - field_185 - (lam field_186 - (lam field_195 - (case - field_195 - (lam field_196 - (lam field_197 - (case - field_197 - (lam field_198 - (lam field_199 - (case - field_199 - (lam field_200 - (lam field_201 - (case - field_201 - (lam field_205 - (lam field_206 - (case - field_206 - (lam field_207 - (lam field_208 - (case field_208 (lam field_209 (lam field_210 (force leaf_75))) field_121))) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75))))) - (force leaf_75))))) - (force leaf_75)))) - [(builtin unIData) generated_375]])] - (delay (force leaf_75))])) - field_116])) - (force leaf_75)))) - [anf_114 (con integer 1)]]) - [eq_4 field_112]])))) - [(builtin unConstrData) generated_374]])] - (delay (force leaf_75))] - (delay (force leaf_75))] - (delay (force leaf_75))] - (delay (force leaf_75))])) - field_109])) - (force leaf_75)))) - [anf_107 (con integer 0)]]) - [eq_4 field_105]])))) - [(builtin unConstrData) generated_373]])] - (delay (force leaf_75))] - (delay (force leaf_75))] - (delay (force leaf_75))] - (delay (force leaf_75))])) - field_102])) - (force leaf_75)))) - [anf_100 (con integer 0)]]) - [eq_4 field_98]])))) - [(builtin unConstrData) generated_372]])] - (delay (force leaf_75))] - (delay (force leaf_75))] - (delay (force leaf_75))] - (delay (force leaf_75))])) - field_95])) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75)))) - (force leaf_75)))) - [anf_79 (con integer 0)]]) - [eq_4 field_77]])))) - [(builtin unConstrData) generated_371]])] - (delay (force leaf_75))] - (delay (force leaf_75))] - (delay (force leaf_75))] - (delay (force leaf_75))])) - field_12]]) - (delay (error))]) - [(builtin unIData) head_72]])) - (error)))) - (error)))))) - [(builtin unConstrData) field_62]] - [(lam projection_236 - (case - projection_236 - (lam tag_237 - (lam fields_238 - (case - fields_238 - (lam head_239 - (lam tail_240 - [(lam leaf_241 - [(lam anf_348 - (case anf_348 (force [[builtin_370 message_3] (delay (error))]) (con unit ()))) - [(lam generated_377 - (force - [[[[[[builtin_376 generated_377] - (delay - [(lam field_242 - (case - field_242 - (lam field_243 - (lam field_244 - [(lam anf_245 - [(lam anf_246 - (case - anf_246 - (force leaf_241) - (case - field_244 - (lam field_247 - (lam field_248 - (case - field_248 - (lam field_249 - (lam field_250 - (case - field_250 - (lam field_251 - (lam field_252 - (case - field_252 - (lam field_253 - (lam field_254 - (case - field_254 - (lam field_255 - (lam field_256 - (case - field_256 - (lam field_257 - (lam field_258 - (case - field_258 - (lam field_259 - (lam field_260 - (case - field_260 - (lam field_261 - (lam field_262 - (case - field_262 - (lam field_263 - (lam field_264 - [(lam generated_378 - (force - [[[[[[builtin_376 generated_378] (delay (force leaf_241))] - (delay (force leaf_241))] - (delay - [(lam field_267 - (case - field_264 - (lam field_268 - (lam field_269 - (case - field_269 - (lam field_270 - (lam field_271 - (case - field_271 - (lam field_272 - (lam field_273 - (case - field_273 - (lam field_274 - (lam field_275 - (case - field_275 - (lam field_276 - (lam field_277 - (case - field_277 - (lam field_278 - (lam field_279 - (case - field_279 - (lam field_280 - (lam field_281 - (case - field_281 - (lam field_297 (lam field_333 (force leaf_241))) - [(lam anf_282 - [(lam worker_295 [worker_295 field_267]) - [(lam self_283 [self_283 self_283]) - (lam self_284 - (lam signers_285 - [(lam leaf_286 - (case - signers_285 - (lam field_287 - (lam field_288 - [(lam generated_379 - (force - [[[[[[builtin_376 generated_379] (delay (force leaf_286))] - (delay (force leaf_286))] - (delay (force leaf_286))] - (delay (force leaf_286))] - (delay - [(lam field_293 - [(lam anf_294 (case anf_294 [[self_284 self_284] field_288] (con bool True))) - [[(builtin equalsByteString) field_293] anf_282]]) - [(builtin unBData) generated_379]])])) - field_287])) - (con bool False))) - (delay (error))]))]]) - [(builtin unBData) head_239]]))) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241))) - [(builtin unListData) generated_378]])] - (delay (force leaf_241))] - (delay (force leaf_241))])) - field_263])) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241)))) - (force leaf_241)))) - [anf_245 (con integer 0)]]) - [eq_4 field_243]])))) - [(builtin unConstrData) generated_377]])] - (delay (force leaf_241))] - (delay (force leaf_241))] - (delay (force leaf_241))] - (delay (force leaf_241))])) - field_12]]) - (delay (error))])) - (error)))))) - [(builtin unConstrData) field_62]]))))) - [(builtin unConstrData) field_14]]))))) - (force leaf_6)))) - [anf_60 (con integer 0)]]) - [eq_4 field_58]])))) - [(builtin unConstrData) generated_369]])] - (delay (force leaf_6))] - (delay (force leaf_6))] - (delay (force leaf_6))] - (delay (force leaf_6))])) - field_55])) - (force leaf_6)))) - (force leaf_6)))) - [anf_27 (con integer 1)]]) - [eq_4 field_21]])))) - [(builtin unConstrData) generated_368]])] - (delay (force leaf_6))] - (delay (force leaf_6))] - (delay (force leaf_6))] - (delay (force leaf_6))])) - field_17])) - (force leaf_6)))) - (force leaf_6)))) - (force leaf_6)))) - [anf_10 (con integer 0)]]) - [eq_4 field_8]])))) - [(builtin unConstrData) generated_367]])] - (delay (force leaf_6))] - (delay (force leaf_6))] - (delay (force leaf_6))] - (delay (force leaf_6))])) + field_277 + (lam field_278 + (lam field_279 + (case + field_279 + (lam field_280 + (lam field_281 + (case + field_281 + (lam field_297 (lam field_333 (force leaf_241))) + [(lam anf_282 + [(lam worker_295 [worker_295 field_267]) + [(lam self_283 [self_283 self_283]) + (lam self_284 + (lam signers_285 + [(lam leaf_286 + (case + signers_285 + (lam field_287 + (lam field_288 + [(lam generated_379 + (force + (case + (constr 0 + generated_379 + (delay (force leaf_286)) + (delay (force leaf_286)) + (delay (force leaf_286)) + (delay (force leaf_286)) + (delay + [(lam field_293 + [(lam anf_294 (case anf_294 [[self_284 self_284] field_288] (con bool True))) + [[(builtin equalsByteString) field_293] anf_282]]) + [(builtin unBData) generated_379]])) + builtin_376))) + field_287])) + (con bool False))) + (delay (error))]))]]) + [(builtin unBData) head_239]]))) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241))) + [(builtin unListData) generated_378]]) + (delay (force leaf_241)) + (delay (force leaf_241))) + builtin_376))) + field_263])) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241)))) + (force leaf_241)))) + [anf_245 (con integer 0)]]) + [eq_4 field_243]])))) + [(builtin unConstrData) generated_377]]) + (delay (force leaf_241)) + (delay (force leaf_241)) + (delay (force leaf_241)) + (delay (force leaf_241))) + builtin_376))) + field_12]]) + (delay (error))])) + (error)))))) + [(builtin unConstrData) field_62]]))))) + [(builtin unConstrData) field_14]]))))) + (force leaf_6)))) + [anf_60 (con integer 0)]]) + [eq_4 field_58]])))) + [(builtin unConstrData) generated_369]]) + (delay (force leaf_6)) + (delay (force leaf_6)) + (delay (force leaf_6)) + (delay (force leaf_6))) + builtin_376))) + field_55])) + (force leaf_6)))) + (force leaf_6)))) + [anf_27 (con integer 1)]]) + [eq_4 field_21]])))) + [(builtin unConstrData) generated_368]]) + (delay (force leaf_6)) + (delay (force leaf_6)) + (delay (force leaf_6)) + (delay (force leaf_6))) + builtin_376))) + field_17])) + (force leaf_6)))) + (force leaf_6)))) + (force leaf_6)))) + [anf_10 (con integer 0)]]) + [eq_4 field_8]])))) + [(builtin unConstrData) generated_367]]) + (delay (force leaf_6)) + (delay (force leaf_6)) + (delay (force leaf_6)) + (delay (force leaf_6))) + builtin_376))) ctx_5]) (delay (error))])) (builtin equalsInteger)]) diff --git a/crates/nash-codegen/tests/snapshots/vesting__vesting_parameter.snap b/crates/nash-codegen/tests/snapshots/vesting__vesting_parameter.snap index 1c16034f..f08fa755 100644 --- a/crates/nash-codegen/tests/snapshots/vesting__vesting_parameter.snap +++ b/crates/nash-codegen/tests/snapshots/vesting__vesting_parameter.snap @@ -1013,509 +1013,546 @@ case@Data ctx#434 of [(lam leaf_7 [(lam generated_369 (force - [[[[[[builtin_378 generated_369] - (delay - [(lam field_8 - (case - field_8 - (lam field_9 - (lam field_10 - [(lam anf_11 - [(lam anf_12 - (case - anf_12 - (force leaf_7) + (case + (constr 0 + generated_369 + (delay + [(lam field_8 + (case + field_8 + (lam field_9 + (lam field_10 + [(lam anf_11 + [(lam anf_12 (case - field_10 - (lam field_13 - (lam field_14 - (case - field_14 - (lam field_15 - (lam field_17 - (case - field_17 - (lam field_18 - (lam field_20 - [(lam generated_370 - (force - [[[[[[builtin_378 generated_370] - (delay - [(lam field_21 - (case - field_21 - (lam field_22 - (lam field_23 - [(lam anf_28 - [(lam anf_48 - (case - anf_48 - (force leaf_7) - (case - field_23 - (lam field_54 - (lam field_55 - (case - field_55 - (lam field_56 - (lam field_57 - [(lam generated_371 - (force - [[[[[[builtin_378 generated_371] - (delay - [(lam field_58 - (case - field_58 - (lam field_59 - (lam field_60 - [(lam anf_61 - [(lam anf_62 - (case - anf_62 - (force leaf_7) - (case - field_60 - (lam field_63 - (lam field_64 + anf_12 + (force leaf_7) + (case + field_10 + (lam field_13 + (lam field_14 + (case + field_14 + (lam field_15 + (lam field_17 + (case + field_17 + (lam field_18 + (lam field_20 + [(lam generated_370 + (force + (case + (constr 0 + generated_370 + (delay + [(lam field_21 + (case + field_21 + (lam field_22 + (lam field_23 + [(lam anf_28 + [(lam anf_48 + (case + anf_48 + (force leaf_7) + (case + field_23 + (lam field_54 + (lam field_55 + (case + field_55 + (lam field_56 + (lam field_57 + [(lam generated_371 + (force + (case + (constr 0 + generated_371 + (delay + [(lam field_58 + (case + field_58 + (lam field_59 + (lam field_60 + [(lam anf_61 + [(lam anf_62 + (case + anf_62 + (force leaf_7) (case - field_64 - (lam field_355 (lam field_356 (force leaf_7))) - (case - field_57 - (lam field_353 (lam field_354 (force leaf_7))) - (case - field_20 - (lam field_351 (lam field_352 (force leaf_7))) - [(lam projection_65 + field_60 + (lam field_63 + (lam field_64 + (case + field_64 + (lam field_355 (lam field_356 (force leaf_7))) (case - projection_65 - (lam tag_66 - (lam fields_67 + field_57 + (lam field_353 (lam field_354 (force leaf_7))) + (case + field_20 + (lam field_351 (lam field_352 (force leaf_7))) + [(lam projection_65 (case - tag_66 - [(lam projection_68 - (case - projection_68 - (lam tag_69 - (lam fields_70 + projection_65 + (lam tag_66 + (lam fields_67 + (case + tag_66 + [(lam projection_68 (case - fields_70 - (lam head_71 - (lam tail_72 + projection_68 + (lam tag_69 + (lam fields_70 (case - tail_72 - (lam head_73 - (lam tail_74 - [(lam anf_75 - [(lam anf_76 - [(lam leaf_77 - [(lam anf_236 - [(lam anf_237 - (case anf_237 (force [[builtin_372 message_3] (delay (error))]) (con unit ()))) - [[(builtin lessThanInteger) anf_76] anf_236]]) - [(lam generated_373 - (force - [[[[[[builtin_378 generated_373] - (delay - [(lam field_78 + fields_70 + (lam head_71 + (lam tail_72 + (case + tail_72 + (lam head_73 + (lam tail_74 + [(lam anf_75 + [(lam anf_76 + [(lam leaf_77 + [(lam anf_236 + [(lam anf_237 + (case anf_237 (force [[builtin_372 message_3] (delay (error))]) (con unit ()))) + [[(builtin lessThanInteger) anf_76] anf_236]]) + [(lam generated_373 + (force (case - field_78 - (lam field_79 - (lam field_80 - [(lam anf_81 - [(lam anf_82 - (case - anf_82 - (force leaf_77) - (case - field_80 - (lam field_83 - (lam field_84 - (case - field_84 - (lam field_85 - (lam field_86 - (case - field_86 - (lam field_87 - (lam field_88 - (case - field_88 - (lam field_89 - (lam field_90 - (case - field_90 - (lam field_91 - (lam field_92 - (case - field_92 - (lam field_93 - (lam field_94 - (case - field_94 - (lam field_95 - (lam field_96 - (case - field_96 - (lam field_97 - (lam field_98 - [(lam generated_374 - (force - [[[[[[builtin_378 generated_374] - (delay - [(lam field_99 - (case - field_99 - (lam field_100 - (lam field_101 - [(lam anf_102 - [(lam anf_103 - (case - anf_103 - (force leaf_77) - (case - field_101 - (lam field_104 - (lam field_105 - [(lam generated_375 - (force - [[[[[[builtin_378 generated_375] - (delay - [(lam field_106 - (case - field_106 - (lam field_107 - (lam field_108 - [(lam anf_109 - [(lam anf_110 - (case - anf_110 - (force leaf_77) - (case - field_108 - (lam field_111 - (lam field_112 - [(lam generated_376 - (force - [[[[[[builtin_378 generated_376] - (delay - [(lam field_113 - (case - field_113 - (lam field_114 - (lam field_115 - [(lam anf_116 - [(lam anf_117 - (case - anf_117 - (force leaf_77) - (case - field_115 - (lam field_118 - (lam field_119 - [(lam generated_377 - (force - [[[[[[builtin_378 generated_377] (delay (force leaf_77))] (delay (force leaf_77))] - (delay (force leaf_77))] - (delay - [(lam field_123 - (case - field_119 - (lam field_217 (lam field_218 (force leaf_77))) - (case - field_112 - (lam field_129 - (lam field_156 - (case - field_156 - (lam field_215 (lam field_216 (force leaf_77))) - (case - field_105 - (lam field_182 - (lam field_183 - (case - field_183 - (lam field_213 (lam field_214 (force leaf_77))) - (case - field_98 - (lam field_184 - (lam field_185 - (case - field_185 - (lam field_186 - (lam field_187 - (case - field_187 - (lam field_188 - (lam field_197 - (case - field_197 - (lam field_198 - (lam field_199 - (case - field_199 - (lam field_200 - (lam field_201 - (case - field_201 - (lam field_202 - (lam field_203 - (case - field_203 - (lam field_207 - (lam field_208 - (case - field_208 - (lam field_209 - (lam field_210 - (case field_210 (lam field_211 (lam field_212 (force leaf_77))) field_123))) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77))))) - (force leaf_77))))) - (force leaf_77)))) - [(builtin unIData) generated_377]])] - (delay (force leaf_77))])) - field_118])) - (force leaf_77)))) - [anf_116 (con integer 1)]]) - [eq_4 field_114]])))) - [(builtin unConstrData) generated_376]])] - (delay (force leaf_77))] - (delay (force leaf_77))] - (delay (force leaf_77))] - (delay (force leaf_77))])) - field_111])) - (force leaf_77)))) - [anf_109 (con integer 0)]]) - [eq_4 field_107]])))) - [(builtin unConstrData) generated_375]])] - (delay (force leaf_77))] - (delay (force leaf_77))] - (delay (force leaf_77))] - (delay (force leaf_77))])) - field_104])) - (force leaf_77)))) - [anf_102 (con integer 0)]]) - [eq_4 field_100]])))) - [(builtin unConstrData) generated_374]])] - (delay (force leaf_77))] - (delay (force leaf_77))] - (delay (force leaf_77))] - (delay (force leaf_77))])) - field_97])) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77)))) - (force leaf_77)))) - [anf_81 (con integer 0)]]) - [eq_4 field_79]])))) - [(builtin unConstrData) generated_373]])] - (delay (force leaf_77))] - (delay (force leaf_77))] - (delay (force leaf_77))] - (delay (force leaf_77))])) - field_13]]) - (delay (error))]) - [[(builtin addInteger) anf_75] minimumLock_5]]) - [(builtin unIData) head_73]])) - (error)))) - (error)))))) - [(builtin unConstrData) field_63]] - [(lam projection_238 - (case - projection_238 - (lam tag_239 - (lam fields_240 - (case - fields_240 - (lam head_241 - (lam tail_242 - [(lam leaf_243 - [(lam anf_350 - (case anf_350 (force [[builtin_372 message_3] (delay (error))]) (con unit ()))) - [(lam generated_379 - (force - [[[[[[builtin_378 generated_379] - (delay - [(lam field_244 - (case - field_244 - (lam field_245 - (lam field_246 - [(lam anf_247 - [(lam anf_248 - (case - anf_248 - (force leaf_243) - (case - field_246 - (lam field_249 - (lam field_250 + (constr 0 + generated_373 + (delay + [(lam field_78 (case - field_250 - (lam field_251 - (lam field_252 - (case - field_252 - (lam field_253 - (lam field_254 + field_78 + (lam field_79 + (lam field_80 + [(lam anf_81 + [(lam anf_82 + (case + anf_82 + (force leaf_77) (case - field_254 - (lam field_255 - (lam field_256 + field_80 + (lam field_83 + (lam field_84 (case - field_256 - (lam field_257 - (lam field_258 + field_84 + (lam field_85 + (lam field_86 (case - field_258 - (lam field_259 - (lam field_260 + field_86 + (lam field_87 + (lam field_88 (case - field_260 - (lam field_261 - (lam field_262 + field_88 + (lam field_89 + (lam field_90 (case - field_262 - (lam field_263 - (lam field_264 + field_90 + (lam field_91 + (lam field_92 (case - field_264 - (lam field_265 - (lam field_266 - [(lam generated_380 - (force - [[[[[[builtin_378 generated_380] (delay (force leaf_243))] - (delay (force leaf_243))] - (delay - [(lam field_269 - (case - field_266 - (lam field_270 - (lam field_271 + field_92 + (lam field_93 + (lam field_94 + (case + field_94 + (lam field_95 + (lam field_96 + (case + field_96 + (lam field_97 + (lam field_98 + [(lam generated_374 + (force (case - field_271 - (lam field_272 - (lam field_273 - (case - field_273 - (lam field_274 - (lam field_275 - (case - field_275 - (lam field_276 - (lam field_277 + (constr 0 + generated_374 + (delay + [(lam field_99 + (case + field_99 + (lam field_100 + (lam field_101 + [(lam anf_102 + [(lam anf_103 (case - field_277 - (lam field_278 - (lam field_279 - (case - field_279 - (lam field_280 - (lam field_281 + anf_103 + (force leaf_77) + (case + field_101 + (lam field_104 + (lam field_105 + [(lam generated_375 + (force (case - field_281 - (lam field_282 - (lam field_283 - (case - field_283 - (lam field_299 (lam field_335 (force leaf_243))) - [(lam anf_284 - [(lam worker_297 [worker_297 field_269]) - [(lam self_285 [self_285 self_285]) - (lam self_286 - (lam signers_287 - [(lam leaf_288 + (constr 0 + generated_375 + (delay + [(lam field_106 + (case + field_106 + (lam field_107 + (lam field_108 + [(lam anf_109 + [(lam anf_110 + (case + anf_110 + (force leaf_77) (case - signers_287 - (lam field_289 - (lam field_290 - [(lam generated_381 + field_108 + (lam field_111 + (lam field_112 + [(lam generated_376 (force - [[[[[[builtin_378 generated_381] (delay (force leaf_288))] - (delay (force leaf_288))] - (delay (force leaf_288))] - (delay (force leaf_288))] - (delay - [(lam field_295 - [(lam anf_296 (case anf_296 [[self_286 self_286] field_290] (con bool True))) - [[(builtin equalsByteString) field_295] anf_284]]) - [(builtin unBData) generated_381]])])) - field_289])) - (con bool False))) - (delay (error))]))]]) - [(builtin unBData) head_241]]))) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243))) - [(builtin unListData) generated_380]])] - (delay (force leaf_243))] - (delay (force leaf_243))])) - field_265])) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243)))) - (force leaf_243)))) - [anf_247 (con integer 0)]]) - [eq_4 field_245]])))) - [(builtin unConstrData) generated_379]])] - (delay (force leaf_243))] - (delay (force leaf_243))] - (delay (force leaf_243))] - (delay (force leaf_243))])) - field_13]]) - (delay (error))])) - (error)))))) - [(builtin unConstrData) field_63]]))))) - [(builtin unConstrData) field_15]]))))) - (force leaf_7)))) - [anf_61 (con integer 0)]]) - [eq_4 field_59]])))) - [(builtin unConstrData) generated_371]])] - (delay (force leaf_7))] - (delay (force leaf_7))] - (delay (force leaf_7))] - (delay (force leaf_7))])) - field_56])) - (force leaf_7)))) - (force leaf_7)))) - [anf_28 (con integer 1)]]) - [eq_4 field_22]])))) - [(builtin unConstrData) generated_370]])] - (delay (force leaf_7))] - (delay (force leaf_7))] - (delay (force leaf_7))] - (delay (force leaf_7))])) - field_18])) - (force leaf_7)))) - (force leaf_7)))) - (force leaf_7)))) - [anf_11 (con integer 0)]]) - [eq_4 field_9]])))) - [(builtin unConstrData) generated_369]])] - (delay (force leaf_7))] - (delay (force leaf_7))] - (delay (force leaf_7))] - (delay (force leaf_7))])) + (case + (constr 0 + generated_376 + (delay + [(lam field_113 + (case + field_113 + (lam field_114 + (lam field_115 + [(lam anf_116 + [(lam anf_117 + (case + anf_117 + (force leaf_77) + (case + field_115 + (lam field_118 + (lam field_119 + [(lam generated_377 + (force + (case + (constr 0 + generated_377 + (delay (force leaf_77)) + (delay (force leaf_77)) + (delay (force leaf_77)) + (delay + [(lam field_123 + (case + field_119 + (lam field_217 (lam field_218 (force leaf_77))) + (case + field_112 + (lam field_129 + (lam field_156 + (case + field_156 + (lam field_215 (lam field_216 (force leaf_77))) + (case + field_105 + (lam field_182 + (lam field_183 + (case + field_183 + (lam field_213 (lam field_214 (force leaf_77))) + (case + field_98 + (lam field_184 + (lam field_185 + (case + field_185 + (lam field_186 + (lam field_187 + (case + field_187 + (lam field_188 + (lam field_197 + (case + field_197 + (lam field_198 + (lam field_199 + (case + field_199 + (lam field_200 + (lam field_201 + (case + field_201 + (lam field_202 + (lam field_203 + (case + field_203 + (lam field_207 + (lam field_208 + (case + field_208 + (lam field_209 + (lam field_210 + (case field_210 (lam field_211 (lam field_212 (force leaf_77))) field_123))) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77))))) + (force leaf_77))))) + (force leaf_77)))) + [(builtin unIData) generated_377]]) + (delay (force leaf_77))) + builtin_378))) + field_118])) + (force leaf_77)))) + [anf_116 (con integer 1)]]) + [eq_4 field_114]])))) + [(builtin unConstrData) generated_376]]) + (delay (force leaf_77)) + (delay (force leaf_77)) + (delay (force leaf_77)) + (delay (force leaf_77))) + builtin_378))) + field_111])) + (force leaf_77)))) + [anf_109 (con integer 0)]]) + [eq_4 field_107]])))) + [(builtin unConstrData) generated_375]]) + (delay (force leaf_77)) + (delay (force leaf_77)) + (delay (force leaf_77)) + (delay (force leaf_77))) + builtin_378))) + field_104])) + (force leaf_77)))) + [anf_102 (con integer 0)]]) + [eq_4 field_100]])))) + [(builtin unConstrData) generated_374]]) + (delay (force leaf_77)) + (delay (force leaf_77)) + (delay (force leaf_77)) + (delay (force leaf_77))) + builtin_378))) + field_97])) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77)))) + (force leaf_77)))) + [anf_81 (con integer 0)]]) + [eq_4 field_79]])))) + [(builtin unConstrData) generated_373]]) + (delay (force leaf_77)) + (delay (force leaf_77)) + (delay (force leaf_77)) + (delay (force leaf_77))) + builtin_378))) + field_13]]) + (delay (error))]) + [[(builtin addInteger) anf_75] minimumLock_5]]) + [(builtin unIData) head_73]])) + (error)))) + (error)))))) + [(builtin unConstrData) field_63]] + [(lam projection_238 + (case + projection_238 + (lam tag_239 + (lam fields_240 + (case + fields_240 + (lam head_241 + (lam tail_242 + [(lam leaf_243 + [(lam anf_350 + (case anf_350 (force [[builtin_372 message_3] (delay (error))]) (con unit ()))) + [(lam generated_379 + (force + (case + (constr 0 + generated_379 + (delay + [(lam field_244 + (case + field_244 + (lam field_245 + (lam field_246 + [(lam anf_247 + [(lam anf_248 + (case + anf_248 + (force leaf_243) + (case + field_246 + (lam field_249 + (lam field_250 + (case + field_250 + (lam field_251 + (lam field_252 + (case + field_252 + (lam field_253 + (lam field_254 + (case + field_254 + (lam field_255 + (lam field_256 + (case + field_256 + (lam field_257 + (lam field_258 + (case + field_258 + (lam field_259 + (lam field_260 + (case + field_260 + (lam field_261 + (lam field_262 + (case + field_262 + (lam field_263 + (lam field_264 + (case + field_264 + (lam field_265 + (lam field_266 + [(lam generated_380 + (force + (case + (constr 0 + generated_380 + (delay (force leaf_243)) + (delay (force leaf_243)) + (delay + [(lam field_269 + (case + field_266 + (lam field_270 + (lam field_271 + (case + field_271 + (lam field_272 + (lam field_273 + (case + field_273 + (lam field_274 + (lam field_275 + (case + field_275 + (lam field_276 + (lam field_277 + (case + field_277 + (lam field_278 + (lam field_279 + (case + field_279 + (lam field_280 + (lam field_281 + (case + field_281 + (lam field_282 + (lam field_283 + (case + field_283 + (lam field_299 (lam field_335 (force leaf_243))) + [(lam anf_284 + [(lam worker_297 [worker_297 field_269]) + [(lam self_285 [self_285 self_285]) + (lam self_286 + (lam signers_287 + [(lam leaf_288 + (case + signers_287 + (lam field_289 + (lam field_290 + [(lam generated_381 + (force + (case + (constr 0 + generated_381 + (delay (force leaf_288)) + (delay (force leaf_288)) + (delay (force leaf_288)) + (delay (force leaf_288)) + (delay + [(lam field_295 + [(lam anf_296 (case anf_296 [[self_286 self_286] field_290] (con bool True))) + [[(builtin equalsByteString) field_295] anf_284]]) + [(builtin unBData) generated_381]])) + builtin_378))) + field_289])) + (con bool False))) + (delay (error))]))]]) + [(builtin unBData) head_241]]))) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243))) + [(builtin unListData) generated_380]]) + (delay (force leaf_243)) + (delay (force leaf_243))) + builtin_378))) + field_265])) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243)))) + (force leaf_243)))) + [anf_247 (con integer 0)]]) + [eq_4 field_245]])))) + [(builtin unConstrData) generated_379]]) + (delay (force leaf_243)) + (delay (force leaf_243)) + (delay (force leaf_243)) + (delay (force leaf_243))) + builtin_378))) + field_13]]) + (delay (error))])) + (error)))))) + [(builtin unConstrData) field_63]]))))) + [(builtin unConstrData) field_15]]))))) + (force leaf_7)))) + [anf_61 (con integer 0)]]) + [eq_4 field_59]])))) + [(builtin unConstrData) generated_371]]) + (delay (force leaf_7)) + (delay (force leaf_7)) + (delay (force leaf_7)) + (delay (force leaf_7))) + builtin_378))) + field_56])) + (force leaf_7)))) + (force leaf_7)))) + [anf_28 (con integer 1)]]) + [eq_4 field_22]])))) + [(builtin unConstrData) generated_370]]) + (delay (force leaf_7)) + (delay (force leaf_7)) + (delay (force leaf_7)) + (delay (force leaf_7))) + builtin_378))) + field_18])) + (force leaf_7)))) + (force leaf_7)))) + (force leaf_7)))) + [anf_11 (con integer 0)]]) + [eq_4 field_9]])))) + [(builtin unConstrData) generated_369]]) + (delay (force leaf_7)) + (delay (force leaf_7)) + (delay (force leaf_7)) + (delay (force leaf_7))) + builtin_378))) ctx_6]) (delay (error))]))) (builtin equalsInteger)]) diff --git a/crates/nash-codegen/tests/support/constant_fold.rs b/crates/nash-codegen/tests/support/constant_fold.rs new file mode 100644 index 00000000..61b4f819 --- /dev/null +++ b/crates/nash-codegen/tests/support/constant_fold.rs @@ -0,0 +1,224 @@ +//! Shared inputs for the constant-evaluation trial and its explicit measurements. +use nash_ir::{ + build::Builder, + core::{Binder, Core}, + ty::Ty, +}; +use nash_plutus::{ + builtin::DefaultFunction as F, constant::Constant as C, data::PlutusData as D, typ::Type, +}; + +pub fn cases<'a>(b: &Builder<'a>) -> Vec<(&'static str, &'a Core<'a>, bool)> { + let a = b.arena; + let bytes = |s| b.lit(C::byte_string(a, s)); + let string = |s| b.lit(C::string(a, s)); + let int = b.int(7); + let data = b.lit(C::data(a, D::integer_from(a, 7))); + let list = b.lit(C::proto_list( + a, + &Type::Integer, + a.alloc([C::integer_from(a, 7), C::integer_from(a, 8)]), + )); + let empty = b.lit(C::proto_list(a, &Type::Integer, &[])); + let pair = b.lit(C::proto_pair( + a, + &Type::Integer, + &Type::ByteString, + C::integer_from(a, 7), + C::byte_string(a, b"a"), + )); + let call = |f, args: &[&'a Core<'a>]| b.builtin(f, args, Ty::Erased); + let add = call(F::AddInteger, &[b.int(20), b.int(22)]); + let x = Binder { + name: b.fresh("x"), + ty: add.ty, + }; + let dlist = b.lit(C::proto_list( + a, + &Type::Data, + a.alloc([C::data(a, D::integer_from(a, 7))]), + )); + let dmap = b.lit(C::proto_list( + a, + a.alloc(Type::Pair(&Type::Data, &Type::Data)), + &[], + )); + let expanding = b.lit(C::data( + a, + D::list(a, a.alloc_slice_copy(&[D::integer_from(a, 7); 30])), + )); + let prefix = string(a.as_bump().alloc_str(&"prefix".repeat(6))); + let shared = Binder { + name: b.fresh("prefix"), + ty: prefix.ty, + }; + let shared_prefix = b.let_( + shared, + prefix, + b.constr( + 0, + &[ + call( + F::AppendString, + &[b.var(shared.name, shared.ty), string("x")], + ), + call( + F::AppendString, + &[b.var(shared.name, shared.ty), string("y")], + ), + ], + Ty::Erased, + ), + ); + let distinct_results = b.constr( + 0, + &[ + call(F::AppendString, &[prefix, string("x")]), + call(F::AppendString, &[prefix, string("y")]), + ], + Ty::Erased, + ); + vec![ + ("shared_prefix_distinct_results", shared_prefix, false), + ("repeated_literal_distinct_results", distinct_results, false), + ( + "expanding_data_list", + call(F::UnListData, &[expanding]), + false, + ), + ("addition", add, false), + ( + "nested_arithmetic", + call(F::MultiplyInteger, &[add, b.int(2)]), + false, + ), + ( + "bound_arithmetic", + b.let_( + x, + add, + call(F::MultiplyInteger, &[b.var(x.name, x.ty), b.int(2)]), + ), + false, + ), + ( + "division", + call(F::DivideInteger, &[b.int(-7), b.int(3)]), + false, + ), + ( + "division_zero", + call(F::DivideInteger, &[int, b.int(0)]), + true, + ), + ( + "wrong_integer_shape", + call(F::AddInteger, &[bytes(b"x"), int]), + true, + ), + ( + "byte_append", + call(F::AppendByteString, &[bytes(b"ab"), bytes(b"cd")]), + false, + ), + ( + "byte_slice", + call(F::SliceByteString, &[b.int(1), b.int(2), bytes(b"abcd")]), + false, + ), + ( + "byte_length", + call(F::LengthOfByteString, &[bytes(b"abcd")]), + false, + ), + ( + "byte_compare", + call(F::LessThanByteString, &[bytes(b"abc"), bytes(b"abd")]), + false, + ), + ( + "string_append", + call(F::AppendString, &[string("hello "), string("world")]), + false, + ), + ("encode_utf8", call(F::EncodeUtf8, &[string("สวัสดี")]), false), + ( + "decode_utf8", + call(F::DecodeUtf8, &[bytes("héllo".as_bytes())]), + false, + ), + ("invalid_utf8", call(F::DecodeUtf8, &[bytes(&[255])]), true), + ("integer_data", call(F::IData, &[int]), false), + ("decode_integer_data", call(F::UnIData, &[data]), false), + ("wrong_data_variant", call(F::UnBData, &[data]), true), + ("list_data", call(F::ListData, &[dlist]), false), + ("map_data", call(F::MapData, &[dmap]), false), + ("data_equal", call(F::EqualsData, &[data, data]), false), + ("serialise_data", call(F::SerialiseData, &[data]), false), + ("list_head", call(F::HeadList, &[list]), false), + ("list_tail", call(F::TailList, &[list]), false), + ("empty_head", call(F::HeadList, &[empty]), true), + ("empty_tail", call(F::TailList, &[empty]), true), + ("list_null", call(F::NullList, &[empty]), false), + ("pair_first", call(F::FstPair, &[pair]), false), + ("pair_second", call(F::SndPair, &[pair]), false), + ("trace_before", b.trace(string("before"), add), false), + ( + "trace_builtin", + call(F::Trace, &[string("keep me"), int]), + false, + ), + ( + "cold_failure", + b.if_( + b.lit(C::bool(a, true)), + int, + call(F::DivideInteger, &[int, b.int(0)]), + ), + false, + ), + ( + "selected_branch", + b.if_( + call(F::EqualsInteger, &[int, b.int(7)]), + b.trace(string("yes"), add), + b.trace(string("no"), b.error(Ty::Erased)), + ), + false, + ), + ( + "strict_failure_order", + call( + F::AddInteger, + &[ + b.trace(string("first"), b.error(int.ty)), + call(F::DivideInteger, &[int, b.int(0)]), + ], + ), + true, + ), + ("unsupported_hash", call(F::Sha2_256, &[bytes(b"x")]), false), + ( + "partial", + b.app( + b.builtin(F::AddInteger, &[int], Ty::Erased), + &[b.int(1)], + Ty::Erased, + ), + false, + ), + ( + "large_input", + call( + F::AppendByteString, + &[bytes(a.alloc_slice_copy(&[42; 4096])), bytes(b"z")], + ), + false, + ), + ( + "repeated_call", + b.constr(0, &[add, add, add], Ty::Erased), + false, + ), + ] +} diff --git a/crates/nash-codegen/tests/support/optimizer.rs b/crates/nash-codegen/tests/support/optimizer.rs index 94150a57..84385947 100644 --- a/crates/nash-codegen/tests/support/optimizer.rs +++ b/crates/nash-codegen/tests/support/optimizer.rs @@ -25,7 +25,7 @@ pub(crate) fn optimize_with<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core /// Prepared once; rendering and evaluation share these exact programs. pub struct Prepared<'a> { core: &'a Core<'a>, - optimized: &'a Core<'a>, + pub optimized: &'a Core<'a>, pub before: program::Compiled<'a>, pub after: program::Compiled<'a>, } @@ -39,7 +39,7 @@ pub fn prepare<'a>(arena: &'a Arena, core: &'a Core<'a>) -> Prepared<'a> { let rewritten = hygiene::freshen(&b, rewritten); hygiene::validate(rewritten, &[]).unwrap(); assert_eq!(core.ty, rewritten.ty); - let named = lower::lower_with_constant_sharing(arena, rewritten).expect("optimized lowering"); + let named = lower::lower_optimized(arena, rewritten).expect("optimized lowering"); let closed = nash_plutus::debruijn::to_debruijn(arena, named).expect("closed snapshot program"); let program = Program::new(arena, Version::plutus_v3(arena), closed); nash_plutus::script::validate_program(program, nash_plutus::machine::PlutusVersion::V3) diff --git a/crates/nash-codegen/tests/support/pair_projection.rs b/crates/nash-codegen/tests/support/pair_projection.rs new file mode 100644 index 00000000..4f489a30 --- /dev/null +++ b/crates/nash-codegen/tests/support/pair_projection.rs @@ -0,0 +1,334 @@ +//! Inputs shared by pair-projection snapshots and explicit measurements. +use nash_ir::{ + build::Builder, + core::*, + ty::{ConstTy, Ty}, +}; +use nash_plutus::{ + builtin::DefaultFunction as F, constant::Constant as C, data::PlutusData as D, typ::Type, +}; + +pub fn cases<'a>(b: &Builder<'a>) -> Vec<(String, &'a Core<'a>, bool)> { + let a = b.arena; + let int = b.int(0).ty; + let pair = b.lit(C::proto_pair( + a, + &Type::Integer, + &Type::Integer, + C::integer_from(a, 7), + C::integer_from(a, 8), + )); + let data = b.lit(C::data(a, D::integer_from(a, 7))); + let made = b.builtin( + F::MkPairData, + &[data, data], + Ty::Const(a.alloc(ConstTy::Pair(data.ty, data.ty))), + ); + let unwrapped = b.builtin( + F::UnConstrData, + &[b.lit(C::data(a, D::constr(a, 0, &[])))], + Ty::Const(a.alloc(ConstTy::Pair( + int, + Ty::Const(a.alloc(ConstTy::List(data.ty))), + ))), + ); + let trace = |s, x| b.trace(b.lit(C::string(a, s)), x); + let mut cases = Vec::new(); + for (name, subject, left_ty, right_ty, fails) in [ + ("literal", pair, int, int, false), + ("traced", trace("subject", pair), int, int, false), + ("made_data", made, data.ty, data.ty, false), + ( + "decoded", + unwrapped, + int, + Ty::Const(a.alloc(ConstTy::List(data.ty))), + false, + ), + ( + "bad_decoder", + b.builtin(F::UnConstrData, &[data], unwrapped.ty), + int, + Ty::Const(a.alloc(ConstTy::List(data.ty))), + true, + ), + ( + "ignored_failure", + b.builtin( + F::MkPairData, + &[data, trace("unused field", b.error(data.ty))], + made.ty, + ), + data.ty, + data.ty, + true, + ), + ( + "wrong_subject", + b.with_type(b.int(1), pair.ty), + int, + int, + true, + ), + // Generic UPLC case accepts this, whereas fstPair would reject it. + ( + "native_constructor", + b.with_type(b.constr(0, &[b.int(7), b.int(8)], Ty::Erased), pair.ty), + int, + int, + false, + ), + ] { + for second in [false, true] { + let x = Binder { + name: b.fresh("x"), + ty: left_ty, + }; + let y = Binder { + name: b.fresh("y"), + ty: right_ty, + }; + let selected = if second { y } else { x }; + let value = b.var(selected.name, selected.ty); + let core = b.case( + CaseKind::Pair, + subject, + &[Branch { + test: Test::Pair, + binders: a.alloc([x, y]), + body: value, + }], + None, + value.ty, + ); + cases.push(( + format!("{name}_{}", if second { "second" } else { "first" }), + core, + fails, + )); + } + } + for mode in ["body", "both", "neither", "delay", "lambda", "repeated"] { + let x = Binder { + name: b.fresh("x"), + ty: int, + }; + let y = Binder { + name: b.fresh("y"), + ty: int, + }; + let xv = b.var(x.name, x.ty); + let body = match mode { + "both" => b.builtin(F::AddInteger, &[xv, b.var(y.name, y.ty)], int), + "neither" => b.int(42), + "delay" => b.delay(xv), + "lambda" => b.lam( + &[Binder { + name: b.fresh("unused"), + ty: int, + }], + xv, + ), + "repeated" => b.builtin(F::AddInteger, &[xv, xv], int), + _ => trace("body", b.builtin(F::AddInteger, &[xv, b.int(1)], int)), + }; + let core = b.case( + CaseKind::Pair, + trace("subject", pair), + &[Branch { + test: Test::Pair, + binders: a.alloc([x, y]), + body, + }], + None, + body.ty, + ); + // Force/application is after the case, exposing any misplaced strict work. + let core = match mode { + "delay" => b.force(core, int), + "lambda" => b.app(core, &[trace("argument", b.int(0))], int), + _ => core, + }; + cases.push((mode.into(), core, false)); + } + for second in [false, true] { + let select = |subject| { + let x = Binder { + name: b.fresh("x"), + ty: int, + }; + let y = Binder { + name: b.fresh("y"), + ty: int, + }; + let selected = if second { y } else { x }; + b.case( + CaseKind::Pair, + subject, + &[Branch { + test: Test::Pair, + binders: a.alloc([x, y]), + body: b.var(selected.name, int), + }], + None, + int, + ) + }; + let first = select(trace("first", pair)); + let second_core = select(trace("second", pair)); + cases.push(( + format!( + "two_projections_{}", + if second { "second" } else { "first" } + ), + b.builtin(F::AddInteger, &[first, second_core], int), + false, + )); + } + for delayed in [false, true] { + let x = Binder { + name: b.fresh("x"), + ty: int, + }; + let y = Binder { + name: b.fresh("y"), + ty: Ty::Const(a.alloc(ConstTy::List(data.ty))), + }; + let value = b.var(x.name, x.ty); + let body = if delayed { + b.delay(value) + } else { + b.lam( + &[Binder { + name: b.fresh("arg"), + ty: int, + }], + value, + ) + }; + let subject = b.builtin( + F::UnConstrData, + &[trace("before failure", data)], + unwrapped.ty, + ); + let case = b.case( + CaseKind::Pair, + subject, + &[Branch { + test: Test::Pair, + binders: a.alloc([x, y]), + body, + }], + None, + body.ty, + ); + let ignored = Binder { + name: b.fresh("ignored closure"), + ty: case.ty, + }; + cases.push(( + format!( + "unconsumed_{}_failure", + if delayed { "delay" } else { "lambda" } + ), + b.let_(ignored, case, b.int(0)), + true, + )); + } + for bad_tag in [false, true] { + for second in [false, true] { + let tag = Binder { + name: b.fresh("tag"), + ty: int, + }; + let fields_ty = Ty::Const(a.alloc(ConstTy::List(data.ty))); + let fields = Binder { + name: b.fresh("fields"), + ty: fields_ty, + }; + let encoded = Binder { + name: b.fresh("encoded"), + ty: data.ty, + }; + let decoded = Binder { + name: b.fresh("decoded"), + ty: unwrapped.ty, + }; + let x = Binder { + name: b.fresh("x"), + ty: int, + }; + let y = Binder { + name: b.fresh("y"), + ty: fields_ty, + }; + let selected = if second { y } else { x }; + let body = b.case( + CaseKind::Pair, + b.var(decoded.name, decoded.ty), + &[Branch { + test: Test::Pair, + binders: a.alloc([x, y]), + body: b.var(selected.name, selected.ty), + }], + None, + selected.ty, + ); + let body = b.let_( + decoded, + b.builtin( + F::UnConstrData, + &[b.var(encoded.name, encoded.ty)], + decoded.ty, + ), + body, + ); + let body = b.let_( + encoded, + b.builtin( + F::ConstrData, + &[b.var(tag.name, tag.ty), b.var(fields.name, fields.ty)], + encoded.ty, + ), + body, + ); + let body = b.let_( + fields, + b.builtin( + F::MkCons, + &[ + trace("field", data), + b.lit(C::proto_list(a, &Type::Data, &[])), + ], + fields_ty, + ), + body, + ); + let tag_value = if bad_tag { + let bytes = b.lit(C::data(a, D::byte_string(a, b"bad"))); + b.with_type( + b.builtin( + F::UnBData, + &[trace("tag", bytes)], + b.lit(C::byte_string(a, b"bad")).ty, + ), + int, + ) + } else { + let tag_data = b.lit(C::data(a, D::integer_from(a, 0))); + b.builtin(F::UnIData, &[trace("tag", tag_data)], int) + }; + let body = b.let_(tag, tag_value, body); + cases.push(( + format!( + "roundtrip_{}_{}", + if bad_tag { "bad_tag" } else { "valid" }, + if second { "second" } else { "first" } + ), + body, + bad_tag, + )); + } + } + cases +} diff --git a/crates/nash-codegen/tests/support/recursive_params.rs b/crates/nash-codegen/tests/support/recursive_params.rs new file mode 100644 index 00000000..07507337 --- /dev/null +++ b/crates/nash-codegen/tests/support/recursive_params.rs @@ -0,0 +1,215 @@ +//! Recursive parameter fixtures shared with the explicit performance workspace. +use nash_ir::{ + build::Builder, + core::*, + ty::{ConstTy, TermTy, Ty}, +}; +use nash_plutus::{builtin::DefaultFunction as F, constant::Constant}; + +pub fn cases<'a>(b: &Builder<'a>) -> Vec<(&'static str, &'a Core<'a>, bool)> { + let a = b.arena; + let int = b.int(0).ty; + let bool_ = Ty::Const(&ConstTy::Bool); + let fun = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int, int]), int))); + let bind = |text, ty| Binder { + name: b.fresh(text), + ty, + }; + let trace = |text, value| b.trace(b.lit(Constant::string(a, text)), value); + let mut cases = Vec::new(); + for (name, mutual, consumed, effects, failure) in [ + ("self_forwarding", false, false, false, false), + ("mutual_forwarding", true, false, false, false), + ("mutual_consumed", true, true, false, false), + ("recursive_trace_order", true, false, true, false), + ("recursive_failure_order", true, false, true, true), + ] { + let f = bind("f", fun); + let g = bind("g", fun); + let x = bind("x", int); + let n = bind("n", int); + let m = bind("m", int); + let y = bind("y", int); + let step = |target: Binder<'a>, unused: Binder<'a>, count: Binder<'a>, swapped: bool| { + let next = b.builtin(F::SubtractInteger, &[b.var(count.name, int), b.int(1)], int); + let discarded = if failure { + trace("discarded", b.error(int)) + } else if effects { + trace("discarded", b.int(7)) + } else { + b.var(unused.name, int) + }; + let next = if effects { + trace("retained", next) + } else { + next + }; + let args = if swapped { + [next, discarded] + } else { + [discarded, next] + }; + b.if_( + b.builtin(F::EqualsInteger, &[b.var(count.name, int), b.int(0)], bool_), + if consumed { + b.var(unused.name, int) + } else { + b.int(42) + }, + b.app(b.var(target.name, fun), &args, int), + ) + }; + let mut group = vec![RecBinder { + binder: f, + params: a.alloc_slice_copy(&[x, n]), + static_params: &[], + body: step(if mutual { g } else { f }, x, n, mutual), + }]; + if mutual { + group.push(RecBinder { + binder: g, + params: a.alloc_slice_copy(&[m, y]), + static_params: &[], + body: step(f, y, m, false), + }); + } + cases.push(( + name, + b.let_rec( + &group, + b.app(b.var(f.name, fun), &[b.int(7), b.int(3)], int), + ), + failure, + )); + } + // Removing every parameter must keep definitions cold and execute each call. + for (name, mutual, cold) in [ + ("all_unused_self", false, false), + ("all_unused_mutual", true, false), + ("all_unused_cold", true, true), + ] { + let unary = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int]), int))); + let f = bind("f", unary); + let g = bind("g", unary); + let x = bind("x", int); + let y = bind("y", int); + let invoke = |target: Binder<'a>, arg| b.app(b.var(target.name, unary), &[arg], int); + let body = b.if_( + b.lit(Constant::bool(a, true)), + trace("body", b.int(21)), + invoke(if mutual { g } else { f }, b.var(x.name, int)), + ); + let mut group = vec![RecBinder { + binder: f, + params: a.alloc_slice_copy(&[x]), + static_params: &[], + body, + }]; + if mutual { + group.push(RecBinder { + binder: g, + params: a.alloc_slice_copy(&[y]), + static_params: &[], + body: invoke(f, b.var(y.name, int)), + }); + } + let calls = b.builtin( + F::AddInteger, + &[ + invoke(f, trace("entry1", b.int(0))), + invoke(if mutual { g } else { f }, trace("entry2", b.int(1))), + ], + int, + ); + let calls = if cold { + b.if_(b.lit(Constant::bool(a, true)), b.int(42), calls) + } else { + calls + }; + cases.push((name, b.let_rec(&group, calls), false)); + } + + for name in [ + "entry_failure", + "partial", + "escaping", + "oversaturated", + "compound_dependency", + "mixed_delayed", + ] { + let f = bind("f", fun); + let g = bind("g", fun); + let x = bind("x", int); + let n = bind("n", int); + let y = bind("y", int); + let m = bind("m", int); + let unary = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int]), int))); + let next = b.builtin(F::SubtractInteger, &[b.var(n.name, int), b.int(1)], int); + let forwarded = if name == "compound_dependency" { + b.builtin(F::AddInteger, &[b.var(x.name, int), b.int(1)], int) + } else { + b.var(x.name, int) + }; + let body = b.if_( + b.builtin(F::EqualsInteger, &[b.var(n.name, int), b.int(0)], bool_), + b.int(42), + b.app(b.var(f.name, fun), &[forwarded, next], int), + ); + let mut group = vec![RecBinder { + binder: f, + params: a.alloc_slice_copy(&[x, n]), + static_params: &[], + body, + }]; + let invoke = b.app(b.var(f.name, fun), &[b.int(7), b.int(2)], int); + let entry = match name { + "entry_failure" => b.app( + b.var(f.name, fun), + &[trace("first", b.error(int)), trace("later", b.int(2))], + int, + ), + "partial" => b.app( + b.app(b.var(f.name, fun), &[b.int(7)], unary), + &[b.int(2)], + int, + ), + "escaping" => { + let alias = bind("alias", fun); + b.let_( + alias, + b.var(f.name, fun), + b.app(b.var(alias.name, fun), &[b.int(7), b.int(2)], int), + ) + } + "oversaturated" => { + let z = bind("z", int); + let ty = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int, int]), unary))); + group[0].binder.ty = ty; + group[0].body = b.lam(&[z], b.var(z.name, int)); + b.app(b.var(f.name, ty), &[b.int(0), b.int(0), b.int(42)], int) + } + "mixed_delayed" => { + group.push(RecBinder { + binder: g, + params: a.alloc_slice_copy(&[y, m]), + static_params: &[], + body: trace( + "delayed", + b.app(b.var(f.name, fun), &[b.int(7), b.int(2)], int), + ), + }); + b.builtin( + F::AddInteger, + &[ + invoke, + b.app(b.var(g.name, fun), &[b.int(0), b.int(0)], int), + ], + int, + ) + } + _ => invoke, + }; + cases.push((name, b.let_rec(&group, entry), name == "entry_failure")); + } + cases +} diff --git a/crates/nash-config/README.md b/crates/nash-config/README.md index 57bd11ba..81c734c7 100644 --- a/crates/nash-config/README.md +++ b/crates/nash-config/README.md @@ -105,7 +105,6 @@ Applications and packages accept these optional top-level fields: | Field | Values | Default | | --- | --- | --- | -| `plutusVersion` | `"v1"`, `"v2"`, `"v3"` | `"v3"` | | `traceLevel` | `"silent"`, `"compact"`, `"verbose"` | `"silent"` | | `compilerTraces` | `true`, `false` | `false` | diff --git a/crates/nash-config/nash.schema.json b/crates/nash-config/nash.schema.json index 5a3f10e3..2f43fe9d 100644 --- a/crates/nash-config/nash.schema.json +++ b/crates/nash-config/nash.schema.json @@ -16,11 +16,6 @@ "type": { "const": "application" }, - "plutusVersion": { - "type": "string", - "enum": ["v1", "v2", "v3"], - "default": "v3" - }, "traceLevel": { "type": "string", "enum": ["silent", "compact", "verbose"], @@ -53,11 +48,6 @@ "type": { "const": "package" }, - "plutusVersion": { - "type": "string", - "enum": ["v1", "v2", "v3"], - "default": "v3" - }, "traceLevel": { "type": "string", "enum": ["silent", "compact", "verbose"], diff --git a/crates/nash-config/src/config.rs b/crates/nash-config/src/config.rs index 9f0fcb45..d9e054ed 100644 --- a/crates/nash-config/src/config.rs +++ b/crates/nash-config/src/config.rs @@ -18,16 +18,6 @@ pub enum Config { Workspace(Workspace), } -/// Plutus ledger language version used for validator compilation. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)] -#[serde(rename_all = "lowercase")] -pub enum PlutusVersion { - V1, - V2, - #[default] - V3, -} - /// Amount of user trace information included in compiled validators. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)] #[serde(rename_all = "lowercase")] @@ -38,13 +28,14 @@ pub enum TraceLevel { Verbose, } -/// Optimization is independent of user and compiler trace settings. +/// O0/O1 preserve the selected trace policy; O2 requires silent scripts. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)] #[serde(try_from = "u8", into = "u8")] pub enum OptimizationLevel { O0, #[default] O1, + O2, } impl TryFrom for OptimizationLevel { type Error = &'static str; @@ -52,7 +43,8 @@ impl TryFrom for OptimizationLevel { match value { 0 => Ok(Self::O0), 1 => Ok(Self::O1), - _ => Err("expected optimization level 0 or 1"), + 2 => Ok(Self::O2), + _ => Err("expected optimization level 0, 1, or 2"), } } } @@ -61,6 +53,7 @@ impl From for u8 { match value { OptimizationLevel::O0 => 0, OptimizationLevel::O1 => 1, + OptimizationLevel::O2 => 2, } } } @@ -70,7 +63,8 @@ impl std::str::FromStr for OptimizationLevel { match value { "0" => Ok(Self::O0), "1" => Ok(Self::O1), - _ => Err("expected optimization level 0 or 1"), + "2" => Ok(Self::O2), + _ => Err("expected optimization level 0, 1, or 2"), } } } @@ -82,10 +76,9 @@ impl OptimizationLevel { /// Project build settings, stored at the top level of `nash.jsonc`. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)] -#[serde(from = "BuildFields", into = "BuildFields")] +#[serde(try_from = "BuildFields", into = "BuildFields")] pub struct Build { pub optimize: OptimizationLevel, - pub plutus_version: PlutusVersion, pub trace_level: TraceLevel, /// Distinguishes an explicit silent setting from the command-specific default. pub trace_level_explicit: bool, @@ -97,23 +90,23 @@ pub struct Build { struct BuildFields { #[serde(default, skip_serializing_if = "OptimizationLevel::is_default")] optimize: OptimizationLevel, - #[serde(default)] - plutus_version: PlutusVersion, #[serde(default, skip_serializing_if = "Option::is_none")] trace_level: Option, #[serde(default)] compiler_traces: bool, } -impl From for Build { - fn from(fields: BuildFields) -> Self { - Self { +impl TryFrom for Build { + type Error = BuildConflict; + fn try_from(fields: BuildFields) -> Result { + let build = Self { optimize: fields.optimize, - plutus_version: fields.plutus_version, trace_level: fields.trace_level.unwrap_or_default(), trace_level_explicit: fields.trace_level.is_some(), compiler_traces: fields.compiler_traces, - } + }; + build.validate()?; + Ok(build) } } @@ -121,7 +114,6 @@ impl From for BuildFields { fn from(build: Build) -> Self { Self { optimize: build.optimize, - plutus_version: build.plutus_version, trace_level: (build.trace_level_explicit || build.trace_level != TraceLevel::Silent) .then_some(build.trace_level), compiler_traces: build.compiler_traces, @@ -129,8 +121,33 @@ impl From for BuildFields { } } +#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)] +pub enum BuildConflict { + #[error("O2 requires silent tracing; compact and verbose tracing are not supported")] + UserTraces, + #[error("O2 does not support compiler traces")] + CompilerTraces, +} + impl Build { + /// Validate effective settings after command overrides, before defaults. + pub fn validate(self) -> Result<(), BuildConflict> { + if self.optimize == OptimizationLevel::O2 { + if self.trace_level != TraceLevel::Silent { + return Err(BuildConflict::UserTraces); + } + if self.compiler_traces { + return Err(BuildConflict::CompilerTraces); + } + } + Ok(()) + } + pub fn for_tests(mut self) -> Self { + if self.optimize == OptimizationLevel::O2 { + // Keep explicit conflicting settings so validation can reject them. + return self; + } if !self.trace_level_explicit { self.trace_level = TraceLevel::Verbose; } diff --git a/crates/nash-config/src/error.rs b/crates/nash-config/src/error.rs index 06dac117..ae1a546c 100644 --- a/crates/nash-config/src/error.rs +++ b/crates/nash-config/src/error.rs @@ -98,9 +98,16 @@ pub enum ConfigError { expected: &'static str, }, - #[error("'{path}' at {pos}: 'optimize' must be the integer 0 or 1")] + #[error("'{path}' at {pos}: 'optimize' must be the integer 0, 1, or 2")] InvalidOptimization { path: PathBuf, pos: Position }, + #[error("'{path}' at {pos}: {source}")] + BuildConflict { + path: PathBuf, + pos: Position, + source: crate::BuildConflict, + }, + #[error( "'{path}' at {pos}: '{field}' must be set in workspace members, not the workspace config" )] diff --git a/crates/nash-config/src/lib.rs b/crates/nash-config/src/lib.rs index 273fe2da..894269e7 100644 --- a/crates/nash-config/src/lib.rs +++ b/crates/nash-config/src/lib.rs @@ -73,8 +73,8 @@ mod name; mod parse; pub use config::{ - Application, Build, CONFIG_FILE_NAME, Config, Dependency, DependencySource, ExposedModules, - GitDep, OptimizationLevel, Package, PathDep, PlutusVersion, TraceLevel, Workspace, + Application, Build, BuildConflict, CONFIG_FILE_NAME, Config, Dependency, DependencySource, + ExposedModules, GitDep, OptimizationLevel, Package, PathDep, TraceLevel, Workspace, WorkspaceDep, }; pub use error::{ConfigError, Position}; diff --git a/crates/nash-config/src/parse.rs b/crates/nash-config/src/parse.rs index 9a3d5ec1..200edd68 100644 --- a/crates/nash-config/src/parse.rs +++ b/crates/nash-config/src/parse.rs @@ -12,7 +12,7 @@ use jsonc_parser::{CollectOptions, ParseOptions, parse_to_ast}; use crate::config::{ Application, Build, Config, Dependency, DependencySource, ExposedModules, GitDep, Package, - PathDep, PlutusVersion, TraceLevel, Workspace, WorkspaceDep, + PathDep, TraceLevel, Workspace, WorkspaceDep, }; use crate::error::{ConfigError, Position}; use crate::name::{PackageName, PackageNameError}; @@ -110,19 +110,6 @@ fn parse_build(contents: &str, path: &Path, obj: &Object) -> Result PlutusVersion::V3, - Some("v1") => PlutusVersion::V1, - Some("v2") => PlutusVersion::V2, - Some(other) => { - return Err(invalid_enum( - "plutusVersion", - other.into(), - "'v1', 'v2', or 'v3'", - )); - } - }; let trace_level = match parse_optional_string(contents, path, obj, "traceLevel")?.as_deref() { None | Some("silent") => TraceLevel::Silent, Some("compact") => TraceLevel::Compact, @@ -157,13 +144,23 @@ fn parse_build(contents: &str, path: &Path, obj: &Object) -> Result Result { @@ -215,7 +212,7 @@ fn parse_package(contents: &str, path: &Path, obj: &Object) -> Result Result { - for field in ["plutusVersion", "traceLevel", "compilerTraces", "optimize"] { + for field in ["traceLevel", "compilerTraces", "optimize"] { if let Some(prop) = find_property(obj, field) { return Err(ConfigError::WorkspaceBuildSetting { path: path.into(), @@ -852,7 +849,7 @@ mod tests { #[cfg(test)] mod build_tests { use super::*; - use crate::{Build, PlutusVersion, TraceLevel}; + use crate::{Build, TraceLevel}; #[test] fn optimization_levels_roundtrip() { @@ -867,6 +864,34 @@ mod build_tests { } } + #[test] + fn silent_o2_roundtrip_and_test_defaults() { + for source in [ + r#"{"type":"application","optimize":2}"#, + r#"{"type":"application","optimize":2,"traceLevel":"silent"}"#, + r#"{"type":"package","name":"test/lib","version":"1.0.0","summary":"","license":"MIT","exposedModules":[],"optimize":2}"#, + ] { + let config = parse(source, "nash.jsonc").expect("silent O2 is valid"); + assert_config_roundtrip_snapshot!(source, config); + let build = config.build(); + assert_eq!(build, build.for_tests()); + assert_eq!(build.for_tests(), build.for_tests().for_tests()); + } + } + + config_error_snapshot!( + o2_compact, + r#"{"type":"application","optimize":2,"traceLevel":"compact"}"# + ); + config_error_snapshot!( + o2_verbose, + r#"{"type":"application","optimize":2,"traceLevel":"verbose"}"# + ); + config_error_snapshot!( + o2_compiler_traces, + r#"{"type":"application","optimize":2,"compilerTraces":true}"# + ); + #[test] fn build_defaults() { for source in [ @@ -876,7 +901,6 @@ mod build_tests { ] { let config = parse(source, "nash.jsonc").unwrap(); assert_eq!(config.build(), Build::default()); - assert_eq!(config.build().plutus_version, PlutusVersion::V3); assert_eq!(config.build().trace_level, TraceLevel::Silent); assert!(!config.build().compiler_traces); assert_eq!(serde_json::from_str::(source).unwrap(), config); @@ -885,46 +909,38 @@ mod build_tests { #[test] fn build_roundtrip() { - for (version, expected_version) in [ - ("v1", PlutusVersion::V1), - ("v2", PlutusVersion::V2), - ("v3", PlutusVersion::V3), + for (trace, expected_trace) in [ + ("silent", TraceLevel::Silent), + ("compact", TraceLevel::Compact), + ("verbose", TraceLevel::Verbose), ] { - for (trace, expected_trace) in [ - ("silent", TraceLevel::Silent), - ("compact", TraceLevel::Compact), - ("verbose", TraceLevel::Verbose), - ] { - for compiler_traces in [false, true] { - let source = format!( - r#"{{"type":"application","plutusVersion":"{version}","traceLevel":"{trace}","compilerTraces":{compiler_traces}}}"# - ); - let config = parse(&source, "nash.jsonc").unwrap(); - assert_eq!( - config.build(), - Build { - optimize: crate::OptimizationLevel::O1, - plutus_version: expected_version, - trace_level: expected_trace, - trace_level_explicit: true, - compiler_traces - } - ); - assert_config_roundtrip_snapshot!(&source, config); - } + for compiler_traces in [false, true] { + let source = format!( + r#"{{"type":"application","traceLevel":"{trace}","compilerTraces":{compiler_traces}}}"# + ); + let config = parse(&source, "nash.jsonc").unwrap(); + assert_eq!( + config.build(), + Build { + optimize: crate::OptimizationLevel::O1, + trace_level: expected_trace, + trace_level_explicit: true, + compiler_traces + } + ); + assert_config_roundtrip_snapshot!(&source, config); } } } #[test] fn package_build_settings() { - let source = r#"{"type":"package","name":"test/lib","version":"1.0.0","summary":"","license":"MIT","exposedModules":[],"plutusVersion":"v1","traceLevel":"verbose","compilerTraces":true}"#; + let source = r#"{"type":"package","name":"test/lib","version":"1.0.0","summary":"","license":"MIT","exposedModules":[],"traceLevel":"verbose","compilerTraces":true}"#; let config = parse(source, "nash.jsonc").unwrap(); assert_eq!( config.build(), Build { optimize: crate::OptimizationLevel::O1, - plutus_version: PlutusVersion::V1, trace_level: TraceLevel::Verbose, trace_level_explicit: true, compiler_traces: true @@ -934,10 +950,6 @@ mod build_tests { assert_config_roundtrip_snapshot!(source, config); } - config_error_snapshot!( - workspace_plutus_version, - r#"{"type":"workspace","members":[],"plutusVersion":"v3"}"# - ); config_error_snapshot!( workspace_trace_level, r#"{"type":"workspace","members":[],"traceLevel":"compact"}"# @@ -946,23 +958,10 @@ mod build_tests { workspace_compiler_traces, r#"{"type":"workspace","members":[],"compilerTraces":false}"# ); - config_error_snapshot!( - invalid_plutus_version, - r#" - { - "type": "application", - "plutusVersion": "v4" - } - "# - ); config_error_snapshot!( invalid_trace_level, r#"{"type":"application","traceLevel":"loud"}"# ); - config_error_snapshot!( - plutus_version_wrong_type, - r#"{"type":"application","plutusVersion":3}"# - ); config_error_snapshot!( trace_level_wrong_type, r#"{"type":"application","traceLevel":null}"# @@ -971,7 +970,7 @@ mod build_tests { compiler_traces_wrong_type, r#"{"type":"application","compilerTraces":"true"}"# ); - config_error_snapshot!(invalid_optimizer, r#"{"type":"application","optimize":2}"#); + config_error_snapshot!(invalid_optimizer, r#"{"type":"application","optimize":3}"#); config_error_snapshot!( workspace_invalid_optimizer, r#"{"type":"workspace","members":[],"optimize":2}"# diff --git a/crates/nash-config/src/snapshots/nash_config__config__test_defaults__tests_distinguish_absent_trace_setting_from_explicit_silent-2.snap b/crates/nash-config/src/snapshots/nash_config__config__test_defaults__tests_distinguish_absent_trace_setting_from_explicit_silent-2.snap index 8644a120..d8f77b64 100644 --- a/crates/nash-config/src/snapshots/nash_config__config__test_defaults__tests_distinguish_absent_trace_setting_from_explicit_silent-2.snap +++ b/crates/nash-config/src/snapshots/nash_config__config__test_defaults__tests_distinguish_absent_trace_setting_from_explicit_silent-2.snap @@ -4,7 +4,6 @@ description: "{\"type\":\"application\",\"traceLevel\":\"silent\"}" --- { "type": "application", - "plutusVersion": "v3", "traceLevel": "silent", "compilerTraces": false, "sourceDirectories": [ diff --git a/crates/nash-config/src/snapshots/nash_config__config__test_defaults__tests_distinguish_absent_trace_setting_from_explicit_silent.snap b/crates/nash-config/src/snapshots/nash_config__config__test_defaults__tests_distinguish_absent_trace_setting_from_explicit_silent.snap index d49957d9..70b7b0d9 100644 --- a/crates/nash-config/src/snapshots/nash_config__config__test_defaults__tests_distinguish_absent_trace_setting_from_explicit_silent.snap +++ b/crates/nash-config/src/snapshots/nash_config__config__test_defaults__tests_distinguish_absent_trace_setting_from_explicit_silent.snap @@ -4,7 +4,6 @@ description: "{\"type\":\"application\"}" --- { "type": "application", - "plutusVersion": "v3", "compilerTraces": false, "sourceDirectories": [ "src" diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-10.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-10.snap deleted file mode 100644 index cf44a31f..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-10.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v2\",\"traceLevel\":\"compact\",\"compilerTraces\":true}" ---- -{ - "type": "application", - "plutusVersion": "v2", - "traceLevel": "compact", - "compilerTraces": true, - "sourceDirectories": [ - "src" - ], - "dependencies": {}, - "testDependencies": {} -} diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-11.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-11.snap deleted file mode 100644 index 679f8562..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-11.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v2\",\"traceLevel\":\"verbose\",\"compilerTraces\":false}" ---- -{ - "type": "application", - "plutusVersion": "v2", - "traceLevel": "verbose", - "compilerTraces": false, - "sourceDirectories": [ - "src" - ], - "dependencies": {}, - "testDependencies": {} -} diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-12.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-12.snap deleted file mode 100644 index 5a87e514..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-12.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v2\",\"traceLevel\":\"verbose\",\"compilerTraces\":true}" ---- -{ - "type": "application", - "plutusVersion": "v2", - "traceLevel": "verbose", - "compilerTraces": true, - "sourceDirectories": [ - "src" - ], - "dependencies": {}, - "testDependencies": {} -} diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-14.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-14.snap deleted file mode 100644 index 5e78f3ef..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-14.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v3\",\"traceLevel\":\"silent\",\"compilerTraces\":true}" ---- -{ - "type": "application", - "plutusVersion": "v3", - "traceLevel": "silent", - "compilerTraces": true, - "sourceDirectories": [ - "src" - ], - "dependencies": {}, - "testDependencies": {} -} diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-15.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-15.snap deleted file mode 100644 index bd83891f..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-15.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v3\",\"traceLevel\":\"compact\",\"compilerTraces\":false}" ---- -{ - "type": "application", - "plutusVersion": "v3", - "traceLevel": "compact", - "compilerTraces": false, - "sourceDirectories": [ - "src" - ], - "dependencies": {}, - "testDependencies": {} -} diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-16.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-16.snap deleted file mode 100644 index a56f593d..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-16.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v3\",\"traceLevel\":\"compact\",\"compilerTraces\":true}" ---- -{ - "type": "application", - "plutusVersion": "v3", - "traceLevel": "compact", - "compilerTraces": true, - "sourceDirectories": [ - "src" - ], - "dependencies": {}, - "testDependencies": {} -} diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-17.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-17.snap deleted file mode 100644 index 72115e39..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-17.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v3\",\"traceLevel\":\"verbose\",\"compilerTraces\":false}" ---- -{ - "type": "application", - "plutusVersion": "v3", - "traceLevel": "verbose", - "compilerTraces": false, - "sourceDirectories": [ - "src" - ], - "dependencies": {}, - "testDependencies": {} -} diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-18.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-18.snap deleted file mode 100644 index 7ce9abaa..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-18.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v3\",\"traceLevel\":\"verbose\",\"compilerTraces\":true}" ---- -{ - "type": "application", - "plutusVersion": "v3", - "traceLevel": "verbose", - "compilerTraces": true, - "sourceDirectories": [ - "src" - ], - "dependencies": {}, - "testDependencies": {} -} diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-2.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-2.snap index 8933631d..1bad6571 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-2.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-2.snap @@ -1,10 +1,9 @@ --- source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v1\",\"traceLevel\":\"silent\",\"compilerTraces\":true}" +description: "{\"type\":\"application\",\"traceLevel\":\"silent\",\"compilerTraces\":true}" --- { "type": "application", - "plutusVersion": "v1", "traceLevel": "silent", "compilerTraces": true, "sourceDirectories": [ diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-3.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-3.snap index e2b807b6..3e079796 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-3.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-3.snap @@ -1,10 +1,9 @@ --- source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v1\",\"traceLevel\":\"compact\",\"compilerTraces\":false}" +description: "{\"type\":\"application\",\"traceLevel\":\"compact\",\"compilerTraces\":false}" --- { "type": "application", - "plutusVersion": "v1", "traceLevel": "compact", "compilerTraces": false, "sourceDirectories": [ diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-4.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-4.snap index fb252865..e61f0939 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-4.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-4.snap @@ -1,10 +1,9 @@ --- source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v1\",\"traceLevel\":\"compact\",\"compilerTraces\":true}" +description: "{\"type\":\"application\",\"traceLevel\":\"compact\",\"compilerTraces\":true}" --- { "type": "application", - "plutusVersion": "v1", "traceLevel": "compact", "compilerTraces": true, "sourceDirectories": [ diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-5.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-5.snap index 861ee66f..78b72ba9 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-5.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-5.snap @@ -1,10 +1,9 @@ --- source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v1\",\"traceLevel\":\"verbose\",\"compilerTraces\":false}" +description: "{\"type\":\"application\",\"traceLevel\":\"verbose\",\"compilerTraces\":false}" --- { "type": "application", - "plutusVersion": "v1", "traceLevel": "verbose", "compilerTraces": false, "sourceDirectories": [ diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-6.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-6.snap index 58addadc..e7e96026 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-6.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-6.snap @@ -1,10 +1,9 @@ --- source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v1\",\"traceLevel\":\"verbose\",\"compilerTraces\":true}" +description: "{\"type\":\"application\",\"traceLevel\":\"verbose\",\"compilerTraces\":true}" --- { "type": "application", - "plutusVersion": "v1", "traceLevel": "verbose", "compilerTraces": true, "sourceDirectories": [ diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-8.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-8.snap deleted file mode 100644 index 7670f8e2..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-8.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v2\",\"traceLevel\":\"silent\",\"compilerTraces\":true}" ---- -{ - "type": "application", - "plutusVersion": "v2", - "traceLevel": "silent", - "compilerTraces": true, - "sourceDirectories": [ - "src" - ], - "dependencies": {}, - "testDependencies": {} -} diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-9.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-9.snap deleted file mode 100644 index b920d3ba..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-9.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v2\",\"traceLevel\":\"compact\",\"compilerTraces\":false}" ---- -{ - "type": "application", - "plutusVersion": "v2", - "traceLevel": "compact", - "compilerTraces": false, - "sourceDirectories": [ - "src" - ], - "dependencies": {}, - "testDependencies": {} -} diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip.snap index b54f8278..7b228a16 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip.snap @@ -1,10 +1,9 @@ --- source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v1\",\"traceLevel\":\"silent\",\"compilerTraces\":false}" +description: "{\"type\":\"application\",\"traceLevel\":\"silent\",\"compilerTraces\":false}" --- { "type": "application", - "plutusVersion": "v1", "traceLevel": "silent", "compilerTraces": false, "sourceDirectories": [ diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__invalid_optimizer.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__invalid_optimizer.snap index 9053a317..8d2f5810 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__invalid_optimizer.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__invalid_optimizer.snap @@ -1,6 +1,6 @@ --- source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"optimize\":2}" +description: "{\"type\":\"application\",\"optimize\":3}" info: diagnostic --- - × 'nash.jsonc' at 1:34: 'optimize' must be the integer 0 or 1 + × 'nash.jsonc' at 1:34: 'optimize' must be the integer 0, 1, or 2 diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__invalid_plutus_version.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__invalid_plutus_version.snap deleted file mode 100644 index ed64c901..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__invalid_plutus_version.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\n \"type\": \"application\",\n \"plutusVersion\": \"v4\"\n}\n" -info: diagnostic ---- - × 'nash.jsonc' at 3:22: invalid value 'v4' for 'plutusVersion' (expected - │ 'v1', 'v2', or 'v3') diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__o2_compact.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__o2_compact.snap new file mode 100644 index 00000000..1346aba9 --- /dev/null +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__o2_compact.snap @@ -0,0 +1,7 @@ +--- +source: crates/nash-config/src/parse.rs +description: "{\"type\":\"application\",\"optimize\":2,\"traceLevel\":\"compact\"}" +info: diagnostic +--- + × 'nash.jsonc' at 1:34: O2 requires silent tracing; compact and verbose + │ tracing are not supported diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__o2_compiler_traces.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__o2_compiler_traces.snap new file mode 100644 index 00000000..aaed69c1 --- /dev/null +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__o2_compiler_traces.snap @@ -0,0 +1,6 @@ +--- +source: crates/nash-config/src/parse.rs +description: "{\"type\":\"application\",\"optimize\":2,\"compilerTraces\":true}" +info: diagnostic +--- + × 'nash.jsonc' at 1:34: O2 does not support compiler traces diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__o2_verbose.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__o2_verbose.snap new file mode 100644 index 00000000..4508daf0 --- /dev/null +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__o2_verbose.snap @@ -0,0 +1,7 @@ +--- +source: crates/nash-config/src/parse.rs +description: "{\"type\":\"application\",\"optimize\":2,\"traceLevel\":\"verbose\"}" +info: diagnostic +--- + × 'nash.jsonc' at 1:34: O2 requires silent tracing; compact and verbose + │ tracing are not supported diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__optimization_levels_roundtrip-2.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__optimization_levels_roundtrip-2.snap index 228f5698..68c49305 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__optimization_levels_roundtrip-2.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__optimization_levels_roundtrip-2.snap @@ -4,7 +4,6 @@ description: "{\"type\":\"application\",\"optimize\":1,\"traceLevel\":\"verbose\ --- { "type": "application", - "plutusVersion": "v3", "traceLevel": "verbose", "compilerTraces": true, "sourceDirectories": [ diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__optimization_levels_roundtrip.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__optimization_levels_roundtrip.snap index aace171d..d831d13d 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__optimization_levels_roundtrip.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__optimization_levels_roundtrip.snap @@ -5,7 +5,6 @@ description: "{\"type\":\"application\",\"optimize\":0,\"traceLevel\":\"verbose\ { "type": "application", "optimize": 0, - "plutusVersion": "v3", "traceLevel": "verbose", "compilerTraces": true, "sourceDirectories": [ diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__package_build_settings.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__package_build_settings.snap index 17a312c8..dff9d6a9 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__package_build_settings.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__package_build_settings.snap @@ -1,10 +1,9 @@ --- source: crates/nash-config/src/parse.rs -description: "{\"type\":\"package\",\"name\":\"test/lib\",\"version\":\"1.0.0\",\"summary\":\"\",\"license\":\"MIT\",\"exposedModules\":[],\"plutusVersion\":\"v1\",\"traceLevel\":\"verbose\",\"compilerTraces\":true}" +description: "{\"type\":\"package\",\"name\":\"test/lib\",\"version\":\"1.0.0\",\"summary\":\"\",\"license\":\"MIT\",\"exposedModules\":[],\"traceLevel\":\"verbose\",\"compilerTraces\":true}" --- { "type": "package", - "plutusVersion": "v1", "traceLevel": "verbose", "compilerTraces": true, "name": "test/lib", diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__package_invalid_optimizer.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__package_invalid_optimizer.snap index 11877305..c34d128f 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__package_invalid_optimizer.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__package_invalid_optimizer.snap @@ -3,4 +3,4 @@ source: crates/nash-config/src/parse.rs description: "{\"type\":\"package\",\"name\":\"test/lib\",\"version\":\"1.0.0\",\"summary\":\"\",\"license\":\"MIT\",\"exposedModules\":[],\"optimize\":null}" info: diagnostic --- - × 'nash.jsonc' at 1:115: 'optimize' must be the integer 0 or 1 + × 'nash.jsonc' at 1:115: 'optimize' must be the integer 0, 1, or 2 diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__plutus_version_wrong_type.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__plutus_version_wrong_type.snap deleted file mode 100644 index 4cfc60a2..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__plutus_version_wrong_type.snap +++ /dev/null @@ -1,6 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":3}" -info: diagnostic ---- - × 'nash.jsonc' at 1:39: expected a string diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-7.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__silent_o2_roundtrip_and_test_defaults-2.snap similarity index 60% rename from crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-7.snap rename to crates/nash-config/src/snapshots/nash_config__parse__build_tests__silent_o2_roundtrip_and_test_defaults-2.snap index c5afd720..23087d83 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-7.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__silent_o2_roundtrip_and_test_defaults-2.snap @@ -1,10 +1,10 @@ --- source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v2\",\"traceLevel\":\"silent\",\"compilerTraces\":false}" +description: "{\"type\":\"application\",\"optimize\":2,\"traceLevel\":\"silent\"}" --- { "type": "application", - "plutusVersion": "v2", + "optimize": 2, "traceLevel": "silent", "compilerTraces": false, "sourceDirectories": [ diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__silent_o2_roundtrip_and_test_defaults-3.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__silent_o2_roundtrip_and_test_defaults-3.snap new file mode 100644 index 00000000..d2c5444a --- /dev/null +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__silent_o2_roundtrip_and_test_defaults-3.snap @@ -0,0 +1,16 @@ +--- +source: crates/nash-config/src/parse.rs +description: "{\"type\":\"package\",\"name\":\"test/lib\",\"version\":\"1.0.0\",\"summary\":\"\",\"license\":\"MIT\",\"exposedModules\":[],\"optimize\":2}" +--- +{ + "type": "package", + "optimize": 2, + "compilerTraces": false, + "name": "test/lib", + "version": "1.0.0", + "summary": "", + "license": "MIT", + "exposedModules": [], + "dependencies": {}, + "testDependencies": {} +} diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-13.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__silent_o2_roundtrip_and_test_defaults.snap similarity index 53% rename from crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-13.snap rename to crates/nash-config/src/snapshots/nash_config__parse__build_tests__silent_o2_roundtrip_and_test_defaults.snap index 23444c57..23a1f474 100644 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__build_roundtrip-13.snap +++ b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__silent_o2_roundtrip_and_test_defaults.snap @@ -1,11 +1,10 @@ --- source: crates/nash-config/src/parse.rs -description: "{\"type\":\"application\",\"plutusVersion\":\"v3\",\"traceLevel\":\"silent\",\"compilerTraces\":false}" +description: "{\"type\":\"application\",\"optimize\":2}" --- { "type": "application", - "plutusVersion": "v3", - "traceLevel": "silent", + "optimize": 2, "compilerTraces": false, "sourceDirectories": [ "src" diff --git a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__workspace_plutus_version.snap b/crates/nash-config/src/snapshots/nash_config__parse__build_tests__workspace_plutus_version.snap deleted file mode 100644 index d7e9b85e..00000000 --- a/crates/nash-config/src/snapshots/nash_config__parse__build_tests__workspace_plutus_version.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: crates/nash-config/src/parse.rs -description: "{\"type\":\"workspace\",\"members\":[],\"plutusVersion\":\"v3\"}" -info: diagnostic ---- - × 'nash.jsonc' at 1:34: 'plutusVersion' must be set in workspace members, - │ not the workspace config diff --git a/crates/nash-driver/src/build.rs b/crates/nash-driver/src/build.rs index 3be571b7..2a9f3caf 100644 --- a/crates/nash-driver/src/build.rs +++ b/crates/nash-driver/src/build.rs @@ -57,6 +57,10 @@ pub fn build_validators_matching_with( let Some(config) = config_for(&module.uri) else { continue; }; + config.validate().map_err(|error| BuildError { + module: module.module.name.name.to_owned(), + message: error.to_string(), + })?; let trace = TraceConfig { user: match config.trace_level { nash_config::TraceLevel::Silent => nash_codegen::build::TraceLevel::Silent, @@ -65,11 +69,6 @@ pub fn build_validators_matching_with( }, compiler: config.compiler_traces, }; - let version = match config.plutus_version { - nash_config::PlutusVersion::V1 => nash_plutus::machine::PlutusVersion::V1, - nash_config::PlutusVersion::V2 => nash_plutus::machine::PlutusVersion::V2, - nash_config::PlutusVersion::V3 => nash_plutus::machine::PlutusVersion::V3, - }; let name = module.module.name.name; let error = |message: String| BuildError { module: name.to_owned(), @@ -100,13 +99,9 @@ pub fn build_validators_matching_with( trace, ) .map_err(|e| error(e.to_string()))?; - let compiled = nash_codegen::program::assemble_core_with_options( - &arena, - core.core, - version, - config.optimize, - ) - .map_err(|e| error(e.to_string()))?; + let compiled = + nash_codegen::program::assemble_core_with_options(&arena, core.core, config.optimize) + .map_err(|e| error(e.to_string()))?; let uplc = pretty::program(Program::new( &arena, compiled.program.version, @@ -118,7 +113,7 @@ pub fn build_validators_matching_with( module: name.to_owned(), uplc, flat: bytes, - hash: nash_plutus::script::script_hash(version, &cbor), + hash: nash_plutus::script::script_hash(nash_plutus::machine::PlutusVersion::V3, &cbor), cbor, }); } @@ -306,13 +301,17 @@ pub fn compile_tests_matching_with( continue; }; let config = config.for_tests(); + config.validate().map_err(|error| BuildError { + module: module.module.name.name.to_owned(), + message: error.to_string(), + })?; let trace = TraceConfig { user: match config.trace_level { nash_config::TraceLevel::Silent => nash_codegen::build::TraceLevel::Silent, nash_config::TraceLevel::Compact => nash_codegen::build::TraceLevel::Compact, nash_config::TraceLevel::Verbose => nash_codegen::build::TraceLevel::Verbose, }, - compiler: true, + compiler: config.compiler_traces, }; let path = module .uri @@ -324,7 +323,6 @@ pub fn compile_tests_matching_with( module.module.name, module.source, &path, - config.plutus_version, trace, config.optimize, |test| include(module.module.name.name, test.name.value), diff --git a/crates/nash-driver/tests/base_traits.rs b/crates/nash-driver/tests/base_traits.rs index e824ed7d..c4573b20 100644 --- a/crates/nash-driver/tests/base_traits.rs +++ b/crates/nash-driver/tests/base_traits.rs @@ -139,7 +139,7 @@ async fn optimization_levels_preserve_test_and_property_traces() { let memory = InMemorySource::new(); let mut modules = bundled_base::modules(); let mut roots = Vec::new(); - for name in ["Baseline", "Optimized"] { + for name in ["Baseline", "Optimized", "Silent"] { let uri = Url::parse(&format!("file:///app/src/{name}.nash")).unwrap(); memory.insert( uri.clone(), @@ -181,10 +181,16 @@ tests roots.contains(uri).then_some(nash_config::Build { optimize: if uri.path().ends_with("Baseline.nash") { nash_config::OptimizationLevel::O0 + } else if uri.path().ends_with("Silent.nash") { + nash_config::OptimizationLevel::O2 } else { nash_config::OptimizationLevel::O1 }, - trace_level: nash_config::TraceLevel::Verbose, + trace_level: if uri.path().ends_with("Silent.nash") { + nash_config::TraceLevel::Silent + } else { + nash_config::TraceLevel::Verbose + }, trace_level_explicit: true, ..Default::default() }) @@ -208,6 +214,7 @@ tests }; let before = render("Baseline"); let after = render("Optimized"); - insta::assert_snapshot!(format!("--- O0\n{before}\n--- O1\n{after}")); + let silent = render("Silent"); + insta::with_settings!({omit_expression => true}, { insta::assert_snapshot!(format!("--- O0\n{before}\n--- O1\n{after}\n--- O2\n{silent}")); }); assert_eq!(before, after); } diff --git a/crates/nash-driver/tests/build.rs b/crates/nash-driver/tests/build.rs index 1aae9220..c73536db 100644 --- a/crates/nash-driver/tests/build.rs +++ b/crates/nash-driver/tests/build.rs @@ -209,7 +209,7 @@ async fn refuses_symlink_artifacts_and_manifests_without_touching_their_targets( } #[tokio::test] -async fn roots_use_their_own_target_settings_and_hashes() { +async fn validator_hashes_use_the_v3_language_tag() { let files = [ ( "First", @@ -220,29 +220,20 @@ async fn roots_use_their_own_target_settings_and_hashes() { "validator module Second exposing (main)\nmain : 'a -> unit\nmain _ = ()\n", ), ]; - let artifacts = outputs_with(&files, |uri| nash_config::Build { - plutus_version: if uri.path().ends_with("First.nash") { - nash_config::PlutusVersion::V1 - } else { - nash_config::PlutusVersion::V3 - }, - ..Default::default() - }) - .await; + let artifacts = outputs_with(&files, |_| nash_config::Build::default()).await; insta::with_settings!({description => files.iter().map(|(_, source)| *source).collect::>().join("\n"), omit_expression => true}, { insta::assert_snapshot!(artifacts.iter().map(|artifact| format!("{}\n{}\nhash: {}", artifact.module, artifact.uplc, hex::encode(artifact.hash))).collect::>().join("\n")); }); - for (artifact, version) in artifacts.iter().zip([ - nash_plutus::machine::PlutusVersion::V1, - nash_plutus::machine::PlutusVersion::V3, - ]) { + for artifact in &artifacts { assert_eq!( artifact.hash, - nash_plutus::script::script_hash(version, &artifact.cbor) + nash_plutus::script::script_hash( + nash_plutus::machine::PlutusVersion::V3, + &artifact.cbor + ) ); } - assert_ne!(artifacts[0].hash, artifacts[1].hash); } #[tokio::test] @@ -392,3 +383,33 @@ async fn roots_select_o0_and_o1_with_the_same_traces() { assert_eq!(observations[0], observations[1]); assert_ne!(outputs[0].flat, outputs[1].flat); } + +#[tokio::test] +async fn o2_validator_settings_and_trace_erasure() { + let source = "validator module Main exposing (main)\nimport Builtin\nmain : Data -> unit\nmain _ = trace \"source\" (Builtin.trace \"builtin\" ())\n"; + for (name, trace_level, compiler_traces) in [ + ("silent", nash_config::TraceLevel::Silent, false), + ("compact", nash_config::TraceLevel::Compact, false), + ("verbose", nash_config::TraceLevel::Verbose, false), + ("compiler", nash_config::TraceLevel::Silent, true), + ] { + let result = outputs_result_with(&[("Main", source)], move |_| nash_config::Build { + optimize: nash_config::OptimizationLevel::O2, + trace_level, + compiler_traces, + ..Default::default() + }) + .await; + let rendered = match result { + Ok(outputs) => outputs + .into_iter() + .map(|output| output.uplc) + .collect::>() + .join("\n"), + Err(error) => error.to_string(), + }; + insta::with_settings!({description => source, omit_expression => true}, { + insta::assert_snapshot!(format!("o2_validator_{name}"), rendered); + }); + } +} diff --git a/crates/nash-driver/tests/production.rs b/crates/nash-driver/tests/production.rs index 7157115c..0a744362 100644 --- a/crates/nash-driver/tests/production.rs +++ b/crates/nash-driver/tests/production.rs @@ -230,10 +230,7 @@ async fn dependency_validators_are_not_emitted_and_selected_roots_keep_their_tar .unwrap(); let (report, outputs) = build_with(db, &graph, &origins, move |solved| { nash_driver::build::build_validators_matching_with(solved, |uri| { - (uri == &main).then_some(nash_config::Build { - plutus_version: nash_config::PlutusVersion::V1, - ..Default::default() - }) + (uri == &main).then_some(nash_config::Build::default()) }) }) .await; @@ -246,6 +243,6 @@ async fn dependency_validators_are_not_emitted_and_selected_roots_keep_their_tar }); assert_eq!( outputs[0].hash, - nash_plutus::script::script_hash(nash_plutus::machine::PlutusVersion::V1, &outputs[0].cbor) + nash_plutus::script::script_hash(nash_plutus::machine::PlutusVersion::V3, &outputs[0].cbor) ); } diff --git a/crates/nash-driver/tests/snapshots/base_traits__optimization_levels_preserve_test_and_property_traces.snap b/crates/nash-driver/tests/snapshots/base_traits__optimization_levels_preserve_test_and_property_traces.snap index 9efd9e8b..10c9d2d6 100644 --- a/crates/nash-driver/tests/snapshots/base_traits__optimization_levels_preserve_test_and_property_traces.snap +++ b/crates/nash-driver/tests/snapshots/base_traits__optimization_levels_preserve_test_and_property_traces.snap @@ -1,6 +1,5 @@ --- source: crates/nash-driver/tests/base_traits.rs -expression: "format!(\"--- O0\\n{before}\\n--- O1\\n{after}\")" --- --- O0 pass: Pass; traces: ["before"]; counterexample: None @@ -10,3 +9,7 @@ property: Pass; traces: ["generator", "body"]; counterexample: None pass: Pass; traces: ["before"]; counterexample: None failure: Pass; traces: ["before failure"]; counterexample: None property: Pass; traces: ["generator", "body"]; counterexample: None +--- O2 +pass: Pass; traces: []; counterexample: None +failure: Pass; traces: []; counterexample: None +property: Pass; traces: []; counterexample: None diff --git a/crates/nash-driver/tests/snapshots/build__o2_validator_compact.snap b/crates/nash-driver/tests/snapshots/build__o2_validator_compact.snap new file mode 100644 index 00000000..fd5cf211 --- /dev/null +++ b/crates/nash-driver/tests/snapshots/build__o2_validator_compact.snap @@ -0,0 +1,5 @@ +--- +source: crates/nash-driver/tests/build.rs +description: "validator module Main exposing (main)\nimport Builtin\nmain : Data -> unit\nmain _ = trace \"source\" (Builtin.trace \"builtin\" ())\n" +--- +code generation failed in Main: O2 requires silent tracing; compact and verbose tracing are not supported diff --git a/crates/nash-driver/tests/snapshots/build__o2_validator_compiler.snap b/crates/nash-driver/tests/snapshots/build__o2_validator_compiler.snap new file mode 100644 index 00000000..0d6e0c9a --- /dev/null +++ b/crates/nash-driver/tests/snapshots/build__o2_validator_compiler.snap @@ -0,0 +1,5 @@ +--- +source: crates/nash-driver/tests/build.rs +description: "validator module Main exposing (main)\nimport Builtin\nmain : Data -> unit\nmain _ = trace \"source\" (Builtin.trace \"builtin\" ())\n" +--- +code generation failed in Main: O2 does not support compiler traces diff --git a/crates/nash-driver/tests/snapshots/build__o2_validator_silent.snap b/crates/nash-driver/tests/snapshots/build__o2_validator_silent.snap new file mode 100644 index 00000000..4664425a --- /dev/null +++ b/crates/nash-driver/tests/snapshots/build__o2_validator_silent.snap @@ -0,0 +1,5 @@ +--- +source: crates/nash-driver/tests/build.rs +description: "validator module Main exposing (main)\nimport Builtin\nmain : Data -> unit\nmain _ = trace \"source\" (Builtin.trace \"builtin\" ())\n" +--- +(program 1.1.0 (lam arg_1 (con unit ()))) diff --git a/crates/nash-driver/tests/snapshots/build__o2_validator_verbose.snap b/crates/nash-driver/tests/snapshots/build__o2_validator_verbose.snap new file mode 100644 index 00000000..fd5cf211 --- /dev/null +++ b/crates/nash-driver/tests/snapshots/build__o2_validator_verbose.snap @@ -0,0 +1,5 @@ +--- +source: crates/nash-driver/tests/build.rs +description: "validator module Main exposing (main)\nimport Builtin\nmain : Data -> unit\nmain _ = trace \"source\" (Builtin.trace \"builtin\" ())\n" +--- +code generation failed in Main: O2 requires silent tracing; compact and verbose tracing are not supported diff --git a/crates/nash-driver/tests/snapshots/build__roots_use_their_own_target_settings_and_hashes.snap b/crates/nash-driver/tests/snapshots/build__validator_hashes_use_the_v3_language_tag.snap similarity index 85% rename from crates/nash-driver/tests/snapshots/build__roots_use_their_own_target_settings_and_hashes.snap rename to crates/nash-driver/tests/snapshots/build__validator_hashes_use_the_v3_language_tag.snap index 488b85bf..92dc6924 100644 --- a/crates/nash-driver/tests/snapshots/build__roots_use_their_own_target_settings_and_hashes.snap +++ b/crates/nash-driver/tests/snapshots/build__validator_hashes_use_the_v3_language_tag.snap @@ -4,7 +4,7 @@ description: "validator module First exposing (main)\nmain : 'a -> unit\nmain _ --- First (program 1.1.0 (lam arg_1 (con unit ()))) -hash: 5224b11324c206181841f0dba49fffc3cb24ad95f9c4180dcdda89b3 +hash: 186e32faa80a26810392fda6d559c7ed4721a65ce1c9d4ef3e1c87b4 Second (program 1.1.0 (lam arg_1 (con unit ()))) hash: 186e32faa80a26810392fda6d559c7ed4721a65ce1c9d4ef3e1c87b4 diff --git a/crates/nash-ir/src/constant_fold.rs b/crates/nash-ir/src/constant_fold.rs new file mode 100644 index 00000000..df4e20af --- /dev/null +++ b/crates/nash-ir/src/constant_fold.rs @@ -0,0 +1,48 @@ +//! Constant-builtin rewriting; evaluation policy belongs to the caller. +use crate::{ + build::Builder, + core::{Core, CoreKind}, +}; +use nash_plutus::{builtin::DefaultFunction, constant::Constant}; +use std::collections::HashMap; + +/// Input names must be globally unique and well scoped. Only literals or aliases +/// of literal bindings are passed to the evaluator. Returning None keeps the call. +/// Strict bindings remain for ordinary cleanup; no computation is copied/moved. +pub fn reduce<'a>( + b: &Builder<'a>, + core: &'a Core<'a>, + evaluate: &mut impl FnMut(DefaultFunction, &[&'a Constant<'a>]) -> Option<&'a Constant<'a>>, +) -> &'a Core<'a> { + let mut constants = HashMap::new(); + core.walk(&mut |node| { + if let CoreKind::Let { binder, value, .. } = node.kind { + let constant = match value.kind { + CoreKind::Lit(c) => Some(c), + CoreKind::Var(n) => constants.get(&n.unique).copied(), + _ => None, + }; + if let Some(c) = constant { + constants.insert(binder.name.unique, c); + } + } + }); + core.map(b, &mut |node| { + let CoreKind::Builtin { func, args } = node.kind else { + return None; + }; + if args.len() != func.arity() { + return None; + } + let args: Option> = args + .iter() + .map(|arg| match arg.kind { + CoreKind::Lit(c) => Some(c), + CoreKind::Var(n) => constants.get(&n.unique).copied(), + _ => None, + }) + .collect(); + let result = evaluate(func, &args?)?; + Some(b.with_type(b.lit(result), node.ty)) + }) +} diff --git a/crates/nash-ir/src/core.rs b/crates/nash-ir/src/core.rs index db1e73fa..7e0d1595 100644 --- a/crates/nash-ir/src/core.rs +++ b/crates/nash-ir/src/core.rs @@ -76,7 +76,7 @@ pub enum CoreKind<'a> { #[derive(Clone, Copy, Debug)] pub struct RecBinder<'a> { pub binder: Binder<'a>, - /// Function parameters. A singleton internal delayed recursive value may + /// Function parameters. An internal delayed recursive value may /// use an empty slice with a `Delay` body and matching delayed binder type. pub params: &'a [Binder<'a>], /// Indices into `params` that every self call passes through unchanged. diff --git a/crates/nash-ir/src/dead_code.rs b/crates/nash-ir/src/dead_code.rs index fb0a0213..7b8ef35a 100644 --- a/crates/nash-ir/src/dead_code.rs +++ b/crates/nash-ir/src/dead_code.rs @@ -59,7 +59,7 @@ fn mark( /// Input must have globally unique, well-scoped binders. Every reference counts, /// including partial applications, escaping values and suspended captures. -/// Function bodies are deferred; the supported singleton delayed worker is too. +/// Function bodies are deferred; delayed workers are too. /// No call-shape analysis, static-parameter inference or parameter removal occurs. pub fn prune_recursive<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { core.map(b, &mut |node| { @@ -68,8 +68,9 @@ pub fn prune_recursive<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> }; // Other zero-parameter groups are unsupported recursive values, not // suspended function definitions. Preserve their lowering error. - if binders.iter().any(|r| r.params.is_empty()) - && !(binders.len() == 1 && matches!(binders[0].body.kind, CoreKind::Delay(_))) + if binders + .iter() + .any(|r| r.params.is_empty() && !matches!(r.body.kind, CoreKind::Delay(_))) { return None; } diff --git a/crates/nash-ir/src/known_case.rs b/crates/nash-ir/src/known_case.rs index 65c9534e..cc67efe7 100644 --- a/crates/nash-ir/src/known_case.rs +++ b/crates/nash-ir/src/known_case.rs @@ -835,7 +835,8 @@ pub fn reduce_constr_data<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<' /// ConstrData folding with accepted cleanup, without another ANF pass. pub fn simplify_constr_data<'a>(b: &Builder<'a>, mut core: &'a Core<'a>) -> &'a Core<'a> { loop { - let next = simplify_data_wrappers(b, reduce_constr_data(b, core)); + let projected = crate::pair_projection::reduce(b, core); + let next = simplify_data_wrappers(b, reduce_constr_data(b, projected)); if std::ptr::eq(core, next) { return next; } diff --git a/crates/nash-ir/src/lib.rs b/crates/nash-ir/src/lib.rs index 47af47e6..ac5533b9 100644 --- a/crates/nash-ir/src/lib.rs +++ b/crates/nash-ir/src/lib.rs @@ -35,4 +35,7 @@ mod test_support { } } +pub mod constant_fold; pub mod inverse; + +pub mod pair_projection; diff --git a/crates/nash-ir/src/pair_projection.rs b/crates/nash-ir/src/pair_projection.rs new file mode 100644 index 00000000..22d32c34 --- /dev/null +++ b/crates/nash-ir/src/pair_projection.rs @@ -0,0 +1,96 @@ +//! Single-field native pair projection only when constructor inverse cleanup cancels it. +use crate::{ + build::Builder, + core::{CaseKind, Core, CoreKind, Test}, + ty::{ConstTy, Ty}, +}; +use nash_plutus::builtin::DefaultFunction as F; +use std::collections::{HashMap, HashSet}; + +fn resolve<'a>(mut node: &'a Core<'a>, bindings: &HashMap>) -> &'a Core<'a> { + while let CoreKind::Var(name) = node.kind { + let Some(value) = bindings.get(&name.unique) else { + break; + }; + node = value; + } + node +} + +/// Requires globally unique, scoped names. Retain both strict producer bindings. +pub fn reduce<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { + let mut bindings = HashMap::new(); + let mut used = HashSet::new(); + core.walk(&mut |node| match node.kind { + CoreKind::Let { binder, value, .. } => { + bindings.insert(binder.name.unique, value); + } + CoreKind::Var(name) => { + used.insert(name.unique); + } + _ => {} + }); + core.map(b, &mut |node| { + let CoreKind::Case { + kind: CaseKind::Pair, + scrutinee, + branches: [branch], + default: None, + } = node.kind + else { + return None; + }; + let [left, right] = branch.binders else { + return None; + }; + if branch.test != Test::Pair || left.name.unique == right.name.unique { + return None; + } + let Ty::Const(ConstTy::Pair(a, c)) = scrutinee.ty else { + return None; + }; + if left.ty != *a || right.ty != *c { + return None; + } + let selected = match ( + used.contains(&left.name.unique), + used.contains(&right.name.unique), + ) { + (true, false) => (left, F::FstPair), + (false, true) => (right, F::SndPair), + _ => return None, + }; + // Match inverse::constructor's exact proof. Trace wrappers are not + // skipped here, and neither decoder nor constructor is discarded. + if !matches!(scrutinee.kind, CoreKind::Var(_)) { + return None; + } + let CoreKind::Builtin { + func: F::UnConstrData, + args: [data], + } = resolve(scrutinee, &bindings).kind + else { + return None; + }; + if !matches!(data.kind, CoreKind::Var(_)) { + return None; + } + let CoreKind::Builtin { + func: F::ConstrData, + args: [tag, fields], + } = resolve(data, &bindings).kind + else { + return None; + }; + let field = if selected.1 == F::FstPair { + tag + } else { + fields + }; + if !matches!(field.kind, CoreKind::Var(_)) { + return None; + } + let projection = b.builtin(selected.1, &[scrutinee], selected.0.ty); + Some(b.with_type(b.let_(*selected.0, projection, branch.body), node.ty)) + }) +} diff --git a/crates/nash-ir/src/single_use.rs b/crates/nash-ir/src/single_use.rs index 2f152e38..93b95d99 100644 --- a/crates/nash-ir/src/single_use.rs +++ b/crates/nash-ir/src/single_use.rs @@ -21,8 +21,8 @@ pub fn simplify<'a>(b: &Builder<'a>, mut core: &'a Core<'a>) -> &'a Core<'a> { /// Input must be typed ANF with globally unique, well-scoped binders. /// Values can move to their sole use, including into a suspended scope. /// Forced builtin references stay bound for top-level sharing, even at one use. -/// Computations only replace an immediate return, retaining their evaluation -/// point. In particular, computed function operands stay bound to preserve ANF. +/// Computations can replace an immediate return or fuse adjacent application +/// stages. Other computed function operands stay bound to preserve ANF. pub fn inline<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { let mut uses: HashMap = HashMap::new(); core.walk(&mut |node| { @@ -47,6 +47,27 @@ pub fn inline<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { if matches!(body.kind,CoreKind::Var(name) if name.unique==binder.name.unique) { return Some(b.with_type(value, node.ty)); } + if uses.get(&binder.name.unique) == Some(&1) + && let CoreKind::App { func, args } = value.kind + && let CoreKind::App { + func: next, + args: later, + } = body.kind + && matches!(next.kind, CoreKind::Var(name) if name.unique == binder.name.unique) + && value.ty == binder.ty + && next.ty == binder.ty + && body.ty == node.ty + && !args.is_empty() + && !later.is_empty() + && anf::is_atom(func) + && args.iter().chain(later).all(|arg| anf::is_atom(arg)) + { + // App lowers left-associatively: concatenation keeps the earlier + // application stage before the later one. The sole occurrence also + // excludes references to this binder inside any later argument. + let args = args.iter().chain(later).copied().collect::>(); + return Some(b.app(func, &args, node.ty)); + } if uses.get(&binder.name.unique) != Some(&1) || !anf::is_atom(value) { return None; } diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__adjacent_calls.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__adjacent_calls.snap new file mode 100644 index 00000000..38e3c202 --- /dev/null +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__adjacent_calls.snap @@ -0,0 +1,10 @@ +--- +source: crates/nash-ir/src/single_use/tests.rs +--- +--- core before rule 3 +\(f#1 : int -> int -> int) -> let p#2 : int -> int = f#1 20 in +p#2 22 +--- core after rule 3 +\(f#1 : int -> int -> int) -> f#1 20 22 +--- core after rules 1 + 2 + 3 +\(f#1 : int -> int -> int) -> f#1 20 22 diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__call_type_view.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__call_type_view.snap new file mode 100644 index 00000000..6be59084 --- /dev/null +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__call_type_view.snap @@ -0,0 +1,12 @@ +--- +source: crates/nash-ir/src/single_use/tests.rs +--- +--- core before rule 3 +\(f#1 : int -> int -> int) -> let p#2 : int -> int = f#1 20 in +p#2 22 +--- core after rule 3 +\(f#1 : int -> int -> int) -> let p#2 : int -> int = f#1 20 in +p#2 22 +--- core after rules 1 + 2 + 3 +\(f#1 : int -> int -> int) -> let p#2 : int -> int = f#1 20 in +p#2 22 diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__computed_capture_is_not_moved_into_a_delay.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__computed_capture_is_not_moved_into_a_delay.snap index f62e7d29..bbe20a7c 100644 --- a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__computed_capture_is_not_moved_into_a_delay.snap +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__computed_capture_is_not_moved_into_a_delay.snap @@ -1,7 +1,6 @@ --- source: crates/nash-ir/src/single_use/tests.rs assertion_line: 105 -expression: "snapshot(&b, core)" --- --- core before rule 3 let x#1 : int = error in diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__computed_function_operand_remains_bound.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__computed_function_operand_remains_bound.snap index 2b42ced8..2bfd83ab 100644 --- a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__computed_function_operand_remains_bound.snap +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__computed_function_operand_remains_bound.snap @@ -1,7 +1,6 @@ --- source: crates/nash-ir/src/single_use/tests.rs assertion_line: 96 -expression: "snapshot(&b, core)" --- --- core before rule 3 let f#2 : int -> int = trace "before" in \x#1 : int -> x#1 in diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__crossed_trace.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__crossed_trace.snap new file mode 100644 index 00000000..b6c7379e --- /dev/null +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__crossed_trace.snap @@ -0,0 +1,15 @@ +--- +source: crates/nash-ir/src/single_use/tests.rs +--- +--- core before rule 3 +\(f#1 : int -> int -> int) -> let p#2 : int -> int = f#1 20 in +let n#3 : int = trace "later" in 22 in +p#2 n#3 +--- core after rule 3 +\(f#1 : int -> int -> int) -> let p#2 : int -> int = f#1 20 in +let n#3 : int = trace "later" in 22 in +p#2 n#3 +--- core after rules 1 + 2 + 3 +\(f#1 : int -> int -> int) -> let p#2 : int -> int = f#1 20 in +let n#3 : int = trace "later" in 22 in +p#2 n#3 diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__escaping_partial_call.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__escaping_partial_call.snap new file mode 100644 index 00000000..80671ecd --- /dev/null +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__escaping_partial_call.snap @@ -0,0 +1,12 @@ +--- +source: crates/nash-ir/src/single_use/tests.rs +--- +--- core before rule 3 +\(f#1 : int -> int -> int) -> let p#2 : int -> int = f#1 20 in +\n#3 : int -> p#2 n#3 +--- core after rule 3 +\(f#1 : int -> int -> int) -> let p#2 : int -> int = f#1 20 in +\n#3 : int -> p#2 n#3 +--- core after rules 1 + 2 + 3 +\(f#1 : int -> int -> int) -> let p#2 : int -> int = f#1 20 in +\n#3 : int -> p#2 n#3 diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__forced_builtin_reference_stays_bound_even_when_returned.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__forced_builtin_reference_stays_bound_even_when_returned.snap index 0d8946ff..ea108c96 100644 --- a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__forced_builtin_reference_stays_bound_even_when_returned.snap +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__forced_builtin_reference_stays_bound_even_when_returned.snap @@ -1,7 +1,6 @@ --- source: crates/nash-ir/src/single_use/tests.rs assertion_line: 194 -expression: "snapshot(&b, core)" --- --- core before rule 3 let tracer#1 : string -> int -> int = trace in diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__immediate_computed_return_is_removed.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__immediate_computed_return_is_removed.snap index c83e9a43..7d4a89d9 100644 --- a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__immediate_computed_return_is_removed.snap +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__immediate_computed_return_is_removed.snap @@ -1,7 +1,6 @@ --- source: crates/nash-ir/src/single_use/tests.rs assertion_line: 38 -expression: "snapshot(&b,\nb.let_(x, b.builtin(F::AddInteger, &[b.int(40), b.int(2)], INT),\nb.var(x.name, INT)))" --- --- core before rule 3 let result#1 : int = addInteger 40 2 in diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__multiple_use_function_stays_shared.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__multiple_use_function_stays_shared.snap index 098bbfb3..00777593 100644 --- a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__multiple_use_function_stays_shared.snap +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__multiple_use_function_stays_shared.snap @@ -1,7 +1,6 @@ --- source: crates/nash-ir/src/single_use/tests.rs assertion_line: 125 -expression: "snapshot(&b, core)" --- --- core before rule 3 let f#3 : int -> int = \x#1 : int -> x#1 in diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__nested_function_bindings_do_not_resurrect_removed_binders.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__nested_function_bindings_do_not_resurrect_removed_binders.snap index c8a44c9c..fec7d29b 100644 --- a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__nested_function_bindings_do_not_resurrect_removed_binders.snap +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__nested_function_bindings_do_not_resurrect_removed_binders.snap @@ -1,7 +1,6 @@ --- source: crates/nash-ir/src/single_use/tests.rs assertion_line: 79 -expression: "snapshot(&b, b.let_(f, outer, b.app(b.var(f.name, f.ty), &[b.int(42)], INT)))" --- --- core before rule 3 let f#4 : int -> int = \x#1 : int -> let g#3 : int -> int = \y#2 : int -> y#2 in diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_builtin.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_builtin.snap index 0de1ae79..aa63a45f 100644 --- a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_builtin.snap +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_builtin.snap @@ -1,7 +1,6 @@ --- source: crates/nash-ir/src/single_use/tests.rs assertion_line: 153 -expression: "snapshot(&b,\nb.let_(f, b.builtin(F::AddInteger, &[], ty),\nb.app(b.var(f.name, ty), &[b.int(40), b.int(2)], INT)))" --- --- core before rule 3 let add#2 : int -> int -> int = addInteger in diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_delay.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_delay.snap index 56ea59e9..f13996ae 100644 --- a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_delay.snap +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_delay.snap @@ -1,7 +1,6 @@ --- source: crates/nash-ir/src/single_use/tests.rs assertion_line: 147 -expression: "snapshot(&b, b.let_(d, delayed, b.force(b.var(d.name, d.ty), INT)))" --- --- core before rule 3 let delayed#1 : @delay int = delay error in diff --git a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_use_function_exposes_beta_reduction.snap b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_use_function_exposes_beta_reduction.snap index c0cf5dc0..b09aff3a 100644 --- a/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_use_function_exposes_beta_reduction.snap +++ b/crates/nash-ir/src/single_use/snapshots/nash_ir__single_use__tests__single_use_function_exposes_beta_reduction.snap @@ -1,7 +1,6 @@ --- source: crates/nash-ir/src/single_use/tests.rs assertion_line: 57 -expression: "snapshot(&b, b.let_(f, lam, b.app(b.var(f.name, f.ty), &[b.int(40)], INT)))" --- --- core before rule 3 let f#2 : int -> int = \x#1 : int -> addInteger x#1 2 in diff --git a/crates/nash-ir/src/single_use/tests.rs b/crates/nash-ir/src/single_use/tests.rs index 9d470aed..8ab32a43 100644 --- a/crates/nash-ir/src/single_use/tests.rs +++ b/crates/nash-ir/src/single_use/tests.rs @@ -20,12 +20,14 @@ macro_rules! assert_optimization_snapshot { let before = crate::beta::simplify(b, core); let after = inline(b, before); let fixed = simplify(b, before); - insta::assert_snapshot!($($name,)? format!( - "--- core before rule 3\n{}\n--- core after rule 3\n{}\n--- core after rules 1 + 2 + 3\n{}", - pretty(before), - pretty(after), - pretty(fixed) - )); + insta::with_settings!({omit_expression => true}, { + insta::assert_snapshot!($($name,)? format!( + "--- core before rule 3\n{}\n--- core after rule 3\n{}\n--- core after rules 1 + 2 + 3\n{}", + pretty(before), + pretty(after), + pretty(fixed) + )); + }); for v in [before, after, fixed] { anf::validate(v).unwrap(); hygiene::validate(v, &[]).unwrap(); @@ -196,3 +198,62 @@ fn forced_builtin_reference_stays_bound_even_when_returned() { assert_optimization_snapshot!(&b, core); assert!(std::ptr::eq(core, inline(&b, core))); } + +#[test] +fn adjacent_applications_preserve_stages_and_type_views() { + use crate::ty::TermTy; + let a = Arena::new(); + let b = Builder::new(&a); + let partial = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[INT]), INT))); + let full = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[INT]), partial))); + let f = binder(&b, "f", full); + let p = binder(&b, "p", partial); + for (name, occurrence_ty) in [("adjacent_calls", partial), ("call_type_view", Ty::Erased)] { + let core = b.lam( + &[f], + b.let_( + p, + b.app(b.var(f.name, full), &[b.int(20)], partial), + b.app(b.var(p.name, occurrence_ty), &[b.int(22)], INT), + ), + ); + assert_optimization_snapshot!(&b, core, name); + } +} + +#[test] +fn application_fusion_does_not_cross_a_computation_or_capture() { + use crate::ty::TermTy; + let a = Arena::new(); + let b = Builder::new(&a); + let partial = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[INT]), INT))); + let full = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[INT]), partial))); + let f = binder(&b, "f", full); + let p = binder(&b, "p", partial); + let n = binder(&b, "n", INT); + let core = b.lam( + &[f], + b.let_( + p, + b.app(b.var(f.name, full), &[b.int(20)], partial), + b.let_( + n, + b.trace(b.lit(Constant::string(&a, "later")), b.int(22)), + b.app(b.var(p.name, partial), &[b.var(n.name, INT)], INT), + ), + ), + ); + assert_optimization_snapshot!(&b, core, "crossed_trace"); + let escape = b.lam( + &[f], + b.let_( + p, + b.app(b.var(f.name, full), &[b.int(20)], partial), + b.lam( + &[n], + b.app(b.var(p.name, partial), &[b.var(n.name, INT)], INT), + ), + ), + ); + assert_optimization_snapshot!(&b, escape, "escaping_partial_call"); +} diff --git a/crates/nash-ir/src/small_inline.rs b/crates/nash-ir/src/small_inline.rs index 4c80d21a..59710029 100644 --- a/crates/nash-ir/src/small_inline.rs +++ b/crates/nash-ir/src/small_inline.rs @@ -7,7 +7,8 @@ use crate::{ }; use std::{collections::HashSet, ptr}; -/// Compose rules 1–4, dead-code cleanup, force/delay cancellation and known Boolean/literal folding. +/// Compose rules 1–4, dead-code cleanup, representation/force-delay cancellation +/// and known Boolean/literal folding. /// Input is typed ANF with globally unique binders. /// Conditional bodies, partial calls and indirect calls are not selected by rule 4. pub fn simplify<'a>(b: &Builder<'a>, mut core: &'a Core<'a>) -> &'a Core<'a> { diff --git a/crates/nash-ir/src/static_lift.rs b/crates/nash-ir/src/static_lift.rs index 61f6a7bf..abf2043b 100644 --- a/crates/nash-ir/src/static_lift.rs +++ b/crates/nash-ir/src/static_lift.rs @@ -1,6 +1,6 @@ //! Lift unchanged self-call parameters while retaining explicit recursion. //! -//! Run before ANF, with globally unique binders. Only singleton recursive groups +//! Use globally unique binders. Only singleton recursive groups //! are lifted; mutual recursion retains its existing dispatcher treatment. use crate::{ build::Builder, @@ -33,6 +33,8 @@ pub fn static_params(f: Name<'_>, params: &[Binder<'_>], body: &Core<'_>) -> Vec /// Capture static parameters in an ordinary wrapper and introduce a recursive /// worker accepting only dynamic parameters. All-static workers are delayed /// recursive values, forced at each original call (never memoized). +/// On ANF input, generated calls retain atomic operands. Cleanup must flatten +/// binding prefixes introduced inside existing strict binding values. pub fn lift<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { let report = crate::analysis::occurrences(core); let mut used: HashSet<_> = report @@ -83,14 +85,15 @@ pub fn lift<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { ) }; let worker = fresh("worker", worker_ty); - let call = |args: &[&'a Core<'a>], ty| { + let mut call = |args: &[&'a Core<'a>], ty| { let target = b.var(worker.name, worker.ty); if dynamic.is_empty() { let forced = b.force(target, result); if args.is_empty() { b.with_type(forced, ty) } else { - b.app(forced, args, ty) + let value = fresh("forced", result); + b.let_(value, forced, b.app(b.var(value.name, result), args, ty)) } } else { b.app(target, args, ty) diff --git a/crates/nash-ir/src/unused_params.rs b/crates/nash-ir/src/unused_params.rs index 64ea360e..c4caa2b0 100644 --- a/crates/nash-ir/src/unused_params.rs +++ b/crates/nash-ir/src/unused_params.rs @@ -1,11 +1,11 @@ -//! Shorten nonrecursive helper signatures before ANF, with exact direct calls only. +//! Shorten helper signatures before ANF, with exact direct calls only. use crate::{ analysis, anf, build::Builder, - core::{Binder, Core, CoreKind}, + core::{Binder, Core, CoreKind, RecBinder}, ty::{RuntimeTy, TermTy, Ty}, }; -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; fn signature<'a>(b: &Builder<'a>, ty: Ty<'a>, keep: &[bool]) -> Option> { let Ty::Term(TermTy::Fun(params, result)) = ty else { @@ -35,8 +35,9 @@ fn signature<'a>(b: &Builder<'a>, ty: Ty<'a>, keep: &[bool]) -> Option> { /// Every non-atomic argument gets a strict binding in source order before the /// shortened call, including discarded arguments. Exact calls to a known lambda /// cannot run its body during partial application. Atoms are safe to discard. -/// Bindings stay call-local; this pass does not remove them or change LetRec -/// parameters. All-unused helpers become delays, forced separately at each call. +/// Bindings stay call-local. Recursive parameter liveness follows bare-variable +/// forwarding dependencies to a fixed point; compound arguments stay strict. +/// All-unused helpers become delays, forced separately at each call. /// Use the enclosing program Builder when optimizing a subtree for reinsertion. pub fn reduce<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { let report = analysis::occurrences(core); @@ -47,6 +48,9 @@ pub fn reduce<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { .chain(report.uses.iter().map(|x| x.name.unique)) .collect(); core.map(b, &mut |node| { + if let CoreKind::LetRec { binders, body } = node.kind { + return recursive(b, node, binders, body, &mut occupied); + } let CoreKind::Let { binder, value, @@ -115,35 +119,7 @@ pub fn reduce<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { if name.unique != binder.name.unique { return None; } - let func = b.var( - name, - signature(b, func.ty, &keep).expect("prechecked signature"), - ); - let mut prefix = Vec::new(); - let mut retained = Vec::new(); - for (arg, keep) in args.iter().zip(&keep) { - let argument = if anf::is_atom(arg) { - *arg - } else { - let name = loop { - let name = b.fresh("arg"); - if occupied.insert(name.unique) { break name; } - }; - let binder = Binder { name, ty: arg.ty }; - prefix.push((binder, *arg)); - b.var(name, arg.ty) - }; - if *keep { retained.push(argument); } - } - let mut result = if retained.is_empty() { - b.force(func, call.ty) - } else { - b.app(func, &retained, call.ty) - }; - for (binder, value) in prefix.into_iter().rev() { - result = b.let_(binder, value, result); - } - Some(result) + Some(shorten_call(b, call, func, args, &keep, &mut occupied)) }); Some(b.with_type( b.let_( @@ -158,3 +134,203 @@ pub fn reduce<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> { )) }) } + +fn shorten_call<'a>( + b: &Builder<'a>, + call: &'a Core<'a>, + func: &'a Core<'a>, + args: &[&'a Core<'a>], + keep: &[bool], + occupied: &mut HashSet, +) -> &'a Core<'a> { + let CoreKind::Var(name) = func.kind else { + unreachable!("prechecked direct call") + }; + let func = b.var( + name, + signature(b, func.ty, keep).expect("prechecked signature"), + ); + let mut prefix = Vec::new(); + let mut retained = Vec::new(); + for (arg, keep) in args.iter().zip(keep) { + let argument = if anf::is_atom(arg) { + *arg + } else { + let name = loop { + let name = b.fresh("arg"); + if occupied.insert(name.unique) { + break name; + } + }; + let binder = Binder { name, ty: arg.ty }; + prefix.push((binder, *arg)); + b.var(name, arg.ty) + }; + if *keep { + retained.push(argument); + } + } + let mut result = if retained.is_empty() { + b.force(func, call.ty) + } else { + b.app(func, &retained, call.ty) + }; + for (binder, value) in prefix.into_iter().rev() { + result = b.let_(binder, value, result); + } + result +} + +fn recursive<'a>( + b: &Builder<'a>, + node: &'a Core<'a>, + binders: &'a [RecBinder<'a>], + body: &'a Core<'a>, + occupied: &mut HashSet, +) -> Option<&'a Core<'a>> { + // Existing delayed workers and unsupported views are left alone. This also + // makes a group containing a newly delayed worker stable on a second pass. + if binders.is_empty() + || binders.iter().any(|r| { + r.params.is_empty() + || !matches!(r.binder.ty, Ty::Term(TermTy::Fun(ps,_)) if ps.len() == r.params.len()) + }) + { + return None; + } + let members: HashMap<_, _> = binders + .iter() + .enumerate() + .map(|(i, r)| (r.binder.name.unique, i)) + .collect(); + let mut offsets = Vec::new(); + let mut slots = HashMap::new(); + for r in binders { + offsets.push(slots.len()); + for p in r.params { + slots.insert(p.name.unique, slots.len()); + } + } + let mut live = vec![false; slots.len()]; + let mut dependencies = vec![Vec::new(); slots.len()]; + let mut uses = vec![0; binders.len()]; + let mut calls = vec![0; binders.len()]; + // A bare variable argument is the only evaluation we can remove outright. + // Every variable inside other arguments remains live because their strict + // evaluation is retained, even when the receiving parameter is removed. + let mut pending: Vec<_> = binders.iter().map(|r| r.body).chain([body]).collect(); + while let Some(term) = pending.pop() { + match term.kind { + CoreKind::Var(name) => { + if let Some(&i) = members.get(&name.unique) { + uses[i] += 1; + } + if let Some(&i) = slots.get(&name.unique) { + live[i] = true; + } + } + CoreKind::App { func, args } if matches!(func.kind,CoreKind::Var(name) if members.contains_key(&name.unique)) => + { + let CoreKind::Var(name) = func.kind else { + unreachable!() + }; + let i = members[&name.unique]; + uses[i] += 1; + if args.len() != binders[i].params.len() + || !matches!(func.ty,Ty::Term(TermTy::Fun(ps,_)) if ps.len()==args.len()) + { + return None; + } + calls[i] += 1; + for (slot, arg) in args.iter().enumerate() { + if let CoreKind::Var(name) = arg.kind + && let Some(&source) = slots.get(&name.unique) + { + dependencies[offsets[i] + slot].push(source); + continue; + } + pending.push(arg); + } + } + _ => term.push_children_reversed(&mut pending), + } + } + if uses != calls || calls.iter().all(|n| *n == 0) { + return None; + } + let mut pending: Vec<_> = live + .iter() + .enumerate() + .filter_map(|(i, v)| v.then_some(i)) + .collect(); + while let Some(target) = pending.pop() { + for &source in &dependencies[target] { + if !live[source] { + live[source] = true; + pending.push(source); + } + } + } + if live.iter().all(|v| *v) { + return None; + } + let masks: Vec<_> = binders + .iter() + .enumerate() + .map(|(i, r)| &live[offsets[i]..offsets[i] + r.params.len()]) + .collect(); + let mut rewrite = |core: &'a Core<'a>| { + core.map(b, &mut |call| { + let CoreKind::App { func, args } = call.kind else { + return None; + }; + let CoreKind::Var(name) = func.kind else { + return None; + }; + let &i = members.get(&name.unique)?; + let keep = masks[i]; + if keep.iter().all(|v| *v) { + return None; + } + Some(shorten_call(b, call, func, args, keep, occupied)) + }) + }; + let mut group = Vec::new(); + for (i, r) in binders.iter().enumerate() { + let keep = masks[i]; + let params: Vec<_> = r + .params + .iter() + .zip(keep) + .filter_map(|(p, k)| k.then_some(*p)) + .collect(); + let statics: Vec<_> = r + .static_params + .iter() + .filter_map(|&old| { + let old = usize::from(old); + keep.get(old) + .copied() + .unwrap_or(false) + .then(|| u16::try_from(keep[..old].iter().filter(|v| **v).count()).ok()) + .flatten() + }) + .collect(); + let body = rewrite(r.body); + group.push(RecBinder { + binder: Binder { + ty: signature(b, r.binder.ty, keep)?, + ..r.binder + }, + params: b.arena.alloc_slice_copy(¶ms), + static_params: b.arena.alloc_slice_copy(&statics), + body: if params.is_empty() { + b.delay(body) + } else { + body + }, + }); + } + let body = rewrite(body); + Some(b.with_type(b.let_rec(&group, body), node.ty)) +} diff --git a/crates/nash-plutus/src/machine/constant_eval.rs b/crates/nash-plutus/src/machine/constant_eval.rs new file mode 100644 index 00000000..093d1d4f --- /dev/null +++ b/crates/nash-plutus/src/machine/constant_eval.rs @@ -0,0 +1,106 @@ +//! Direct evaluation of pure constant builtin applications for compiler folding. +use bumpalo::collections::Vec as BumpVec; + +use crate::{arena::Arena, binder::DeBruijn, builtin::DefaultFunction, constant::Constant}; + +use super::{ + CostModel, ExBudget, Machine, PlutusVersion, + cost_model::{builtin_costs::BuiltinCostModel, cost_map::CostMap}, + runtime::Runtime, + value::Value, +}; + +#[derive(Default)] +struct NoCosts; + +impl BuiltinCostModel for NoCosts { + fn initialize(_: &CostMap) -> Self { + Self + } + + fn get_cost(&self, _: DefaultFunction, _: &[i64]) -> Option { + Some(ExBudget::new(0, 0)) + } +} + +/// Evaluate one fully applied pure builtin without an execution budget. +/// Arguments must have consistent container metadata and payload types. +/// Errors and effectful calls return None. Ordinary program evaluation retains +/// its ledger cost model and budget. +pub fn eval_constant_builtin<'a>( + arena: &'a Arena, + func: DefaultFunction, + args: &[&'a Constant<'a>], +) -> Option<&'a Constant<'a>> { + if func == DefaultFunction::Trace || args.len() != func.arity() { + return None; + } + let mut values = BumpVec::new_in(arena.as_bump()); + values.extend(args.iter().map(|c| Value::con(arena, c))); + let runtime = arena.alloc(Runtime { + args: values, + fun: arena.alloc(func), + forces: func.force_count(), + }); + let mut machine: Machine<'_, NoCosts, DeBruijn> = Machine::new( + arena, + ExBudget::new(0, 0), + CostModel::default(), + (&PlutusVersion::V3).into(), + ); + match machine.call(runtime).ok()? { + Value::Con(c) => Some(c), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{constant::Integer, typ::Type}; + + #[test] + fn large_pure_evaluation_has_no_cost_budget() { + let arena = Arena::new(); + let value = Constant::string(&arena, arena.as_bump().alloc_str(&"x".repeat(100_000))); + let result = + eval_constant_builtin(&arena, DefaultFunction::AppendString, &[value, value]).unwrap(); + let Constant::String(result) = result else { + panic!("expected string"); + }; + // Independent semantic check on a result exceeding the former memory and byte caps. + assert_eq!(*result, "x".repeat(200_000)); + } + + #[test] + fn huge_drop_uses_builtin_semantics_without_costing_overflow() { + let arena = Arena::new(); + let count = Constant::integer(&arena, arena.alloc_integer(Integer::from(1) << 200)); + let list = Constant::proto_list( + &arena, + &Type::Integer, + arena.alloc([Constant::integer_from(&arena, 1)]), + ); + let result = + eval_constant_builtin(&arena, DefaultFunction::DropList, &[count, list]).unwrap(); + assert_eq!(result, Constant::proto_list(&arena, &Type::Integer, &[])); + } + + #[test] + fn effects_and_failed_calls_are_not_folded() { + let arena = Arena::new(); + let one = Constant::integer_from(&arena, 1); + let zero = Constant::integer_from(&arena, 0); + assert!( + eval_constant_builtin( + &arena, + DefaultFunction::Trace, + &[Constant::string(&arena, "trace"), one] + ) + .is_none() + ); + assert!( + eval_constant_builtin(&arena, DefaultFunction::DivideInteger, &[one, zero]).is_none() + ); + } +} diff --git a/crates/nash-plutus/src/machine/mod.rs b/crates/nash-plutus/src/machine/mod.rs index f730b187..804e7329 100644 --- a/crates/nash-plutus/src/machine/mod.rs +++ b/crates/nash-plutus/src/machine/mod.rs @@ -1,4 +1,5 @@ mod cek; +mod constant_eval; mod context; pub(crate) mod cost_model; mod discharge; @@ -18,3 +19,5 @@ pub use eval_result::*; pub use info::*; pub use runtime::BuiltinSemantics; pub use runtime::PlutusVersion; + +pub use constant_eval::eval_constant_builtin; diff --git a/crates/nash-plutus/src/machine/runtime.rs b/crates/nash-plutus/src/machine/runtime.rs index 551e680f..38e97f1e 100644 --- a/crates/nash-plutus/src/machine/runtime.rs +++ b/crates/nash-plutus/src/machine/runtime.rs @@ -626,10 +626,10 @@ impl<'a, B: BuiltinCostModel, V: Eval<'a>> Machine<'a, B, V> { self.spend_budget(budget)?; - let index: i128 = arg2.try_into().unwrap(); + let index = usize::try_from(arg2).ok(); - if 0 <= index && (index as usize) < arg1.len() { - let result: Integer = arg1[index as usize].into(); + if let Some(byte) = index.and_then(|i| arg1.get(i)) { + let result: Integer = (*byte).into(); let new = self.arena.alloc_integer(result); let value = Value::integer(self.arena, new); @@ -1337,7 +1337,9 @@ impl<'a, B: BuiltinCostModel, V: Eval<'a>> Machine<'a, B, V> { )); } - let tag = tag.try_into().expect("should cast to u64 just fine"); + let tag = tag + .try_into() + .map_err(|_| MachineError::MaxConstrTagExceeded(runtime.args[0]))?; let fields: BumpVec<'_, _> = fields .iter() .map(|d| match d { @@ -2756,10 +2758,7 @@ impl<'a, B: BuiltinCostModel, V: Eval<'a>> Machine<'a, B, V> { let bytes = runtime.args[0].unwrap_byte_string()?; let shift = runtime.args[1].unwrap_integer()?; - let arg1: i64 = u64::try_from(shift.abs()) - .unwrap() - .try_into() - .unwrap_or(i64::MAX); + let arg1: i64 = i64::try_from(shift.abs()).unwrap_or(i64::MAX); let budget = self .costs @@ -2787,7 +2786,7 @@ impl<'a, B: BuiltinCostModel, V: Eval<'a>> Machine<'a, B, V> { if is_shift_left { if bit_shift == 0 { // If we can shift entire bytes, that's much simpler - let copy_len = length - bit_shift; + let copy_len = length - byte_shift; // For example, consider the following byte array [1,0,1,0,1] being shifted 8 bits (1 byte) // Result: [0,1,0,1,0] result[..copy_len].copy_from_slice(&bytes[byte_shift..]); @@ -2849,10 +2848,7 @@ impl<'a, B: BuiltinCostModel, V: Eval<'a>> Machine<'a, B, V> { let bytes = runtime.args[0].unwrap_byte_string()?; let shift = runtime.args[1].unwrap_integer()?; - let arg1: i64 = u64::try_from(shift.abs()) - .unwrap() - .try_into() - .unwrap_or(i64::MAX); + let arg1: i64 = i64::try_from(shift.abs()).unwrap_or(i64::MAX); let budget = self .costs @@ -3034,10 +3030,7 @@ impl<'a, B: BuiltinCostModel, V: Eval<'a>> Machine<'a, B, V> { let elements_to_drop = runtime.args[0].unwrap_integer()?; let (list_type, list) = runtime.args[1].unwrap_list()?; - let arg0: i64 = u64::try_from(elements_to_drop.abs()) - .unwrap() - .try_into() - .unwrap_or(i64::MAX); + let arg0: i64 = i64::try_from(elements_to_drop.abs()).unwrap_or(i64::MAX); let budget = self .costs @@ -3131,10 +3124,9 @@ impl<'a, B: BuiltinCostModel, V: Eval<'a>> Machine<'a, B, V> { .ok_or(MachineError::NoCostForBuiltin(DefaultFunction::IndexArray))?; self.spend_budget(budget)?; - let index: i128 = arg1.try_into().unwrap(); + let index = usize::try_from(arg1).ok(); - if 0 <= index && (index as usize) < array.len() { - let element = array[index as usize]; + if let Some(element) = index.and_then(|i| array.get(i)) { let value = Value::con(self.arena, element); Ok(value) } else { diff --git a/crates/nash-report/src/type_/records.rs b/crates/nash-report/src/type_/records.rs index 014521b5..89f14f61 100644 --- a/crates/nash-report/src/type_/records.rs +++ b/crates/nash-report/src/type_/records.rs @@ -172,13 +172,19 @@ pub(super) fn missing_field( record: &ErrorType<'_>, available: &[&str], ) -> Report { + let receiver = if matches!(iterated_dealias(record), ErrorType::Type {home,name:"pair",..} if *home == nash_ast::primitives::primitive_home()) + { + "Pair" + } else { + "Record" + }; let (details, suggestions) = match iterated_dealias(record) { ErrorType::Record { fields } => nearby(l, field, fields), _ => { let sorted = crate::suggest::sort(field, |name| (*name).to_string(), available.to_vec()); let mut docs = vec![Doc::cat([ - Doc::text("Record type: "), + Doc::text(format!("{receiver} type: ")), type_diff::to_doc(l, Ctx::None, record), ])]; if let Some(nearest) = sorted.first() { @@ -204,7 +210,7 @@ pub(super) fn missing_field( "TYPE MISMATCH", region, None, - Doc::text(format!("Record has no field `{field}`.")), + Doc::text(format!("{receiver} has no field `{field}`.")), details, ) .with_suggestions(suggestions); diff --git a/crates/nash-solve/src/solve.rs b/crates/nash-solve/src/solve.rs index f1c24005..f2bc5c96 100644 --- a/crates/nash-solve/src/solve.rs +++ b/crates/nash-solve/src/solve.rs @@ -412,6 +412,49 @@ impl<'a> Solver<'a, '_> { }; } Content::Structure(FlatType::App1(home, name, args)) => { + if home == nash_ast::primitives::primitive_home() + && name == "pair" + && args.len() == 2 + { + // Pair projections are read-only fields, not record updates. + if !matches!( + field.context, + type_::FieldContext::Access { .. } | type_::FieldContext::Accessor + ) { + break; + } + let Some((name, field_type)) = field.field else { + break; + }; + let actual = match name { + "fst" => args[0], + "snd" => args[1], + _ => { + errors.push(Error::MissingField { + region: field.region, + context: field.context, + field: name, + record: to_error_type(self.bump, uf, field.record), + available: self.bump.alloc_slice_copy(&["fst", "snd"]), + }); + return true; + } + }; + match self.unify(uf, actual, field_type) { + unify::Answer::Ok(vars) => self.introduce(uf, rank, &vars), + unify::Answer::Err(vars, actual, expected) => { + self.introduce(uf, rank, &vars); + errors.push(Error::FieldMismatch { + region: field.region, + context: field.context, + field: name, + actual, + expected, + }); + } + } + return true; + } let visible = if field.test_scope { &self.tables.test_fields } else { diff --git a/crates/nash-solve/tests/inference.rs b/crates/nash-solve/tests/inference.rs index 9ac6c6ba..eba0931f 100644 --- a/crates/nash-solve/tests/inference.rs +++ b/crates/nash-solve/tests/inference.rs @@ -5261,3 +5261,84 @@ fn nominal_reflexive_lift_does_not_block_alias_conversion_inference() { .unwrap(); assert_inference_snapshot!(@output source, &annotations); } + +#[test] +fn builtin_pair_accessors() { + assert_inference_snapshot!( + r#" + module Main exposing (..) + first : pair 'a 'b -> 'a + first p = p.fst + second : pair 'a 'b -> 'b + second = .snd + nested : pair (pair int bytes) int -> bytes + nested p = p.fst.snd + "# + ); +} + +#[test] +fn builtin_pair_accessor_alias() { + assert_inference_snapshot!( + r#" + module Main exposing (..) + type alias entry 'a = pair int 'a + value : entry bytes -> bytes + value = .snd + "# + ); +} + +#[test] +fn builtin_pair_unknown_field() { + assert_inference_error_snapshot!( + "module Main exposing (..)\nf : pair int int -> int\nf p = p.third\n" + ); +} + +#[test] +fn builtin_pair_accessor_remains_ambiguous() { + assert_inference_error_snapshot!("module Main exposing (..)\nf = .fst\n"); +} + +#[test] +fn builtin_pair_rejects_update() { + assert_inference_error_snapshot!( + "module Main exposing (..)\nf : pair int int -> pair int int\nf p = { p | fst = 1 }\n" + ); +} + +#[test] +fn record_named_pair_fields() { + assert_inference_snapshot!( + r#" + module Main exposing (..) + type alias point = { fst : int, snd : bytes } + first : point -> int + first = .fst + second : point -> bytes + second p = p.snd + "# + ); +} + +#[test] +fn builtin_pair_alias_rejects_update() { + assert_inference_error_snapshot!( + "module Main exposing (..)\ntype alias entry = pair int int\nf : entry -> entry\nf p = { p | snd = 1 }\n" + ); +} + +#[test] +fn builtin_pair_rejects_record_pattern() { + assert_inference_error_snapshot!( + "module Main exposing (..)\nf : pair int int -> int\nf { fst } = fst\n" + ); +} + +#[test] +fn builtin_pair_field_type_mismatch() { + assert_inference_error_snapshot!( + "module Main exposing (..)\nf : pair int bytes -> int\nf p = p.snd\n" + ); +} diff --git a/crates/nash-solve/tests/snapshots/inference__builtin_pair_accessor_alias.snap b/crates/nash-solve/tests/snapshots/inference__builtin_pair_accessor_alias.snap new file mode 100644 index 00000000..5fa9bf86 --- /dev/null +++ b/crates/nash-solve/tests/snapshots/inference__builtin_pair_accessor_alias.snap @@ -0,0 +1,5 @@ +--- +source: crates/nash-solve/tests/inference.rs +description: "Code:\n\nmodule Main exposing (..)\ntype alias entry 'a = pair int 'a\nvalue : entry bytes -> bytes\nvalue = .snd\n" +--- +value : entry bytes -> bytes diff --git a/crates/nash-solve/tests/snapshots/inference__builtin_pair_accessor_remains_ambiguous.snap b/crates/nash-solve/tests/snapshots/inference__builtin_pair_accessor_remains_ambiguous.snap new file mode 100644 index 00000000..d2944a51 --- /dev/null +++ b/crates/nash-solve/tests/snapshots/inference__builtin_pair_accessor_remains_ambiguous.snap @@ -0,0 +1,15 @@ +--- +source: crates/nash-solve/tests/inference.rs +description: "module Main exposing (..)\nf = .fst\n" +info: diagnostic +--- +nash::type::ambiguous_record_access + + × Cannot determine record type `'a`. + ╭─[Main.nash:2:5] + 1 │ module Main exposing (..) + 2 │ f = .fst + · ──┬─ + · ╰── field `fst` accessor + ╰──── + help: Add a type annotation that identifies the record. diff --git a/crates/nash-solve/tests/snapshots/inference__builtin_pair_accessors.snap b/crates/nash-solve/tests/snapshots/inference__builtin_pair_accessors.snap new file mode 100644 index 00000000..43c3aa54 --- /dev/null +++ b/crates/nash-solve/tests/snapshots/inference__builtin_pair_accessors.snap @@ -0,0 +1,7 @@ +--- +source: crates/nash-solve/tests/inference.rs +description: "Code:\n\nmodule Main exposing (..)\nfirst : pair 'a 'b -> 'a\nfirst p = p.fst\nsecond : pair 'a 'b -> 'b\nsecond = .snd\nnested : pair (pair int bytes) int -> bytes\nnested p = p.fst.snd\n" +--- +first : forall a b. (Storable a, Storable b) => pair a b -> a +nested : pair (pair int bytes) int -> bytes +second : forall a b. (Storable a, Storable b) => pair a b -> b diff --git a/crates/nash-solve/tests/snapshots/inference__builtin_pair_alias_rejects_update.snap b/crates/nash-solve/tests/snapshots/inference__builtin_pair_alias_rejects_update.snap new file mode 100644 index 00000000..aa12eaff --- /dev/null +++ b/crates/nash-solve/tests/snapshots/inference__builtin_pair_alias_rejects_update.snap @@ -0,0 +1,14 @@ +--- +source: crates/nash-solve/tests/inference.rs +description: "module Main exposing (..)\ntype alias entry = pair int int\nf : entry -> entry\nf p = { p | snd = 1 }\n" +info: diagnostic +--- +nash::type::not_a_record + + × Expected a record, found `entry`. + ╭─[Main.nash:4:13] + 3 │ f : entry -> entry + 4 │ f p = { p | snd = 1 } + · ─┬─ + · ╰── field `snd` update of `p` + ╰──── diff --git a/crates/nash-solve/tests/snapshots/inference__builtin_pair_field_type_mismatch.snap b/crates/nash-solve/tests/snapshots/inference__builtin_pair_field_type_mismatch.snap new file mode 100644 index 00000000..8677521f --- /dev/null +++ b/crates/nash-solve/tests/snapshots/inference__builtin_pair_field_type_mismatch.snap @@ -0,0 +1,17 @@ +--- +source: crates/nash-solve/tests/inference.rs +description: "module Main exposing (..)\nf : pair int bytes -> int\nf p = p.snd\n" +info: diagnostic +--- +nash::type::mismatch + + × Type mismatch: expected `int`, found `bytes`. + ╭─[Main.nash:3:7] + 1 │ module Main exposing (..) + 2 │ f : pair int bytes -> int + · ──────────┬────────── + · ╰── declared type + 3 │ f p = p.snd + · ──┬── + · ╰── body of `f` + ╰──── diff --git a/crates/nash-solve/tests/snapshots/inference__builtin_pair_rejects_record_pattern.snap b/crates/nash-solve/tests/snapshots/inference__builtin_pair_rejects_record_pattern.snap new file mode 100644 index 00000000..cc8f4edb --- /dev/null +++ b/crates/nash-solve/tests/snapshots/inference__builtin_pair_rejects_record_pattern.snap @@ -0,0 +1,14 @@ +--- +source: crates/nash-solve/tests/inference.rs +description: "module Main exposing (..)\nf : pair int int -> int\nf { fst } = fst\n" +info: diagnostic +--- +nash::type::not_a_record + + × Expected a record, found `pair int int`. + ╭─[Main.nash:3:3] + 2 │ f : pair int int -> int + 3 │ f { fst } = fst + · ───┬─── + · ╰── field `fst` pattern + ╰──── diff --git a/crates/nash-solve/tests/snapshots/inference__builtin_pair_rejects_update.snap b/crates/nash-solve/tests/snapshots/inference__builtin_pair_rejects_update.snap new file mode 100644 index 00000000..cf866392 --- /dev/null +++ b/crates/nash-solve/tests/snapshots/inference__builtin_pair_rejects_update.snap @@ -0,0 +1,14 @@ +--- +source: crates/nash-solve/tests/inference.rs +description: "module Main exposing (..)\nf : pair int int -> pair int int\nf p = { p | fst = 1 }\n" +info: diagnostic +--- +nash::type::not_a_record + + × Expected a record, found `pair int int`. + ╭─[Main.nash:3:13] + 2 │ f : pair int int -> pair int int + 3 │ f p = { p | fst = 1 } + · ─┬─ + · ╰── field `fst` update of `p` + ╰──── diff --git a/crates/nash-solve/tests/snapshots/inference__builtin_pair_unknown_field.snap b/crates/nash-solve/tests/snapshots/inference__builtin_pair_unknown_field.snap new file mode 100644 index 00000000..56883907 --- /dev/null +++ b/crates/nash-solve/tests/snapshots/inference__builtin_pair_unknown_field.snap @@ -0,0 +1,19 @@ +--- +source: crates/nash-solve/tests/inference.rs +description: "module Main exposing (..)\nf : pair int int -> int\nf p = p.third\n" +info: diagnostic +--- +nash::type::missing_field + + × Pair has no field `third`. + ╭─[Main.nash:3:7] + 2 │ f : pair int int -> int + 3 │ f p = p.third + · ───┬─── + · ╰── field `third` of `p` + ╰──── + help: Pair type: pair int int + + Did you mean `snd`? + + Available fields: `snd`, `fst`. diff --git a/crates/nash-solve/tests/snapshots/inference__record_named_pair_fields.snap b/crates/nash-solve/tests/snapshots/inference__record_named_pair_fields.snap new file mode 100644 index 00000000..04b23e88 --- /dev/null +++ b/crates/nash-solve/tests/snapshots/inference__record_named_pair_fields.snap @@ -0,0 +1,6 @@ +--- +source: crates/nash-solve/tests/inference.rs +description: "Code:\n\nmodule Main exposing (..)\ntype alias point = { fst : int, snd : bytes }\nfirst : point -> int\nfirst = .fst\nsecond : point -> bytes\nsecond p = p.snd\n" +--- +first : point -> int +second : point -> bytes diff --git a/crates/nash-test/src/run.rs b/crates/nash-test/src/run.rs index 28a278d8..433a4f1c 100644 --- a/crates/nash-test/src/run.rs +++ b/crates/nash-test/src/run.rs @@ -3,7 +3,7 @@ use crate::{ prng::{Prng, Trace}, shrink, *, }; -use nash_plutus::{arena::Arena, machine::PlutusVersion as MachineVersion}; +use nash_plutus::{arena::Arena, machine::PlutusVersion}; use rayon::prelude::*; pub fn run_all(tests: Vec, config: &Config) -> Vec { @@ -21,13 +21,6 @@ pub fn run_all(tests: Vec, config: &Config) -> Vec { Err(_) => run(), } } -fn version(v: PlutusVersion) -> MachineVersion { - match v { - PlutusVersion::V1 => MachineVersion::V1, - PlutusVersion::V2 => MachineVersion::V2, - PlutusVersion::V3 => MachineVersion::V3, - } -} fn exceeded(limit: Option, used: ExBudget) -> Option { limit .filter(|b| match b { @@ -60,7 +53,7 @@ fn run_one(test: TestProgram, config: &Config) -> Outcome { run_one_with_budget(test, config, ExBudget::max()) } fn run_one_with_budget(test: TestProgram, config: &Config, machine_budget: ExBudget) -> Outcome { - let v = version(test.plutus_version); + let v = PlutusVersion::V3; let mut out = Outcome { test, status: Status::Pass, @@ -253,7 +246,6 @@ mod tests { programs, asserts: vec![], binder_texts: vec![], - plutus_version: PlutusVersion::V3, source: String::new(), source_path: "Budget.nash".into(), } @@ -303,7 +295,7 @@ mod tests { let arena = &Arena::new(); let run = bytes(arena, Term::error(arena)); let exhausted = - eval::evaluate_with_budget(arena, MachineVersion::V3, &run, None, ExBudget::new(0, 0)); + eval::evaluate_with_budget(arena, PlutusVersion::V3, &run, None, ExBudget::new(0, 0)); assert!(exhausted.term.is_err()); assert_eq!(exhausted.exhausted, Some(ExBudget::new(0, 0))); assert!(invalid_shrink_evaluation(&exhausted, None)); @@ -311,7 +303,7 @@ mod tests { &exhausted, Some(Budget::Cpu(i128::MAX)) )); - let body_error = eval::evaluate(arena, MachineVersion::V3, &run, None); + let body_error = eval::evaluate(arena, PlutusVersion::V3, &run, None); assert!(body_error.term.is_err()); assert_eq!(body_error.exhausted, None); assert!(!invalid_shrink_evaluation(&body_error, None)); @@ -325,7 +317,7 @@ mod tests { ); let failure = eval::prepare( arena, - MachineVersion::V3, + PlutusVersion::V3, &program, &Prng::from_seed(42), ExBudget::new(0, 0), diff --git a/crates/nash-test/src/types.rs b/crates/nash-test/src/types.rs index dd238c63..e8250d29 100644 --- a/crates/nash-test/src/types.rs +++ b/crates/nash-test/src/types.rs @@ -1,4 +1,3 @@ -pub use nash_config::PlutusVersion; pub use nash_plutus::machine::ExBudget; use nash_region::Region; pub use nash_source::{Budget, Expect}; @@ -14,7 +13,6 @@ pub struct TestProgram { pub programs: Programs, pub asserts: Vec, pub binder_texts: Vec, - pub plutus_version: PlutusVersion, pub source: String, pub source_path: PathBuf, } diff --git a/crates/nash-test/tests/runtime.rs b/crates/nash-test/tests/runtime.rs index 44dd1a48..a1b79516 100644 --- a/crates/nash-test/tests/runtime.rs +++ b/crates/nash-test/tests/runtime.rs @@ -30,7 +30,6 @@ fn fixture(programs: Programs, expect: Expect) -> TestProgram { programs, asserts: vec![], binder_texts: vec!["x".into()], - plutus_version: PlutusVersion::V3, source: "x == 2".into(), source_path: "Example.nash".into(), } diff --git a/docs/cli.md b/docs/cli.md index 291af595..28e201cc 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -36,8 +36,7 @@ Global flags, accepted before the subcommand: | Flag | Default | Effect | |---|---|---| -| `-O0` / `-O1`, `--optimize 0\|1` | config `optimize`, else `1` | Select baseline or trace-preserving optimization. | -| `--plutus-version v1\|v2\|v3` | config `plutusVersion`, else `v3` | Ledger language target at the protocol 11 baseline. | +| `-O0` / `-O1` / `-O2`, `--optimize 0\|1\|2` | config `optimize`, else `1` | Select baseline, trace-preserving O1, or silent O2. | | `--trace-level silent\|compact\|verbose` | config `traceLevel`, else `silent` | User `trace` compilation mode. | | `--compiler-traces[=true\|false]` | config `compilerTraces`, else false | Independently control compiler traces; the bare flag enables them. | | `--out DIR` | `build` | Output directory. | @@ -46,20 +45,25 @@ CLI options override the owning project's configuration. `-O0` / `--optimize 0` keeps baseline lowering. `-O1` / `--optimize 1` enables accepted optimizations (the default) while preserving enabled user/compiler traces and their order. Both `build` and `test` accept this option. O1 does not enable or disable traces. +`-O2` requires silent settings: explicit compact/verbose tracing or enabled compiler +traces are errors. O2 strips all emitted traces and removes their message +computations even if those computations fail or diverge, then runs O1. Returned +values and ordinary work outside the trace remain strict. O2 tests are silent, +including assertion payloads and property labels; runner status reporting remains +available. See [the erasure boundary](codegen.md#o1-composition-and-convergence). See [target compatibility](validators.md#target-compatibility). `nash test`: | Flag | Default | Effect | |---|---|---| -| `-O0` / `-O1`, `--optimize 0\|1` | config `optimize`, else `1` | Same pipeline as `build`. | +| `-O0` / `-O1` / `-O2`, `--optimize 0\|1\|2` | config `optimize`, else `1` | Same pipeline as `build`. | | `--seed N` | random `u32` | Seed for property tests. Printed in the summary so a run can be replayed. | | `--max-success N` | `100` | Iterations per property. | | `--match PATTERN` | all | Run only tests whose `Module.Name` or name contains `PATTERN`. Repeatable. `--match "Vesting.{claim}"` selects a test by name inside a module. | | `--exact` | off | `--match` compares whole strings. | -| `--trace-level` | config `traceLevel`, else `verbose` | As for `build`, but tests default to `verbose`. | +| `--trace-level` | config `traceLevel`, else `verbose` (O0/O1) or `silent` (O2) | As for `build`; O2 rejects non-silent settings. | | `--jobs N` | number of cores | Positive worker count; fixed seeds give the same ordered results across worker counts. | -| `--plutus-version v1\|v2\|v3` | member config, else `v3` | Target validation and bundled execution cost model. | | `--json` | off | Write one structured result document to stdout. | | `--coverage labels\|tests` | `labels` | Denominator of the label table: total labels, or total iterations. | @@ -141,8 +145,7 @@ Three optional build settings are accepted on `application` and `package` config { "type": "application", "sourceDirectories": ["src"], - "plutusVersion": "v3", // "v1" | "v2" | "v3"; default "v3" - "optimize": 1, // 0 or 1 (default); independent of trace settings + "optimize": 1, // 0, 1 (default), or 2; O2 requires silent settings "traceLevel": "compact", // "silent" | "compact" | "verbose"; default "silent" "compilerTraces": false, // boolean; default false "dependencies": { } @@ -151,8 +154,7 @@ Three optional build settings are accepted on `application` and `package` config | Field | Used by | Meaning | |---|---|---| -| `plutusVersion` | `build` | Ledger language target and permitted generated features at the supported protocol baseline. | -| `optimize` | `build`, `test` | Default for `-O` / `--optimize`; 0 or 1. | +| `optimize` | `build`, `test` | Default for `-O` / `--optimize`; 0, 1, or 2; O2 requires silent settings. | | `traceLevel` | `build` | Default for `--trace-level`. | | `compilerTraces` | `build` | Default for `--compiler-traces`; independent of user traces. | @@ -161,7 +163,7 @@ apply to every member for that invocation. A dependency's values are ignored: the building project's settings apply to the whole script. -Rust side (`crates/nash-config/src/config.rs`): `PlutusVersion` and +Rust side (`crates/nash-config/src/config.rs`): `OptimizationLevel` and `TraceLevel` enums and `Build` settings with validated JSONC defaults. Details in [plans/09](../plans/09-validators-build.md). ## Open questions diff --git a/docs/codegen.md b/docs/codegen.md index be856412..897be6a9 100644 --- a/docs/codegen.md +++ b/docs/codegen.md @@ -833,15 +833,15 @@ local bindings also retain strict evaluation. ## Build targets -Production assembly accepts a ledger target and validates generated UPLC against +Production assembly targets Plutus V3 only and validates generated UPLC against the protocol 11 compatibility baseline described in [validators.md](validators.md#target-compatibility). -`assemble_core` remains the default V3 entrypoint; `assemble_core_for_version` -emits UPLC 1.1.0 for V1, V2, and V3 and checks the complete program. +`assemble_core` is the O0 entrypoint; it emits UPLC 1.1.0 and checks the complete program. O1 is the build/test default; O0 remains available (required recursion rewriting then ordinary lowering). `assemble_core_with_options` also supports O1: shared `optimizer::optimize` -performs freshening, static lifting, unused-parameter removal, direct constructor -folding and representation inverse cancellation, then one ANF normalization and accepted -cleanup/known-case passes. Recursion is encoded afterwards, binders are freshened, +performs freshening, static lifting and unused-parameter removal, then one ANF +normalization. Constructor folding and representation cancellation run in the +post-ANF cleanup/known-case loops. Bounded constant folding then repeats with +cleanup to stability, without another ANF normalization. Recursion is encoded afterwards, binders are freshened, and forced-builtin/constant-prefix sharing runs during lowering. O1 preserves all traces generated by the selected trace settings; it does not strip traces. Snapshot and performance pipelines reuse this production optimizer. Explicit @@ -906,12 +906,12 @@ rooted in continuation references and their transitive member dependencies. It retains source order and existing metadata. Repeating cleanup releases newly unused safe captures while preserving effectful initializers. The accepted pre-ANF `unused_params::reduce` pass removes unused parameters from nonrecursive -let-bound lambdas only when all uses are exact direct calls. It preserves strict +let-bound lambdas and recursive groups only when all uses are exact direct calls. It preserves strict argument evaluation before or after ANF: each non-atomic argument gets a call-local strict binding in source order, including discarded arguments. It uses Delay/Force when every parameter is unused. The pass runs after static lifting and before the single ANF normalization, followed by accepted cleanup. -Partial/staged/escaping/oversaturated uses and recursive signatures are unchanged; +Partial/staged/escaping/oversaturated uses retain the whole recursive group; these accepted passes run in production O1. @@ -923,10 +923,20 @@ lets without another ANF pass. Cancellation runs in the accepted fixed-point loop before beta cleanup. -Plan 08 Chunk 6 also requires recursive unused-parameter removal. This is pending -design and implementation, including self/mutual forwarding dependencies, strict -argument evaluation and consistent worker/static-parameter metadata. The current -accepted nonrecursive pass does not implement that scope. +Recursive parameter liveness reaches a fixed point across the group. A bare +parameter passed to another member creates a dependency from the receiving slot +to the sending slot; all other uses consume the parameter. Thus a forwarding-only +cycle is removable, but a use inside a strict compound argument is retained. +Signatures, direct-call type views and retained static-parameter indices change +together. Captures retain their original unique IDs. Existing delayed workers +are conservatively left unchanged by signature reduction. + +All-unused workers have no parameters, a delayed binder type and an explicit +`Delay` body. Self-application and the mutual dispatcher both keep this body cold +until `Force`; repeated entry repeats execution rather than memoizing it. +Mutual groups can mix delayed workers and functions. Reachability cleanup handles +both. This remains one traversal after static lifting and before ANF, not a new +whole-program fixed point. See [measurements](research/recursive-parameters.md). Chunk 7 includes accepted `known_case::reduce_bool` cleanup. A literal Boolean subject @@ -937,18 +947,123 @@ force/delay cancellation and before beta cleanup. This lets cleanup expose new literal subjects and remove dead branch helpers, without another ANF pass. Production O1 includes these accepted passes. -Accepted native-constructor folding (`known_case::reduce_constr`) runs after -static lifting and unused-parameter removal, before the single ANF pass. It -selects a direct `Constr` subject's matching `CaseKind::Tag` branch and replaces -field binders with strict lets in original field order. Ignored fields still -evaluate. Malformed tables, absent tags, arity mismatches and non-direct subjects -stay unchanged. No constructor fact propagation is included. +Native-constructor folding runs through `known_case::reduce_bound_constr` in the +post-ANF known-case loops. It follows constructor bindings/aliases and preserves +strict field evaluation, including unused fields. Inlining and cleanup can expose +new matches on subsequent iterations. There is no early constructor-folding pass. -Representation cancellation (`inverse::reduce`) runs both before ANF and inside -the main cleanup loop. It cancels integer/byte/list/map Data round trips and +Representation cancellation (`inverse::reduce`) runs inside the post-ANF main cleanup +loop. There is no early inverse-cancellation pass. It cancels integer/byte/list/map Data round trips and UTF-8 round trips only with runtime-shape evidence; reverse conversions require the precise Data variant or valid UTF-8. Let-bound operands stay at their original evaluation point and only variables are reused. Constructor Data projections and reconstruction reuse variables through retained strict producer bindings, keeping all tag/field/variant checks. Unknown unary shapes stay unchanged. See Plan 08 Chunk 8 for exact retained rules and the zero-regression measurements. + +### Constant builtin evaluation + +Production O1 follows literal bindings and aliases and evaluates exactly saturated +pure builtin calls. Successful, representable results become literals. Static lifting, unused +parameter removal, constant folding and cleanup repeat until Core is unchanged. +There are no attempt, CPU, memory, payload byte, node, depth or output-growth +limits on folding. All pure builtins use the runtime's V3 semantics through a +direct constant evaluator with zero costs, without running a budgeted CEK program. + +Evaluation errors leave calls intact. Trace remains at runtime to preserve effects. +Container metadata must match payloads. Flat cannot represent BLS literals, and +an existing CBOR defect prevents folding negative multi-limb Data integers; those +results remain runtime calls. These are representation constraints, not resource +cutoffs. Explicit user comptime retains its separate budget and diagnostics. + +### Pair fields and restricted pair cleanup + +Field resolution recognizes `fst`/`snd` on known primitive pair types and their +aliases. Codegen supplies the component types and lowers both direct access and +accessor functions to `FstPair`/`SndPair`; the receiver is evaluated once. Pair +record updates and record patterns remain invalid. + +O1's existing `simplify_constr_data` loop runs `pair_projection::reduce` before +constructor/wrapper cleanup. Only a single-used-field case whose subject variable +resolves to `unConstrData dataVar`, with `dataVar` resolving to `constrData tag fields` +and the selected operand already a variable, is rewritten. The following inverse +cleanup removes the introduced projection while retaining both producer bindings. +No general case-to-projection rewrite is enabled and ANF still runs once. + + +### O1 composition and convergence + +The final retained pipeline is binder freshening, static lifting, one traversal +of nonrecursive/recursive unused-parameter removal, one ANF normalization, the +accepted inlining/dead-code cleanup, constructor and representation cleanup, then +static lifting, constant folding and unused-parameter removal with cleanup to a +joint fixed point. Recursion encoding follows optimization. +Freshening and builtin/constant sharing in lowering follow recursion encoding. +The common O1 entry point `lower::lower_optimized` then runs late UPLC binding +cleanup and native application packing. There is no second ANF pass or optimizer +loop that repeats recursion encoding. + +Cleanup stops on unchanged pointers. The traversal preserves pointers for no-op +nodes, and each accepted rewrite returns a changed pointer only for real progress. +This detects same-size binding reassociation as progress. Substitution consumes +bindings or direct applications, case/inverse rules consume known eliminations, +and no inverse rule rebuilds the representation it removes. Recursive call cycles +remain Core data during optimization; cleanup does not execute their bodies. +Composition tests check hygiene and root types after individual rewrites, ANF at +valid cleanup boundaries, cleanup pointer idempotence, same-size progress and +deterministic Core/closed UPLC from independent name supplies. + +Static lifting and unused-parameter removal run again after cleanup. Removing a +constant branch can reveal an unchanged recursive argument or an unused parameter; +pruning a recursive group can reveal a singleton eligible for lifting. These +opportunities are consumed in the same invocation. All-static lifted workers bind +their forced result before applying extra arguments, so call operands stay atomic. +Cleanup flattens introduced binding prefixes without repeating ANF. Tests cover +this joint fixed point, folding beyond 128 calls, large inputs and growing outputs, +failed calls alongside successful folds, and semantic equivalence across invocations. +Executable fixture checks compare Core code after one, two and three invocations +and require late UPLC pointer stability. The explicit performance corpus compares +complete O1 Flat code after all three runs. ANF is not repeated. + +Adjacent `let p = f a in p b` application stages fuse inside single-use Core cleanup +when the binder has exactly one direct use, operands are atomic and intermediate +type views agree. Concatenated App arguments retain left-associative evaluation. +Intervening computations and escaping partial applications remain bound. + +Late UPLC cleanup handles the bindings encoded as lambda applications after +recursion/lowering. It removes immediate identities, substitutes single-use values, +drops unused values and cancels force/delay pairs. It preserves strict computations +and builtin sharing, rejects possible name capture, and never duplicates a lambda +body to unfold recursive self-application. Input is closed, well-scoped named UPLC. + +Native packing turns eligible spines into `Case(Constr(0, args), [function])` only +when function and arguments are UPLC values. It starts at three arguments, where +two native nodes replace more Apply nodes. A non-value later argument remains +outside an eligible packed prefix. Cleanup and packing reach a shrinking fixed +point without reversing packs. These are O1 rules in Plan 08; they preserve traces, +failure and termination. See the [measured report](research/application-packing-trial.md). + +Build and test default to O1. `-O0`, `-O1`, `-O2` and `--optimize 0|1|2` +override the owning project's integer `optimize` setting. O0 retains ordinary +lowering with only required recursion encoding. Explicit comptime evaluation +remains O0. O0/O1 preserve their selected trace policy. + +O2 requires silent tracing: explicit compact/verbose tracing and compiler traces +are configuration errors. Test defaults are applied after command overrides and +do not enable traces for O2. Source user/compiler traces are disabled during +code generation. `optimizer::optimize_silent` removes Core traces and direct or +aliased builtin trace messages before the unchanged O1 pipeline. The emitted UPLC +contains no trace builtin, including inside lambdas and delays. + +O2 deliberately discards a trace's message computation even if it fails or +diverges. Its returned value still evaluates. Independently bound work outside +the trace remains strict; first-class trace values become typed no-log functions. +For example, `Builtin.trace (fail) 42` becomes `42`, but a separate strict +`let message = fail in Builtin.trace message 42` still fails. A message evaluated +by an ordinary higher-order caller also stays strict: erasure does not make +ordinary function arguments lazy. Erasure runs before O1 inlining. +This is an explicit semantic relaxation, so O0/O1 failure equivalence does not +apply to discarded trace messages. See [Plan 15](../plans/15-o2-optimizer.md) and +[measurements](research/o2-silence-trial.md). Broader grouping/motion remains future +work. There are no per-pass settings. Cost regressions remain in the separate +explicit performance workspace. diff --git a/docs/overview.md b/docs/overview.md index c921b6f9..75497670 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -81,8 +81,10 @@ implementation, default imports, Prop and the full validator example. | Deriving | Implemented as macros (`@derive(Eq, Ord, Show, Validate)`). | | IR | Single tree IR (`Core`): monomorphized lambda calculus with explicit reprs. Core -> Core optimization passes. Core -> UPLC `Term`. | | Pattern matching | Maranget decision trees, hoisted leaves, memoized accessors. Exhaustiveness from Elm's `Nitpick/PatternMatches`. | +| Pair access | Known builtin pairs expose read-only `.fst`/`.snd` fields and accessors, lowering to the corresponding builtins. Receiver types resolve these names; ordinary record fields retain their meaning. Pair patterns use native case, with O1 projecting only when constructor inverse cleanup can cancel the projection. | | Native maps | `Primitive.map k v` aliases `list (pair k v)` with Storable components. Map builtins and helper results retain the alias. Library Eq uses structural Data equality for Big/Big maps and selected element equality otherwise; native lists similarly split Big/Little element Eq. | | Recursion | Self-application with static-parameter lifting; mutual recursion via a combined dispatcher. No Y combinator. Plan 08 optimizes ANF Core with explicit recursion first, then rewrites recursion and lowers directly without repeating ANF. O0 keeps required recursion rewriting without optimization. | +| Optimization levels | O0 is the baseline; O1 preserves enabled traces. Planned O2 automatically disables all script traces while preserving success/failure and termination; trace-preserving rewrites remain O1. O1 stays the default. See [Plan 15](../plans/15-o2-optimizer.md). | | Runtime errors | `fail`, `todo`, `trace`, `assert`. Trace levels silent / compact / verbose; compiler-generated traces separate switch. | | Diagnostics | Concise diagnostics with expected/actual types, source labels, stable codes, and shared terminal/JSON/LSP output. One `nash-report` crate. | | Stdlib | `nash/base` package in-repo (`crates/nash-driver/base/`), implicit default imports like Elm's `core`. `Builtin` exposes only real UPLC builtin functions. Synthetic `Primitive` owns primitive types, representation traits, constructors, and unchecked `coerce`. Base ships embedded in `nash-driver`; applications need no explicit dependency or download. Defaults affect canonical scope, not source imports. One module per type pair named by the uppercase name (`List`, `Int`, ...); helpers accept Big or little outer inputs and return little outer results, preserving payload types. No Big `String`. | diff --git a/docs/research/application-packing-trial.md b/docs/research/application-packing-trial.md new file mode 100644 index 00000000..a3bbbce6 --- /dev/null +++ b/docs/research/application-packing-trial.md @@ -0,0 +1,171 @@ +# Application fusion and native packing — case 1 + +The initial case below was measured on 5 October 2026 against `c2259d95` in an +isolated checkout. The user then requested production implementation under +Plan 08, including late UPLC binding cleanup. The integrated results follow the +initial evidence. O2 remains unimplemented. + +The user clarified that application fusion includes the native `Case`/`Constr` +replacement. This trial therefore measures both steps separately and together. + +## Source and generated code + +The source defines a recursive function that returns an addition function: + +```elm +choose : int -> int -> int -> int +choose n = + if Builtin.equalsInteger n 0 then + \x y -> Builtin.addInteger x y + else + choose (Builtin.subtractInteger n 1) + +main : int +main = + let + p = choose 3 20 + in + p 22 +``` + +Current O1 retains the following call sequence after the recursive definition +(binder identifiers omitted here for readability): + +```text +let anf : int -> int -> int = choose 3 in +let p : int -> int = anf 20 in +p 22 +``` + +Two adjacent fusions produce `choose 3 20 22`. Ordinary lowering then emits +`(((choose 3) 20) 22)`. Native packing instead emits: + +```text +case (constr 0 [3, 20, 22]) [choose] +``` + +The recursive implementation of `choose` remains present. This is compiled +source evidence, rather than a hand-built application example. The complete +module, exact generated Core, all before/after UPLC, costs, compiler settings and +reproduction patch are in the [raw trial](../../tools/optimizer-perf/trials/application-packing-case1.json). + +## Measurements + +Each measurement includes the same source inputs in the program. Size is raw +Flat bytes; CPU and memory are Plutus V3/PV11 ledger costs, not wall-clock time. + +| Pipeline | CPU | Memory | Flat bytes | +| --- | ---: | ---: | ---: | +| O0 | 2,470,264 | 11,712 | 61 | +| Current O1 | 2,278,264 | 10,512 | 53 | +| O1 + packing only | 2,278,264 | 10,512 | 53 | +| O1 + fusion only | 2,182,264 | 9,912 | 48 | +| O1 + fusion + packing | 2,166,264 | 9,812 | 50 | + +Fusion removes two binding/application wrappers. Packing alone cannot see across +the retained bindings. After fusion it packs exactly one three-argument call, +saving another 16,000 CPU and 100 memory units at a cost of two bytes compared +with ordinary fusion. The combined result saves 112,000 CPU, 700 memory units +and three bytes compared with current O1. No metric has been used as an automatic +acceptance or rejection gate. + +## Scope and checks + +The Core trial matches only an adjacent, single-use application binding followed +immediately by an application of that binder. It requires atomic operands and +matching RHS, binder and variable type views. The concatenated arguments retain +their original order. Hidden uses in lambda or delay bodies count against the +single-use requirement. + +The lowering trial packs only calls whose function and arguments lower to UPLC +values: variables, constants, lambdas, delays or bare builtins. It does not treat +`Force(Builtin)` as a value. Evaluating the constructor fields before the function +and its application stages therefore crosses no effectful or divergent argument +computation in well-scoped code. Unknown function arity is allowed by this narrow +proof. This is an O1 candidate; it does not depend on disabling traces. + +The trial's two-argument minimum is experimental, not an adopted arity policy. +Only the three-argument case was packed in this fixture. It does not establish +cost tradeoffs for other arities, first-class builtins or real validators. + +All four variants return integer `42` with no logs, and their O0 results and costs +are identical. Independent checks pass for ANF, closed binder hygiene, result +type and fusion pointer idempotence. For this source, both trial pipelines produce +identical closed Flat bytes after one, two and three optimizer invocations. +Strict Clippy passes for the isolated trial workspace. With trial flags absent, +all 195 performance cases match the unchanged production baseline. + +The initial prototype exists only in a temporary checkout. The reproduction patch is +embedded in the raw trial; it is not linked into normal Cargo tests or production +code. That trial did not update a permanent baseline. The subsequent integration below +adds trace/failure cases and updates the reviewed production baseline. + + +## Integrated O1 scope + +All three operations are now part of Plan 08: adjacent application fusion in Core, +late UPLC binding cleanup, and values-only native application packing. The common +`lower_optimized` entry point serves production, shared snapshots, source fixtures +and performance measurements. It runs existing builtin/constant sharing, then +late cleanup and packing to a pointer fixed point. O0 and the isolated sharing +entry points are unchanged. + +Cleanup removes identity applications while preserving argument evaluation, +substitutes single-use values, discards unused values and cancels force/delay. +It keeps computations strict, including shared forced builtin references and +partial builtin applications. Capture checks support shadowed names conservatively. +Multi-use lambda substitution is excluded, so recursive self applications do not +unfold. The pass requires closed, well-scoped named input. + +Packing starts at three value arguments: three or more Apply nodes can be replaced +with two native nodes. This is a cost-derived choice, with no size-growth cutoff. +A four-argument spine extends an already packed prefix. A non-value fourth argument +stays outside the prefix so earlier applications still run before it. + +### Corpus measurements + +The baseline contains 199 cases: the existing 195 plus four compiled source cases. +Every previous O0 row is unchanged. All results and trace logs match O0. +Of the previous rows, 175 are unchanged and 20 change: 14 consume less CPU and +memory, and none consume more. Seven scripts shrink; 13 rows grow in size. Twelve +of those rows are scenarios for two vesting scripts, rather than twelve different +scripts. The remaining growth is an oversaturated recursive-parameter fixture. + +| Existing case | CPU before → after | Memory before → after | Flat bytes before → after | +| --- | ---: | ---: | ---: | +| Mutual recursive source | 2,876,554 → 2,732,554 | 14,542 → 13,642 | 81 → 67 | +| Vesting claim after deadline | 9,093,501 → 8,581,501 | 48,616 → 45,416 | 821 → 822 | +| Vesting cancel signed | 7,915,016 → 7,467,016 | 42,850 → 40,050 | 821 → 822 | +| Parameterized vesting claim | 9,354,709 → 8,842,709 | 49,618 → 46,418 | 827 → 829 | +| Mutual consumed parameter | 2,529,056 → 2,193,056 | 12,710 → 10,610 | 99 → 74 | +| Oversaturated parameter fixture | 304,100 → 288,100 | 2,000 → 1,900 | 22 → 24 | + +Failing vesting scenarios can have unchanged runtime costs while carrying the +same larger script. These size tradeoffs are retained explicitly; they are not +hidden by a growth gate. The [full before/after report](../../tools/optimizer-perf/trials/application-cleanup.json) +contains every changed row, both complete reports, fixture sources and cost settings. + +| New source case | O1 result | Trace order | CPU | Memory | Flat bytes | +| --- | --- | --- | ---: | ---: | ---: | +| Staged application | 42 | none | 2,166,264 | 9,812 | 50 | +| Application stage traces | 42 | first, second | 2,541,260 | 11,476 | 79 | +| Later argument trace | 42 | first, argument, second | 2,856,758 | 13,108 | 100 | +| Failure in first application | explicit error | first | 572,554 | 142 | 85 | + +The failing case does not execute the later argument's trace. Additional named +UPLC snapshots cover packing four values, an eligible three-value prefix before a +traced/failing fourth argument, strict unused computations, cold values, shadowing, +forced references and deliberate recursive divergence without evaluating it. + +### Integrated validation + +All 199 performance fixtures produce identical complete O1 Flat bytes after one, +two and three optimizer invocations. Their late named output is also pointer-stable +under repeated cleanup/packing. Normal fixture checks separately cover Core and +late-pass fixed points. Existing O0 snapshot content is preserved; snapshot changes +show optimized output and isolated-pass results. + +All 3,876 workspace nextest tests pass. The 199-case performance baseline check, +formatting, root strict Clippy and isolated performance-workspace strict Clippy +also pass. Performance fixtures and cost assertions +remain in the separate workspace outside normal test discovery. diff --git a/docs/research/constant-fold-trial.md b/docs/research/constant-fold-trial.md new file mode 100644 index 00000000..eb023c21 --- /dev/null +++ b/docs/research/constant-fold-trial.md @@ -0,0 +1,175 @@ +# Constant builtin evaluation trial — 4 October 2026 + +Status: approved and integrated into production O1 on 5 October 2026, including +the reported shared-prefix size tradeoffs. The original trial measurements below +are historical: they used `08f0831f` before the post-ANF placement correction. + +## Production integration — 5 October 2026 + +`optimizer::optimize_with` now calls the private codegen `constant_fold` pass after +known-case cleanup. The pass folds constants and runs cleanup until neither changes +Core, without a total attempt cap or another ANF pass. The assistant-added +128-attempt restriction was not an approved keep decision and was removed on +5 October 2026. Evaluation and Flat sizing +use O0 assembly; explicit comptime retains its original policy. The old public +trial entrypoint and `constant-trial` command are removed. + +The refreshed [148-case baseline](../../tools/optimizer-perf/baseline.json) compares +O0 with production O1. Against the previous 108-case O1 baseline, 26 cases improve +and 82 are unchanged, with identical results/logs. The additional 40 fixtures +cover the approved folding behavior, including the two shared-prefix size +tradeoffs. Reproduce with normal `measure`/`check` in the optimizer-perf workspace. +The pair-projection candidates remain outside production O1. + +## Result + +148 deterministic cases compare **accepted O1** with **O1 plus the trial**: +36 improve without a metric regression, 110 are unchanged, and two save CPU/memory +but increase Flat size. All results and trace logs agree. Measurements use Plutus +V3/PV11, UPLC 1.1.0, the bundled V3 default cost model, and raw Flat bytes. Runtime +evaluation is capped at 100,000,000 CPU and 2,000,000 memory units. + +| Fixture | CPU before → after | Memory before → after | Flat bytes before → after | +| --- | ---: | ---: | ---: | +| Source list traversal | 4,764,660 → 3,225,764 | 21,472 → 15,216 | 93 → 41 | +| Source validation success | 364,689 → 111,399 | 2,033 → 732 | 47 → 10 | +| Constant addition | 181,308 → 16,100 | 602 → 200 | 10 → 6 | +| Shared prefix, distinct appended suffixes | 1,401,326 → 48,100 | 2,126 → 400 | **70 → 87** | +| Repeated literal prefix, distinct suffixes | 1,369,326 → 48,100 | 1,926 → 400 | **68 → 87** | + +The size regressions are real. A 36-byte prefix previously shared by two appends +becomes two distinct 37-byte literals. The isolated-call size check approves each +fold, but it does not account for sharing across calls. The CPU/memory reduction +does not satisfy a zero-loss size policy. The initial recommendation was to refine the profitability +rule before adoption. The user subsequently accepted these tradeoffs; accounting +for shared constants remains a possible follow-up. Do not copy the candidate measurements into the accepted baseline. + +[Raw measurements and fixture sources](../../tools/optimizer-perf/trials/constant-fold.json) +contain all 148 rows and tool/revision provenance. The historical trial command has been retired. Check current production with: + +```sh +cargo run --locked --manifest-path tools/optimizer-perf/Cargo.toml -- measure +cargo run --locked --manifest-path tools/optimizer-perf/Cargo.toml -- check +``` + +## Historical rewrite and limits + +`nash_ir::constant_fold::reduce` calls a supplied evaluator for exactly saturated +builtins with literal arguments, including aliases of literal bindings. The IR +has no dependency on codegen. It retains original strict bindings for cleanup, +preserves the outer type view, and requires scoped, globally unique names. + +The original `nash_codegen::constant_trial` started with accepted O1 and repeated folding and +existing ANF cleanup while the tree changes. It never repeated ANF. That historical +trial imposed 128 evaluation attempts per invocation, including failures; this +unapproved total cap is no longer in production. Each historical trial call got 1,000,000 CPU +and 10,000 memory units. Input/output preflight allows at most 4,096 payload bytes, +1,024 nodes and depth 64 across constants, Data and type annotations. This runs +before recursive runtime costing and Flat encoding. List/pair payloads must +match their declared types. + +The trial covers integer arithmetic/comparisons, byte append/slice/length and +comparisons, string append/equality, UTF-8 conversion, list/pair operations, and +selected Data construction/decoding/equality/serialization. It excludes Trace, +cryptography, version-sensitive ConsByteString, panic-prone IndexByteString and +ConstrData, and newer array/value/bit operations. The historical allowlist was in +`crates/nash-codegen/src/constant_fold.rs`. + +A failed, unsupported, over-budget or oversized evaluation leaves the original +call intact. Runtime errors never become compiler errors. A successful replacement +must not increase the isolated expression's Flat encoding; this gate needs the +sharing refinement described above. Explicit user `comptime` keeps its existing +budget and diagnostic behavior through the same closed-term evaluator. + +## Existing serializer limitation + +`nash-plutus/src/flat/data.rs` encodes multi-limb negative Data integers with CBOR +tag 3 and their absolute magnitude, while tag 3 denotes `-1 - magnitude`. Its +matching decoder hides the discrepancy in local round-trip checks. In particular, +folding `IData (-(2^64 + 1))` into a serialized literal could change ledger meaning. +The trial rejects negative Data integers with more than 64 magnitude bits, including +nested input/output Data. This serializer defect needs a separate correction with +an external-format oracle; this trial does not modify serialization. + +## Historical trial validation + +- 607 IR/codegen nextest tests pass, including existing explicit-comptime tests. +- 40 trial fixtures have paired accepted O0/O1 and candidate snapshots with + differential results/logs, type, scope and ANF checks. +- Four boundary snapshots cover exhausted CPU, memory, attempt and input-size + limits. Structural checks reject malformed containers, excessive type depth and + unsupported large negative Data. The expanding Data-list fixture stays unchanged. +- Root and isolated performance-workspace strict Clippy pass; formatting and diff + checks pass. +- The accepted 108-row performance baseline still matches exactly. No existing + accepted snapshots or baseline rows were replaced. + +The preceding validation section describes the historical trial; current +integration validation is recorded below. + +## Integration validation + +The initial integration full workspace run passed 3,834 tests. Root and performance-workspace +strict Clippy pass, formatting checks pass, and the refreshed 148-case performance +baseline matches. All 170 changed existing snapshots with O0/O1 sections retain +identical unoptimized Core and UPLC. Added boundary fixtures verify that failures +consumed the then-present shared attempt allowance across cleanup iterations and +unsafe negative Data results remained runtime calls. The attempt-cap fixture was +subsequently replaced by fixed-point tests when that restriction was removed. A separate read-only review confirms there is +no optimizer re-entry and ANF normalization still runs once. + +## Unbounded folding correction + +On 5 October 2026, the user required optimization to continue until unchanged. +The assistant-added attempt, per-call CPU/memory, constant byte/node/depth, +builtin allowlist and Flat no-growth restrictions have all been removed from +production. All pure builtin calls with valid constants are attempted using the +runtime directly with zero costs. Errors, effects and unrepresentable literals +remain at runtime. Unused-parameter removal repeats with folding and cleanup, +including parameters exposed by later branch simplification. ANF still runs once. +Ordinary evaluation and explicit comptime keep their existing budget semantics. + +### Unbounded folding measurements + +Compared with the previous 194-case baseline, all O0 measurements, O1 results +and traces are unchanged. Twenty-two cases improve CPU and memory; six increase +Flat bytes after removal of the growth gate. The other 172 cases are unchanged. +These costs are Plutus V3 model units, not compiler wall time or host memory. + +| Fixture | CPU | Memory | Flat bytes | +| --- | ---: | ---: | ---: | +| Workloads.dataMatch (fixtures/Workloads.nash) | 111399 → 16100 | 732 → 200 | 11 → 6 | +| Workloads.decoding (fixtures/Workloads.nash) | 878161 → 16100 | 4392 → 200 | 45 → 6 | +| Workloads.validationPass (fixtures/Workloads.nash) | 111399 → 16100 | 732 → 200 | 10 → 5 | +| Workloads.validationFail (fixtures/Workloads.nash) | 74897 → 59598 | 164 → 132 | 36 → 30 | +| representation cancellation: integer_direct | 164143 → 16100 | 964 → 200 | 12 → 6 | +| representation cancellation: integer_decoded | 111399 → 16100 | 732 → 200 | 11 → 6 | +| representation cancellation: integer_reverse | 63399 → 16100 | 432 → 200 | 8 → 9 | +| representation cancellation: integer_oversaturated | 36143 → 100 | 164 → 100 | 17 → 9 | +| representation cancellation: integer_partial | 164143 → 68844 | 964 → 432 | 12 → 11 | +| representation cancellation: map_direct | 72723 → 16100 | 432 → 200 | 13 → 17 | +| representation cancellation: map_decoded | 268969 → 16100 | 1264 → 200 | 20 → 17 | +| representation cancellation: map_reverse | 220969 → 16100 | 964 → 200 | 17 → 11 | +| representation cancellation: map_oversaturated | 24723 → 100 | 132 → 100 | 18 → 19 | +| representation cancellation: constructor_tag | 254839 → 16100 | 1464 → 200 | 22 → 6 | +| representation cancellation: constructor_fields | 302839 → 16100 | 1764 → 200 | 24 → 10 | +| representation cancellation: constructor_rebuild | 254839 → 16100 | 1464 → 200 | 22 → 13 | +| constant folding: expanding_data_list | 74033 → 16100 | 432 → 200 | 42 → 126 | +| constant folding: integer_data | 63399 → 16100 | 432 → 200 | 8 → 9 | +| constant folding: data_equal | 1114643 → 16100 | 601 → 200 | 16 → 5 | +| constant folding: serialise_data | 2070166 → 16100 | 410 → 200 | 11 → 9 | +| constant folding: unsupported_hash | 341340 → 16100 | 404 → 200 | 11 → 40 | +| constant folding: large_input | 169849 → 16100 | 1113 → 200 | 4127 → 4121 | + +### Correction validation + +All 3,862 workspace nextest tests pass. Root and isolated performance-workspace +strict Clippy pass; formatting and whitespace checks pass. All 194 reviewed +performance cases match the refreshed baseline. All 133 changed existing +snapshots with O0/O1 sections retain identical unoptimized Core and UPLC. +Tests cover more than 128 folds, 5,000-byte inputs and growing outputs, metadata +deeper than 64, containers larger than 1,024 nodes, and direct evaluation of a +200,000-character result without a memory budget. The signature regression now +reduces to 42 in the first invocation and remains unchanged in the second. +Huge DropList inputs are checked through the unbudgeted helper; ordinary runtime +cost arithmetic still has its pre-existing overflow for such extreme inputs. diff --git a/docs/research/o2-silence-trial.md b/docs/research/o2-silence-trial.md new file mode 100644 index 00000000..ea0be0f3 --- /dev/null +++ b/docs/research/o2-silence-trial.md @@ -0,0 +1,30 @@ +# Initial O2 silence trial + +O2 removes source/compiler traces and Core/builtin trace message expressions, then runs the existing O1 pipeline. As explicitly requested, removed messages may fail or diverge. Returned values still evaluate. No broader application motion is included. + +Measured with the explicit `silent-experiment` command in `tools/optimizer-perf`, using Plutus V3/PV11, UPLC 1.1.0 and the bundled cost model. Sizes are raw Flat bytes. Each O2 case also checks identical Flat output across three pipeline applications. + +| Case | Mode | CPU | Memory | Bytes | Result | Logs | +| --- | --- | ---: | ---: | ---: | --- | --- | +| source | O1 verbose | 2,451,550 | 11,206 | 53 | `(con integer 42)` | 3 | +| source | O0 silent | 2,113,056 | 10,110 | 47 | `(con integer 42)` | 0 | +| source | O1 silent | 1,921,056 | 8,910 | 39 | `(con integer 42)` | 0 | +| source | O2 silent | 1,921,056 | 8,910 | 39 | `(con integer 42)` | 0 | +| builtin | O1 verbose | 2,643,550 | 12,406 | 57 | `(con integer 42)` | 3 | +| builtin | O0 silent | 2,787,550 | 13,306 | 68 | `(con integer 42)` | 3 | +| builtin | O1 silent | 2,643,550 | 12,406 | 57 | `(con integer 42)` | 3 | +| builtin | O2 silent | 1,921,056 | 8,910 | 39 | `(con integer 42)` | 0 | +| failure | O1 verbose | 100 | 100 | 14 | `error: ExplicitErrorTerm` | 0 | +| failure | O0 silent | 100 | 100 | 19 | `error: ExplicitErrorTerm` | 0 | +| failure | O1 silent | 100 | 100 | 14 | `error: ExplicitErrorTerm` | 0 | +| failure | O2 silent | 16,100 | 200 | 6 | `(con integer 42)` | 0 | + +1. Source trace loop: O1 silent and O2 produce the same output. The existing silent source policy already omits these messages. +2. Aliased builtin trace loop: O1 silent still emits builtin logs. O2 removes them, exposing the same 39-byte loop as the source-silent case. +3. Failing aliased message: O0/O1 fail before producing a value. O2 intentionally returns 42. Its CPU increase is not a cost regression for equivalent execution; the outcome changes under the authorized O2 rule. + +Sources: [SourceTrace](../../tools/optimizer-perf/fixtures/o2/SourceTrace.nash), [BuiltinTrace](../../tools/optimizer-perf/fixtures/o2/BuiltinTrace.nash), [FailingMessage](../../tools/optimizer-perf/fixtures/o2/FailingMessage.nash). [Raw report](../../tools/optimizer-perf/trials/o2-silence.json) includes source, Core, UPLC, logs, costs and revision metadata. + +Regression tests additionally cover failing returned values, partial trace calls, builtin aliases, Core traces, traces inside lambdas/delays and a diverging message. The diverging O0 program is rendered without evaluation; O2 returns 42. Build/test configuration conflicts and silent test outcomes are checked through Rust APIs. CLI execution is left for manual testing. + +Validation: all 3,896 workspace tests passed. After arranging source snapshots beside their source tests, all 580 codegen tests passed again. Strict Clippy passed for the repository and performance workspace, and all 199 existing O0/O1 performance cases matched their baseline. diff --git a/docs/research/optimizer-convergence.md b/docs/research/optimizer-convergence.md new file mode 100644 index 00000000..423c0df4 --- /dev/null +++ b/docs/research/optimizer-convergence.md @@ -0,0 +1,77 @@ +# O1 convergence follow-up + +The earlier removal of attempt and resource caps fixed two known cases, but did +not include static recursive parameter lifting in the cleanup fixed point. +A second O1 invocation could therefore still remove work. + +## Reproduced causes + +- A recursive argument such as `if True then x else 0` initially fails static + parameter detection, which requires the recursive argument to be the parameter + variable. Cleanup reduces it to `x`, but lifting had already finished. +- A recursive group with two members initially fails the singleton requirement + for lifting. Pruning an unreachable member exposes a singleton after lifting. + +The source regression is `cleanupExposesStatic` in the performance workloads. +An explicit `next` binding keeps the recursive call saturated after ANF: + +```text +loop x n = + if n == 0 then x + else let next = n - 1 in loop (if True then x else 0) next +main = loop 42 3 +``` + +Before this fix, one O1 invocation produced 46 Flat bytes and two produced 39. +This was a missed optimization caused by pass ordering, not an accepted limit. +The existing 194 performance cases did not expose it. + +## Correction + +Keep initial static lifting before the sole ANF normalization, then repeat static +lifting, unused-parameter removal, constant folding and cleanup until pointers +are unchanged. Each lift removes unchanged parameters from the recursive worker; +no rule restores them. This preserves the existing static-lifting eligibility +rules while revisiting opportunities exposed by other accepted rewrites. + +For an all-static oversaturated self-call, bind the forced worker result before +applying extra arguments. That retains atomic call operands and keeps the force +at its original execution point. Existing cleanup flattens generated binding +prefixes. No second ANF pass is needed. + +The shared executable fixture harness now checks closed Flat equality after one +and two O1 invocations, after rendering snapshots. New regressions cover both +exposure paths plus all-static oversaturation with traces and nested bindings. + +## Measurements + +Same Plutus V3 cost model and Flat measurement as the existing performance tool. +The source returns 42 without traces in all cases. + +| Pipeline | CPU cost | Memory cost | Flat bytes | +| --- | ---: | ---: | ---: | +| O0 | 2,737,056 | 14,010 | 66 | +| Previous O1 | 2,161,056 | 10,410 | 46 | +| Corrected O1 | 1,921,056 | 8,910 | 39 | + +All 194 existing rows are unchanged. The new source case extends the explicit +performance baseline to 195 cases. A separate audit applies O1 twice to each +performance input and compares complete closed Flat output, not just its size. + +## Validation + +All 3,864 workspace nextest tests pass. The final fixture-reuse cleanup and shared +assertion placement also pass all 557 codegen tests. Strict root and performance +workspace Clippy, formatting, and whitespace checks pass. All 195 performance +cases match the reviewed baseline, and the separate two-invocation audit reports +identical complete closed Flat output for every input. Existing fixture outputs +remain unchanged; the new regressions demonstrate the previously missed rewrites. + +## Historical budget distinction + +The removed 1,000,000 CPU / 10,000 memory allowance was specific to O1's automatic +constant-builtin folding. It reused `comptime::eval_closed_budget`, but explicit +`comptime` called `eval_closed` with the separate default of 10,000,000,000 CPU / +14,000,000 memory. Failed automatic folding retained the runtime call; failed +explicit `comptime` reported a compilation error. O1 now calls the unbudgeted +constant-builtin evaluator directly. Explicit `comptime` is unchanged. diff --git a/docs/research/pair-projection-trial.md b/docs/research/pair-projection-trial.md new file mode 100644 index 00000000..56e4ae69 --- /dev/null +++ b/docs/research/pair-projection-trial.md @@ -0,0 +1,136 @@ +# Single-field pair projection trial — 5 October 2026 + +Status: the restricted rule was accepted and integrated into production O1 on +5 October 2026. The general rule was rejected and removed. The original trial +measurements below predate constant-folding and pair integration. + +## Production integration + +The restricted rule now runs inside the existing constructor/wrapper cleanup +loop before inverse cancellation, without another ANF pass. Both producer +bindings remain strict. The trial CLI was removed; normal `measure`/`check` cover +178 O0/O1 fixtures, including the 30 pair fixtures. Against the preceding 148-case +O1 baseline with constant folding, source decoding improves from 94 to 45 bytes, +1,681,280 to 878,161 CPU and 8,756 to 4,392 memory. The other 147 cases are unchanged. +Results/logs match. The source language also supports explicit `.fst`/`.snd` pair +fields, independently of this restricted optimization of pair patterns. + +## Results + +Thirty synthetic and eleven compiled source fixtures compare current O1 with +O1 plus each candidate and existing cleanup. Both sides use the same lowering +mode, tested separately with ordinary lowering and production builtin/constant +sharing. That gives 164 measurements: 41 inputs × two rules × two lowering modes. +All evaluated results and trace logs match. Failed execution remains failed. + +| Rule / lowering | Improve without regression | Unchanged | Regress only | Tradeoffs | +| --- | ---: | ---: | ---: | ---: | +| General / ordinary | 7 | 20 | 10 | 4 | +| General / shared | 5 | 16 | 18 | 2 | +| Cancellation only / ordinary | 5 | 36 | 0 | 0 | +| Cancellation only / shared | 5 | 36 | 0 | 0 | + +Representative measurements use production sharing: + +| Fixture / rule | CPU before → after | Memory before → after | Flat bytes before → after | +| --- | ---: | ---: | ---: | +| Literal first field / general | 80,100 → 269,995 | 600 → 932 | 13 → 15 | +| Larger body / general | 668,304 → 906,199 | 2,966 → 3,598 | 49 → 53 | +| Source decoding / either rule | 1,681,280 → 878,161 | 8,756 → 4,392 | 94 → 45 | + +The general rewrite pays the runtime cost of `fstPair`/`sndPair`, including their +forces and any sharing binding. A native pair case already transfers both fields +to its branch efficiently. A shorter-looking Core expression is not necessarily +cheaper. Some ordinary-lowering fixtures save a few bytes or memory units while +using more CPU; that does not justify the general rule. + +## The useful exception + +Source fixture: + +```text +decode value = + case value of + Constr pair(_, [I n, _]) -> n + _ -> 0 + +decoding = decode (Builtin.constrData 0 [I 42, I 7]) +``` + +Generated Core binds `fields`, then `d = constrData 0 fields`, then +`p = unConstrData d`. The pair case only uses the fields component. Introducing +`sndPair p` lets the existing inverse pass replace it with `fields`. List/Data +cleanup can then resolve the remaining matches to `42`. The original constructor +and decoder bindings remain strict, preserving validation and effects. + +The restricted rule requires all of the following: + +- A valid one-branch native pair case, two binders, no default, and matching field + types. Exactly one field binder is used; it may be used multiple times. +- The subject is a variable resolving through aliases to saturated `unConstrData`. +- Its Data operand is a variable resolving to saturated `constrData`. +- The selected constructor operand is already a variable. + +These are the existing constructor inverse rule's preconditions. The candidate +emits a strict projection let at the original case point; cleanup removes that +projection. It does not extract and re-evaluate a constructor argument. The four +synthetic constructor round-trip fixtures also improve: two valid cases save CPU, +memory and bytes; two malformed-tag-shape failures save bytes with the same errors +and logs. All other fixtures remain unchanged under the restriction. + +This is measured evidence, not a proof that every program's Flat size decreases. +Reusing an earlier variable can change De Bruijn indices and encoded size. + +## Safety and scope + +Native `CaseKind::Pair` lowers to generic UPLC `case`, which can also handle other +runtime shapes. Replacing a tag-zero constructor case with `fstPair` would change +a successful evaluation into a failure. The general candidate therefore requires +runtime pair evidence from a literal pair, saturated `mkPairData` or `unConstrData`, +following aliases/traces. Type annotations alone are insufficient. Unknown pair +parameters are deliberately excluded. + +Fixtures cover first/second fields, repeated use, both/neither fields, larger +bodies, returned lambdas/delays, discarded closures with failing subjects, traces, +ignored failing fields, invalid decoder inputs, forged pair annotations and +constructor round trips. Six guard snapshots cover invalid branch tables, +inconsistent field types and an unknown parameter. Negative constructor tags +are not executed: the current evaluator panics while converting them to `u64`. +The malformed-tag fixture instead checks a wrong runtime shape. This trial does +not change that evaluator limitation. + +The rewrite requires globally unique, scoped names. It uses binding facts and +keeps subject evaluation and the projection strict. It does not repeat ANF. + +## Reproduction and validation + +[Raw measurements](../../tools/optimizer-perf/trials/pair-projection.json) include +fixture sources, candidate source, pipeline source, per-row Core before/after, +revision and toolchain. Measurements use Plutus V3/PV11, UPLC 1.1.0, bundled V3 +costs, 100,000,000 CPU and 2,000,000 memory limits, and raw Flat bytes. + +```sh +cargo run --locked --manifest-path tools/optimizer-perf/Cargo.toml -- measure +cargo nextest run -p nash-ir -p nash-codegen +cargo run --locked --manifest-path tools/optimizer-perf/Cargo.toml -- check +``` + +Snapshots show the shared O0/O1 pipeline followed by each candidate and isolated +Core rewrite. Differential checks verify outcomes/logs, root type, scope and ANF. +Malformed tables preserve lowering errors. Those trial measurements left the then-current 108-row baseline unchanged. +The production integration above now uses the expanded baseline. + +Historical trial validation: all 609 IR/codegen tests pass, the 108-case accepted +performance baseline matches, root and performance-workspace strict Clippy pass, +and both formatting checks pass. A separate read-only review confirmed the +report counts and embedded sources match the final code. + +## Integration validation + +The full workspace run passes 3,845 tests. After improving the unknown-pair-field +message, all 672 targeted diagnostic tests pass. Root and performance-workspace +strict Clippy pass, both formatting checks pass, and the accepted 178-case baseline +matches. Source snapshots cover direct/accessor forms, aliases and strict trace +behavior; inference snapshots cover ambiguity, field types, record name collisions, +invalid updates and record patterns. A separate read-only review found no semantic +blocker. diff --git a/docs/research/recursive-parameters.md b/docs/research/recursive-parameters.md new file mode 100644 index 00000000..8ccc7a49 --- /dev/null +++ b/docs/research/recursive-parameters.md @@ -0,0 +1,54 @@ +# Recursive unused parameters — 5 October 2026 + +The recursive rule is integrated into production O1 after static lifting and +before its single ANF pass. It follows bare-variable forwarding dependencies to +a liveness fixed point within each group. Other parameter uses remain live, +including uses inside strict compound arguments. Unsupported call shapes leave +the entire group unchanged. Non-atomic arguments retain source evaluation order. + +All-unused self and mutual workers become delayed values. The mutual dispatcher +executes their body only when forced; mixed delayed/function groups and returned +closures keep captures and repeated execution. Static parameter indices are +remapped, and call sites retain their own type views. No whole-program signature +fixed point, additional ANF pass or general recursive inlining was added. + +## Measurements + +Compared previous production O1 with this rule across 194 cases: the existing +178, 14 Core fixtures and two compiled source workloads. Six improve with no +regression and 188 are unchanged. Every O0 measurement, result and trace log is +unchanged. The original 178 O1 cases are all unchanged. The self-recursive source +case is unchanged because existing static lifting already removes that forwarding +parameter; the mutual source case benefits from the new dependency analysis. + +| Case | CPU before → after | Memory before → after | Flat bytes before → after | +| --- | ---: | ---: | ---: | +| Mutual source | 3,196,554 → 2,876,554 | 16,542 → 14,542 | 93 → 81 | +| Mutual forwarding | 2,529,056 → 2,209,056 | 12,710 → 10,710 | 101 → 82 | +| Recursive trace order | 3,926,044 → 3,318,044 | 19,402 → 15,602 | 160 → 134 | +| Recursive failure order | 272,637 → 272,637 | 167 → 167 | 156 → 130 | +| All-unused mutual | 1,731,300 → 1,635,300 | 8,930 → 8,330 | 97 → 89 | +| Mixed delayed/function | 4,671,636 → 3,727,636 | 23,848 → 17,948 | 115 → 89 | + +[Raw comparison](../../tools/optimizer-perf/trials/recursive-parameters.json) +embeds fixtures, previous/current parameter reduction and the recursion encoding +diff. The normal baseline now retains all 194 O0/O1 cases. Measurements use the +same Plutus V3/PV11, UPLC 1.1.0 and cost/budget settings as the prior baseline. + +## Validation + +Semantic snapshots cover forwarding and consumed parameters, permuted mutual +slots, strict traces/failures, cold/repeated all-unused calls, mixed groups, +compound dependencies, partial/escaping/oversaturated calls, static indices, +independent type views, returned closures and explicit divergence. Divergence is +rendered without execution. Independent checks cover outcomes/logs, types, +hygiene, ANF and pass pointer idempotence. Source snapshots cover self-recursive +static lifting and mutual forwarding. + +Performance checks stay in the separate workspace and never run under normal +`cargo test` or root nextest commands. + +Validation completed: all 3,852 workspace nextest tests pass, root and isolated +performance-workspace strict Clippy pass, formatting/whitespace checks pass, and +all 194 explicit performance cases match. Existing O0 snapshot sections are +unchanged. A read-only review found no correctness blocker or report mismatch. diff --git a/docs/syntax.md b/docs/syntax.md index db6bc80b..7080f7f7 100644 --- a/docs/syntax.md +++ b/docs/syntax.md @@ -715,3 +715,22 @@ in Pair destructuring lowers to native UPLC `case`, including wildcard fields. It does not implicitly construct a pair or convert a tuple to a pair. + +### Builtin pair access + +A known builtin pair type supports read-only fields `fst` and `snd`: + +```nash +first : pair 'a 'b -> 'a +first p = p.fst + +second : pair 'a 'b -> 'b +second = .snd +``` + +Both `p.fst`/`p.snd` and accessor functions `.fst`/`.snd` use the existing field +syntax. They lower directly to `fstPair`/`sndPair`. Aliases of pair types work the +same way. The receiver type must be known; an unannotated standalone `.fst` does +not assume a pair. Records with fields named `fst` or `snd` keep ordinary record +semantics. Pair record updates and record patterns are not supported; destructure +with `pair(first, second)` instead. This does not add tuple field access. diff --git a/docs/testing.md b/docs/testing.md index 83491023..ec61b906 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -152,7 +152,7 @@ The first counterexample stops the loop and is shrunk. This is Aiken's The test fails when the consumed budget exceeds a given limit; a missing limit is unbounded. For a `prop` the limit applies to every iteration, and the report shows the maximum. Budgets -are measured with the bundled cost model of the configured `plutusVersion` +are measured with the bundled Plutus V3 cost model after the same Core passes `nash build` runs. The evaluator does not query live protocol parameters; these measurements do not establish current mainnet costs. `within` and @@ -523,8 +523,7 @@ across tests, as in Aiken (`aiken-project/src/lib.rs:1173-1176`). - Test programs use the same selected O0/O1 pipeline as validator builds. Optimization does not change user/compiler trace settings or test protocol logs. Compiler traces are enabled; user traces default to verbose unless the owning project explicitly configures a level or the CLI overrides it. Plan 08 remains - deferred. Property result tuples/options use native constructors and cases, - supported for V1, V2, and V3 at the protocol 11 baseline. + deferred. Property result tuples/options use native constructors and cases. ## Interactions diff --git a/docs/validators.md b/docs/validators.md index eb5c82be..99a443f8 100644 --- a/docs/validators.md +++ b/docs/validators.md @@ -159,19 +159,16 @@ byte followed by the single-wrapped bytes) for each validator. ## Target compatibility -Each validator uses its owning application's or package's `plutusVersion` -(default `"v3"`), overridden by `--plutus-version`. Workspace members retain -their own settings; dependency settings do not change the caller's script. +Nash produces Plutus V3 validators only. The script context differs between +ledger languages and Nash supports the V3 one, so there is no setting for +another ledger language. The script hash always uses the V3 language tag. -Compatibility targets **protocol version 11**. Ledger language versions and -UPLC versions are distinct. V1, V2, and V3 all emit UPLC 1.1.0 and permit the -builtins supported by this compiler at this protocol baseline; the selected -ledger language still determines the script hash tag and evaluator semantics. +Compatibility targets **protocol version 11**. Scripts are UPLC 1.1.0 and may +use the builtins supported by this compiler at this protocol baseline. The entire generated program is validated, including nested terms and empty -typed containers. Native `constr`/`case` terms are available for all three ledger -languages. Protocol 11 also permits `case` on boolean, integer, list, pair, -and unit constants. `Data` is not directly supported by native `case`: Nash +typed containers. Native `constr`/`case` terms are available. Protocol 11 also +permits `case` on boolean, integer, list, pair, and unit constants. `Data` is not directly supported by native `case`: Nash uses `chooseData` directly with delayed branches, forcing only the selected one. BLS runtime constants cannot be serialized as script literals; BLS builtins can construct values at runtime. @@ -189,15 +186,14 @@ without a manifest must be relocated or removed explicitly before reuse. ## `nash build` flags ``` -nash build [PATH] [--plutus-version v1|v2|v3] [--trace-level LEVEL] - [--compiler-traces[=true|false]] [--out DIR] +nash build [PATH] [--trace-level LEVEL] [--compiler-traces[=true|false]] + [--out DIR] ``` | Flag | Values | Default | Effect | |---|---|---|---| | `--trace-level` | `silent`, `compact`, `verbose` | `traceLevel` in `nash.jsonc`, else `silent` | How user `trace` calls compile. `silent` removes them, `compact` keeps a short code per site, `verbose` keeps the full message. | | `--compiler-traces` | optional boolean | `compilerTraces` in config, else false | Keep compiler traces independently of user traces. The bare flag enables them; `--compiler-traces=false` disables them. | -| `--plutus-version` | `v1`, `v2`, `v3` | `plutusVersion` in config, else `v3` | Select the target compatibility rules. | | `--out` | path | `build` | Output directory. | Flags override config values for one run. Builds remain unoptimized; optimizer diff --git a/plans/08-optimizer.md b/plans/08-optimizer.md index 895dc645..de0af868 100644 --- a/plans/08-optimizer.md +++ b/plans/08-optimizer.md @@ -1,7 +1,31 @@ -# Plan 08 — Core -> Core optimizer +# Plan 08 — O1 optimizer (Core and UPLC) ## Status and accepted scope +**O1 application fusion, native packing and late binding cleanup are part of +this plan (5 October 2026).** The user moved these items here from Plan 15 and +requested implementation. The original eleven chunks remain complete; the +additional scope in Chunk 12 is complete and validated. All 3,876 workspace tests +and strict Clippy pass; all 199 performance cases match the reviewed baseline and +produce identical complete O1 code after one, two and three runs. +O2 silence remains separate in Plan 15. + +The existing Core passes retain one ANF normalization and their joint fixed +point, with no optimizer resource or iteration caps. Recursion is encoded once; +late UPLC cleanup has its own shrinking fixed point. See the +[convergence follow-up](../docs/research/optimizer-convergence.md) for the prior +195-case checkpoint and the [application report](../docs/research/application-packing-trial.md) +for the new scope. + +**Placement correction (4 October 2026).** Constructor folding and representation +cancellation run only in the post-ANF loops. The early `reduce_constr` and +`inverse::reduce` calls were removed at the user's request. Existing bound-constructor +and inverse loops handle bindings produced by codegen and opportunities exposed by +inlining. Earlier pre-ANF placement/measurements below are historical, superseded +by this decision; synthetic adjacent-expression savings do not justify early passes. +The 23 source/validator performance rows are unchanged. The direct-expression +regressions and changed constructor cases are recorded in the refreshed baseline. + Chunks 1 and 2 are accepted and complete, including mandatory Core typing, pre-ANF static-parameter lifting and ANF. Chunk 3 is complete with an isolated performance runner. The user @@ -16,13 +40,12 @@ sharing during optimized lowering. Step 2 is accepted with a two-occurrence mini for one leading literal; the retained Chunk 5 scope is complete. Chunk 6 safe unused-binding removal, recursive-member reachability and pre-ANF nonrecursive unused-parameter removal are accepted. Direct force/delay cancellation in Chunk 8 -is also accepted. Recursive unused-parameter removal is approved Chunk 6 scope -but remains unimplemented. Known Boolean, direct/bound native-constructor and +is also accepted. Recursive unused-parameter removal completes the approved Chunk 6 scope. Known Boolean, direct/bound native-constructor and native-list folding in Chunk 7 are accepted. Literal Data-shape folding is also accepted, as is IData/BData/ListData/MapData/ConstrData producer case folding; known native-constructor field and native integer/byte case folding are accepted -as well. The retained Chunk 7 scope is complete. Continue -with Chunks 9, 10 and 11. The retained Chunk 8 representation cancellations +as well. The retained Chunk 7 scope is complete. Chunks 9 and 10 are now +integrated; the retained scope and Chunk 11 review are complete. The retained Chunk 8 representation cancellations are accepted, including integer/byte/list/map Data round trips, UTF-8 round trips and bound constructor Data projections/reconstruction. Normal build/test defaults are O1; explicit O0 is available in build/test and project config. Current assembly in @@ -54,8 +77,9 @@ during discovery, so the focused suites were run through Cargo instead. Accepted decisions (26 September 2026, reconciled with later keep decisions): - Start with binder hygiene, static-parameter lifting and A-normal form (ANF), - retaining explicit recursive workers in Core. Lift before ANF splits calls; - do not reconstruct application chains to recover this information. + retaining explicit recursive workers in Core. Lift before ANF splits calls. + The later accepted adjacent-call fusion rule may recover a call only under + its single-use, atomic-operand and type-view guards. - Optimize while recursive functions remain explicit `LetRec`, then rewrite recursion once and lower the generated code directly. Normalize only once, before Core optimization; do not rerun ANF after recursion rewriting. @@ -1140,28 +1164,27 @@ validation passed all 513 IR/codegen tests with no snapshot changes, root and isolated strict Clippy, and formatting. All 23 performance rows remain identical; only baseline pipeline settings and revision metadata were refreshed. -**Fourth rule, required scope (27 September 2026): recursive unused parameters.** -This belongs in Chunk 6. Its scope is approved, but it is not implemented or -validated yet. The user subsequently directed starting the Chunk 7 Boolean-case -trial; this authorization does not mark recursive parameter removal implemented. Cover self-recursive and mutually recursive helpers, -including parameters only forwarded through recursive calls rather than consumed. -Specify how parameter-use dependencies reach a fixed point across the group; -a recursive forwarding occurrence alone is not proof that a value is needed. - -Design and trial this on complete calls before ANF, with an explicit ordering -relative to static lifting. Preserve strict evaluation and source order for both -retained and discarded arguments at entry calls and recursive calls. Keep worker -captures, type views and static-parameter metadata consistent with any changed -signature. All-unused recursive workers must preserve delayed entry, repeated -execution and divergence. State conservative behavior for partial, escaping and -oversaturated uses; do not recover ANF call chains to enable the rule. - -Start with a concrete self-recursive example and proposed algorithm, then cover -mutual forwarding dependencies. Add paired Core/UPLC semantic snapshots and -explicit-only measurements before the keep decision. Required cases include -real parameter consumption, forwarding-only cycles, strict traces/failures in -dropped arguments, all-unused workers, partial/escaping uses and static lifting -interaction. Chunk 6 remains open until this rule has a reviewed outcome. +**Fourth rule, integrated (5 October 2026): recursive unused parameters.** +The existing pre-ANF pass now handles self-recursive and mutual groups after +static lifting. Parameter liveness starts at real uses and propagates backward +through direct, bare-variable forwarding dependencies until stable. Forwarding +alone does not keep a parameter live. Compound argument evaluation remains strict, +so its parameter references are consumers even when the receiving slot is unused. +All entry and recursive calls retain non-atomic arguments in source order. + +Any partial, escaping, oversaturated or unsupported type view leaves the group +unchanged. Retained static indices are remapped and each direct call keeps its +own result type view. All-unused workers become delayed recursive values; +recursion lowering and dead-member cleanup support mutual groups containing such +workers. Captures, cold entry, repeated execution and divergence are preserved. +No second ANF pass or general unused-signature fixed point was added. + +Semantic snapshots cover self/mutual forwarding, permuted slots, real consumers, +compound arguments, traces/failures, all-unused/mixed workers, partial/escaping/ +oversaturated calls, static indices, type views, captured returned closures and +unevaluated divergence. Source fixtures cover static-lift interaction and mutual +recursion. Explicit measurements and validation are recorded in +[the recursive parameter report](../docs/research/recursive-parameters.md). Remove unused bindings only when their evaluation is safe to discard. Remove unreachable recursive members by continuation reachability. Remove unused @@ -1577,7 +1600,8 @@ incorporates only the `decoding` improvement above; all source inputs, O0 metric results and logs are unchanged. Formatting, strict workspace/runner Clippy and the explicit baseline check pass. -The evaluator currently panics for negative tags and tags above `u64::MAX`. +At the time of this trial, the evaluator panicked for negative tags and tags +above `u64::MAX`; the unbounded folding integration now returns evaluation errors. Those two fixtures render before/after Core and UPLC and independently check retained construction without evaluating that existing panic path. In-range boundary tags are evaluated normally. This is case folding, not permission to remove producers @@ -1717,7 +1741,7 @@ retaining the validating construction. Reconstruction from `fstPair p` and variant checks and evaluation of unused fields remain in place. Arbitrary direct constructor round trips and unknown-shape unary conversions remain unchanged. -The pass runs before ANF and within the existing `small_inline::simplify` cleanup +The pass now runs only within the post-ANF `small_inline::simplify` cleanup loop, before beta cleanup. The latter catches bindings exposed by ANF/inlining; ANF is not repeated. The pass requires globally unique, well-scoped binders. @@ -1765,23 +1789,51 @@ input tests and measured output; no trait-selection magic is added. ## Chunk 9 — Constant builtin evaluation -Use a callback supplied by codegen around its existing closed-term evaluator; -keep `nash-ir` independent of codegen. Evaluate only supported, saturated, -constant-argument builtin calls under an explicit compile-time budget. Review -per-builtin input-shape and error-safety rules against the current runtime. - -On unsupported results, budget exhaustion or runtime failure, leave the original -expression. A runtime failure must not become a compile error. Account for result -literal size: a computation that produces a huge constant is not automatically a -win. This is optimizer folding, separate from explicit user `comptime` semantics. +**Accepted and integrated (5 October 2026).** Production O1 now runs unbudgeted +constant folding after the post-ANF cleanup/known-case loops, repeating folding +and cleanup to stability without another ANF pass. The callback keeps evaluation +policy in codegen and IR independent of codegen. There is no total attempt or +iteration cap: stop only when folding and cleanup both leave Core unchanged. +The earlier 128-attempt cap was an assistant-added restriction, not an approved +keep decision, and was removed on 5 October 2026. The per-call CPU/memory, payload byte/node/depth, allowlist and Flat growth +gates were also removed. All pure, representable successful calls fold; invalid +constants and unsafe large negative Data literals remain runtime calls. O0 and explicit comptime policy are unchanged. + +The user accepted the two shared-prefix size tradeoffs. The initial integration baseline +had 148 O0/O1 cases, including the 40 constant-folding fixtures. Relative to the +previous 108-row O1 baseline, 26 improve and 82 are unchanged; all results/logs +match. See [the report](../docs/research/constant-fold-trial.md) for historical +trial measurements and current integration details. The temporary constant-trial +command and public trial entrypoint were removed. + +Use a callback supplied by codegen around the direct unbudgeted builtin evaluator; +keep `nash-ir` independent of codegen. Evaluate saturated, pure constant-argument +calls using current V3 semantics. Runtime errors leave the original expression; +they must not become compile errors. Enforce type and serialization correctness, +without imposing resource or literal-size policy. Explicit user `comptime` +retains its own evaluation semantics. + +Tests cover arithmetic, cryptography, byte/string/Data/container operations, +nonzero/zero division, malformed constants, large inputs, growing outputs, +large indices/tags, and folding and signature removal to an unchanged tree. + +**Done when:** pure representable successful calls fold until unchanged; +effectful, unrepresentable and failing computations retain runtime behavior. -Tests: arithmetic, byte/string/Data/container operations, nonzero/zero division, -empty/nonempty head/tail, malformed data, oversized results and exhausted budgets. +## Chunk 10 — Single-field native pair projection -**Done when:** supported folds are reviewed for semantics and cost/size tradeoffs; -unsupported/failing computations retain runtime behavior. +**Accepted and integrated (5 October 2026).** Keep only the restriction whose +introduced projection is removed by constructor inverse cleanup. It runs inside +`simplify_constr_data`'s existing loop before constructor/wrapper cleanup; producer +bindings remain strict and ANF is not repeated. The general projection rule and +trial CLI were removed. The baseline now includes 178 O0/O1 cases, adding the 30 +pair fixtures. Against the previous 148-case O1 baseline, source `decoding` +improves from 94 to 45 bytes, 1,681,280 to 878,161 CPU and 8,756 to 4,392 memory; +the other 147 cases are unchanged. Results/logs match throughout. -## Chunk 10 — Single-field native pair projection +The language also exposes explicit `.fst`/`.snd` fields/accessors for known pair +types, lowering directly to the builtins. These do not change pattern lowering. +See [historical pair trial and integration](../docs/research/pair-projection-trial.md). Compare `CaseKind::Pair` with `fstPair`/`sndPair` when exactly one branch binder is used, for a valid one-branch case without a default: @@ -1807,17 +1859,44 @@ rule. No assumption that projection wins, and no per-program tuning engine. ## Chunk 11 — Composition, convergence and final configuration +**Complete (5 October 2026), retained scope.** + +The final composition review adds five regression tests: a mixed cleanup pipeline +with phase/type/hygiene evidence, same-node-count reassociation exposing further +cleanup, a reachable recursive cycle rendered without evaluation, cleanup-exposed +signature removal, and a 130-call fixture that reaches a folding fixed point. +Independent builders produce deterministic Core and closed UPLC. Accepted cleanup +reaches an unchanged-pointer fixed point; no node-count stopping rule is used. + +Static lifting and unused-parameter removal now repeat with constant folding and cleanup until all +leave Core unchanged. There are no optimization iteration or resource cutoffs. +The regression with a parameter used only in a constant dead branch now verifies +equal closed output across two optimizer invocations. Further regressions cover +static parameters exposed by branch cleanup or recursive pruning and all-static +oversaturated recursion. The shared executable fixture harness checks second-run +closed-code equality after each semantic snapshot. ANF still runs once. See +[the convergence follow-up](../docs/research/optimizer-convergence.md). +The mode decision retains O0/O1, default O1, and the existing project/CLI precedence. + +Initial composition validation: all 3,857 workspace nextest tests pass; the five composition +checks also pass independently. Strict workspace Clippy, formatting and whitespace +checks pass. All 194 explicit performance cases match the accepted baseline, and +Cargo metadata still excludes the performance package from the root workspace. +The retained Plan 08 scope is complete; deferred work below remains deferred. + **O1 integration (29 September 2026), accepted scope.** Production `nash-codegen::optimizer` owns the accepted Core pipeline; snapshots and performance measurements reuse it. Build/test accept `-O0`/`-O1` and `--optimize 0|1`; application/package config accepts integer `optimize: 0|1`. The build/test default is O1. Workspace members own these settings, as with trace/target -settings. CLI overrides each owning project's level. No O2 is defined. +settings. CLI overrides each owning project's level. O2 was not part of this +integration; silent O2 is now implemented separately in [Plan 15](15-o2-optimizer.md). O1 preserves enabled traces and their order; trace generation remains independent. -It includes accepted direct integer inverse cancellation before the single ANF. +Representation cancellation and bound-constructor folding run only in the +cleanup loops after the single ANF normalization. Post-recursion work is freshening and optimized lowering with builtin/constant sharing, never a second normalization. Explicit comptime execution remains O0. -Chunks 9–10 and final convergence review stay open. +Chunks 9–10 and the final convergence review are complete. Default-O1 validation exposed deep-tree stack overflows; assembly traversals now use heap work lists, with no stack enlargement; UPLC term printing is also iterative. Remaining depth risks and follow-up probes are recorded in [the compiler stack audit](../docs/research/compiler-stack-audit.md). @@ -1830,7 +1909,7 @@ Do not repeat ANF-dependent passes or whole-program sharing after recursion rewr Detect actual structural progress or accurate rewrite reports, not equal node counts. Keep generated names deterministic. Test same-size rewrites, cycles, -optimizer and cleanup idempotence, and hygiene after every pass. Check ANF only +cleanup idempotence, the joint signature/folding fixed point, and hygiene after every pass. Check ANF only in the main optimization phase, before recursion rewriting. Retain named phase sections for raw Core, ANF, optimized recursive Core, rewritten @@ -1841,21 +1920,71 @@ Every executable codegen snapshot must expose the original Core and O0 UPLC, then accepted optimized Core and optimized UPLC, using the shared test pipeline in `crates/nash-codegen/tests/support/optimizer.rs`. Thus accepting a pass updates the full source and hand-built fixture corpus, not only its dedicated examples. +Source fixtures also retain their Nash text in the snapshot description and +capture evaluation results/traces where applicable. Hand-built Core/UPLC pass +fixtures capture their actual IR inputs, not invented Nash or Rust source text. +Omit Rust expression metadata from pass snapshots. Automated tests call compiler, +optimizer and evaluator Rust APIs directly; do not launch the Nash CLI binary. +CLI behavior is tested manually by the user. Keep independent type, hygiene, +semantic-equivalence and fixed-point checks after snapshot assertions. Retain isolated-pass and intermediate-phase evidence after this common comparison. Metadata and invalid-Core diagnostics remain focused; close open fixtures explicitly for rendering, and never execute deliberately divergent fixtures. Keep O0 snapshots; never mass-replace them with optimized ones. Run ordinary semantic checks separately from the explicit performance regression command. -Only after reviewing the accepted set, decide whether there is one optimized mode -or several, their flags/configuration, defaults and pass assignments. Do not -implement the old `Level::O1/O2` sketch or expose arbitrary tuning knobs first. -Existing CLI/config optimizer rejection remains until a reviewed mode is wired. +Final configuration is one optimized mode, O1, alongside explicit O0. Existing +CLI/configuration validation accepts only 0 and 1, project settings belong to the +owning workspace member, and command-line overrides take precedence. Defaults, +trace policy, trait/Logic/Big/little semantics and both lowering modes retain their +existing source, driver and configuration tests. **Done when:** the accepted combination is semantically equivalent, convergent, measured and reviewed; final configuration is decided and documented. Mark SPEC.md complete only when the retained scope is implemented and validated. +## Chunk 12 — Application fusion, native packing and late binding cleanup + +These are O1 rules. They preserve enabled traces, success/failure and termination; +none requires silent O2. The user requested adoption after the first measured +fusion/packing case and explicitly assigned this work to Plan 08. + +- Adjacent Core application stages fuse inside `single_use::inline`, within the + existing cleanup fixed point. Only a sole direct use qualifies; operands remain + atomic and intermediate type views must agree. Arguments containing the binder, + escaping uses and intervening computations cannot fuse. +- `lower::lower_optimized` is the common O1 entry point for production, shared + snapshots, source tests and performance checks. It lowers with builtin/constant + sharing, then calls `uplc_optimizer::optimize`. O0 and isolated sharing APIs + remain available unchanged. +- Late cleanup removes identity applications without dropping argument evaluation, + substitutes single-use values, removes unused value bindings and cancels direct + force/delay pairs. Forced builtins and applied prefixes remain computations, so + their sharing is retained. Substitution rejects potential name capture, including + shadowed names. Recursive self-application is never unfolded by multi-use beta + substitution. +- Native packing replaces eligible application spines with `Case(Constr(0, args), + [function])`, requiring both function and arguments to be UPLC values. Three + arguments is the first arity where two native nodes replace more Apply nodes. + This is a cost-derived rule, not an optimizer execution limit. Existing packed + prefixes can extend; an effectful later argument retains its outer Apply. +- Cleanup and packing reach a pointer fixed point without rebuilding Apply nodes + from packs. Neither repeats ANF nor re-encodes recursion. Named inputs must be + closed and well-scoped. + +The isolated baseline now includes four additional source cases: the original +staged call, traces between call stages, an effectful later argument, and failure +before that argument. Unit snapshots also cover shadowing, strict unused bindings, +forced references, recursive divergence (rendered only), and four-argument packing. +Full O1 Flat code is compared after one, two and three runs for all performance +fixtures; normal fixture checks cover Core and late-pass fixed points separately. + +**Complete.** All 3,876 workspace nextest tests pass, as do root and isolated +performance-workspace strict Clippy and formatting checks. All 199 explicit +performance cases match the reviewed baseline. Every changed snapshot preserves +its original O0 content. The application report records the size tradeoffs. +Performance checks remain outside normal Cargo tests. + ## Boundaries and deferred work - Integer dispatch is explicit in [Plan 11](11-macros-comptime.md), via an AST/Core diff --git a/plans/15-o2-optimizer.md b/plans/15-o2-optimizer.md new file mode 100644 index 00000000..c6066e5a --- /dev/null +++ b/plans/15-o2-optimizer.md @@ -0,0 +1,183 @@ +# Plan 15 — Silent O2 and application regrouping + +## Status and confirmed contract + +**Initial silent O2 implemented (5 October 2026); broader motion remains planned.** Application fusion, +values-only native packing and late UPLC binding cleanup belong to +[Plan 08](08-optimizer.md), as confirmed by the user. This plan retains O2 silence +and the broader grouping/motion investigations. + +User decisions: + +- O2 automatically runs silently: no user or compiler traces in emitted scripts. +- O2 discards trace message computations even if they fail or diverge, as + explicitly confirmed by the user. The value returned by a trace still evaluates. + Unrelated failure or divergence must not move under an unused lambda. +- Rewrites that preserve the full O1 contract, including traces, belong in O1. +- Optimization continues until unchanged. Do not introduce attempt, execution, + payload, depth, node, growth or iteration cutoffs without a separate decision. + +Keep the current O1 default. O2 is an explicit build/test/project setting when +used. Explicit compact/verbose tracing or compiler traces with O2 are errors. +Merge command overrides before applying test defaults; O2 tests remain silent. +Do not rewrite saved configuration. O0 and O1 retain their trace policy. + +Compare O2 with O0 under the same silent source semantics. Source trace syntax +already omits its message computation in silent mode. Direct `Builtin.Trace` is +strict under O0/O1. O2 explicitly removes its message expression, including +failure or divergence, for direct and aliased calls. Preserve evaluation of its +returned value. Separately evaluated expressions outside the trace remain strict. +A first-class trace value becomes a correctly typed no-log function. Calls through +unknown function parameters remain ordinary strict caller work; no lazy calling +convention is introduced. Erasure precedes O1 inlining. + +## Current source findings + +- `nash-ir/src/anf.rs` preserves application stages: it evaluates an earlier + application before a later non-atomic argument. An earlier application may + execute a body, emit a trace, fail or diverge. +- `nash-codegen/src/lower.rs` lowers Core applications left-associatively. Flattening + an application representation is different from evaluating all arguments early. +- `single_use::inline` deliberately keeps computed function operands bound. It + does not generally turn `let p = f a in p b` into `f a b`. +- `analysis::safe_to_discard` is not a proof that a term can move or be duplicated. +- Source `user_trace` obeys silent configuration, but direct `Builtin.Trace` + bypasses it. Tests also enable compiler traces separately in the driver. +- `assemble_core_with_options` accepts prebuilt Core without a `TraceConfig`. + O2 silence therefore needs enforcement beyond CLI configuration. + +These observations describe the pre-extension source. Plan 08 now implements +adjacent fusion, values-only native packing and late UPLC cleanup. The remaining +O2 entry-point and broader motion observations still apply. + +## Aiken reference and semantic classification + +Reference checkout: `aiken-lang/aiken`, commit +`bd0e4e30c6d8f51221bd9aabf22cfeb794d72884`. + +| Candidate | Classification and proof required | +| --- | --- | +| Adjacent application fusion: `let p = f a in p b` to `f a b` | O1 candidate when `p` has only that use, operands are atomic, and the same application stages remain in the same order. Preserve type views and hygiene. | +| Adjacent independent binding grouping: `let x=A in let y=B in C` to `(lambda x y -> C) A B` | O1 candidate when `x` is not free in `B` and A-before-B evaluation is unchanged. Measure whether it helps directly or only enables a later encoding. | +| Grouping across a later computation using known arity | O1 candidate only when actual lambda/builtin shape proves each crossed partial application returns a value without executing a body. A function type alone is not this proof. | +| Dependency-based reordering of nonadjacent bindings | Dependencies alone are insufficient. Require a motion proof covering traces, failures and divergence; after trace erasure, O2 still needs the failure/termination proof. | +| Moving bindings or traces under unapplied lambdas | An effectful or nonterminating RHS cannot move just because its value is used later. Trace-only work disappears in O2; arbitrary strict work still needs a proof. | +| Packing applications into native `Case`/`Constr` | Candidate for O1 or O2 depending on the proven evaluation-order preconditions. Use the actual target's native term support. Do not treat this as cosmetic application flattening. | + +Aiken's `crates/uplc/src/optimize/shrinker.rs` contains: + +- `split_body_lambda` (around line 1879): groups bindings by variable dependencies, + may reorder independent groups, and moves unmatched lambdas outside rebuilt + bindings. It has no general effect/termination gate. In particular, + `(lambda x -> lambda y -> B) A` can become + `lambda y -> (lambda x -> B) A`, delaying A until y is supplied. That unrestricted + rule violates this plan's contract when A fails or diverges. +- `case_constr_apply_reducer` (around line 2058): rewrites application spines to a + native constructor/case encoding and merges more arguments into existing packs. + Ordinary application evaluates F, A, applies F to A, then evaluates B; a packed + constructor evaluates its fields before the branch function is run. Safe cases + need an explicit proof of which computations are crossed. +- `afterwards` applies these rewrites without a silent-mode gate. Its group-size + heuristics and argument-count threshold are not Nash policy. + +Aiken's `builder::delayed_trace` emits `force (trace message (delay body))`. +That emits before evaluating the body. There is no separate trace-sinking pass +in the inspected shrinker; the lambda motion can explain traces moving later. + +## Execution and review + +Follow the existing optimizer experiment workflow: three concrete cases, one at a +time. Show the source-generated Core and before/after UPLC, check behavior, and +measure CPU cost, memory cost and raw Flat bytes in `tools/optimizer-perf`. +Review each candidate before production adoption. Do not implement this entire +plan before reviewing the first candidate. Do not use size growth as an implicit +rejection gate or silently import Aiken's thresholds. + +Keep normal tests semantic and structural. Performance experiments and cost +regressions remain outside normal Cargo test discovery. Preserve O0 snapshots. +Reuse compiled fixtures; render snapshots before independent property assertions. + +## O1 work moved to Plan 08 + +Application fusion, values-only native `Case`/`Constr` packing and late UPLC +binding cleanup are implemented under [Plan 08, Chunk 12](08-optimizer.md). +Their source measurements and semantic boundaries are in the +[application report](../docs/research/application-packing-trial.md). They are not +pending O2 features. Continue broader grouping only from those validated rules. + +## Chunk 2 — Automatic O2 silence (complete) + +Implemented through config, CLI settings resolution, driver, test compilation and +public Core assembly. Source and Core snapshots cover failure erasure, retained +value failure, partial/aliased trace references, and lambda/delay bodies. The +[three-case report](../docs/research/o2-silence-trial.md) compares O1 verbose, +O0/O1 silent and O2 silent. No broader grouping or motion is added. + +Completed scope: + +- Add O2 numeric parsing/serialization and CLI help for `-O2` / `--optimize 2`. +- Resolve effective silence after project settings, command defaults and overrides. + Cover `Build::for_tests` and the driver's currently hardcoded compiler tracing. +- Disable source user/compiler trace generation before constructing bodies whose + trace expressions can be omitted under existing silent syntax semantics. +- At the Core/assembly boundary, handle both `CoreKind::Trace` and direct builtin + Trace, including saturated, partial, aliased and first-class uses. +- Remove trace message expressions, even failing/diverging ones. Replace bare + builtin references with typed no-log functions; retain returned-value evaluation, + remaining applications and type views. +- Check emitted UPLC, including lambda and delay bodies, contains no Trace builtin. + +Reject explicit compact/verbose/compiler-trace settings for O2 in build and test. +Test +nested project ownership and direct assembly of hand-built Core. Test successful +values, failing messages, partial calls and unused functions. Do not confuse test +runner diagnostics with script traces. Explicit `comptime` evaluation is a separate +feature; this plan does not change its budget or evaluation policy. + +## Chunk 3 — Known-arity grouping, then native application packing + +Investigate after the Plan 08 application work is validated. Use actual lambda/builtin arity to +identify intermediate applications that cannot execute a body. Do not weaken +ANF staging globally based on function types. + +For native `Case`/`Constr` packing, explicitly identify the function and argument +computations whose order changes. Known values/closure-building stages may make +some cases O1-safe. Erased traces can expose additional eligible cases under O2, +but potential failure/divergence remains a barrier. + +For each candidate, compare direct calls, effect-sensitive/excess-argument cases, +and real source workloads. Select Core versus late UPLC placement from the emitted +code and semantic proof. Avoid adding an IR node solely to copy Aiken's machinery. + +## Chunk 4 — Lambda and binding movement + +Consider dependency grouping and motion only with a sufficient proof that crossed +computations cannot change observable behavior. Partial applications, escaping +functions, unused functions, early failures and recursive divergence are mandatory +counterexamples. Trace erasure alone is not that proof. + +Do not add a trace-after-lambda rewrite to O1 if it changes when or how often traces +occur. In O2, erased trace nodes do not need to be moved. Measure a remaining code +shape before proposing a separate pass. + +## Chunk 5 — Composition and completion + +- All accepted Core passes reach a joint unchanged-pointer fixed point; freshening + and the initial normalization are not repeated as a substitute for convergence. +- Late UPLC rewrites, if adopted, have their own stable structural contract and do + not repeatedly expand recursive encodings. +- Check one/two/three optimizer runs produce the same closed code, including cases + exposed by interactions between grouping, lifting, parameter removal and folding. +- For O1 compare values, failures, traces and termination against O0. For O2 compare + against silent O0, assert no emitted traces, and preserve failures/termination + outside discarded trace message computations. + Render deliberate divergent cases; use isolated bounded observations for runtime + experiments without introducing optimizer execution limits. +- Review changed performance rows explicitly; preserve result evidence and distinguish + changes in budget consumption from semantic changes. +- Run formatting, strict Clippy and `cargo nextest run --workspace`; run the explicit + performance workspace separately. Update changesets, docs and SPEC as chunks land. + +**Done when:** O2 is automatically silent at every entry point, each adopted rewrite +has a reviewed semantic classification and measurements, and the complete pipeline +converges without violating the selected mode's contract. diff --git a/tools/optimizer-perf/Cargo.lock b/tools/optimizer-perf/Cargo.lock index c6f44e2c..70a716ee 100644 --- a/tools/optimizer-perf/Cargo.lock +++ b/tools/optimizer-perf/Cargo.lock @@ -393,6 +393,7 @@ dependencies = [ "nash-ast", "nash-can", "nash-codegen", + "nash-config", "nash-constrain", "nash-ir", "nash-nitpick", diff --git a/tools/optimizer-perf/Cargo.toml b/tools/optimizer-perf/Cargo.toml index fdaec8fc..700aa327 100644 --- a/tools/optimizer-perf/Cargo.toml +++ b/tools/optimizer-perf/Cargo.toml @@ -22,6 +22,7 @@ nash-parse = { path = "../../crates/nash-parse" } nash-constrain = { path = "../../crates/nash-constrain" } nash-solve = { path = "../../crates/nash-solve" } nash-nitpick = { path = "../../crates/nash-nitpick" } +nash-config = { path = "../../crates/nash-config" } nash-codegen = { path = "../../crates/nash-codegen" } nash-ir = { path = "../../crates/nash-ir" } nash-plutus = { path = "../../crates/nash-plutus" } diff --git a/tools/optimizer-perf/README.md b/tools/optimizer-perf/README.md index 179b57f0..2367fbe9 100644 --- a/tools/optimizer-perf/README.md +++ b/tools/optimizer-perf/README.md @@ -19,11 +19,11 @@ mismatch, a compilation failure or an exhausted budget. `measure` prints JSON without changing any baseline. Debug/release profiles produce the same ledger budgets: these are CEK costs, not Rust wall-clock benchmarks. -The 108 rows include the original 20 covering list traversal, static recursion, Data matching and -misses, field decoding, validation success/failure, the real base Logic helpers, -and six ledger scenarios each for the existing Vesting and VestingParam source -fixtures, plus constant-prefix two-use, cold and loop regressions and 85 representation -cancellation cases shared with semantic tests. Validators receive one V3 ScriptContext containing TxInfo, redeemer and spending +The 199 rows cover list traversal, static recursion, Data matching and misses, +field decoding, validation success/failure, base Logic helpers, constant folding, +representation cancellation, pair projection, recursive parameters, application +staging and trace/failure order. They also include six ledger scenarios each for +the Vesting and VestingParam source fixtures. Validators receive one V3 ScriptContext containing TxInfo, redeemer and spending datum; the optional minimum-lock parameter is applied off-chain first. Times are POSIX milliseconds from the validity-range lower bound. Validator CPU/memory include parameter and context application; @@ -31,10 +31,10 @@ validator bytes exclude those arguments. Ordinary expression fixtures include their inputs in the measured program. The `before` pipeline is O0 (recursion rewrite and lowering). The `after` pipeline -is the accepted static lifting, pre-ANF unused-parameter removal, direct native-constructor folding and representation inverse cancellation, one ANF normalization and rules 1+2+3+4 plus safe dead-binding, recursive-reachability, representation cancellation, force/delay, known-Boolean/integer/bytes, bound-constructor, known-constructor field, known-list, literal-Data and IData/BData/ListData/MapData/ConstrData producer cleanup, +is the accepted static lifting, pre-ANF unused-parameter removal, one ANF normalization and rules 1+2+3+4 plus safe dead-binding, recursive-reachability, representation cancellation, force/delay, known-Boolean/integer/bytes, bound-constructor, known-constructor field, known-list, literal-Data and IData/BData/ListData/MapData/ConstrData producer cleanup, then recursion rewrite, binder freshening and lowering with both Chunk 5 sharing steps. No second normalization or ANF-dependent cleanup runs after recursion rewriting. Rule 3 was accepted on 27 September 2026. These figures record current behavior, including overhead -from ANF; they are not a claim that the incomplete optimizer beats O0 everywhere. +from ANF; they are not a claim that O1 beats O0 everywhere. ## Explicit baseline updates @@ -105,3 +105,41 @@ source once its decision is recorded. The Core pipeline is shared with production O1 in `nash-codegen::optimizer`. Builds and tests default to O1; these measurements still compare explicit O0 and O1. + +## Accepted constant folding + +Normal `measure`/`check` include the original 108, 40 constant-folding +fixtures and 30 pair fixtures, plus the recursive cases below. Both use production O1, including unbudgeted folding. The user +accepted the two shared-prefix size tradeoffs. Historical pre-integration evidence +remains in `trials/constant-fold.json` and `docs/research/constant-fold-trial.md`; +the old `constant-trial` command has been removed. + +## Accepted restricted pair projection + +Normal `measure`/`check` include the restricted pair rewrite in production O1 and +all 30 pair fixtures. The general rewrite was rejected; the `pair-trial` command +was removed. Historical comparisons remain in `trials/pair-projection.json` and +[the report](../../docs/research/pair-projection-trial.md). + +## Recursive unused parameters + +Normal `measure`/`check` include 14 recursive Core fixtures and two source +workloads, bringing the baseline to 194 cases. These cover forwarding cycles, +consumers, strict effects, blocked call shapes, and delayed/mixed groups. +Performance checks remain explicit and outside normal Cargo tests. See +[the report](../../docs/research/recursive-parameters.md). + +## Application fusion, packing and late cleanup + +The Plan 08 O1 pipeline now uses `lower_optimized`, including late binding cleanup +and values-only native Case/Constr application packing. Four source cases bring +the baseline to 199: a staged call, traces at call stages, a traced later argument, +and failure before that argument. Every run checks complete O1 Flat equality after +one, two and three Core optimizations and late-pass idempotence. The original +195 O0 rows are unchanged. See the +[application report](../../docs/research/application-packing-trial.md) for the +reviewed performance changes, including the size tradeoffs. + +## Initial O2 silence experiment + +`cargo run --release --manifest-path tools/optimizer-perf/Cargo.toml -- silent-experiment MODULE.nash` compares O1 verbose, O0/O1 silent and O2 silent with source/Core/UPLC and costs. O2 discards trace messages even if they fail or diverge; outcomes can therefore differ. This command keeps the existing O0/O1 baseline separate. Fixtures and reviewed results are in `fixtures/o2/`, `trials/o2-silence.json` and [the report](../../docs/research/o2-silence-trial.md). diff --git a/tools/optimizer-perf/baseline.json b/tools/optimizer-perf/baseline.json index ebb62ed1..5abdaed8 100644 --- a/tools/optimizer-perf/baseline.json +++ b/tools/optimizer-perf/baseline.json @@ -1,18 +1,21 @@ { - "settings": "v1; Plutus V3/PV11; UPLC 1.1.0; bundled V3 default cost model; CPU=100000000; memory=2000000; raw Flat bytes before ledger application; O0 vs static lift/unused-parameters/known-constr/representation-inverse/ANF once/rules1+2+3+4+dead-bindings+recursive-reachability+representation-inverse+force-delay+known-bool+int-bytes/bound-constr+known-fields+list+data+idata-bdata-listdata-mapdata-constrdata-cleanup/recursion/hygiene/lower+forced-builtin-sharing+constant-prefix-sharing", + "settings": "v1; Plutus V3/PV11; UPLC 1.1.0; bundled V3 default cost model; CPU=100000000; memory=2000000; raw Flat bytes before ledger application; O0 vs static lift/unused-parameters(nonrecursive+recursive)/ANF once/rules1+2+3+4+dead-bindings+recursive-reachability+representation-inverse+force-delay+known-bool+int-bytes/bound-constr+known-fields+list+data+idata-bdata-listdata-mapdata-constrdata+restricted-pair-cleanup/static-lift+unused-parameters+constant-fold+cleanup(unbudgeted-fixed-point,all-pure-representable)/adjacent-application-fusion/recursion/hygiene/lower+forced-builtin-sharing+constant-prefix-sharing/late-value-binding-cleanup+native-value-application-packing", "sources": { "Cardano.Tx": "module Cardano.Tx exposing (validAfter, signedBy)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\n\n-- V3 TxInfo field 7 is the validity interval. Require a finite lower bound.\n-- Times are POSIX milliseconds, not slots or the current wall-clock time.\nvalidAfter : Data -> int\nvalidAfter tx =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, Constr pair(0, [ Constr pair(0, [ Constr pair(1, [ I time ]), _ ]), _ ]), _, _, _, _, _, _, _, _ ]) -> time\n _ -> fail\n\n-- V3 TxInfo field 8 contains every extra signatory.\nsignedBy : Data -> Bytes -> bool\nsignedBy tx owner =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, _, List signers, _, _, _, _, _, _, _ ]) -> hasSigner signers (lower owner)\n _ -> fail\n\nhasSigner : list Data -> bytes -> bool\nhasSigner signers owner =\n case signers of\n [] -> False\n B signer :: rest ->\n if Builtin.equalsByteString signer owner then True\n else hasSigner rest owner\n _ -> fail\n", + "ConstantInputs": "//! Shared inputs for the constant-evaluation trial and its explicit measurements.\nuse nash_ir::{\n build::Builder,\n core::{Binder, Core},\n ty::Ty,\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant as C, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(&'static str, &'a Core<'a>, bool)> {\n let a = b.arena;\n let bytes = |s| b.lit(C::byte_string(a, s));\n let string = |s| b.lit(C::string(a, s));\n let int = b.int(7);\n let data = b.lit(C::data(a, D::integer_from(a, 7)));\n let list = b.lit(C::proto_list(\n a,\n &Type::Integer,\n a.alloc([C::integer_from(a, 7), C::integer_from(a, 8)]),\n ));\n let empty = b.lit(C::proto_list(a, &Type::Integer, &[]));\n let pair = b.lit(C::proto_pair(\n a,\n &Type::Integer,\n &Type::ByteString,\n C::integer_from(a, 7),\n C::byte_string(a, b\"a\"),\n ));\n let call = |f, args: &[&'a Core<'a>]| b.builtin(f, args, Ty::Erased);\n let add = call(F::AddInteger, &[b.int(20), b.int(22)]);\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: add.ty,\n };\n let dlist = b.lit(C::proto_list(\n a,\n &Type::Data,\n a.alloc([C::data(a, D::integer_from(a, 7))]),\n ));\n let dmap = b.lit(C::proto_list(\n a,\n a.alloc(Type::Pair(&Type::Data, &Type::Data)),\n &[],\n ));\n let expanding = b.lit(C::data(\n a,\n D::list(a, a.alloc_slice_copy(&[D::integer_from(a, 7); 30])),\n ));\n let prefix = string(a.as_bump().alloc_str(&\"prefix\".repeat(6)));\n let shared = Binder {\n name: b.fresh(\"prefix\"),\n ty: prefix.ty,\n };\n let shared_prefix = b.let_(\n shared,\n prefix,\n b.constr(\n 0,\n &[\n call(\n F::AppendString,\n &[b.var(shared.name, shared.ty), string(\"x\")],\n ),\n call(\n F::AppendString,\n &[b.var(shared.name, shared.ty), string(\"y\")],\n ),\n ],\n Ty::Erased,\n ),\n );\n let distinct_results = b.constr(\n 0,\n &[\n call(F::AppendString, &[prefix, string(\"x\")]),\n call(F::AppendString, &[prefix, string(\"y\")]),\n ],\n Ty::Erased,\n );\n vec![\n (\"shared_prefix_distinct_results\", shared_prefix, false),\n (\"repeated_literal_distinct_results\", distinct_results, false),\n (\n \"expanding_data_list\",\n call(F::UnListData, &[expanding]),\n false,\n ),\n (\"addition\", add, false),\n (\n \"nested_arithmetic\",\n call(F::MultiplyInteger, &[add, b.int(2)]),\n false,\n ),\n (\n \"bound_arithmetic\",\n b.let_(\n x,\n add,\n call(F::MultiplyInteger, &[b.var(x.name, x.ty), b.int(2)]),\n ),\n false,\n ),\n (\n \"division\",\n call(F::DivideInteger, &[b.int(-7), b.int(3)]),\n false,\n ),\n (\n \"division_zero\",\n call(F::DivideInteger, &[int, b.int(0)]),\n true,\n ),\n (\n \"wrong_integer_shape\",\n call(F::AddInteger, &[bytes(b\"x\"), int]),\n true,\n ),\n (\n \"byte_append\",\n call(F::AppendByteString, &[bytes(b\"ab\"), bytes(b\"cd\")]),\n false,\n ),\n (\n \"byte_slice\",\n call(F::SliceByteString, &[b.int(1), b.int(2), bytes(b\"abcd\")]),\n false,\n ),\n (\n \"byte_length\",\n call(F::LengthOfByteString, &[bytes(b\"abcd\")]),\n false,\n ),\n (\n \"byte_compare\",\n call(F::LessThanByteString, &[bytes(b\"abc\"), bytes(b\"abd\")]),\n false,\n ),\n (\n \"string_append\",\n call(F::AppendString, &[string(\"hello \"), string(\"world\")]),\n false,\n ),\n (\"encode_utf8\", call(F::EncodeUtf8, &[string(\"\u0e2a\u0e27\u0e31\u0e2a\u0e14\u0e35\")]), false),\n (\n \"decode_utf8\",\n call(F::DecodeUtf8, &[bytes(\"h\u00e9llo\".as_bytes())]),\n false,\n ),\n (\"invalid_utf8\", call(F::DecodeUtf8, &[bytes(&[255])]), true),\n (\"integer_data\", call(F::IData, &[int]), false),\n (\"decode_integer_data\", call(F::UnIData, &[data]), false),\n (\"wrong_data_variant\", call(F::UnBData, &[data]), true),\n (\"list_data\", call(F::ListData, &[dlist]), false),\n (\"map_data\", call(F::MapData, &[dmap]), false),\n (\"data_equal\", call(F::EqualsData, &[data, data]), false),\n (\"serialise_data\", call(F::SerialiseData, &[data]), false),\n (\"list_head\", call(F::HeadList, &[list]), false),\n (\"list_tail\", call(F::TailList, &[list]), false),\n (\"empty_head\", call(F::HeadList, &[empty]), true),\n (\"empty_tail\", call(F::TailList, &[empty]), true),\n (\"list_null\", call(F::NullList, &[empty]), false),\n (\"pair_first\", call(F::FstPair, &[pair]), false),\n (\"pair_second\", call(F::SndPair, &[pair]), false),\n (\"trace_before\", b.trace(string(\"before\"), add), false),\n (\n \"trace_builtin\",\n call(F::Trace, &[string(\"keep me\"), int]),\n false,\n ),\n (\n \"cold_failure\",\n b.if_(\n b.lit(C::bool(a, true)),\n int,\n call(F::DivideInteger, &[int, b.int(0)]),\n ),\n false,\n ),\n (\n \"selected_branch\",\n b.if_(\n call(F::EqualsInteger, &[int, b.int(7)]),\n b.trace(string(\"yes\"), add),\n b.trace(string(\"no\"), b.error(Ty::Erased)),\n ),\n false,\n ),\n (\n \"strict_failure_order\",\n call(\n F::AddInteger,\n &[\n b.trace(string(\"first\"), b.error(int.ty)),\n call(F::DivideInteger, &[int, b.int(0)]),\n ],\n ),\n true,\n ),\n (\"unsupported_hash\", call(F::Sha2_256, &[bytes(b\"x\")]), false),\n (\n \"partial\",\n b.app(\n b.builtin(F::AddInteger, &[int], Ty::Erased),\n &[b.int(1)],\n Ty::Erased,\n ),\n false,\n ),\n (\n \"large_input\",\n call(\n F::AppendByteString,\n &[bytes(a.alloc_slice_copy(&[42; 4096])), bytes(b\"z\")],\n ),\n false,\n ),\n (\n \"repeated_call\",\n b.constr(0, &[add, add, add], Ty::Erased),\n false,\n ),\n ]\n}\n", "Eq": "module Eq exposing ( Eq )\n\n\nimport Literal\nimport Logic exposing ( not, xor, (&&) )\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\n\n{-| Compare values for equality and inequality. -}\ntrait Eq 'a where\n eq : 'a -> 'a -> bool\n\n neq : 'a -> 'a -> bool\n neq a b = not (eq a b)\n\n\nimpl Eq int where\n eq = Builtin.equalsInteger\n\n\nimpl Eq bytes where\n eq = Builtin.equalsByteString\n\n\nimpl Eq string where\n eq = Builtin.equalsString\n\n\nimpl Eq bool where\n eq a b = not (xor a b)\n\n\nimpl Eq unit where\n eq _ _ = True\n\n\nimpl Eq (list ('a : Big)) where\n eq xs ys =\n eq (Builtin.listData xs) (Builtin.listData ys)\n\n\nimpl Eq 'a => Eq (list ('a : Little)) where\n eq xs ys =\n case xs of\n [] ->\n case ys of\n [] ->\n True\n\n _ :: _ ->\n False\n\n x :: restX ->\n case ys of\n [] ->\n False\n\n y :: restY ->\n eq x y && eq restX restY\n\n\nimpl ( Eq 'a, Eq 'b ) => Eq (pair 'a 'b) where\n eq a b =\n let\n pair(firstA, secondA) = a\n\n pair(firstB, secondB) = b\n in\n eq firstA firstB && eq secondA secondB\n\n\nimpl Eq (map ('k : Big) ('v : Big)) where\n eq xs ys = eq (Builtin.mapData xs) (Builtin.mapData ys)\n\n\nimpl ( Eq 'k, Eq 'v ) => Eq (map ('k : Little) 'v) where\n eq = eqMapEntries\n\n\nimpl Eq 'v => Eq (map ('k : Big) ('v : Little)) where\n eq = eqMapEntries\n\n\neqMapEntries : ( Eq 'k, Eq 'v ) => list (pair 'k 'v) -> list (pair 'k 'v) -> bool\neqMapEntries = eq\n\n\nimpl Eq value where\n eq a b = Builtin.equalsData (Builtin.valueData a) (Builtin.valueData b)\n", - "InverseInputs": "//! Shared semantic and explicit performance inputs for representation cancellation.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, Ty},\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(String, &'a Core<'a>, bool)> {\n let a = b.arena;\n let d = D::integer_from(a, 7);\n let data = Constant::data(a, d);\n let pair = Constant::proto_pair(a, &Type::Data, &Type::Data, data, data);\n let list = Constant::proto_list(a, &Type::Data, a.alloc([data]));\n let map = Constant::proto_list(\n a,\n a.alloc(Type::Pair(&Type::Data, &Type::Data)),\n a.alloc([pair]),\n );\n let mut cases = Vec::new();\n for (name, encode, decode, value, encoded) in [\n (\"integer\", F::IData, F::UnIData, b.int(7), b.lit(data)),\n (\n \"bytes\",\n F::BData,\n F::UnBData,\n b.lit(Constant::byte_string(a, b\"hello\")),\n b.lit(Constant::data(a, D::byte_string(a, b\"hello\"))),\n ),\n (\n \"list\",\n F::ListData,\n F::UnListData,\n b.lit(list),\n b.lit(Constant::data(a, D::list(a, a.alloc([d])))),\n ),\n (\n \"map\",\n F::MapData,\n F::UnMapData,\n b.lit(map),\n b.lit(Constant::data(a, D::map(a, a.alloc([(d, d)])))),\n ),\n (\n \"utf8\",\n F::EncodeUtf8,\n F::DecodeUtf8,\n b.lit(Constant::string(a, \"héllo\")),\n b.lit(Constant::byte_string(a, \"héllo\".as_bytes())),\n ),\n ] {\n let wrap = |x| b.builtin(decode, &[b.builtin(encode, &[x], encoded.ty)], value.ty);\n let trace = |s, x| b.trace(b.lit(Constant::string(a, s)), x);\n cases.push((format!(\"{name}_direct\"), wrap(value), false));\n cases.push((\n format!(\"{name}_trace\"),\n wrap(trace(\"operand\", value)),\n false,\n ));\n cases.push((\n format!(\"{name}_decoded\"),\n wrap(b.builtin(decode, &[encoded], value.ty)),\n false,\n ));\n cases.push((\n format!(\"{name}_decode_failure\"),\n wrap(b.builtin(decode, &[b.int(0)], value.ty)),\n true,\n ));\n cases.push((\n format!(\"{name}_reverse\"),\n b.builtin(\n encode,\n &[b.builtin(decode, &[encoded], value.ty)],\n encoded.ty,\n ),\n false,\n ));\n cases.push((\n format!(\"{name}_wrong_kind\"),\n wrap(b.with_type(b.lit(Constant::bool(a, false)), value.ty)),\n true,\n ));\n cases.push((\n format!(\"{name}_cold\"),\n b.if_(\n b.lit(Constant::bool(a, true)),\n value,\n wrap(trace(\"cold\", value)),\n ),\n false,\n ));\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: value.ty,\n };\n let y = Binder {\n name: b.fresh(\"encoded\"),\n ty: encoded.ty,\n };\n let z = Binder {\n name: b.fresh(\"alias\"),\n ty: encoded.ty,\n };\n let decoded = b.builtin(decode, &[b.var(z.name, z.ty)], value.ty);\n let bindings = |body| {\n b.let_(\n x,\n trace(\"once\", value),\n b.let_(\n y,\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n b.let_(z, b.var(y.name, y.ty), body),\n ),\n )\n };\n cases.push((\n format!(\"{name}_bound\"),\n bindings(trace(\"after encoding\", decoded)),\n false,\n ));\n cases.push((\n format!(\"{name}_captured\"),\n bindings(b.force(b.delay(decoded), decoded.ty)),\n false,\n ));\n cases.push((\n format!(\"{name}_escaping\"),\n bindings(b.constr(0, &[b.var(y.name, y.ty), decoded, decoded], Ty::Erased)),\n false,\n ));\n cases.push((\n format!(\"{name}_bound_invalid\"),\n b.let_(\n x,\n trace(\n \"operand\",\n b.with_type(b.lit(Constant::bool(a, false)), value.ty),\n ),\n b.let_(\n y,\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n trace(\n \"must not run\",\n b.builtin(decode, &[b.var(y.name, y.ty)], value.ty),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_reverse_bound_invalid\"),\n b.let_(\n y,\n b.with_type(b.int(0), encoded.ty),\n b.let_(\n x,\n b.builtin(decode, &[b.var(y.name, y.ty)], value.ty),\n trace(\n \"must not run\",\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_oversaturated\"),\n b.app(wrap(value), &[b.int(1)], value.ty),\n true,\n ));\n let unknown = Binder {\n name: b.fresh(\"unknown\"),\n ty: value.ty,\n };\n cases.push((\n format!(\"{name}_unknown_invalid\"),\n b.app(\n b.lam(&[unknown], wrap(b.var(unknown.name, unknown.ty))),\n &[b.lit(Constant::bool(a, false))],\n value.ty,\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_partial\"),\n b.app(\n b.builtin(decode, &[], Ty::Erased),\n &[b.builtin(encode, &[value], encoded.ty)],\n value.ty,\n ),\n false,\n ));\n }\n let bad_utf8 = b.lit(Constant::byte_string(a, &[255]));\n cases.push((\n \"utf8_reverse_invalid\".into(),\n b.builtin(\n F::EncodeUtf8,\n &[b.builtin(F::DecodeUtf8, &[bad_utf8], Ty::Const(&ConstTy::String))],\n bad_utf8.ty,\n ),\n true,\n ));\n for (name, encode, decode, typ) in [\n (\"list_wrong_tag\", F::ListData, F::UnListData, &Type::Integer),\n (\"map_wrong_tag\", F::MapData, F::UnMapData, &Type::Data),\n ] {\n let value = b.lit(Constant::proto_list(a, typ, &[]));\n cases.push((\n name.into(),\n b.builtin(decode, &[b.builtin(encode, &[value], Ty::Erased)], value.ty),\n true,\n ));\n }\n let data_ty = b.lit(data).ty;\n let fields = Binder {\n name: b.fresh(\"fields\"),\n ty: b.lit(list).ty,\n };\n let tag = Binder {\n name: b.fresh(\"tag\"),\n ty: b.int(0).ty,\n };\n let encoded = Binder {\n name: b.fresh(\"constructor\"),\n ty: data_ty,\n };\n let payload = Binder {\n name: b.fresh(\"payload\"),\n ty: Ty::Erased,\n };\n let p = b.var(payload.name, payload.ty);\n let fst = b.builtin(F::FstPair, &[p], tag.ty);\n let snd = b.builtin(F::SndPair, &[p], fields.ty);\n let constructor = b.builtin(\n F::ConstrData,\n &[b.var(tag.name, tag.ty), b.var(fields.name, fields.ty)],\n data_ty,\n );\n let bind = |body| {\n b.let_(\n tag,\n b.int(0),\n b.let_(\n fields,\n b.lit(list),\n b.let_(\n encoded,\n constructor,\n b.let_(\n payload,\n b.builtin(\n F::UnConstrData,\n &[b.var(encoded.name, encoded.ty)],\n Ty::Erased,\n ),\n body,\n ),\n ),\n ),\n )\n };\n cases.push((\"constructor_tag\".into(), bind(fst), false));\n cases.push((\"constructor_fields\".into(), bind(snd), false));\n cases.push((\n \"constructor_rebuild\".into(),\n bind(b.builtin(F::ConstrData, &[fst, snd], data_ty)),\n false,\n ));\n for (name, subject, fails) in [\n (\n \"constructor_known_reverse\",\n b.lit(Constant::data(a, D::constr(a, 3, a.alloc([d])))),\n false,\n ),\n (\"constructor_wrong_variant\", b.lit(data), true),\n ] {\n cases.push((\n name.into(),\n b.let_(\n encoded,\n subject,\n b.let_(\n payload,\n b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased),\n b.trace(\n b.lit(Constant::string(a, \"after decoding\")),\n b.builtin(F::ConstrData, &[fst, snd], data_ty),\n ),\n ),\n ),\n fails,\n ));\n }\n let bad_tag = b.with_type(b.lit(Constant::bool(a, false)), tag.ty);\n cases.push((\n \"constructor_bad_tag\".into(),\n b.let_(\n tag,\n bad_tag,\n b.let_(\n fields,\n b.trace(b.lit(Constant::string(a, \"fields evaluated\")), b.lit(list)),\n b.let_(\n encoded,\n constructor,\n b.builtin(\n F::FstPair,\n &[b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased)],\n tag.ty,\n ),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n \"constructor_bad_fields\".into(),\n b.let_(\n tag,\n b.int(0),\n b.let_(\n fields,\n b.with_type(b.lit(Constant::bool(a, false)), fields.ty),\n b.let_(\n encoded,\n constructor,\n b.builtin(\n F::SndPair,\n &[b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased)],\n fields.ty,\n ),\n ),\n ),\n ),\n true,\n ));\n cases\n}\n", + "InverseInputs": "//! Shared semantic and explicit performance inputs for representation cancellation.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, Ty},\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(String, &'a Core<'a>, bool)> {\n let a = b.arena;\n let d = D::integer_from(a, 7);\n let data = Constant::data(a, d);\n let pair = Constant::proto_pair(a, &Type::Data, &Type::Data, data, data);\n let list = Constant::proto_list(a, &Type::Data, a.alloc([data]));\n let map = Constant::proto_list(\n a,\n a.alloc(Type::Pair(&Type::Data, &Type::Data)),\n a.alloc([pair]),\n );\n let mut cases = Vec::new();\n for (name, encode, decode, value, encoded) in [\n (\"integer\", F::IData, F::UnIData, b.int(7), b.lit(data)),\n (\n \"bytes\",\n F::BData,\n F::UnBData,\n b.lit(Constant::byte_string(a, b\"hello\")),\n b.lit(Constant::data(a, D::byte_string(a, b\"hello\"))),\n ),\n (\n \"list\",\n F::ListData,\n F::UnListData,\n b.lit(list),\n b.lit(Constant::data(a, D::list(a, a.alloc([d])))),\n ),\n (\n \"map\",\n F::MapData,\n F::UnMapData,\n b.lit(map),\n b.lit(Constant::data(a, D::map(a, a.alloc([(d, d)])))),\n ),\n (\n \"utf8\",\n F::EncodeUtf8,\n F::DecodeUtf8,\n b.lit(Constant::string(a, \"h\u00e9llo\")),\n b.lit(Constant::byte_string(a, \"h\u00e9llo\".as_bytes())),\n ),\n ] {\n let wrap = |x| b.builtin(decode, &[b.builtin(encode, &[x], encoded.ty)], value.ty);\n let trace = |s, x| b.trace(b.lit(Constant::string(a, s)), x);\n cases.push((format!(\"{name}_direct\"), wrap(value), false));\n cases.push((\n format!(\"{name}_trace\"),\n wrap(trace(\"operand\", value)),\n false,\n ));\n cases.push((\n format!(\"{name}_decoded\"),\n wrap(b.builtin(decode, &[encoded], value.ty)),\n false,\n ));\n cases.push((\n format!(\"{name}_decode_failure\"),\n wrap(b.builtin(decode, &[b.int(0)], value.ty)),\n true,\n ));\n cases.push((\n format!(\"{name}_reverse\"),\n b.builtin(\n encode,\n &[b.builtin(decode, &[encoded], value.ty)],\n encoded.ty,\n ),\n false,\n ));\n cases.push((\n format!(\"{name}_wrong_kind\"),\n wrap(b.with_type(b.lit(Constant::bool(a, false)), value.ty)),\n true,\n ));\n cases.push((\n format!(\"{name}_cold\"),\n b.if_(\n b.lit(Constant::bool(a, true)),\n value,\n wrap(trace(\"cold\", value)),\n ),\n false,\n ));\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: value.ty,\n };\n let y = Binder {\n name: b.fresh(\"encoded\"),\n ty: encoded.ty,\n };\n let z = Binder {\n name: b.fresh(\"alias\"),\n ty: encoded.ty,\n };\n let decoded = b.builtin(decode, &[b.var(z.name, z.ty)], value.ty);\n let bindings = |body| {\n b.let_(\n x,\n trace(\"once\", value),\n b.let_(\n y,\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n b.let_(z, b.var(y.name, y.ty), body),\n ),\n )\n };\n cases.push((\n format!(\"{name}_bound\"),\n bindings(trace(\"after encoding\", decoded)),\n false,\n ));\n cases.push((\n format!(\"{name}_captured\"),\n bindings(b.force(b.delay(decoded), decoded.ty)),\n false,\n ));\n cases.push((\n format!(\"{name}_escaping\"),\n bindings(b.constr(0, &[b.var(y.name, y.ty), decoded, decoded], Ty::Erased)),\n false,\n ));\n cases.push((\n format!(\"{name}_bound_invalid\"),\n b.let_(\n x,\n trace(\n \"operand\",\n b.with_type(b.lit(Constant::bool(a, false)), value.ty),\n ),\n b.let_(\n y,\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n trace(\n \"must not run\",\n b.builtin(decode, &[b.var(y.name, y.ty)], value.ty),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_reverse_bound_invalid\"),\n b.let_(\n y,\n b.with_type(b.int(0), encoded.ty),\n b.let_(\n x,\n b.builtin(decode, &[b.var(y.name, y.ty)], value.ty),\n trace(\n \"must not run\",\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_oversaturated\"),\n b.app(wrap(value), &[b.int(1)], value.ty),\n true,\n ));\n let unknown = Binder {\n name: b.fresh(\"unknown\"),\n ty: value.ty,\n };\n cases.push((\n format!(\"{name}_unknown_invalid\"),\n b.app(\n b.lam(&[unknown], wrap(b.var(unknown.name, unknown.ty))),\n &[b.lit(Constant::bool(a, false))],\n value.ty,\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_partial\"),\n b.app(\n b.builtin(decode, &[], Ty::Erased),\n &[b.builtin(encode, &[value], encoded.ty)],\n value.ty,\n ),\n false,\n ));\n }\n let bad_utf8 = b.lit(Constant::byte_string(a, &[255]));\n cases.push((\n \"utf8_reverse_invalid\".into(),\n b.builtin(\n F::EncodeUtf8,\n &[b.builtin(F::DecodeUtf8, &[bad_utf8], Ty::Const(&ConstTy::String))],\n bad_utf8.ty,\n ),\n true,\n ));\n for (name, encode, decode, typ) in [\n (\"list_wrong_tag\", F::ListData, F::UnListData, &Type::Integer),\n (\"map_wrong_tag\", F::MapData, F::UnMapData, &Type::Data),\n ] {\n let value = b.lit(Constant::proto_list(a, typ, &[]));\n cases.push((\n name.into(),\n b.builtin(decode, &[b.builtin(encode, &[value], Ty::Erased)], value.ty),\n true,\n ));\n }\n let data_ty = b.lit(data).ty;\n let fields = Binder {\n name: b.fresh(\"fields\"),\n ty: b.lit(list).ty,\n };\n let tag = Binder {\n name: b.fresh(\"tag\"),\n ty: b.int(0).ty,\n };\n let encoded = Binder {\n name: b.fresh(\"constructor\"),\n ty: data_ty,\n };\n let payload = Binder {\n name: b.fresh(\"payload\"),\n ty: Ty::Erased,\n };\n let p = b.var(payload.name, payload.ty);\n let fst = b.builtin(F::FstPair, &[p], tag.ty);\n let snd = b.builtin(F::SndPair, &[p], fields.ty);\n let constructor = b.builtin(\n F::ConstrData,\n &[b.var(tag.name, tag.ty), b.var(fields.name, fields.ty)],\n data_ty,\n );\n let bind = |body| {\n b.let_(\n tag,\n b.int(0),\n b.let_(\n fields,\n b.lit(list),\n b.let_(\n encoded,\n constructor,\n b.let_(\n payload,\n b.builtin(\n F::UnConstrData,\n &[b.var(encoded.name, encoded.ty)],\n Ty::Erased,\n ),\n body,\n ),\n ),\n ),\n )\n };\n cases.push((\"constructor_tag\".into(), bind(fst), false));\n cases.push((\"constructor_fields\".into(), bind(snd), false));\n cases.push((\n \"constructor_rebuild\".into(),\n bind(b.builtin(F::ConstrData, &[fst, snd], data_ty)),\n false,\n ));\n for (name, subject, fails) in [\n (\n \"constructor_known_reverse\",\n b.lit(Constant::data(a, D::constr(a, 3, a.alloc([d])))),\n false,\n ),\n (\"constructor_wrong_variant\", b.lit(data), true),\n ] {\n cases.push((\n name.into(),\n b.let_(\n encoded,\n subject,\n b.let_(\n payload,\n b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased),\n b.trace(\n b.lit(Constant::string(a, \"after decoding\")),\n b.builtin(F::ConstrData, &[fst, snd], data_ty),\n ),\n ),\n ),\n fails,\n ));\n }\n let bad_tag = b.with_type(b.lit(Constant::bool(a, false)), tag.ty);\n cases.push((\n \"constructor_bad_tag\".into(),\n b.let_(\n tag,\n bad_tag,\n b.let_(\n fields,\n b.trace(b.lit(Constant::string(a, \"fields evaluated\")), b.lit(list)),\n b.let_(\n encoded,\n constructor,\n b.builtin(\n F::FstPair,\n &[b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased)],\n tag.ty,\n ),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n \"constructor_bad_fields\".into(),\n b.let_(\n tag,\n b.int(0),\n b.let_(\n fields,\n b.with_type(b.lit(Constant::bool(a, false)), fields.ty),\n b.let_(\n encoded,\n constructor,\n b.builtin(\n F::SndPair,\n &[b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased)],\n fields.ty,\n ),\n ),\n ),\n ),\n true,\n ));\n cases\n}\n", "Lift": "module Lift exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait Lift 'a 'b where\n lift : 'a -> 'b\n lower : 'b -> 'a\n\nimpl Lift int Int where\n lift value = Builtin.iData value\n lower value = Builtin.unIData value\n\nimpl Lift bytes Bytes where\n lift value = Builtin.bData value\n lower value = Builtin.unBData value\n", "Literal": "module Literal exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait FromInt 'a where\n fromInt : int -> 'a\n\ntrait FromString 'a where\n fromString : string -> 'a\n\ntrait FromBytes 'a where\n fromBytes : bytes -> 'a\n\nimpl FromInt int where\n fromInt x = x\n\nimpl FromString string where\n fromString x = x\n\nimpl FromBytes bytes where\n fromBytes x = x\n\ntrait FromBool 'a where\n fromBool : bool -> 'a\n\ntrait FromUnit 'a where\n fromUnit : unit -> 'a\n\nimpl FromBool bool where\n fromBool value = value\n\nimpl FromUnit unit where\n fromUnit value = value\n", "Logic": "module Logic exposing ( not, and, or, xor, (&&), (||) )\n\n\nimport Primitive\nimport Lift exposing ( Lift )\n\n\ninfix right 2 (||) = or\n\n\ninfix right 3 (&&) = and\n\n\n{-| Negate a Big or little Boolean, returning bool. -}\nnot : Lift bool 'a => 'a -> bool\nnot value =\n if lower value then\n Primitive.False\n else\n Primitive.True\n\n\n{-| Boolean conjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nand : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nand a b =\n if lower a then\n lower b\n else\n Primitive.False\n\n\n{-| Boolean disjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nor a b =\n if lower a then\n Primitive.True\n else\n lower b\n\n\n{-| Return True when the Boolean operands differ. -}\nxor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nxor a b =\n if lower a then\n not b\n else\n lower b\n", + "PairInputs": "//! Inputs shared by pair-projection snapshots and explicit measurements.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, Ty},\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant as C, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(String, &'a Core<'a>, bool)> {\n let a = b.arena;\n let int = b.int(0).ty;\n let pair = b.lit(C::proto_pair(\n a,\n &Type::Integer,\n &Type::Integer,\n C::integer_from(a, 7),\n C::integer_from(a, 8),\n ));\n let data = b.lit(C::data(a, D::integer_from(a, 7)));\n let made = b.builtin(\n F::MkPairData,\n &[data, data],\n Ty::Const(a.alloc(ConstTy::Pair(data.ty, data.ty))),\n );\n let unwrapped = b.builtin(\n F::UnConstrData,\n &[b.lit(C::data(a, D::constr(a, 0, &[])))],\n Ty::Const(a.alloc(ConstTy::Pair(\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n ))),\n );\n let trace = |s, x| b.trace(b.lit(C::string(a, s)), x);\n let mut cases = Vec::new();\n for (name, subject, left_ty, right_ty, fails) in [\n (\"literal\", pair, int, int, false),\n (\"traced\", trace(\"subject\", pair), int, int, false),\n (\"made_data\", made, data.ty, data.ty, false),\n (\n \"decoded\",\n unwrapped,\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n false,\n ),\n (\n \"bad_decoder\",\n b.builtin(F::UnConstrData, &[data], unwrapped.ty),\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n true,\n ),\n (\n \"ignored_failure\",\n b.builtin(\n F::MkPairData,\n &[data, trace(\"unused field\", b.error(data.ty))],\n made.ty,\n ),\n data.ty,\n data.ty,\n true,\n ),\n (\n \"wrong_subject\",\n b.with_type(b.int(1), pair.ty),\n int,\n int,\n true,\n ),\n // Generic UPLC case accepts this, whereas fstPair would reject it.\n (\n \"native_constructor\",\n b.with_type(b.constr(0, &[b.int(7), b.int(8)], Ty::Erased), pair.ty),\n int,\n int,\n false,\n ),\n ] {\n for second in [false, true] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: left_ty,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: right_ty,\n };\n let selected = if second { y } else { x };\n let value = b.var(selected.name, selected.ty);\n let core = b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: value,\n }],\n None,\n value.ty,\n );\n cases.push((\n format!(\"{name}_{}\", if second { \"second\" } else { \"first\" }),\n core,\n fails,\n ));\n }\n }\n for mode in [\"body\", \"both\", \"neither\", \"delay\", \"lambda\", \"repeated\"] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: int,\n };\n let xv = b.var(x.name, x.ty);\n let body = match mode {\n \"both\" => b.builtin(F::AddInteger, &[xv, b.var(y.name, y.ty)], int),\n \"neither\" => b.int(42),\n \"delay\" => b.delay(xv),\n \"lambda\" => b.lam(\n &[Binder {\n name: b.fresh(\"unused\"),\n ty: int,\n }],\n xv,\n ),\n \"repeated\" => b.builtin(F::AddInteger, &[xv, xv], int),\n _ => trace(\"body\", b.builtin(F::AddInteger, &[xv, b.int(1)], int)),\n };\n let core = b.case(\n CaseKind::Pair,\n trace(\"subject\", pair),\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body,\n }],\n None,\n body.ty,\n );\n // Force/application is after the case, exposing any misplaced strict work.\n let core = match mode {\n \"delay\" => b.force(core, int),\n \"lambda\" => b.app(core, &[trace(\"argument\", b.int(0))], int),\n _ => core,\n };\n cases.push((mode.into(), core, false));\n }\n for second in [false, true] {\n let select = |subject| {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: int,\n };\n let selected = if second { y } else { x };\n b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: b.var(selected.name, int),\n }],\n None,\n int,\n )\n };\n let first = select(trace(\"first\", pair));\n let second_core = select(trace(\"second\", pair));\n cases.push((\n format!(\n \"two_projections_{}\",\n if second { \"second\" } else { \"first\" }\n ),\n b.builtin(F::AddInteger, &[first, second_core], int),\n false,\n ));\n }\n for delayed in [false, true] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: Ty::Const(a.alloc(ConstTy::List(data.ty))),\n };\n let value = b.var(x.name, x.ty);\n let body = if delayed {\n b.delay(value)\n } else {\n b.lam(\n &[Binder {\n name: b.fresh(\"arg\"),\n ty: int,\n }],\n value,\n )\n };\n let subject = b.builtin(\n F::UnConstrData,\n &[trace(\"before failure\", data)],\n unwrapped.ty,\n );\n let case = b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body,\n }],\n None,\n body.ty,\n );\n let ignored = Binder {\n name: b.fresh(\"ignored closure\"),\n ty: case.ty,\n };\n cases.push((\n format!(\n \"unconsumed_{}_failure\",\n if delayed { \"delay\" } else { \"lambda\" }\n ),\n b.let_(ignored, case, b.int(0)),\n true,\n ));\n }\n for bad_tag in [false, true] {\n for second in [false, true] {\n let tag = Binder {\n name: b.fresh(\"tag\"),\n ty: int,\n };\n let fields_ty = Ty::Const(a.alloc(ConstTy::List(data.ty)));\n let fields = Binder {\n name: b.fresh(\"fields\"),\n ty: fields_ty,\n };\n let encoded = Binder {\n name: b.fresh(\"encoded\"),\n ty: data.ty,\n };\n let decoded = Binder {\n name: b.fresh(\"decoded\"),\n ty: unwrapped.ty,\n };\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: fields_ty,\n };\n let selected = if second { y } else { x };\n let body = b.case(\n CaseKind::Pair,\n b.var(decoded.name, decoded.ty),\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: b.var(selected.name, selected.ty),\n }],\n None,\n selected.ty,\n );\n let body = b.let_(\n decoded,\n b.builtin(\n F::UnConstrData,\n &[b.var(encoded.name, encoded.ty)],\n decoded.ty,\n ),\n body,\n );\n let body = b.let_(\n encoded,\n b.builtin(\n F::ConstrData,\n &[b.var(tag.name, tag.ty), b.var(fields.name, fields.ty)],\n encoded.ty,\n ),\n body,\n );\n let body = b.let_(\n fields,\n b.builtin(\n F::MkCons,\n &[\n trace(\"field\", data),\n b.lit(C::proto_list(a, &Type::Data, &[])),\n ],\n fields_ty,\n ),\n body,\n );\n let tag_value = if bad_tag {\n let bytes = b.lit(C::data(a, D::byte_string(a, b\"bad\")));\n b.with_type(\n b.builtin(\n F::UnBData,\n &[trace(\"tag\", bytes)],\n b.lit(C::byte_string(a, b\"bad\")).ty,\n ),\n int,\n )\n } else {\n let tag_data = b.lit(C::data(a, D::integer_from(a, 0)));\n b.builtin(F::UnIData, &[trace(\"tag\", tag_data)], int)\n };\n let body = b.let_(tag, tag_value, body);\n cases.push((\n format!(\n \"roundtrip_{}_{}\",\n if bad_tag { \"bad_tag\" } else { \"valid\" },\n if second { \"second\" } else { \"first\" }\n ),\n body,\n bad_tag,\n ));\n }\n }\n cases\n}\n", + "RecursiveParameterInputs": "//! Recursive parameter fixtures shared with the explicit performance workspace.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, TermTy, Ty},\n};\nuse nash_plutus::{builtin::DefaultFunction as F, constant::Constant};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(&'static str, &'a Core<'a>, bool)> {\n let a = b.arena;\n let int = b.int(0).ty;\n let bool_ = Ty::Const(&ConstTy::Bool);\n let fun = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int, int]), int)));\n let bind = |text, ty| Binder {\n name: b.fresh(text),\n ty,\n };\n let trace = |text, value| b.trace(b.lit(Constant::string(a, text)), value);\n let mut cases = Vec::new();\n for (name, mutual, consumed, effects, failure) in [\n (\"self_forwarding\", false, false, false, false),\n (\"mutual_forwarding\", true, false, false, false),\n (\"mutual_consumed\", true, true, false, false),\n (\"recursive_trace_order\", true, false, true, false),\n (\"recursive_failure_order\", true, false, true, true),\n ] {\n let f = bind(\"f\", fun);\n let g = bind(\"g\", fun);\n let x = bind(\"x\", int);\n let n = bind(\"n\", int);\n let m = bind(\"m\", int);\n let y = bind(\"y\", int);\n let step = |target: Binder<'a>, unused: Binder<'a>, count: Binder<'a>, swapped: bool| {\n let next = b.builtin(F::SubtractInteger, &[b.var(count.name, int), b.int(1)], int);\n let discarded = if failure {\n trace(\"discarded\", b.error(int))\n } else if effects {\n trace(\"discarded\", b.int(7))\n } else {\n b.var(unused.name, int)\n };\n let next = if effects {\n trace(\"retained\", next)\n } else {\n next\n };\n let args = if swapped {\n [next, discarded]\n } else {\n [discarded, next]\n };\n b.if_(\n b.builtin(F::EqualsInteger, &[b.var(count.name, int), b.int(0)], bool_),\n if consumed {\n b.var(unused.name, int)\n } else {\n b.int(42)\n },\n b.app(b.var(target.name, fun), &args, int),\n )\n };\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x, n]),\n static_params: &[],\n body: step(if mutual { g } else { f }, x, n, mutual),\n }];\n if mutual {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[m, y]),\n static_params: &[],\n body: step(f, y, m, false),\n });\n }\n cases.push((\n name,\n b.let_rec(\n &group,\n b.app(b.var(f.name, fun), &[b.int(7), b.int(3)], int),\n ),\n failure,\n ));\n }\n // Removing every parameter must keep definitions cold and execute each call.\n for (name, mutual, cold) in [\n (\"all_unused_self\", false, false),\n (\"all_unused_mutual\", true, false),\n (\"all_unused_cold\", true, true),\n ] {\n let unary = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int]), int)));\n let f = bind(\"f\", unary);\n let g = bind(\"g\", unary);\n let x = bind(\"x\", int);\n let y = bind(\"y\", int);\n let invoke = |target: Binder<'a>, arg| b.app(b.var(target.name, unary), &[arg], int);\n let body = b.if_(\n b.lit(Constant::bool(a, true)),\n trace(\"body\", b.int(21)),\n invoke(if mutual { g } else { f }, b.var(x.name, int)),\n );\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x]),\n static_params: &[],\n body,\n }];\n if mutual {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[y]),\n static_params: &[],\n body: invoke(f, b.var(y.name, int)),\n });\n }\n let calls = b.builtin(\n F::AddInteger,\n &[\n invoke(f, trace(\"entry1\", b.int(0))),\n invoke(if mutual { g } else { f }, trace(\"entry2\", b.int(1))),\n ],\n int,\n );\n let calls = if cold {\n b.if_(b.lit(Constant::bool(a, true)), b.int(42), calls)\n } else {\n calls\n };\n cases.push((name, b.let_rec(&group, calls), false));\n }\n\n for name in [\n \"entry_failure\",\n \"partial\",\n \"escaping\",\n \"oversaturated\",\n \"compound_dependency\",\n \"mixed_delayed\",\n ] {\n let f = bind(\"f\", fun);\n let g = bind(\"g\", fun);\n let x = bind(\"x\", int);\n let n = bind(\"n\", int);\n let y = bind(\"y\", int);\n let m = bind(\"m\", int);\n let unary = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int]), int)));\n let next = b.builtin(F::SubtractInteger, &[b.var(n.name, int), b.int(1)], int);\n let forwarded = if name == \"compound_dependency\" {\n b.builtin(F::AddInteger, &[b.var(x.name, int), b.int(1)], int)\n } else {\n b.var(x.name, int)\n };\n let body = b.if_(\n b.builtin(F::EqualsInteger, &[b.var(n.name, int), b.int(0)], bool_),\n b.int(42),\n b.app(b.var(f.name, fun), &[forwarded, next], int),\n );\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x, n]),\n static_params: &[],\n body,\n }];\n let invoke = b.app(b.var(f.name, fun), &[b.int(7), b.int(2)], int);\n let entry = match name {\n \"entry_failure\" => b.app(\n b.var(f.name, fun),\n &[trace(\"first\", b.error(int)), trace(\"later\", b.int(2))],\n int,\n ),\n \"partial\" => b.app(\n b.app(b.var(f.name, fun), &[b.int(7)], unary),\n &[b.int(2)],\n int,\n ),\n \"escaping\" => {\n let alias = bind(\"alias\", fun);\n b.let_(\n alias,\n b.var(f.name, fun),\n b.app(b.var(alias.name, fun), &[b.int(7), b.int(2)], int),\n )\n }\n \"oversaturated\" => {\n let z = bind(\"z\", int);\n let ty = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int, int]), unary)));\n group[0].binder.ty = ty;\n group[0].body = b.lam(&[z], b.var(z.name, int));\n b.app(b.var(f.name, ty), &[b.int(0), b.int(0), b.int(42)], int)\n }\n \"mixed_delayed\" => {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[y, m]),\n static_params: &[],\n body: trace(\n \"delayed\",\n b.app(b.var(f.name, fun), &[b.int(7), b.int(2)], int),\n ),\n });\n b.builtin(\n F::AddInteger,\n &[\n invoke,\n b.app(b.var(g.name, fun), &[b.int(0), b.int(0)], int),\n ],\n int,\n )\n }\n _ => invoke,\n };\n cases.push((name, b.let_rec(&group, entry), name == \"entry_failure\"));\n }\n cases\n}\n", "Vesting": "validator module Vesting exposing (main)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\nimport Cardano.Tx exposing (validAfter, signedBy)\n\ntype Datum = Datum { owner : Bytes, deadline : Int }\n\ntype step 'a = Done 'a | Next int 'a\n\ntype alias acc = { total : int, seen : list Int }\n\ntype Redeemer = Claim | Cancel\n\n-- The ledger supplies one V3 ScriptContext; spending datum is in ScriptInfo.\nmain : Data -> unit\nmain ctx =\n case ctx of\n Constr pair(0, [ tx, action, Constr pair(1, [ _, Constr pair(0, [ datum ]) ]) ]) ->\n check (Primitive.coerce datum) (Primitive.coerce action) tx\n _ -> fail\n\ncheck : Datum -> Redeemer -> Data -> unit\ncheck datum redeemer tx =\n case redeemer of\n Claim -> assert (Builtin.lessThanInteger (lower datum.deadline) (validAfter tx))\n Cancel -> assert (signedBy tx datum.owner)\n", "VestingContextInput": "//! Shared ledger input for the vesting snapshots, artifact tests and explicit perf runner.\nuse nash_plutus::{arena::Arena, data::PlutusData};\n\npub fn context<'a>(\n arena: &'a Arena,\n datum: &'a PlutusData<'a>,\n redeemer: &'a PlutusData<'a>,\n lower_time: i128,\n signer: &'a [u8],\n) -> &'a PlutusData<'a> {\n let constr = |tag, fields: &[&'a PlutusData<'a>]| {\n PlutusData::constr(arena, tag, arena.alloc_slice_copy(fields))\n };\n let empty_list = PlutusData::list(arena, &[]);\n let empty_map = PlutusData::map(arena, &[]);\n let zero = PlutusData::integer_from(arena, 0);\n let tx_id = PlutusData::byte_string(arena, &[0; 32]);\n let closed = constr(1, &[]);\n let lower = constr(\n 0,\n &[\n constr(1, &[PlutusData::integer_from(arena, lower_time)]),\n closed,\n ],\n );\n let upper = constr(0, &[constr(2, &[]), closed]);\n let signers = if signer.is_empty() {\n empty_list\n } else {\n // The owner is deliberately second: signedBy must search the whole list.\n PlutusData::list(\n arena,\n arena.alloc_slice_copy(&[\n PlutusData::byte_string(arena, &[0xbb]),\n PlutusData::byte_string(arena, signer),\n ]),\n )\n };\n let tx = constr(\n 0,\n &[\n empty_list, // inputs\n empty_list, // reference inputs\n empty_list, // outputs\n zero, // fee\n empty_map, // mint\n empty_list, // certificates\n empty_map, // withdrawals\n constr(0, &[lower, upper]), // validity range\n signers,\n empty_map, // redeemers\n empty_map, // datums\n tx_id,\n empty_map, // votes\n empty_list, // proposals\n constr(1, &[]), // current treasury\n constr(1, &[]), // treasury donation\n ],\n );\n let reference = constr(0, &[tx_id, zero]);\n let spending = constr(1, &[reference, constr(0, &[datum])]);\n constr(0, &[tx, redeemer, spending])\n}\n", "VestingParam": "validator module VestingParam exposing (main)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\nimport Cardano.Tx exposing (validAfter, signedBy)\n\ntype Datum = Datum { owner : Bytes, deadline : Int }\n\ntype Redeemer = Claim | Cancel\n\n-- The ledger supplies one V3 ScriptContext; spending datum is in ScriptInfo.\nmain : int -> Data -> unit\nmain minimumLock ctx =\n case ctx of\n Constr pair(0, [ tx, action, Constr pair(1, [ _, Constr pair(0, [ datum ]) ]) ]) ->\n check minimumLock (Primitive.coerce datum) (Primitive.coerce action) tx\n _ -> fail\n\ncheck : int -> Datum -> Redeemer -> Data -> unit\ncheck minimumLock datum redeemer tx =\n case redeemer of\n Claim ->\n assert\n (Builtin.lessThanInteger\n (Builtin.addInteger (lower datum.deadline) minimumLock)\n (validAfter tx))\n Cancel -> assert (signedBy tx datum.owner)\n", - "Workloads": "module Workloads exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Logic exposing (..)\n\nsum : list int -> int\nsum xs =\n case xs of\n [] -> 0\n x :: rest -> Builtin.addInteger x (sum rest)\n\nlistTraversal : int\nlistTraversal = sum [1, 2, 3, 4, 5, 6, 7, 8]\n\ncountdown : int -> int -> int\ncountdown n result =\n if Builtin.equalsInteger n 0 then\n result\n else\n countdown (Builtin.subtractInteger n 1) result\n\nstaticRecursion : int\nstaticRecursion = countdown 8 42\n\nmatchData : Data -> int\nmatchData value =\n case value of\n I n -> n\n _ -> 0\n\ndataMatch : int\ndataMatch = matchData (I 42)\n\ndataMiss : int\ndataMiss = matchData (B #\"ab\")\n\ndecode : Data -> int\ndecode value =\n case value of\n Constr pair(_, [I n, _]) -> n\n _ -> 0\n\ndecoding : int\ndecoding = decode (Builtin.constrData 0 [I 42, I 7])\n\nvalidate : Data -> unit\nvalidate value =\n case value of\n I n -> assert (Builtin.lessThanInteger 0 n)\n _ -> fail\n\nvalidationPass : unit\nvalidationPass = validate (I 42)\n\nvalidationFail : unit\nvalidationFail = validate (I 0)\n\nbooleanHelpers : bool\nbooleanHelpers = (True && False) || (True && True)\n\nconstantPrefixTwice : int\nconstantPrefixTwice =\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nconstantPrefixCold : int\nconstantPrefixCold =\n if True then\n 42\n else\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nprefixLoop : int -> int\nprefixLoop n =\n if Builtin.equalsInteger n 0 then\n 0\n else\n Builtin.addInteger\n (Builtin.addInteger (Builtin.subtractInteger 100 n) (Builtin.subtractInteger 100 n))\n (prefixLoop (Builtin.subtractInteger n 1))\n\nconstantPrefixLoop : int\nconstantPrefixLoop = prefixLoop 8\n" + "Workloads": "module Workloads exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Logic exposing (..)\n\nsum : list int -> int\nsum xs =\n case xs of\n [] -> 0\n x :: rest -> Builtin.addInteger x (sum rest)\n\nlistTraversal : int\nlistTraversal = sum [1, 2, 3, 4, 5, 6, 7, 8]\n\ncountdown : int -> int -> int\ncountdown n result =\n if Builtin.equalsInteger n 0 then\n result\n else\n countdown (Builtin.subtractInteger n 1) result\n\nstaticRecursion : int\nstaticRecursion = countdown 8 42\n\nmatchData : Data -> int\nmatchData value =\n case value of\n I n -> n\n _ -> 0\n\ndataMatch : int\ndataMatch = matchData (I 42)\n\ndataMiss : int\ndataMiss = matchData (B #\"ab\")\n\ndecode : Data -> int\ndecode value =\n case value of\n Constr pair(_, [I n, _]) -> n\n _ -> 0\n\ndecoding : int\ndecoding = decode (Builtin.constrData 0 [I 42, I 7])\n\nvalidate : Data -> unit\nvalidate value =\n case value of\n I n -> assert (Builtin.lessThanInteger 0 n)\n _ -> fail\n\nvalidationPass : unit\nvalidationPass = validate (I 42)\n\nvalidationFail : unit\nvalidationFail = validate (I 0)\n\nbooleanHelpers : bool\nbooleanHelpers = (True && False) || (True && True)\n\nconstantPrefixTwice : int\nconstantPrefixTwice =\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nconstantPrefixCold : int\nconstantPrefixCold =\n if True then\n 42\n else\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nprefixLoop : int -> int\nprefixLoop n =\n if Builtin.equalsInteger n 0 then\n 0\n else\n Builtin.addInteger\n (Builtin.addInteger (Builtin.subtractInteger 100 n) (Builtin.subtractInteger 100 n))\n (prefixLoop (Builtin.subtractInteger n 1))\n\nconstantPrefixLoop : int\nconstantPrefixLoop = prefixLoop 8\n\nunusedSelf : int -> int -> int\nunusedSelf unused n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n unusedSelf unused (Builtin.subtractInteger n 1)\n\nrecursiveUnusedSelf : int\nrecursiveUnusedSelf = unusedSelf (Builtin.trace \"entry\" 7) 3\n\nunusedFirst : int -> int -> int\nunusedFirst unused n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n unusedSecond (Builtin.subtractInteger n 1) unused\n\nunusedSecond : int -> int -> int\nunusedSecond n unused = unusedFirst unused n\n\nrecursiveUnusedMutual : int\nrecursiveUnusedMutual = unusedFirst (Builtin.trace \"entry\" 7) 3\n\nhiddenStatic : int -> int -> int\nhiddenStatic x n =\n if Builtin.equalsInteger n 0 then\n x\n else\n let\n next = Builtin.subtractInteger n 1\n in\n hiddenStatic (if True then x else 0) next\n\ncleanupExposesStatic : int\ncleanupExposesStatic = hiddenStatic 42 3\n\npackingChoose : int -> int -> int -> int\npackingChoose n =\n if Builtin.equalsInteger n 0 then\n \\x y -> Builtin.addInteger x y\n else\n packingChoose (Builtin.subtractInteger n 1)\n\nstagedApplication : int\nstagedApplication =\n let\n p = packingChoose 3 20\n in\n p 22\n\npackingTraced : int -> int -> int -> int\npackingTraced n =\n if Builtin.equalsInteger n 0 then\n \\x -> trace \"first\" (\\y -> trace \"second\" (Builtin.addInteger x y))\n else\n packingTraced (Builtin.subtractInteger n 1)\n\nstagedApplicationTraces : int\nstagedApplicationTraces =\n let\n p = packingTraced 3 20\n in\n p 22\n\nstagedArgumentTrace : int\nstagedArgumentTrace =\n let\n p = packingTraced 3 20\n in\n p (trace \"argument\" 22)\n\npackingFailure : int -> int -> int -> int\npackingFailure n =\n if Builtin.equalsInteger n 0 then\n \\x -> trace \"first\" fail\n else\n packingFailure (Builtin.subtractInteger n 1)\n\nstagedApplicationFailure : int\nstagedApplicationFailure =\n let\n p = packingFailure 3 20\n in\n p (trace \"must not run\" 22)\n" }, - "revision": "a20f787e814b319691b3b10476b693cb8d142e3f", + "revision": "a0b88ebebc67fd04e5a062d74640a211d74d200b", "rustc": "rustc 1.98.1 (48a229cea 2026-09-01)", "rows": [ { @@ -25,9 +28,9 @@ "logs": [] }, "after": { - "cpu": 4764660, - "memory": 21472, - "bytes": 93, + "cpu": 3225764, + "memory": 15216, + "bytes": 41, "result": "(con integer 36)", "logs": [] } @@ -49,6 +52,23 @@ "logs": [] } }, + { + "input": "Workloads.cleanupExposesStatic (fixtures/Workloads.nash)", + "before": { + "cpu": 2737056, + "memory": 14010, + "bytes": 66, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1921056, + "memory": 8910, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, { "input": "Workloads.dataMatch (fixtures/Workloads.nash)", "before": { @@ -59,9 +79,9 @@ "logs": [] }, "after": { - "cpu": 111399, - "memory": 732, - "bytes": 11, + "cpu": 16100, + "memory": 200, + "bytes": 6, "result": "(con integer 42)", "logs": [] } @@ -76,9 +96,9 @@ "logs": [] }, "after": { - "cpu": 107283, - "memory": 732, - "bytes": 14, + "cpu": 16100, + "memory": 200, + "bytes": 6, "result": "(con integer 0)", "logs": [] } @@ -93,9 +113,9 @@ "logs": [] }, "after": { - "cpu": 1681280, - "memory": 8756, - "bytes": 94, + "cpu": 16100, + "memory": 200, + "bytes": 6, "result": "(con integer 42)", "logs": [] } @@ -110,9 +130,9 @@ "logs": [] }, "after": { - "cpu": 364689, - "memory": 2033, - "bytes": 47, + "cpu": 16100, + "memory": 200, + "bytes": 5, "result": "(con unit ())", "logs": [] } @@ -129,9 +149,9 @@ ] }, "after": { - "cpu": 120187, - "memory": 165, - "bytes": 47, + "cpu": 59598, + "memory": 132, + "bytes": 30, "result": "error: ExplicitErrorTerm", "logs": [ "assertion failed" @@ -165,9 +185,9 @@ "logs": [] }, "after": { - "cpu": 623724, - "memory": 2106, - "bytes": 26, + "cpu": 16100, + "memory": 200, + "bytes": 7, "result": "(con integer 197)", "logs": [] } @@ -206,6 +226,134 @@ "logs": [] } }, + { + "input": "Workloads.recursiveUnusedSelf (fixtures/Workloads.nash)", + "before": { + "cpu": 2540554, + "memory": 12442, + "bytes": 75, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + }, + "after": { + "cpu": 2156554, + "memory": 10042, + "bytes": 56, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + } + }, + { + "input": "Workloads.recursiveUnusedMutual (fixtures/Workloads.nash)", + "before": { + "cpu": 3436554, + "memory": 18042, + "bytes": 104, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + }, + "after": { + "cpu": 2732554, + "memory": 13642, + "bytes": 67, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + } + }, + { + "input": "Workloads.stagedApplication (fixtures/Workloads.nash)", + "before": { + "cpu": 2470264, + "memory": 11712, + "bytes": 61, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 2166264, + "memory": 9812, + "bytes": 50, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.stagedApplicationTraces (fixtures/Workloads.nash)", + "before": { + "cpu": 3053260, + "memory": 14676, + "bytes": 100, + "result": "(con integer 42)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 2541260, + "memory": 11476, + "bytes": 79, + "result": "(con integer 42)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "Workloads.stagedArgumentTrace (fixtures/Workloads.nash)", + "before": { + "cpu": 3320758, + "memory": 16008, + "bytes": 121, + "result": "(con integer 42)", + "logs": [ + "first", + "argument", + "second" + ] + }, + "after": { + "cpu": 2856758, + "memory": 13108, + "bytes": 100, + "result": "(con integer 42)", + "logs": [ + "first", + "argument", + "second" + ] + } + }, + { + "input": "Workloads.stagedApplicationFailure (fixtures/Workloads.nash)", + "before": { + "cpu": 572554, + "memory": 142, + "bytes": 101, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + }, + "after": { + "cpu": 572554, + "memory": 142, + "bytes": 85, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + } + }, { "input": "Vesting: claim after deadline; deadline=10, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", "before": { @@ -216,9 +364,9 @@ "logs": [] }, "after": { - "cpu": 9093501, - "memory": 48616, - "bytes": 821, + "cpu": 8581501, + "memory": 45416, + "bytes": 822, "result": "(con unit ())", "logs": [] } @@ -237,7 +385,7 @@ "after": { "cpu": 7888999, "memory": 40748, - "bytes": 821, + "bytes": 822, "result": "error: ExplicitErrorTerm", "logs": [ "assertion failed" @@ -254,9 +402,9 @@ "logs": [] }, "after": { - "cpu": 7915016, - "memory": 42850, - "bytes": 821, + "cpu": 7467016, + "memory": 40050, + "bytes": 822, "result": "(con unit ())", "logs": [] } @@ -275,7 +423,7 @@ "after": { "cpu": 4134408, "memory": 20552, - "bytes": 821, + "bytes": 822, "result": "error: ExplicitErrorTerm", "logs": [ "assertion failed" @@ -292,9 +440,9 @@ "logs": [] }, "after": { - "cpu": 9093501, - "memory": 48616, - "bytes": 821, + "cpu": 8581501, + "memory": 45416, + "bytes": 822, "result": "(con unit ())", "logs": [] } @@ -309,9 +457,9 @@ "logs": [] }, "after": { - "cpu": 9093501, - "memory": 48616, - "bytes": 821, + "cpu": 8581501, + "memory": 45416, + "bytes": 822, "result": "(con unit ())", "logs": [] } @@ -326,9 +474,9 @@ "logs": [] }, "after": { - "cpu": 9354709, - "memory": 49618, - "bytes": 827, + "cpu": 8842709, + "memory": 46418, + "bytes": 829, "result": "(con unit ())", "logs": [] } @@ -347,7 +495,7 @@ "after": { "cpu": 7990207, "memory": 40750, - "bytes": 827, + "bytes": 829, "result": "error: ExplicitErrorTerm", "logs": [ "assertion failed" @@ -364,9 +512,9 @@ "logs": [] }, "after": { - "cpu": 7963016, - "memory": 43150, - "bytes": 827, + "cpu": 7515016, + "memory": 40350, + "bytes": 829, "result": "(con unit ())", "logs": [] } @@ -385,7 +533,7 @@ "after": { "cpu": 4134408, "memory": 20552, - "bytes": 827, + "bytes": 829, "result": "error: ExplicitErrorTerm", "logs": [ "assertion failed" @@ -402,9 +550,9 @@ "logs": [] }, "after": { - "cpu": 9354709, - "memory": 49618, - "bytes": 827, + "cpu": 8842709, + "memory": 46418, + "bytes": 829, "result": "(con unit ())", "logs": [] } @@ -423,7 +571,7 @@ "after": { "cpu": 7990207, "memory": 40750, - "bytes": 827, + "bytes": 829, "result": "error: ExplicitErrorTerm", "logs": [ "assertion failed" @@ -459,9 +607,9 @@ ] }, "after": { - "cpu": 235598, - "memory": 1232, - "bytes": 23, + "cpu": 378897, + "memory": 2064, + "bytes": 30, "result": "(con integer 7)", "logs": [ "operand" @@ -478,9 +626,9 @@ "logs": [] }, "after": { - "cpu": 68844, - "memory": 432, - "bytes": 11, + "cpu": 16100, + "memory": 200, + "bytes": 6, "result": "(con integer 7)", "logs": [] } @@ -497,7 +645,7 @@ "after": { "cpu": 100, "memory": 100, - "bytes": 8, + "bytes": 15, "result": "error: Runtime(NotData(Integer(0)))", "logs": [] } @@ -700,9 +848,9 @@ "logs": [] }, "after": { - "cpu": 164143, - "memory": 964, - "bytes": 12, + "cpu": 68844, + "memory": 432, + "bytes": 11, "result": "(con integer 7)", "logs": [] } @@ -736,9 +884,9 @@ ] }, "after": { - "cpu": 235598, - "memory": 1232, - "bytes": 29, + "cpu": 374781, + "memory": 2064, + "bytes": 36, "result": "(con bytestring #68656c6c6f)", "logs": [ "operand" @@ -755,9 +903,9 @@ "logs": [] }, "after": { - "cpu": 68242, - "memory": 432, - "bytes": 16, + "cpu": 16100, + "memory": 200, + "bytes": 13, "result": "(con bytestring #68656c6c6f)", "logs": [] } @@ -774,7 +922,7 @@ "after": { "cpu": 100, "memory": 100, - "bytes": 8, + "bytes": 15, "result": "error: Runtime(NotData(Integer(0)))", "logs": [] } @@ -977,9 +1125,9 @@ "logs": [] }, "after": { - "cpu": 159425, - "memory": 964, - "bytes": 19, + "cpu": 68242, + "memory": 432, + "bytes": 16, "result": "(con bytestring #68656c6c6f)", "logs": [] } @@ -1013,9 +1161,9 @@ ] }, "after": { - "cpu": 235598, - "memory": 1232, - "bytes": 28, + "cpu": 397450, + "memory": 2064, + "bytes": 35, "result": "(con (list data) [(I 7)])", "logs": [ "operand" @@ -1032,9 +1180,9 @@ "logs": [] }, "after": { - "cpu": 74033, - "memory": 432, - "bytes": 13, + "cpu": 16100, + "memory": 200, + "bytes": 10, "result": "(con (list data) [(I 7)])", "logs": [] } @@ -1051,7 +1199,7 @@ "after": { "cpu": 100, "memory": 100, - "bytes": 8, + "bytes": 15, "result": "error: Runtime(NotData(Integer(0)))", "logs": [] } @@ -1254,9 +1402,9 @@ "logs": [] }, "after": { - "cpu": 187885, - "memory": 964, - "bytes": 16, + "cpu": 74033, + "memory": 432, + "bytes": 13, "result": "(con (list data) [(I 7)])", "logs": [] } @@ -1290,9 +1438,9 @@ ] }, "after": { - "cpu": 235598, - "memory": 1232, - "bytes": 34, + "cpu": 431844, + "memory": 2064, + "bytes": 41, "result": "(con (list (pair data data)) [((I 7), (I 7))])", "logs": [ "operand" @@ -1309,9 +1457,9 @@ "logs": [] }, "after": { - "cpu": 72723, - "memory": 432, - "bytes": 13, + "cpu": 16100, + "memory": 200, + "bytes": 17, "result": "(con (list (pair data data)) [((I 7), (I 7))])", "logs": [] } @@ -1328,7 +1476,7 @@ "after": { "cpu": 100, "memory": 100, - "bytes": 8, + "bytes": 15, "result": "error: Runtime(NotData(Integer(0)))", "logs": [] } @@ -1531,9 +1679,9 @@ "logs": [] }, "after": { - "cpu": 220969, - "memory": 964, - "bytes": 23, + "cpu": 72723, + "memory": 432, + "bytes": 13, "result": "(con (list (pair data data)) [((I 7), (I 7))])", "logs": [] } @@ -1544,14 +1692,14 @@ "cpu": 215979, "memory": 612, "bytes": 18, - "result": "(con string \"héllo\")", + "result": "(con string \"h\u00e9llo\")", "logs": [] }, "after": { "cpu": 16100, "memory": 200, "bytes": 14, - "result": "(con string \"héllo\")", + "result": "(con string \"h\u00e9llo\")", "logs": [] } }, @@ -1561,16 +1709,16 @@ "cpu": 387477, "memory": 1344, "bytes": 32, - "result": "(con string \"héllo\")", + "result": "(con string \"h\u00e9llo\")", "logs": [ "operand" ] }, "after": { - "cpu": 235598, - "memory": 1232, - "bytes": 30, - "result": "(con string \"héllo\")", + "cpu": 407519, + "memory": 2038, + "bytes": 37, + "result": "(con string \"h\u00e9llo\")", "logs": [ "operand" ] @@ -1582,14 +1730,14 @@ "cpu": 339937, "memory": 818, "bytes": 19, - "result": "(con string \"héllo\")", + "result": "(con string \"h\u00e9llo\")", "logs": [] }, "after": { - "cpu": 140058, - "memory": 406, - "bytes": 16, - "result": "(con string \"héllo\")", + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"h\u00e9llo\")", "logs": [] } }, @@ -1605,7 +1753,7 @@ "after": { "cpu": 100, "memory": 100, - "bytes": 8, + "bytes": 15, "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", "logs": [] } @@ -1650,14 +1798,14 @@ "cpu": 48100, "memory": 400, "bytes": 41, - "result": "(con string \"héllo\")", + "result": "(con string \"h\u00e9llo\")", "logs": [] }, "after": { "cpu": 16100, "memory": 200, "bytes": 14, - "result": "(con string \"héllo\")", + "result": "(con string \"h\u00e9llo\")", "logs": [] } }, @@ -1667,7 +1815,7 @@ "cpu": 702975, "memory": 2976, "bytes": 58, - "result": "(con string \"héllo\")", + "result": "(con string \"h\u00e9llo\")", "logs": [ "once", "after encoding" @@ -1677,7 +1825,7 @@ "cpu": 563017, "memory": 2670, "bytes": 55, - "result": "(con string \"héllo\")", + "result": "(con string \"h\u00e9llo\")", "logs": [ "once", "after encoding" @@ -1690,7 +1838,7 @@ "cpu": 563477, "memory": 2444, "bytes": 37, - "result": "(con string \"héllo\")", + "result": "(con string \"h\u00e9llo\")", "logs": [ "once" ] @@ -1699,7 +1847,7 @@ "cpu": 407519, "memory": 2038, "bytes": 34, - "result": "(con string \"héllo\")", + "result": "(con string \"h\u00e9llo\")", "logs": [ "once" ] @@ -1711,7 +1859,7 @@ "cpu": 703435, "memory": 2750, "bytes": 43, - "result": "(constr 0\n (con bytestring #68c3a96c6c6f)\n (con string \"héllo\")\n (con string \"héllo\"))", + "result": "(constr 0\n (con bytestring #68c3a96c6c6f)\n (con string \"h\u00e9llo\")\n (con string \"h\u00e9llo\"))", "logs": [ "once" ] @@ -1720,7 +1868,7 @@ "cpu": 455519, "memory": 2338, "bytes": 39, - "result": "(constr 0\n (con bytestring #68c3a96c6c6f)\n (con string \"héllo\")\n (con string \"héllo\"))", + "result": "(constr 0\n (con bytestring #68c3a96c6c6f)\n (con string \"h\u00e9llo\")\n (con string \"h\u00e9llo\"))", "logs": [ "once" ] @@ -1770,14 +1918,14 @@ "cpu": 135979, "memory": 112, "bytes": 20, - "result": "error: NonFunctionApplication(Con(Integer(1)), Con(String(\"héllo\")))", + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(String(\"h\u00e9llo\")))", "logs": [] }, "after": { "cpu": 100, "memory": 100, "bytes": 16, - "result": "error: NonFunctionApplication(Con(Integer(1)), Con(String(\"héllo\")))", + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(String(\"h\u00e9llo\")))", "logs": [] } }, @@ -1804,14 +1952,14 @@ "cpu": 215979, "memory": 612, "bytes": 18, - "result": "(con string \"héllo\")", + "result": "(con string \"h\u00e9llo\")", "logs": [] }, "after": { - "cpu": 263979, - "memory": 912, - "bytes": 20, - "result": "(con string \"héllo\")", + "cpu": 140058, + "memory": 406, + "bytes": 16, + "result": "(con string \"h\u00e9llo\")", "logs": [] } }, @@ -1876,9 +2024,9 @@ "logs": [] }, "after": { - "cpu": 254839, - "memory": 1464, - "bytes": 22, + "cpu": 16100, + "memory": 200, + "bytes": 6, "result": "(con integer 0)", "logs": [] } @@ -1893,9 +2041,9 @@ "logs": [] }, "after": { - "cpu": 302839, - "memory": 1764, - "bytes": 24, + "cpu": 16100, + "memory": 200, + "bytes": 10, "result": "(con (list data) [(I 7)])", "logs": [] } @@ -1910,9 +2058,9 @@ "logs": [] }, "after": { - "cpu": 404990, - "memory": 2296, - "bytes": 29, + "cpu": 16100, + "memory": 200, + "bytes": 13, "result": "(con data (Constr 0 [I 7]))", "logs": [] } @@ -1929,9 +2077,9 @@ ] }, "after": { - "cpu": 388186, - "memory": 2064, - "bytes": 43, + "cpu": 235598, + "memory": 1232, + "bytes": 36, "result": "(con data (Constr 3 [I 7]))", "logs": [ "after decoding" @@ -1950,7 +2098,7 @@ "after": { "cpu": 100, "memory": 100, - "bytes": 39, + "bytes": 55, "result": "error: Runtime(MalFormedData(Integer(7)))", "logs": [] } @@ -1969,7 +2117,7 @@ "after": { "cpu": 59598, "memory": 132, - "bytes": 48, + "bytes": 52, "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", "logs": [ "fields evaluated" @@ -1988,10 +2136,1590 @@ "after": { "cpu": 100, "memory": 100, - "bytes": 15, + "bytes": 19, "result": "error: Runtime(ExpectedList(Boolean(false)))", "logs": [] } + }, + { + "input": "constant folding: shared_prefix_distinct_results", + "before": { + "cpu": 1305326, + "memory": 1526, + "bytes": 64, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + }, + "after": { + "cpu": 48100, + "memory": 400, + "bytes": 87, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + } + }, + { + "input": "constant folding: repeated_literal_distinct_results", + "before": { + "cpu": 1257326, + "memory": 1226, + "bytes": 100, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + }, + "after": { + "cpu": 48100, + "memory": 400, + "bytes": 87, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + } + }, + { + "input": "constant folding: expanding_data_list", + "before": { + "cpu": 74033, + "memory": 432, + "bytes": 42, + "result": "(con (list data) [(I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 126, + "result": "(con (list data) [(I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7)])", + "logs": [] + } + }, + { + "input": "constant folding: addition", + "before": { + "cpu": 181308, + "memory": 602, + "bytes": 10, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "constant folding: nested_arithmetic", + "before": { + "cpu": 336261, + "memory": 1004, + "bytes": 15, + "result": "(con integer 84)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con integer 84)", + "logs": [] + } + }, + { + "input": "constant folding: bound_arithmetic", + "before": { + "cpu": 384261, + "memory": 1304, + "bytes": 18, + "result": "(con integer 84)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con integer 84)", + "logs": [] + } + }, + { + "input": "constant folding: division", + "before": { + "cpu": 212030, + "memory": 601, + "bytes": 10, + "result": "(con integer -3)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer -3)", + "logs": [] + } + }, + { + "input": "constant folding: division_zero", + "before": { + "cpu": 132030, + "memory": 101, + "bytes": 10, + "result": "error: Runtime(DivisionByZero(7, 0))", + "logs": [] + }, + "after": { + "cpu": 132030, + "memory": 101, + "bytes": 10, + "result": "error: Runtime(DivisionByZero(7, 0))", + "logs": [] + } + }, + { + "input": "constant folding: wrong_integer_shape", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([120])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([120])))", + "logs": [] + } + }, + { + "input": "constant folding: byte_append", + "before": { + "cpu": 81446, + "memory": 602, + "bytes": 18, + "result": "(con bytestring #61626364)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 12, + "result": "(con bytestring #61626364)", + "logs": [] + } + }, + { + "input": "constant folding: byte_slice", + "before": { + "cpu": 132568, + "memory": 804, + "bytes": 19, + "result": "(con bytestring #6263)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con bytestring #6263)", + "logs": [] + } + }, + { + "input": "constant folding: byte_length", + "before": { + "cpu": 70200, + "memory": 410, + "bytes": 14, + "result": "(con integer 4)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 4)", + "logs": [] + } + }, + { + "input": "constant folding: byte_compare", + "before": { + "cpu": 109173, + "memory": 601, + "bytes": 20, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: string_append", + "before": { + "cpu": 201014, + "memory": 606, + "bytes": 25, + "result": "(con string \"hello world\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 19, + "result": "(con string \"hello world\")", + "logs": [] + } + }, + { + "input": "constant folding: encode_utf8", + "before": { + "cpu": 220784, + "memory": 412, + "bytes": 28, + "result": "(con bytestring #e0b8aae0b8a7e0b8b1e0b8aae0b894e0b8b5)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 26, + "result": "(con bytestring #e0b8aae0b8a7e0b8b1e0b8aae0b894e0b8b5)", + "logs": [] + } + }, + { + "input": "constant folding: decode_utf8", + "before": { + "cpu": 140058, + "memory": 406, + "bytes": 16, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + } + }, + { + "input": "constant folding: invalid_utf8", + "before": { + "cpu": 92058, + "memory": 106, + "bytes": 11, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + }, + "after": { + "cpu": 92058, + "memory": 106, + "bytes": 11, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + } + }, + { + "input": "constant folding: integer_data", + "before": { + "cpu": 63399, + "memory": 432, + "bytes": 8, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "constant folding: decode_integer_data", + "before": { + "cpu": 68844, + "memory": 432, + "bytes": 11, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: wrong_data_variant", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "constant folding: list_data", + "before": { + "cpu": 81952, + "memory": 432, + "bytes": 12, + "result": "(con data (List [I 7]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (List [I 7]))", + "logs": [] + } + }, + { + "input": "constant folding: map_data", + "before": { + "cpu": 116346, + "memory": 432, + "bytes": 11, + "result": "(con data (Map []))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con data (Map []))", + "logs": [] + } + }, + { + "input": "constant folding: data_equal", + "before": { + "cpu": 1114643, + "memory": 601, + "bytes": 16, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: serialise_data", + "before": { + "cpu": 2070166, + "memory": 410, + "bytes": 11, + "result": "(con bytestring #07)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con bytestring #07)", + "logs": [] + } + }, + { + "input": "constant folding: list_head", + "before": { + "cpu": 147250, + "memory": 532, + "bytes": 11, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: list_tail", + "before": { + "cpu": 145763, + "memory": 532, + "bytes": 11, + "result": "(con (list integer) [8])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con (list integer) [8])", + "logs": [] + } + }, + { + "input": "constant folding: empty_head", + "before": { + "cpu": 83250, + "memory": 132, + "bytes": 9, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + }, + "after": { + "cpu": 83250, + "memory": 132, + "bytes": 11, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + } + }, + { + "input": "constant folding: empty_tail", + "before": { + "cpu": 81763, + "memory": 132, + "bytes": 9, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + }, + "after": { + "cpu": 81763, + "memory": 132, + "bytes": 11, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + } + }, + { + "input": "constant folding: list_null", + "before": { + "cpu": 138533, + "memory": 532, + "bytes": 9, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: pair_first", + "before": { + "cpu": 221995, + "memory": 632, + "bytes": 15, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: pair_second", + "before": { + "cpu": 222092, + "memory": 632, + "bytes": 15, + "result": "(con bytestring #61)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con bytestring #61)", + "logs": [] + } + }, + { + "input": "constant folding: trace_before", + "before": { + "cpu": 352806, + "memory": 1334, + "bytes": 24, + "result": "(con integer 42)", + "logs": [ + "before" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 22, + "result": "(con integer 42)", + "logs": [ + "before" + ] + } + }, + { + "input": "constant folding: trace_builtin", + "before": { + "cpu": 155598, + "memory": 732, + "bytes": 20, + "result": "(con integer 7)", + "logs": [ + "keep me" + ] + }, + "after": { + "cpu": 203598, + "memory": 1032, + "bytes": 22, + "result": "(con integer 7)", + "logs": [ + "keep me" + ] + } + }, + { + "input": "constant folding: cold_failure", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 15, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: selected_branch", + "before": { + "cpu": 501139, + "memory": 1935, + "bytes": 39, + "result": "(con integer 42)", + "logs": [ + "yes" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 19, + "result": "(con integer 42)", + "logs": [ + "yes" + ] + } + }, + { + "input": "constant folding: strict_failure_order", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 26, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 33, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + } + }, + { + "input": "constant folding: unsupported_hash", + "before": { + "cpu": 341340, + "memory": 404, + "bytes": 11, + "result": "(con bytestring #2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 40, + "result": "(con bytestring #2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881)", + "logs": [] + } + }, + { + "input": "constant folding: partial", + "before": { + "cpu": 181308, + "memory": 602, + "bytes": 10, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 229308, + "memory": 902, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "constant folding: large_input", + "before": { + "cpu": 169849, + "memory": 1113, + "bytes": 4127,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a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a7a)", + "logs": [] + } + }, + { + "input": "constant folding: repeated_call", + "before": { + "cpu": 559724, + "memory": 1706, + "bytes": 26, + "result": "(constr 0 (con integer 42) (con integer 42) (con integer 42))", + "logs": [] + }, + "after": { + "cpu": 64100, + "memory": 500, + "bytes": 12, + "result": "(constr 0 (con integer 42) (con integer 42) (con integer 42))", + "logs": [] + } + }, + { + "input": "pair projection: literal_first", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair projection: literal_second", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair projection: traced_first", + "before": { + "cpu": 251598, + "memory": 1332, + "bytes": 28, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: traced_second", + "before": { + "cpu": 251598, + "memory": 1332, + "bytes": 28, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: made_data_first", + "before": { + "cpu": 155646, + "memory": 1032, + "bytes": 19, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 18, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair projection: made_data_second", + "before": { + "cpu": 155646, + "memory": 1032, + "bytes": 19, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 18, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair projection: decoded_first", + "before": { + "cpu": 136688, + "memory": 832, + "bytes": 15, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "pair projection: decoded_second", + "before": { + "cpu": 136688, + "memory": 832, + "bytes": 15, + "result": "(con (list data) [])", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con (list data) [])", + "logs": [] + } + }, + { + "input": "pair projection: bad_decoder_first", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair projection: bad_decoder_second", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair projection: ignored_failure_first", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 34, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair projection: ignored_failure_second", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 34, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair projection: wrong_subject_first", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair projection: wrong_subject_second", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair projection: native_constructor_first", + "before": { + "cpu": 112100, + "memory": 800, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair projection: native_constructor_second", + "before": { + "cpu": 112100, + "memory": 800, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair projection: body", + "before": { + "cpu": 588304, + "memory": 2466, + "bytes": 44, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + }, + "after": { + "cpu": 668304, + "memory": 2966, + "bytes": 49, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + } + }, + { + "input": "pair projection: both", + "before": { + "cpu": 416806, + "memory": 1734, + "bytes": 31, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: neither", + "before": { + "cpu": 251598, + "memory": 1332, + "bytes": 28, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: delay", + "before": { + "cpu": 283598, + "memory": 1532, + "bytes": 28, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 427598, + "memory": 2432, + "bytes": 36, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: lambda", + "before": { + "cpu": 471096, + "memory": 2364, + "bytes": 46, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + }, + "after": { + "cpu": 647096, + "memory": 3464, + "bytes": 56, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + } + }, + { + "input": "pair projection: repeated", + "before": { + "cpu": 416806, + "memory": 1734, + "bytes": 31, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: two_projections_first", + "before": { + "cpu": 652304, + "memory": 2866, + "bytes": 51, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair projection: two_projections_second", + "before": { + "cpu": 652304, + "memory": 2866, + "bytes": 51, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair projection: unconsumed_lambda_failure", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 39, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair projection: unconsumed_delay_failure", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 39, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair projection: roundtrip_valid_first", + "before": { + "cpu": 962941, + "memory": 4692, + "bytes": 62, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 1074941, + "memory": 5392, + "bytes": 67, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair projection: roundtrip_valid_second", + "before": { + "cpu": 962941, + "memory": 4692, + "bytes": 62, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 1074941, + "memory": 5392, + "bytes": 67, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair projection: roundtrip_bad_tag_first", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 65, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair projection: roundtrip_bad_tag_second", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 65, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "recursive parameters: self_forwarding", + "before": { + "cpu": 1777056, + "memory": 8010, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1921056, + "memory": 8910, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mutual_forwarding", + "before": { + "cpu": 2049056, + "memory": 9710, + "bytes": 83, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 2065056, + "memory": 9810, + "bytes": 69, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mutual_consumed", + "before": { + "cpu": 2049056, + "memory": 9710, + "bytes": 82, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 2193056, + "memory": 10610, + "bytes": 74, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "recursive parameters: recursive_trace_order", + "before": { + "cpu": 3078044, + "memory": 14102, + "bytes": 149, + "result": "(con integer 42)", + "logs": [ + "retained", + "discarded", + "discarded", + "retained", + "retained", + "discarded" + ] + }, + "after": { + "cpu": 3174044, + "memory": 14702, + "bytes": 120, + "result": "(con integer 42)", + "logs": [ + "retained", + "discarded", + "discarded", + "retained", + "retained", + "discarded" + ] + } + }, + { + "input": "recursive parameters: recursive_failure_order", + "before": { + "cpu": 272637, + "memory": 167, + "bytes": 145, + "result": "error: ExplicitErrorTerm", + "logs": [ + "retained", + "discarded" + ] + }, + "after": { + "cpu": 272637, + "memory": 167, + "bytes": 117, + "result": "error: ExplicitErrorTerm", + "logs": [ + "retained", + "discarded" + ] + } + }, + { + "input": "recursive parameters: all_unused_self", + "before": { + "cpu": 1171300, + "memory": 5430, + "bytes": 70, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + }, + "after": { + "cpu": 1523300, + "memory": 7630, + "bytes": 75, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + } + }, + { + "input": "recursive parameters: all_unused_mutual", + "before": { + "cpu": 1603300, + "memory": 8130, + "bytes": 95, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + }, + "after": { + "cpu": 1443300, + "memory": 7130, + "bytes": 81, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + } + }, + { + "input": "recursive parameters: all_unused_cold", + "before": { + "cpu": 192100, + "memory": 1300, + "bytes": 100, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: entry_failure", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 63, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 70, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + } + }, + { + "input": "recursive parameters: partial", + "before": { + "cpu": 1319515, + "memory": 6107, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1415515, + "memory": 6707, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: escaping", + "before": { + "cpu": 1367515, + "memory": 6407, + "bytes": 41, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1415515, + "memory": 6707, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: oversaturated", + "before": { + "cpu": 304100, + "memory": 2000, + "bytes": 22, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 288100, + "memory": 1900, + "bytes": 24, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: compound_dependency", + "before": { + "cpu": 1649931, + "memory": 6911, + "bytes": 44, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 2081931, + "memory": 9611, + "bytes": 54, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mixed_delayed", + "before": { + "cpu": 3471636, + "memory": 16348, + "bytes": 95, + "result": "(con integer 84)", + "logs": [ + "delayed" + ] + }, + "after": { + "cpu": 3551636, + "memory": 16848, + "bytes": 80, + "result": "(con integer 84)", + "logs": [ + "delayed" + ] + } } ] } diff --git a/tools/optimizer-perf/fixtures/Workloads.nash b/tools/optimizer-perf/fixtures/Workloads.nash index b3e4f84e..14f2c6f7 100644 --- a/tools/optimizer-perf/fixtures/Workloads.nash +++ b/tools/optimizer-perf/fixtures/Workloads.nash @@ -82,3 +82,88 @@ prefixLoop n = constantPrefixLoop : int constantPrefixLoop = prefixLoop 8 + +unusedSelf : int -> int -> int +unusedSelf unused n = + if Builtin.equalsInteger n 0 then + 42 + else + unusedSelf unused (Builtin.subtractInteger n 1) + +recursiveUnusedSelf : int +recursiveUnusedSelf = unusedSelf (Builtin.trace "entry" 7) 3 + +unusedFirst : int -> int -> int +unusedFirst unused n = + if Builtin.equalsInteger n 0 then + 42 + else + unusedSecond (Builtin.subtractInteger n 1) unused + +unusedSecond : int -> int -> int +unusedSecond n unused = unusedFirst unused n + +recursiveUnusedMutual : int +recursiveUnusedMutual = unusedFirst (Builtin.trace "entry" 7) 3 + +hiddenStatic : int -> int -> int +hiddenStatic x n = + if Builtin.equalsInteger n 0 then + x + else + let + next = Builtin.subtractInteger n 1 + in + hiddenStatic (if True then x else 0) next + +cleanupExposesStatic : int +cleanupExposesStatic = hiddenStatic 42 3 + +packingChoose : int -> int -> int -> int +packingChoose n = + if Builtin.equalsInteger n 0 then + \x y -> Builtin.addInteger x y + else + packingChoose (Builtin.subtractInteger n 1) + +stagedApplication : int +stagedApplication = + let + p = packingChoose 3 20 + in + p 22 + +packingTraced : int -> int -> int -> int +packingTraced n = + if Builtin.equalsInteger n 0 then + \x -> trace "first" (\y -> trace "second" (Builtin.addInteger x y)) + else + packingTraced (Builtin.subtractInteger n 1) + +stagedApplicationTraces : int +stagedApplicationTraces = + let + p = packingTraced 3 20 + in + p 22 + +stagedArgumentTrace : int +stagedArgumentTrace = + let + p = packingTraced 3 20 + in + p (trace "argument" 22) + +packingFailure : int -> int -> int -> int +packingFailure n = + if Builtin.equalsInteger n 0 then + \x -> trace "first" fail + else + packingFailure (Builtin.subtractInteger n 1) + +stagedApplicationFailure : int +stagedApplicationFailure = + let + p = packingFailure 3 20 + in + p (trace "must not run" 22) diff --git a/tools/optimizer-perf/fixtures/o2/BuiltinTrace.nash b/tools/optimizer-perf/fixtures/o2/BuiltinTrace.nash new file mode 100644 index 00000000..1596e2c3 --- /dev/null +++ b/tools/optimizer-perf/fixtures/o2/BuiltinTrace.nash @@ -0,0 +1,13 @@ +module Main exposing (..) +import Primitive exposing (..) +import Builtin +log : string -> int -> int +log = Builtin.trace +loop : int -> int +loop n = + if Builtin.equalsInteger n 0 then + 42 + else + log "step" (loop (Builtin.subtractInteger n 1)) +main : int +main = loop 3 diff --git a/tools/optimizer-perf/fixtures/o2/FailingMessage.nash b/tools/optimizer-perf/fixtures/o2/FailingMessage.nash new file mode 100644 index 00000000..66e04acf --- /dev/null +++ b/tools/optimizer-perf/fixtures/o2/FailingMessage.nash @@ -0,0 +1,7 @@ +module Main exposing (..) +import Primitive exposing (..) +import Builtin +log : string -> int -> int +log = Builtin.trace +main : int +main = log (fail) 42 diff --git a/tools/optimizer-perf/fixtures/o2/SourceTrace.nash b/tools/optimizer-perf/fixtures/o2/SourceTrace.nash new file mode 100644 index 00000000..594b2573 --- /dev/null +++ b/tools/optimizer-perf/fixtures/o2/SourceTrace.nash @@ -0,0 +1,11 @@ +module Main exposing (..) +import Primitive exposing (..) +import Builtin +loop : int -> int +loop n = + if Builtin.equalsInteger n 0 then + 42 + else + trace "step" (loop (Builtin.subtractInteger n 1)) +main : int +main = loop 3 diff --git a/tools/optimizer-perf/src/main.rs b/tools/optimizer-perf/src/main.rs index d1652ccd..9aa6ea5a 100644 --- a/tools/optimizer-perf/src/main.rs +++ b/tools/optimizer-perf/src/main.rs @@ -1,6 +1,12 @@ //! Explicit-only performance checks. This binary is not a Cargo test target. +#[path = "../../../crates/nash-codegen/tests/support/constant_fold.rs"] +mod constant_input; #[path = "../../../crates/nash-codegen/tests/support/inverse.rs"] mod inverse_input; +#[path = "../../../crates/nash-codegen/tests/support/pair_projection.rs"] +mod pair_input; +#[path = "../../../crates/nash-codegen/tests/support/recursive_params.rs"] +mod recursive_input; mod source; #[path = "../../../crates/nash-codegen/tests/support/vesting.rs"] @@ -25,7 +31,7 @@ const BUDGET: ExBudget = ExBudget { cpu: 100_000_000, mem: 2_000_000, }; -const SETTINGS: &str = "v1; Plutus V3/PV11; UPLC 1.1.0; bundled V3 default cost model; CPU=100000000; memory=2000000; raw Flat bytes before ledger application; O0 vs static lift/unused-parameters/known-constr/representation-inverse/ANF once/rules1+2+3+4+dead-bindings+recursive-reachability+representation-inverse+force-delay+known-bool+int-bytes/bound-constr+known-fields+list+data+idata-bdata-listdata-mapdata-constrdata-cleanup/recursion/hygiene/lower+forced-builtin-sharing+constant-prefix-sharing"; +const SETTINGS: &str = "v1; Plutus V3/PV11; UPLC 1.1.0; bundled V3 default cost model; CPU=100000000; memory=2000000; raw Flat bytes before ledger application; O0 vs static lift/unused-parameters(nonrecursive+recursive)/ANF once/rules1+2+3+4+dead-bindings+recursive-reachability+representation-inverse+force-delay+known-bool+int-bytes/bound-constr+known-fields+list+data+idata-bdata-listdata-mapdata-constrdata+restricted-pair-cleanup/static-lift+unused-parameters+constant-fold+cleanup(unbudgeted-fixed-point,all-pure-representable)/adjacent-application-fusion/recursion/hygiene/lower+forced-builtin-sharing+constant-prefix-sharing/late-value-binding-cleanup+native-value-application-packing"; #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] #[serde(deny_unknown_fields)] @@ -69,10 +75,13 @@ fn main() { fn run() -> Result<()> { let args: Vec<_> = std::env::args().skip(1).collect(); let command = args.first().map(String::as_str).unwrap_or("help"); + if command == "silent-experiment" && args.len() == 2 { + return silent_experiment(Path::new(&args[1])); + } match (command, args.len()) { ("measure", 1) | ("check", 1..=2) | ("record", 2) | ("experiment", 2) => {} _ => { - return Err("usage: nash-optimizer-perf measure | check [baseline.json] | record NEW.json | experiment MODULE.nash\nrecord refuses overwrites; review and copy explicitly to update baselines".into()); + return Err("usage: nash-optimizer-perf measure | check [baseline.json] | record NEW.json | experiment MODULE.nash | silent-experiment MODULE.nash\nrecord refuses overwrites; review and copy explicitly to update baselines".into()); } } let mut sources: BTreeMap = source::SUPPORT @@ -116,6 +125,18 @@ fn run() -> Result<()> { "InverseInputs".into(), include_str!("../../../crates/nash-codegen/tests/support/inverse.rs").into(), ); + sources.insert( + "ConstantInputs".into(), + include_str!("../../../crates/nash-codegen/tests/support/constant_fold.rs").into(), + ); + sources.insert( + "PairInputs".into(), + include_str!("../../../crates/nash-codegen/tests/support/pair_projection.rs").into(), + ); + sources.insert( + "RecursiveParameterInputs".into(), + include_str!("../../../crates/nash-codegen/tests/support/recursive_params.rs").into(), + ); suite()? }; let report = Report { @@ -130,7 +151,9 @@ fn run() -> Result<()> { rows, }; match command { - "measure" | "experiment" => println!("{}", serde_json::to_string_pretty(&report)?), + "measure" | "experiment" => { + println!("{}", serde_json::to_string_pretty(&report)?) + } "record" => { let mut file = fs::OpenOptions::new() .write(true) @@ -191,10 +214,38 @@ fn accepted<'a>(arena: &'a Arena, core: &'a Core<'a>) -> &'a Core<'a> { let b = Builder::new(arena); let core = nash_codegen::optimizer::optimize(arena, core); anf::validate(core).expect("ANF before recursion rewriting"); - let core = nash_codegen::recursion::rewrite(&b, core).expect("recursion rewrite"); - let core = hygiene::freshen(&b, core); - hygiene::validate(core, &[]).expect("unique closed binders"); - core + let rewrite = |core| { + let core = nash_codegen::recursion::rewrite(&b, core).expect("recursion rewrite"); + let core = hygiene::freshen(&b, core); + hygiene::validate(core, &[]).expect("unique closed binders"); + core + }; + let encode = |core| { + let named = nash_codegen::lower::lower_optimized(arena, core).expect("O1 lowering"); + let twice = nash_codegen::uplc_optimizer::optimize(arena, named); + assert!( + std::ptr::eq(named, twice), + "late O1 must be at a fixed point" + ); + assert!(std::ptr::eq( + twice, + nash_codegen::uplc_optimizer::optimize(arena, twice) + )); + let closed = debruijn::to_debruijn(arena, named).expect("closed O1 program"); + flat::encode(Program::new(arena, Version::plutus_v3(arena), closed)).expect("O1 Flat") + }; + let rewritten = rewrite(core); + let once = encode(rewritten); + let mut repeated = core; + for _ in 0..2 { + repeated = nash_codegen::optimizer::optimize(arena, repeated); + assert_eq!( + once, + encode(rewrite(repeated)), + "repeated O1 must produce identical Flat code" + ); + } + rewritten } fn compare<'a>( @@ -236,11 +287,19 @@ fn measure<'a>( sharing: bool, ) -> Result { let named = if sharing { - nash_codegen::lower::lower_with_constant_sharing(arena, core) + nash_codegen::lower::lower_optimized(arena, core) } else { nash_codegen::lower::lower(arena, core) } .expect("lowering"); + measure_named(arena, named, args) +} + +fn measure_named<'a>( + arena: &'a Arena, + named: &'a Term<'a, nash_plutus::binder::Name<'a>>, + args: &[&'a Term<'a, DeBruijn>], +) -> Result { let term = debruijn::to_debruijn(arena, named).expect("closed UPLC"); let mut program = Program::new(arena, Version::plutus_v3(arena), term); let bytes = flat::encode(program).expect("Flat encoding").len(); @@ -268,6 +327,72 @@ fn measure<'a>( logs: eval.info.logs, }) } +fn silent_experiment(path: &Path) -> Result<()> { + use nash_codegen::build::{TraceConfig, TraceLevel}; + use nash_config::OptimizationLevel; + let source = fs::read_to_string(path)?; + let arena = Arena::new(); + let mut rows = Vec::new(); + for (policy, trace) in [ + ("verbose", TraceConfig::default()), + ( + "silent", + TraceConfig { + user: TraceLevel::Silent, + compiler: false, + }, + ), + ] { + let core = source::compile_with_trace(&arena, &source, &["main"], trace)[0]; + let levels: &[OptimizationLevel] = if policy == "verbose" { + &[OptimizationLevel::O1] + } else { + &[ + OptimizationLevel::O0, + OptimizationLevel::O1, + OptimizationLevel::O2, + ] + }; + for &level in levels { + let compiled = nash_codegen::program::assemble_core_with_options(&arena, core, level) + .map_err(|e| e.to_string())?; + let optimized = match level { + OptimizationLevel::O0 => core, + OptimizationLevel::O1 => nash_codegen::optimizer::optimize(&arena, core), + OptimizationLevel::O2 => nash_codegen::optimizer::optimize_silent(&arena, core)?, + }; + if level == OptimizationLevel::O2 { + let once = flat::encode(compiled.program)?; + let mut repeated = optimized; + for _ in 0..2 { + let compiled = + nash_codegen::program::assemble_core_with_options(&arena, repeated, level) + .map_err(|e| e.to_string())?; + assert_eq!(once, flat::encode(compiled.program)?, "O2 must converge"); + repeated = nash_codegen::optimizer::optimize_silent(&arena, repeated)?; + } + } + rows.push(serde_json::json!({ + "mode": format!("O{} {policy}", u8::from(level)), + "core": nash_ir::pretty::pretty(optimized), + "uplc": pretty::term(compiled.named), + "measurement": measure_named(&arena, compiled.named, &[])?, + })); + } + } + println!( + "{}", + serde_json::to_string_pretty(&serde_json::json!({ + "settings": "Plutus V3/PV11; UPLC 1.1.0; bundled cost model; CPU=100000000; memory=2000000; raw Flat bytes; O2 erases trace messages even if they fail or diverge, then runs O1", + "source": source, + "revision": output("jj", &["log", "-r", "@", "--no-graph", "-T", "commit_id"], Some(repo())), + "rustc": output("rustc", &["--version"], None), + "rows": rows, + }))? + ); + Ok(()) +} + fn ground(term: &Term<'_, DeBruijn>) -> bool { match term { Term::Constant(_) => true, @@ -282,6 +407,7 @@ fn suite() -> Result> { let names = [ "listTraversal", "staticRecursion", + "cleanupExposesStatic", "dataMatch", "dataMiss", "decoding", @@ -291,12 +417,19 @@ fn suite() -> Result> { "constantPrefixTwice", "constantPrefixCold", "constantPrefixLoop", + "recursiveUnusedSelf", + "recursiveUnusedMutual", + "stagedApplication", + "stagedApplicationTraces", + "stagedArgumentTrace", + "stagedApplicationFailure", ]; let cores = source::compile(&arena, include_str!("../fixtures/Workloads.nash"), &names); let expected = [ "(con integer 36)", "(con integer 42)", "(con integer 42)", + "(con integer 42)", "(con integer 0)", "(con integer 42)", "(con unit ())", @@ -305,6 +438,12 @@ fn suite() -> Result> { "(con integer 197)", "(con integer 42)", "(con integer 1528)", + "(con integer 42)", + "(con integer 42)", + "(con integer 42)", + "(con integer 42)", + "(con integer 42)", + "error: ExplicitErrorTerm", ]; for ((name, core), expected) in names.into_iter().zip(cores).zip(expected) { rows.push(compare( @@ -382,5 +521,37 @@ fn suite() -> Result> { None, )?); } + { + let arena = Arena::new(); + for (name, core, _) in constant_input::cases(&Builder::new(&arena)) { + rows.push(compare( + &arena, + format!("constant folding: {name}"), + core, + &[], + None, + )?); + } + } + let arena = Arena::new(); + for (name, core, _) in pair_input::cases(&Builder::new(&arena)) { + rows.push(compare( + &arena, + format!("pair projection: {name}"), + core, + &[], + None, + )?); + } + let arena = Arena::new(); + for (name, core, _) in recursive_input::cases(&Builder::new(&arena)) { + rows.push(compare( + &arena, + format!("recursive parameters: {name}"), + core, + &[], + None, + )?); + } Ok(rows) } diff --git a/tools/optimizer-perf/src/source.rs b/tools/optimizer-perf/src/source.rs index bf0daeda..1a4e79c5 100644 --- a/tools/optimizer-perf/src/source.rs +++ b/tools/optimizer-perf/src/source.rs @@ -13,6 +13,15 @@ struct Module<'a> { } pub fn compile<'a>(arena: &'a Arena, source: &str, roots: &[&str]) -> Vec<&'a Core<'a>> { + compile_with_trace(arena, source, roots, TraceConfig::default()) +} + +pub fn compile_with_trace<'a>( + arena: &'a Arena, + source: &str, + roots: &[&str], + trace: TraceConfig, +) -> Vec<&'a Core<'a>> { let bump = arena.as_bump(); let mut interfaces = BTreeMap::from([("Builtin", nash_can::kinds::builtin_interface(bump))]); let mut modules = Vec::new(); @@ -40,7 +49,7 @@ pub fn compile<'a>(arena: &'a Arena, source: &str, roots: &[&str]) -> Vec<&'a Co name: bump.alloc_str(name), }, None, - TraceConfig::default(), + trace, ) .expect("fixture codegen") .core diff --git a/tools/optimizer-perf/trials/application-cleanup.json b/tools/optimizer-perf/trials/application-cleanup.json new file mode 100644 index 00000000..96d8608f --- /dev/null +++ b/tools/optimizer-perf/trials/application-cleanup.json @@ -0,0 +1,7787 @@ +{ + "status": "Integrated into O1 under Plan 08; O0 unchanged", + "previous_revision": "c2259d95", + "summary": { + "previous_cases": 195, + "current_cases": 199, + "old_rows_changed": 20, + "old_rows_unchanged": 175, + "cpu": { + "increased": 0, + "decreased": 14 + }, + "memory": { + "increased": 0, + "decreased": 14 + }, + "bytes": { + "increased": 13, + "decreased": 7 + } + }, + "changed_existing_rows": [ + { + "input": "Workloads.recursiveUnusedMutual (fixtures/Workloads.nash)", + "before": { + "cpu": 2876554, + "memory": 14542, + "bytes": 81, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + }, + "after": { + "cpu": 2732554, + "memory": 13642, + "bytes": 67, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + } + }, + { + "input": "Vesting: claim after deadline; deadline=10, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 8581501, + "memory": 45416, + "bytes": 822, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: claim before deadline; deadline=30, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7888999, + "memory": 40748, + "bytes": 821, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7888999, + "memory": 40748, + "bytes": 822, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "Vesting: cancel signed; deadline=10, action=1, signer=[170], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7915016, + "memory": 42850, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 7467016, + "memory": 40050, + "bytes": 822, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: cancel unsigned; deadline=10, action=1, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 4134408, + "memory": 20552, + "bytes": 821, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 4134408, + "memory": 20552, + "bytes": 822, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "Vesting: boundary zero minimum; deadline=18, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 8581501, + "memory": 45416, + "bytes": 822, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: boundary five minimum; deadline=18, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 8581501, + "memory": 45416, + "bytes": 822, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: claim after deadline; deadline=10, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9354709, + "memory": 49618, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 8842709, + "memory": 46418, + "bytes": 829, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: claim before deadline; deadline=30, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7990207, + "memory": 40750, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7990207, + "memory": 40750, + "bytes": 829, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "VestingParam: cancel signed; deadline=10, action=1, signer=[170], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7963016, + "memory": 43150, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 7515016, + "memory": 40350, + "bytes": 829, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: cancel unsigned; deadline=10, action=1, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 4134408, + "memory": 20552, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 4134408, + "memory": 20552, + "bytes": 829, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "VestingParam: boundary zero minimum; deadline=18, action=0, signer=[], minimum=0, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9354709, + "memory": 49618, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 8842709, + "memory": 46418, + "bytes": 829, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: boundary five minimum; deadline=18, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7990207, + "memory": 40750, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7990207, + "memory": 40750, + "bytes": 829, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "recursive parameters: mutual_forwarding", + "before": { + "cpu": 2209056, + "memory": 10710, + "bytes": 82, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 2065056, + "memory": 9810, + "bytes": 69, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mutual_consumed", + "before": { + "cpu": 2529056, + "memory": 12710, + "bytes": 99, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 2193056, + "memory": 10610, + "bytes": 74, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "recursive parameters: recursive_trace_order", + "before": { + "cpu": 3318044, + "memory": 15602, + "bytes": 134, + "result": "(con integer 42)", + "logs": [ + "retained", + "discarded", + "discarded", + "retained", + "retained", + "discarded" + ] + }, + "after": { + "cpu": 3174044, + "memory": 14702, + "bytes": 120, + "result": "(con integer 42)", + "logs": [ + "retained", + "discarded", + "discarded", + "retained", + "retained", + "discarded" + ] + } + }, + { + "input": "recursive parameters: recursive_failure_order", + "before": { + "cpu": 272637, + "memory": 167, + "bytes": 130, + "result": "error: ExplicitErrorTerm", + "logs": [ + "retained", + "discarded" + ] + }, + "after": { + "cpu": 272637, + "memory": 167, + "bytes": 117, + "result": "error: ExplicitErrorTerm", + "logs": [ + "retained", + "discarded" + ] + } + }, + { + "input": "recursive parameters: all_unused_mutual", + "before": { + "cpu": 1635300, + "memory": 8330, + "bytes": 89, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + }, + "after": { + "cpu": 1443300, + "memory": 7130, + "bytes": 81, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + } + }, + { + "input": "recursive parameters: oversaturated", + "before": { + "cpu": 304100, + "memory": 2000, + "bytes": 22, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 288100, + "memory": 1900, + "bytes": 24, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mixed_delayed", + "before": { + "cpu": 3727636, + "memory": 17948, + "bytes": 89, + "result": "(con integer 84)", + "logs": [ + "delayed" + ] + }, + "after": { + "cpu": 3551636, + "memory": 16848, + "bytes": 80, + "result": "(con integer 84)", + "logs": [ + "delayed" + ] + } + } + ], + "previous_report": { + "settings": "v1; Plutus V3/PV11; UPLC 1.1.0; bundled V3 default cost model; CPU=100000000; memory=2000000; raw Flat bytes before ledger application; O0 vs static lift/unused-parameters(nonrecursive+recursive)/ANF once/rules1+2+3+4+dead-bindings+recursive-reachability+representation-inverse+force-delay+known-bool+int-bytes/bound-constr+known-fields+list+data+idata-bdata-listdata-mapdata-constrdata+restricted-pair-cleanup/static-lift+unused-parameters+constant-fold+cleanup(unbudgeted-fixed-point,all-pure-representable)/recursion/hygiene/lower+forced-builtin-sharing+constant-prefix-sharing", + "sources": { + "Cardano.Tx": "module Cardano.Tx exposing (validAfter, signedBy)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\n\n-- V3 TxInfo field 7 is the validity interval. Require a finite lower bound.\n-- Times are POSIX milliseconds, not slots or the current wall-clock time.\nvalidAfter : Data -> int\nvalidAfter tx =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, Constr pair(0, [ Constr pair(0, [ Constr pair(1, [ I time ]), _ ]), _ ]), _, _, _, _, _, _, _, _ ]) -> time\n _ -> fail\n\n-- V3 TxInfo field 8 contains every extra signatory.\nsignedBy : Data -> Bytes -> bool\nsignedBy tx owner =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, _, List signers, _, _, _, _, _, _, _ ]) -> hasSigner signers (lower owner)\n _ -> fail\n\nhasSigner : list Data -> bytes -> bool\nhasSigner signers owner =\n case signers of\n [] -> False\n B signer :: rest ->\n if Builtin.equalsByteString signer owner then True\n else hasSigner rest owner\n _ -> fail\n", + "ConstantInputs": "//! Shared inputs for the constant-evaluation trial and its explicit measurements.\nuse nash_ir::{\n build::Builder,\n core::{Binder, Core},\n ty::Ty,\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant as C, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(&'static str, &'a Core<'a>, bool)> {\n let a = b.arena;\n let bytes = |s| b.lit(C::byte_string(a, s));\n let string = |s| b.lit(C::string(a, s));\n let int = b.int(7);\n let data = b.lit(C::data(a, D::integer_from(a, 7)));\n let list = b.lit(C::proto_list(\n a,\n &Type::Integer,\n a.alloc([C::integer_from(a, 7), C::integer_from(a, 8)]),\n ));\n let empty = b.lit(C::proto_list(a, &Type::Integer, &[]));\n let pair = b.lit(C::proto_pair(\n a,\n &Type::Integer,\n &Type::ByteString,\n C::integer_from(a, 7),\n C::byte_string(a, b\"a\"),\n ));\n let call = |f, args: &[&'a Core<'a>]| b.builtin(f, args, Ty::Erased);\n let add = call(F::AddInteger, &[b.int(20), b.int(22)]);\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: add.ty,\n };\n let dlist = b.lit(C::proto_list(\n a,\n &Type::Data,\n a.alloc([C::data(a, D::integer_from(a, 7))]),\n ));\n let dmap = b.lit(C::proto_list(\n a,\n a.alloc(Type::Pair(&Type::Data, &Type::Data)),\n &[],\n ));\n let expanding = b.lit(C::data(\n a,\n D::list(a, a.alloc_slice_copy(&[D::integer_from(a, 7); 30])),\n ));\n let prefix = string(a.as_bump().alloc_str(&\"prefix\".repeat(6)));\n let shared = Binder {\n name: b.fresh(\"prefix\"),\n ty: prefix.ty,\n };\n let shared_prefix = b.let_(\n shared,\n prefix,\n b.constr(\n 0,\n &[\n call(\n F::AppendString,\n &[b.var(shared.name, shared.ty), string(\"x\")],\n ),\n call(\n F::AppendString,\n &[b.var(shared.name, shared.ty), string(\"y\")],\n ),\n ],\n Ty::Erased,\n ),\n );\n let distinct_results = b.constr(\n 0,\n &[\n call(F::AppendString, &[prefix, string(\"x\")]),\n call(F::AppendString, &[prefix, string(\"y\")]),\n ],\n Ty::Erased,\n );\n vec![\n (\"shared_prefix_distinct_results\", shared_prefix, false),\n (\"repeated_literal_distinct_results\", distinct_results, false),\n (\n \"expanding_data_list\",\n call(F::UnListData, &[expanding]),\n false,\n ),\n (\"addition\", add, false),\n (\n \"nested_arithmetic\",\n call(F::MultiplyInteger, &[add, b.int(2)]),\n false,\n ),\n (\n \"bound_arithmetic\",\n b.let_(\n x,\n add,\n call(F::MultiplyInteger, &[b.var(x.name, x.ty), b.int(2)]),\n ),\n false,\n ),\n (\n \"division\",\n call(F::DivideInteger, &[b.int(-7), b.int(3)]),\n false,\n ),\n (\n \"division_zero\",\n call(F::DivideInteger, &[int, b.int(0)]),\n true,\n ),\n (\n \"wrong_integer_shape\",\n call(F::AddInteger, &[bytes(b\"x\"), int]),\n true,\n ),\n (\n \"byte_append\",\n call(F::AppendByteString, &[bytes(b\"ab\"), bytes(b\"cd\")]),\n false,\n ),\n (\n \"byte_slice\",\n call(F::SliceByteString, &[b.int(1), b.int(2), bytes(b\"abcd\")]),\n false,\n ),\n (\n \"byte_length\",\n call(F::LengthOfByteString, &[bytes(b\"abcd\")]),\n false,\n ),\n (\n \"byte_compare\",\n call(F::LessThanByteString, &[bytes(b\"abc\"), bytes(b\"abd\")]),\n false,\n ),\n (\n \"string_append\",\n call(F::AppendString, &[string(\"hello \"), string(\"world\")]),\n false,\n ),\n (\"encode_utf8\", call(F::EncodeUtf8, &[string(\"\u0e2a\u0e27\u0e31\u0e2a\u0e14\u0e35\")]), false),\n (\n \"decode_utf8\",\n call(F::DecodeUtf8, &[bytes(\"h\u00e9llo\".as_bytes())]),\n false,\n ),\n (\"invalid_utf8\", call(F::DecodeUtf8, &[bytes(&[255])]), true),\n (\"integer_data\", call(F::IData, &[int]), false),\n (\"decode_integer_data\", call(F::UnIData, &[data]), false),\n (\"wrong_data_variant\", call(F::UnBData, &[data]), true),\n (\"list_data\", call(F::ListData, &[dlist]), false),\n (\"map_data\", call(F::MapData, &[dmap]), false),\n (\"data_equal\", call(F::EqualsData, &[data, data]), false),\n (\"serialise_data\", call(F::SerialiseData, &[data]), false),\n (\"list_head\", call(F::HeadList, &[list]), false),\n (\"list_tail\", call(F::TailList, &[list]), false),\n (\"empty_head\", call(F::HeadList, &[empty]), true),\n (\"empty_tail\", call(F::TailList, &[empty]), true),\n (\"list_null\", call(F::NullList, &[empty]), false),\n (\"pair_first\", call(F::FstPair, &[pair]), false),\n (\"pair_second\", call(F::SndPair, &[pair]), false),\n (\"trace_before\", b.trace(string(\"before\"), add), false),\n (\n \"trace_builtin\",\n call(F::Trace, &[string(\"keep me\"), int]),\n false,\n ),\n (\n \"cold_failure\",\n b.if_(\n b.lit(C::bool(a, true)),\n int,\n call(F::DivideInteger, &[int, b.int(0)]),\n ),\n false,\n ),\n (\n \"selected_branch\",\n b.if_(\n call(F::EqualsInteger, &[int, b.int(7)]),\n b.trace(string(\"yes\"), add),\n b.trace(string(\"no\"), b.error(Ty::Erased)),\n ),\n false,\n ),\n (\n \"strict_failure_order\",\n call(\n F::AddInteger,\n &[\n b.trace(string(\"first\"), b.error(int.ty)),\n call(F::DivideInteger, &[int, b.int(0)]),\n ],\n ),\n true,\n ),\n (\"unsupported_hash\", call(F::Sha2_256, &[bytes(b\"x\")]), false),\n (\n \"partial\",\n b.app(\n b.builtin(F::AddInteger, &[int], Ty::Erased),\n &[b.int(1)],\n Ty::Erased,\n ),\n false,\n ),\n (\n \"large_input\",\n call(\n F::AppendByteString,\n &[bytes(a.alloc_slice_copy(&[42; 4096])), bytes(b\"z\")],\n ),\n false,\n ),\n (\n \"repeated_call\",\n b.constr(0, &[add, add, add], Ty::Erased),\n false,\n ),\n ]\n}\n", + "Eq": "module Eq exposing ( Eq )\n\n\nimport Literal\nimport Logic exposing ( not, xor, (&&) )\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\n\n{-| Compare values for equality and inequality. -}\ntrait Eq 'a where\n eq : 'a -> 'a -> bool\n\n neq : 'a -> 'a -> bool\n neq a b = not (eq a b)\n\n\nimpl Eq int where\n eq = Builtin.equalsInteger\n\n\nimpl Eq bytes where\n eq = Builtin.equalsByteString\n\n\nimpl Eq string where\n eq = Builtin.equalsString\n\n\nimpl Eq bool where\n eq a b = not (xor a b)\n\n\nimpl Eq unit where\n eq _ _ = True\n\n\nimpl Eq (list ('a : Big)) where\n eq xs ys =\n eq (Builtin.listData xs) (Builtin.listData ys)\n\n\nimpl Eq 'a => Eq (list ('a : Little)) where\n eq xs ys =\n case xs of\n [] ->\n case ys of\n [] ->\n True\n\n _ :: _ ->\n False\n\n x :: restX ->\n case ys of\n [] ->\n False\n\n y :: restY ->\n eq x y && eq restX restY\n\n\nimpl ( Eq 'a, Eq 'b ) => Eq (pair 'a 'b) where\n eq a b =\n let\n pair(firstA, secondA) = a\n\n pair(firstB, secondB) = b\n in\n eq firstA firstB && eq secondA secondB\n\n\nimpl Eq (map ('k : Big) ('v : Big)) where\n eq xs ys = eq (Builtin.mapData xs) (Builtin.mapData ys)\n\n\nimpl ( Eq 'k, Eq 'v ) => Eq (map ('k : Little) 'v) where\n eq = eqMapEntries\n\n\nimpl Eq 'v => Eq (map ('k : Big) ('v : Little)) where\n eq = eqMapEntries\n\n\neqMapEntries : ( Eq 'k, Eq 'v ) => list (pair 'k 'v) -> list (pair 'k 'v) -> bool\neqMapEntries = eq\n\n\nimpl Eq value where\n eq a b = Builtin.equalsData (Builtin.valueData a) (Builtin.valueData b)\n", + "InverseInputs": "//! Shared semantic and explicit performance inputs for representation cancellation.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, Ty},\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(String, &'a Core<'a>, bool)> {\n let a = b.arena;\n let d = D::integer_from(a, 7);\n let data = Constant::data(a, d);\n let pair = Constant::proto_pair(a, &Type::Data, &Type::Data, data, data);\n let list = Constant::proto_list(a, &Type::Data, a.alloc([data]));\n let map = Constant::proto_list(\n a,\n a.alloc(Type::Pair(&Type::Data, &Type::Data)),\n a.alloc([pair]),\n );\n let mut cases = Vec::new();\n for (name, encode, decode, value, encoded) in [\n (\"integer\", F::IData, F::UnIData, b.int(7), b.lit(data)),\n (\n \"bytes\",\n F::BData,\n F::UnBData,\n b.lit(Constant::byte_string(a, b\"hello\")),\n b.lit(Constant::data(a, D::byte_string(a, b\"hello\"))),\n ),\n (\n \"list\",\n F::ListData,\n F::UnListData,\n b.lit(list),\n b.lit(Constant::data(a, D::list(a, a.alloc([d])))),\n ),\n (\n \"map\",\n F::MapData,\n F::UnMapData,\n b.lit(map),\n b.lit(Constant::data(a, D::map(a, a.alloc([(d, d)])))),\n ),\n (\n \"utf8\",\n F::EncodeUtf8,\n F::DecodeUtf8,\n b.lit(Constant::string(a, \"h\u00e9llo\")),\n b.lit(Constant::byte_string(a, \"h\u00e9llo\".as_bytes())),\n ),\n ] {\n let wrap = |x| b.builtin(decode, &[b.builtin(encode, &[x], encoded.ty)], value.ty);\n let trace = |s, x| b.trace(b.lit(Constant::string(a, s)), x);\n cases.push((format!(\"{name}_direct\"), wrap(value), false));\n cases.push((\n format!(\"{name}_trace\"),\n wrap(trace(\"operand\", value)),\n false,\n ));\n cases.push((\n format!(\"{name}_decoded\"),\n wrap(b.builtin(decode, &[encoded], value.ty)),\n false,\n ));\n cases.push((\n format!(\"{name}_decode_failure\"),\n wrap(b.builtin(decode, &[b.int(0)], value.ty)),\n true,\n ));\n cases.push((\n format!(\"{name}_reverse\"),\n b.builtin(\n encode,\n &[b.builtin(decode, &[encoded], value.ty)],\n encoded.ty,\n ),\n false,\n ));\n cases.push((\n format!(\"{name}_wrong_kind\"),\n wrap(b.with_type(b.lit(Constant::bool(a, false)), value.ty)),\n true,\n ));\n cases.push((\n format!(\"{name}_cold\"),\n b.if_(\n b.lit(Constant::bool(a, true)),\n value,\n wrap(trace(\"cold\", value)),\n ),\n false,\n ));\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: value.ty,\n };\n let y = Binder {\n name: b.fresh(\"encoded\"),\n ty: encoded.ty,\n };\n let z = Binder {\n name: b.fresh(\"alias\"),\n ty: encoded.ty,\n };\n let decoded = b.builtin(decode, &[b.var(z.name, z.ty)], value.ty);\n let bindings = |body| {\n b.let_(\n x,\n trace(\"once\", value),\n b.let_(\n y,\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n b.let_(z, b.var(y.name, y.ty), body),\n ),\n )\n };\n cases.push((\n format!(\"{name}_bound\"),\n bindings(trace(\"after encoding\", decoded)),\n false,\n ));\n cases.push((\n format!(\"{name}_captured\"),\n bindings(b.force(b.delay(decoded), decoded.ty)),\n false,\n ));\n cases.push((\n format!(\"{name}_escaping\"),\n bindings(b.constr(0, &[b.var(y.name, y.ty), decoded, decoded], Ty::Erased)),\n false,\n ));\n cases.push((\n format!(\"{name}_bound_invalid\"),\n b.let_(\n x,\n trace(\n \"operand\",\n b.with_type(b.lit(Constant::bool(a, false)), value.ty),\n ),\n b.let_(\n y,\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n trace(\n \"must not run\",\n b.builtin(decode, &[b.var(y.name, y.ty)], value.ty),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_reverse_bound_invalid\"),\n b.let_(\n y,\n b.with_type(b.int(0), encoded.ty),\n b.let_(\n x,\n b.builtin(decode, &[b.var(y.name, y.ty)], value.ty),\n trace(\n \"must not run\",\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_oversaturated\"),\n b.app(wrap(value), &[b.int(1)], value.ty),\n true,\n ));\n let unknown = Binder {\n name: b.fresh(\"unknown\"),\n ty: value.ty,\n };\n cases.push((\n format!(\"{name}_unknown_invalid\"),\n b.app(\n b.lam(&[unknown], wrap(b.var(unknown.name, unknown.ty))),\n &[b.lit(Constant::bool(a, false))],\n value.ty,\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_partial\"),\n b.app(\n b.builtin(decode, &[], Ty::Erased),\n &[b.builtin(encode, &[value], encoded.ty)],\n value.ty,\n ),\n false,\n ));\n }\n let bad_utf8 = b.lit(Constant::byte_string(a, &[255]));\n cases.push((\n \"utf8_reverse_invalid\".into(),\n b.builtin(\n F::EncodeUtf8,\n &[b.builtin(F::DecodeUtf8, &[bad_utf8], Ty::Const(&ConstTy::String))],\n bad_utf8.ty,\n ),\n true,\n ));\n for (name, encode, decode, typ) in [\n (\"list_wrong_tag\", F::ListData, F::UnListData, &Type::Integer),\n (\"map_wrong_tag\", F::MapData, F::UnMapData, &Type::Data),\n ] {\n let value = b.lit(Constant::proto_list(a, typ, &[]));\n cases.push((\n name.into(),\n b.builtin(decode, &[b.builtin(encode, &[value], Ty::Erased)], value.ty),\n true,\n ));\n }\n let data_ty = b.lit(data).ty;\n let fields = Binder {\n name: b.fresh(\"fields\"),\n ty: b.lit(list).ty,\n };\n let tag = Binder {\n name: b.fresh(\"tag\"),\n ty: b.int(0).ty,\n };\n let encoded = Binder {\n name: b.fresh(\"constructor\"),\n ty: data_ty,\n };\n let payload = Binder {\n name: b.fresh(\"payload\"),\n ty: Ty::Erased,\n };\n let p = b.var(payload.name, payload.ty);\n let fst = b.builtin(F::FstPair, &[p], tag.ty);\n let snd = b.builtin(F::SndPair, &[p], fields.ty);\n let constructor = b.builtin(\n F::ConstrData,\n &[b.var(tag.name, tag.ty), b.var(fields.name, fields.ty)],\n data_ty,\n );\n let bind = |body| {\n b.let_(\n tag,\n b.int(0),\n b.let_(\n fields,\n b.lit(list),\n b.let_(\n encoded,\n constructor,\n b.let_(\n payload,\n b.builtin(\n F::UnConstrData,\n &[b.var(encoded.name, encoded.ty)],\n Ty::Erased,\n ),\n body,\n ),\n ),\n ),\n )\n };\n cases.push((\"constructor_tag\".into(), bind(fst), false));\n cases.push((\"constructor_fields\".into(), bind(snd), false));\n cases.push((\n \"constructor_rebuild\".into(),\n bind(b.builtin(F::ConstrData, &[fst, snd], data_ty)),\n false,\n ));\n for (name, subject, fails) in [\n (\n \"constructor_known_reverse\",\n b.lit(Constant::data(a, D::constr(a, 3, a.alloc([d])))),\n false,\n ),\n (\"constructor_wrong_variant\", b.lit(data), true),\n ] {\n cases.push((\n name.into(),\n b.let_(\n encoded,\n subject,\n b.let_(\n payload,\n b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased),\n b.trace(\n b.lit(Constant::string(a, \"after decoding\")),\n b.builtin(F::ConstrData, &[fst, snd], data_ty),\n ),\n ),\n ),\n fails,\n ));\n }\n let bad_tag = b.with_type(b.lit(Constant::bool(a, false)), tag.ty);\n cases.push((\n \"constructor_bad_tag\".into(),\n b.let_(\n tag,\n bad_tag,\n b.let_(\n fields,\n b.trace(b.lit(Constant::string(a, \"fields evaluated\")), b.lit(list)),\n b.let_(\n encoded,\n constructor,\n b.builtin(\n F::FstPair,\n &[b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased)],\n tag.ty,\n ),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n \"constructor_bad_fields\".into(),\n b.let_(\n tag,\n b.int(0),\n b.let_(\n fields,\n b.with_type(b.lit(Constant::bool(a, false)), fields.ty),\n b.let_(\n encoded,\n constructor,\n b.builtin(\n F::SndPair,\n &[b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased)],\n fields.ty,\n ),\n ),\n ),\n ),\n true,\n ));\n cases\n}\n", + "Lift": "module Lift exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait Lift 'a 'b where\n lift : 'a -> 'b\n lower : 'b -> 'a\n\nimpl Lift int Int where\n lift value = Builtin.iData value\n lower value = Builtin.unIData value\n\nimpl Lift bytes Bytes where\n lift value = Builtin.bData value\n lower value = Builtin.unBData value\n", + "Literal": "module Literal exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait FromInt 'a where\n fromInt : int -> 'a\n\ntrait FromString 'a where\n fromString : string -> 'a\n\ntrait FromBytes 'a where\n fromBytes : bytes -> 'a\n\nimpl FromInt int where\n fromInt x = x\n\nimpl FromString string where\n fromString x = x\n\nimpl FromBytes bytes where\n fromBytes x = x\n\ntrait FromBool 'a where\n fromBool : bool -> 'a\n\ntrait FromUnit 'a where\n fromUnit : unit -> 'a\n\nimpl FromBool bool where\n fromBool value = value\n\nimpl FromUnit unit where\n fromUnit value = value\n", + "Logic": "module Logic exposing ( not, and, or, xor, (&&), (||) )\n\n\nimport Primitive\nimport Lift exposing ( Lift )\n\n\ninfix right 2 (||) = or\n\n\ninfix right 3 (&&) = and\n\n\n{-| Negate a Big or little Boolean, returning bool. -}\nnot : Lift bool 'a => 'a -> bool\nnot value =\n if lower value then\n Primitive.False\n else\n Primitive.True\n\n\n{-| Boolean conjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nand : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nand a b =\n if lower a then\n lower b\n else\n Primitive.False\n\n\n{-| Boolean disjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nor a b =\n if lower a then\n Primitive.True\n else\n lower b\n\n\n{-| Return True when the Boolean operands differ. -}\nxor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nxor a b =\n if lower a then\n not b\n else\n lower b\n", + "PairInputs": "//! Inputs shared by pair-projection snapshots and explicit measurements.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, Ty},\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant as C, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(String, &'a Core<'a>, bool)> {\n let a = b.arena;\n let int = b.int(0).ty;\n let pair = b.lit(C::proto_pair(\n a,\n &Type::Integer,\n &Type::Integer,\n C::integer_from(a, 7),\n C::integer_from(a, 8),\n ));\n let data = b.lit(C::data(a, D::integer_from(a, 7)));\n let made = b.builtin(\n F::MkPairData,\n &[data, data],\n Ty::Const(a.alloc(ConstTy::Pair(data.ty, data.ty))),\n );\n let unwrapped = b.builtin(\n F::UnConstrData,\n &[b.lit(C::data(a, D::constr(a, 0, &[])))],\n Ty::Const(a.alloc(ConstTy::Pair(\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n ))),\n );\n let trace = |s, x| b.trace(b.lit(C::string(a, s)), x);\n let mut cases = Vec::new();\n for (name, subject, left_ty, right_ty, fails) in [\n (\"literal\", pair, int, int, false),\n (\"traced\", trace(\"subject\", pair), int, int, false),\n (\"made_data\", made, data.ty, data.ty, false),\n (\n \"decoded\",\n unwrapped,\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n false,\n ),\n (\n \"bad_decoder\",\n b.builtin(F::UnConstrData, &[data], unwrapped.ty),\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n true,\n ),\n (\n \"ignored_failure\",\n b.builtin(\n F::MkPairData,\n &[data, trace(\"unused field\", b.error(data.ty))],\n made.ty,\n ),\n data.ty,\n data.ty,\n true,\n ),\n (\n \"wrong_subject\",\n b.with_type(b.int(1), pair.ty),\n int,\n int,\n true,\n ),\n // Generic UPLC case accepts this, whereas fstPair would reject it.\n (\n \"native_constructor\",\n b.with_type(b.constr(0, &[b.int(7), b.int(8)], Ty::Erased), pair.ty),\n int,\n int,\n false,\n ),\n ] {\n for second in [false, true] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: left_ty,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: right_ty,\n };\n let selected = if second { y } else { x };\n let value = b.var(selected.name, selected.ty);\n let core = b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: value,\n }],\n None,\n value.ty,\n );\n cases.push((\n format!(\"{name}_{}\", if second { \"second\" } else { \"first\" }),\n core,\n fails,\n ));\n }\n }\n for mode in [\"body\", \"both\", \"neither\", \"delay\", \"lambda\", \"repeated\"] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: int,\n };\n let xv = b.var(x.name, x.ty);\n let body = match mode {\n \"both\" => b.builtin(F::AddInteger, &[xv, b.var(y.name, y.ty)], int),\n \"neither\" => b.int(42),\n \"delay\" => b.delay(xv),\n \"lambda\" => b.lam(\n &[Binder {\n name: b.fresh(\"unused\"),\n ty: int,\n }],\n xv,\n ),\n \"repeated\" => b.builtin(F::AddInteger, &[xv, xv], int),\n _ => trace(\"body\", b.builtin(F::AddInteger, &[xv, b.int(1)], int)),\n };\n let core = b.case(\n CaseKind::Pair,\n trace(\"subject\", pair),\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body,\n }],\n None,\n body.ty,\n );\n // Force/application is after the case, exposing any misplaced strict work.\n let core = match mode {\n \"delay\" => b.force(core, int),\n \"lambda\" => b.app(core, &[trace(\"argument\", b.int(0))], int),\n _ => core,\n };\n cases.push((mode.into(), core, false));\n }\n for second in [false, true] {\n let select = |subject| {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: int,\n };\n let selected = if second { y } else { x };\n b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: b.var(selected.name, int),\n }],\n None,\n int,\n )\n };\n let first = select(trace(\"first\", pair));\n let second_core = select(trace(\"second\", pair));\n cases.push((\n format!(\n \"two_projections_{}\",\n if second { \"second\" } else { \"first\" }\n ),\n b.builtin(F::AddInteger, &[first, second_core], int),\n false,\n ));\n }\n for delayed in [false, true] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: Ty::Const(a.alloc(ConstTy::List(data.ty))),\n };\n let value = b.var(x.name, x.ty);\n let body = if delayed {\n b.delay(value)\n } else {\n b.lam(\n &[Binder {\n name: b.fresh(\"arg\"),\n ty: int,\n }],\n value,\n )\n };\n let subject = b.builtin(\n F::UnConstrData,\n &[trace(\"before failure\", data)],\n unwrapped.ty,\n );\n let case = b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body,\n }],\n None,\n body.ty,\n );\n let ignored = Binder {\n name: b.fresh(\"ignored closure\"),\n ty: case.ty,\n };\n cases.push((\n format!(\n \"unconsumed_{}_failure\",\n if delayed { \"delay\" } else { \"lambda\" }\n ),\n b.let_(ignored, case, b.int(0)),\n true,\n ));\n }\n for bad_tag in [false, true] {\n for second in [false, true] {\n let tag = Binder {\n name: b.fresh(\"tag\"),\n ty: int,\n };\n let fields_ty = Ty::Const(a.alloc(ConstTy::List(data.ty)));\n let fields = Binder {\n name: b.fresh(\"fields\"),\n ty: fields_ty,\n };\n let encoded = Binder {\n name: b.fresh(\"encoded\"),\n ty: data.ty,\n };\n let decoded = Binder {\n name: b.fresh(\"decoded\"),\n ty: unwrapped.ty,\n };\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: fields_ty,\n };\n let selected = if second { y } else { x };\n let body = b.case(\n CaseKind::Pair,\n b.var(decoded.name, decoded.ty),\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: b.var(selected.name, selected.ty),\n }],\n None,\n selected.ty,\n );\n let body = b.let_(\n decoded,\n b.builtin(\n F::UnConstrData,\n &[b.var(encoded.name, encoded.ty)],\n decoded.ty,\n ),\n body,\n );\n let body = b.let_(\n encoded,\n b.builtin(\n F::ConstrData,\n &[b.var(tag.name, tag.ty), b.var(fields.name, fields.ty)],\n encoded.ty,\n ),\n body,\n );\n let body = b.let_(\n fields,\n b.builtin(\n F::MkCons,\n &[\n trace(\"field\", data),\n b.lit(C::proto_list(a, &Type::Data, &[])),\n ],\n fields_ty,\n ),\n body,\n );\n let tag_value = if bad_tag {\n let bytes = b.lit(C::data(a, D::byte_string(a, b\"bad\")));\n b.with_type(\n b.builtin(\n F::UnBData,\n &[trace(\"tag\", bytes)],\n b.lit(C::byte_string(a, b\"bad\")).ty,\n ),\n int,\n )\n } else {\n let tag_data = b.lit(C::data(a, D::integer_from(a, 0)));\n b.builtin(F::UnIData, &[trace(\"tag\", tag_data)], int)\n };\n let body = b.let_(tag, tag_value, body);\n cases.push((\n format!(\n \"roundtrip_{}_{}\",\n if bad_tag { \"bad_tag\" } else { \"valid\" },\n if second { \"second\" } else { \"first\" }\n ),\n body,\n bad_tag,\n ));\n }\n }\n cases\n}\n", + "RecursiveParameterInputs": "//! Recursive parameter fixtures shared with the explicit performance workspace.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, TermTy, Ty},\n};\nuse nash_plutus::{builtin::DefaultFunction as F, constant::Constant};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(&'static str, &'a Core<'a>, bool)> {\n let a = b.arena;\n let int = b.int(0).ty;\n let bool_ = Ty::Const(&ConstTy::Bool);\n let fun = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int, int]), int)));\n let bind = |text, ty| Binder {\n name: b.fresh(text),\n ty,\n };\n let trace = |text, value| b.trace(b.lit(Constant::string(a, text)), value);\n let mut cases = Vec::new();\n for (name, mutual, consumed, effects, failure) in [\n (\"self_forwarding\", false, false, false, false),\n (\"mutual_forwarding\", true, false, false, false),\n (\"mutual_consumed\", true, true, false, false),\n (\"recursive_trace_order\", true, false, true, false),\n (\"recursive_failure_order\", true, false, true, true),\n ] {\n let f = bind(\"f\", fun);\n let g = bind(\"g\", fun);\n let x = bind(\"x\", int);\n let n = bind(\"n\", int);\n let m = bind(\"m\", int);\n let y = bind(\"y\", int);\n let step = |target: Binder<'a>, unused: Binder<'a>, count: Binder<'a>, swapped: bool| {\n let next = b.builtin(F::SubtractInteger, &[b.var(count.name, int), b.int(1)], int);\n let discarded = if failure {\n trace(\"discarded\", b.error(int))\n } else if effects {\n trace(\"discarded\", b.int(7))\n } else {\n b.var(unused.name, int)\n };\n let next = if effects {\n trace(\"retained\", next)\n } else {\n next\n };\n let args = if swapped {\n [next, discarded]\n } else {\n [discarded, next]\n };\n b.if_(\n b.builtin(F::EqualsInteger, &[b.var(count.name, int), b.int(0)], bool_),\n if consumed {\n b.var(unused.name, int)\n } else {\n b.int(42)\n },\n b.app(b.var(target.name, fun), &args, int),\n )\n };\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x, n]),\n static_params: &[],\n body: step(if mutual { g } else { f }, x, n, mutual),\n }];\n if mutual {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[m, y]),\n static_params: &[],\n body: step(f, y, m, false),\n });\n }\n cases.push((\n name,\n b.let_rec(\n &group,\n b.app(b.var(f.name, fun), &[b.int(7), b.int(3)], int),\n ),\n failure,\n ));\n }\n // Removing every parameter must keep definitions cold and execute each call.\n for (name, mutual, cold) in [\n (\"all_unused_self\", false, false),\n (\"all_unused_mutual\", true, false),\n (\"all_unused_cold\", true, true),\n ] {\n let unary = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int]), int)));\n let f = bind(\"f\", unary);\n let g = bind(\"g\", unary);\n let x = bind(\"x\", int);\n let y = bind(\"y\", int);\n let invoke = |target: Binder<'a>, arg| b.app(b.var(target.name, unary), &[arg], int);\n let body = b.if_(\n b.lit(Constant::bool(a, true)),\n trace(\"body\", b.int(21)),\n invoke(if mutual { g } else { f }, b.var(x.name, int)),\n );\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x]),\n static_params: &[],\n body,\n }];\n if mutual {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[y]),\n static_params: &[],\n body: invoke(f, b.var(y.name, int)),\n });\n }\n let calls = b.builtin(\n F::AddInteger,\n &[\n invoke(f, trace(\"entry1\", b.int(0))),\n invoke(if mutual { g } else { f }, trace(\"entry2\", b.int(1))),\n ],\n int,\n );\n let calls = if cold {\n b.if_(b.lit(Constant::bool(a, true)), b.int(42), calls)\n } else {\n calls\n };\n cases.push((name, b.let_rec(&group, calls), false));\n }\n\n for name in [\n \"entry_failure\",\n \"partial\",\n \"escaping\",\n \"oversaturated\",\n \"compound_dependency\",\n \"mixed_delayed\",\n ] {\n let f = bind(\"f\", fun);\n let g = bind(\"g\", fun);\n let x = bind(\"x\", int);\n let n = bind(\"n\", int);\n let y = bind(\"y\", int);\n let m = bind(\"m\", int);\n let unary = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int]), int)));\n let next = b.builtin(F::SubtractInteger, &[b.var(n.name, int), b.int(1)], int);\n let forwarded = if name == \"compound_dependency\" {\n b.builtin(F::AddInteger, &[b.var(x.name, int), b.int(1)], int)\n } else {\n b.var(x.name, int)\n };\n let body = b.if_(\n b.builtin(F::EqualsInteger, &[b.var(n.name, int), b.int(0)], bool_),\n b.int(42),\n b.app(b.var(f.name, fun), &[forwarded, next], int),\n );\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x, n]),\n static_params: &[],\n body,\n }];\n let invoke = b.app(b.var(f.name, fun), &[b.int(7), b.int(2)], int);\n let entry = match name {\n \"entry_failure\" => b.app(\n b.var(f.name, fun),\n &[trace(\"first\", b.error(int)), trace(\"later\", b.int(2))],\n int,\n ),\n \"partial\" => b.app(\n b.app(b.var(f.name, fun), &[b.int(7)], unary),\n &[b.int(2)],\n int,\n ),\n \"escaping\" => {\n let alias = bind(\"alias\", fun);\n b.let_(\n alias,\n b.var(f.name, fun),\n b.app(b.var(alias.name, fun), &[b.int(7), b.int(2)], int),\n )\n }\n \"oversaturated\" => {\n let z = bind(\"z\", int);\n let ty = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int, int]), unary)));\n group[0].binder.ty = ty;\n group[0].body = b.lam(&[z], b.var(z.name, int));\n b.app(b.var(f.name, ty), &[b.int(0), b.int(0), b.int(42)], int)\n }\n \"mixed_delayed\" => {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[y, m]),\n static_params: &[],\n body: trace(\n \"delayed\",\n b.app(b.var(f.name, fun), &[b.int(7), b.int(2)], int),\n ),\n });\n b.builtin(\n F::AddInteger,\n &[\n invoke,\n b.app(b.var(g.name, fun), &[b.int(0), b.int(0)], int),\n ],\n int,\n )\n }\n _ => invoke,\n };\n cases.push((name, b.let_rec(&group, entry), name == \"entry_failure\"));\n }\n cases\n}\n", + "Vesting": "validator module Vesting exposing (main)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\nimport Cardano.Tx exposing (validAfter, signedBy)\n\ntype Datum = Datum { owner : Bytes, deadline : Int }\n\ntype step 'a = Done 'a | Next int 'a\n\ntype alias acc = { total : int, seen : list Int }\n\ntype Redeemer = Claim | Cancel\n\n-- The ledger supplies one V3 ScriptContext; spending datum is in ScriptInfo.\nmain : Data -> unit\nmain ctx =\n case ctx of\n Constr pair(0, [ tx, action, Constr pair(1, [ _, Constr pair(0, [ datum ]) ]) ]) ->\n check (Primitive.coerce datum) (Primitive.coerce action) tx\n _ -> fail\n\ncheck : Datum -> Redeemer -> Data -> unit\ncheck datum redeemer tx =\n case redeemer of\n Claim -> assert (Builtin.lessThanInteger (lower datum.deadline) (validAfter tx))\n Cancel -> assert (signedBy tx datum.owner)\n", + "VestingContextInput": "//! Shared ledger input for the vesting snapshots, artifact tests and explicit perf runner.\nuse nash_plutus::{arena::Arena, data::PlutusData};\n\npub fn context<'a>(\n arena: &'a Arena,\n datum: &'a PlutusData<'a>,\n redeemer: &'a PlutusData<'a>,\n lower_time: i128,\n signer: &'a [u8],\n) -> &'a PlutusData<'a> {\n let constr = |tag, fields: &[&'a PlutusData<'a>]| {\n PlutusData::constr(arena, tag, arena.alloc_slice_copy(fields))\n };\n let empty_list = PlutusData::list(arena, &[]);\n let empty_map = PlutusData::map(arena, &[]);\n let zero = PlutusData::integer_from(arena, 0);\n let tx_id = PlutusData::byte_string(arena, &[0; 32]);\n let closed = constr(1, &[]);\n let lower = constr(\n 0,\n &[\n constr(1, &[PlutusData::integer_from(arena, lower_time)]),\n closed,\n ],\n );\n let upper = constr(0, &[constr(2, &[]), closed]);\n let signers = if signer.is_empty() {\n empty_list\n } else {\n // The owner is deliberately second: signedBy must search the whole list.\n PlutusData::list(\n arena,\n arena.alloc_slice_copy(&[\n PlutusData::byte_string(arena, &[0xbb]),\n PlutusData::byte_string(arena, signer),\n ]),\n )\n };\n let tx = constr(\n 0,\n &[\n empty_list, // inputs\n empty_list, // reference inputs\n empty_list, // outputs\n zero, // fee\n empty_map, // mint\n empty_list, // certificates\n empty_map, // withdrawals\n constr(0, &[lower, upper]), // validity range\n signers,\n empty_map, // redeemers\n empty_map, // datums\n tx_id,\n empty_map, // votes\n empty_list, // proposals\n constr(1, &[]), // current treasury\n constr(1, &[]), // treasury donation\n ],\n );\n let reference = constr(0, &[tx_id, zero]);\n let spending = constr(1, &[reference, constr(0, &[datum])]);\n constr(0, &[tx, redeemer, spending])\n}\n", + "VestingParam": "validator module VestingParam exposing (main)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\nimport Cardano.Tx exposing (validAfter, signedBy)\n\ntype Datum = Datum { owner : Bytes, deadline : Int }\n\ntype Redeemer = Claim | Cancel\n\n-- The ledger supplies one V3 ScriptContext; spending datum is in ScriptInfo.\nmain : int -> Data -> unit\nmain minimumLock ctx =\n case ctx of\n Constr pair(0, [ tx, action, Constr pair(1, [ _, Constr pair(0, [ datum ]) ]) ]) ->\n check minimumLock (Primitive.coerce datum) (Primitive.coerce action) tx\n _ -> fail\n\ncheck : int -> Datum -> Redeemer -> Data -> unit\ncheck minimumLock datum redeemer tx =\n case redeemer of\n Claim ->\n assert\n (Builtin.lessThanInteger\n (Builtin.addInteger (lower datum.deadline) minimumLock)\n (validAfter tx))\n Cancel -> assert (signedBy tx datum.owner)\n", + "Workloads": "module Workloads exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Logic exposing (..)\n\nsum : list int -> int\nsum xs =\n case xs of\n [] -> 0\n x :: rest -> Builtin.addInteger x (sum rest)\n\nlistTraversal : int\nlistTraversal = sum [1, 2, 3, 4, 5, 6, 7, 8]\n\ncountdown : int -> int -> int\ncountdown n result =\n if Builtin.equalsInteger n 0 then\n result\n else\n countdown (Builtin.subtractInteger n 1) result\n\nstaticRecursion : int\nstaticRecursion = countdown 8 42\n\nmatchData : Data -> int\nmatchData value =\n case value of\n I n -> n\n _ -> 0\n\ndataMatch : int\ndataMatch = matchData (I 42)\n\ndataMiss : int\ndataMiss = matchData (B #\"ab\")\n\ndecode : Data -> int\ndecode value =\n case value of\n Constr pair(_, [I n, _]) -> n\n _ -> 0\n\ndecoding : int\ndecoding = decode (Builtin.constrData 0 [I 42, I 7])\n\nvalidate : Data -> unit\nvalidate value =\n case value of\n I n -> assert (Builtin.lessThanInteger 0 n)\n _ -> fail\n\nvalidationPass : unit\nvalidationPass = validate (I 42)\n\nvalidationFail : unit\nvalidationFail = validate (I 0)\n\nbooleanHelpers : bool\nbooleanHelpers = (True && False) || (True && True)\n\nconstantPrefixTwice : int\nconstantPrefixTwice =\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nconstantPrefixCold : int\nconstantPrefixCold =\n if True then\n 42\n else\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nprefixLoop : int -> int\nprefixLoop n =\n if Builtin.equalsInteger n 0 then\n 0\n else\n Builtin.addInteger\n (Builtin.addInteger (Builtin.subtractInteger 100 n) (Builtin.subtractInteger 100 n))\n (prefixLoop (Builtin.subtractInteger n 1))\n\nconstantPrefixLoop : int\nconstantPrefixLoop = prefixLoop 8\n\nunusedSelf : int -> int -> int\nunusedSelf unused n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n unusedSelf unused (Builtin.subtractInteger n 1)\n\nrecursiveUnusedSelf : int\nrecursiveUnusedSelf = unusedSelf (Builtin.trace \"entry\" 7) 3\n\nunusedFirst : int -> int -> int\nunusedFirst unused n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n unusedSecond (Builtin.subtractInteger n 1) unused\n\nunusedSecond : int -> int -> int\nunusedSecond n unused = unusedFirst unused n\n\nrecursiveUnusedMutual : int\nrecursiveUnusedMutual = unusedFirst (Builtin.trace \"entry\" 7) 3\n\nhiddenStatic : int -> int -> int\nhiddenStatic x n =\n if Builtin.equalsInteger n 0 then\n x\n else\n let\n next = Builtin.subtractInteger n 1\n in\n hiddenStatic (if True then x else 0) next\n\ncleanupExposesStatic : int\ncleanupExposesStatic = hiddenStatic 42 3\n" + }, + "revision": "f6289c9b1a15e9c702dbe9382333e2f16295a5ef", + "rustc": "rustc 1.98.1 (48a229cea 2026-09-01)", + "rows": [ + { + "input": "Workloads.listTraversal (fixtures/Workloads.nash)", + "before": { + "cpu": 5788660, + "memory": 27872, + "bytes": 102, + "result": "(con integer 36)", + "logs": [] + }, + "after": { + "cpu": 3225764, + "memory": 15216, + "bytes": 41, + "result": "(con integer 36)", + "logs": [] + } + }, + { + "input": "Workloads.staticRecursion (fixtures/Workloads.nash)", + "before": { + "cpu": 4736761, + "memory": 21725, + "bytes": 52, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.cleanupExposesStatic (fixtures/Workloads.nash)", + "before": { + "cpu": 2737056, + "memory": 14010, + "bytes": 66, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1921056, + "memory": 8910, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.dataMatch (fixtures/Workloads.nash)", + "before": { + "cpu": 978518, + "memory": 5496, + "bytes": 58, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.dataMiss (fixtures/Workloads.nash)", + "before": { + "cpu": 953658, + "memory": 5464, + "bytes": 64, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "Workloads.decoding (fixtures/Workloads.nash)", + "before": { + "cpu": 2271655, + "memory": 11888, + "bytes": 125, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.validationPass (fixtures/Workloads.nash)", + "before": { + "cpu": 1215808, + "memory": 6697, + "bytes": 90, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Workloads.validationFail (fixtures/Workloads.nash)", + "before": { + "cpu": 235306, + "memory": 229, + "bytes": 90, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 30, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "Workloads.booleanHelpers (fixtures/Workloads.nash)", + "before": { + "cpu": 400100, + "memory": 2600, + "bytes": 29, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "Workloads.constantPrefixTwice (fixtures/Workloads.nash)", + "before": { + "cpu": 799724, + "memory": 3206, + "bytes": 35, + "result": "(con integer 197)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con integer 197)", + "logs": [] + } + }, + { + "input": "Workloads.constantPrefixCold (fixtures/Workloads.nash)", + "before": { + "cpu": 288100, + "memory": 1900, + "bytes": 47, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.constantPrefixLoop (fixtures/Workloads.nash)", + "before": { + "cpu": 10695417, + "memory": 38789, + "bytes": 70, + "result": "(con integer 1528)", + "logs": [] + }, + "after": { + "cpu": 10839417, + "memory": 39689, + "bytes": 67, + "result": "(con integer 1528)", + "logs": [] + } + }, + { + "input": "Workloads.recursiveUnusedSelf (fixtures/Workloads.nash)", + "before": { + "cpu": 2540554, + "memory": 12442, + "bytes": 75, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + }, + "after": { + "cpu": 2156554, + "memory": 10042, + "bytes": 56, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + } + }, + { + "input": "Workloads.recursiveUnusedMutual (fixtures/Workloads.nash)", + "before": { + "cpu": 3436554, + "memory": 18042, + "bytes": 104, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + }, + "after": { + "cpu": 2876554, + "memory": 14542, + "bytes": 81, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + } + }, + { + "input": "Vesting: claim after deadline; deadline=10, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 10053501, + "memory": 54616, + "bytes": 886, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: claim before deadline; deadline=30, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7888999, + "memory": 40748, + "bytes": 886, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7888999, + "memory": 40748, + "bytes": 821, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "Vesting: cancel signed; deadline=10, action=1, signer=[170], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9243016, + "memory": 51150, + "bytes": 886, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 7915016, + "memory": 42850, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: cancel unsigned; deadline=10, action=1, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7334408, + "memory": 40552, + "bytes": 886, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 4134408, + "memory": 20552, + "bytes": 821, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "Vesting: boundary zero minimum; deadline=18, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 10053501, + "memory": 54616, + "bytes": 886, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: boundary five minimum; deadline=18, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 10053501, + "memory": 54616, + "bytes": 886, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: claim after deadline; deadline=10, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 10314709, + "memory": 55618, + "bytes": 893, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 9354709, + "memory": 49618, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: claim before deadline; deadline=30, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7990207, + "memory": 40750, + "bytes": 893, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7990207, + "memory": 40750, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "VestingParam: cancel signed; deadline=10, action=1, signer=[170], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9339016, + "memory": 51750, + "bytes": 893, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 7963016, + "memory": 43150, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: cancel unsigned; deadline=10, action=1, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7334408, + "memory": 40552, + "bytes": 893, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 4134408, + "memory": 20552, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "VestingParam: boundary zero minimum; deadline=18, action=0, signer=[], minimum=0, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 10314709, + "memory": 55618, + "bytes": 893, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 9354709, + "memory": 49618, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: boundary five minimum; deadline=18, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7990207, + "memory": 40750, + "bytes": 893, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7990207, + "memory": 40750, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "representation cancellation: integer_direct", + "before": { + "cpu": 116143, + "memory": 664, + "bytes": 10, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_trace", + "before": { + "cpu": 287641, + "memory": 1396, + "bytes": 24, + "result": "(con integer 7)", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 378897, + "memory": 2064, + "bytes": 30, + "result": "(con integer 7)", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: integer_decoded", + "before": { + "cpu": 168887, + "memory": 896, + "bytes": 14, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_reverse", + "before": { + "cpu": 116143, + "memory": 664, + "bytes": 13, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_cold", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 26, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_bound", + "before": { + "cpu": 603139, + "memory": 3028, + "bytes": 50, + "result": "(con integer 7)", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 534395, + "memory": 2696, + "bytes": 48, + "result": "(con integer 7)", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: integer_captured", + "before": { + "cpu": 463641, + "memory": 2496, + "bytes": 29, + "result": "(con integer 7)", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 378897, + "memory": 2064, + "bytes": 27, + "result": "(con integer 7)", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: integer_escaping", + "before": { + "cpu": 532385, + "memory": 2828, + "bytes": 35, + "result": "(constr 0 (con data (I 7)) (con integer 7) (con integer 7))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 426897, + "memory": 2364, + "bytes": 32, + "result": "(constr 0 (con data (I 7)) (con integer 7) (con integer 7))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: integer_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 47, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: integer_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_oversaturated", + "before": { + "cpu": 36143, + "memory": 164, + "bytes": 12, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(Integer(7)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_partial", + "before": { + "cpu": 116143, + "memory": 664, + "bytes": 10, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 68844, + "memory": 432, + "bytes": 11, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_direct", + "before": { + "cpu": 111425, + "memory": 664, + "bytes": 17, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_trace", + "before": { + "cpu": 282923, + "memory": 1396, + "bytes": 31, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 374781, + "memory": 2064, + "bytes": 36, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: bytes_decoded", + "before": { + "cpu": 163567, + "memory": 896, + "bytes": 19, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_reverse", + "before": { + "cpu": 111425, + "memory": 664, + "bytes": 18, + "result": "(con data (B #68656c6c6f))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con data (B #68656c6c6f))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_cold", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 39, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_bound", + "before": { + "cpu": 598421, + "memory": 3028, + "bytes": 57, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 530279, + "memory": 2696, + "bytes": 54, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: bytes_captured", + "before": { + "cpu": 458923, + "memory": 2496, + "bytes": 36, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 374781, + "memory": 2064, + "bytes": 33, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: bytes_escaping", + "before": { + "cpu": 527065, + "memory": 2828, + "bytes": 42, + "result": "(constr 0\n (con data (B #68656c6c6f))\n (con bytestring #68656c6c6f)\n (con bytestring #68656c6c6f))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 422781, + "memory": 2364, + "bytes": 38, + "result": "(constr 0\n (con data (B #68656c6c6f))\n (con bytestring #68656c6c6f)\n (con bytestring #68656c6c6f))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: bytes_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 47, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: bytes_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_oversaturated", + "before": { + "cpu": 31425, + "memory": 164, + "bytes": 19, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ByteString([104, 101, 108, 108, 111])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ByteString([104, 101, 108, 108, 111])))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_partial", + "before": { + "cpu": 111425, + "memory": 664, + "bytes": 17, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 68242, + "memory": 432, + "bytes": 16, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: list_direct", + "before": { + "cpu": 139885, + "memory": 664, + "bytes": 14, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: list_trace", + "before": { + "cpu": 311383, + "memory": 1396, + "bytes": 29, + "result": "(con (list data) [(I 7)])", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 397450, + "memory": 2064, + "bytes": 35, + "result": "(con (list data) [(I 7)])", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: list_decoded", + "before": { + "cpu": 197818, + "memory": 896, + "bytes": 16, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: list_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_reverse", + "before": { + "cpu": 139885, + "memory": 664, + "bytes": 15, + "result": "(con data (List [I 7]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (List [I 7]))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_cold", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 34, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: list_bound", + "before": { + "cpu": 626881, + "memory": 3028, + "bytes": 55, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 552948, + "memory": 2696, + "bytes": 53, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: list_captured", + "before": { + "cpu": 487383, + "memory": 2496, + "bytes": 34, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 397450, + "memory": 2064, + "bytes": 32, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: list_escaping", + "before": { + "cpu": 561316, + "memory": 2828, + "bytes": 40, + "result": "(constr 0\n (con data (List [I 7]))\n (con (list data) [(I 7)])\n (con (list data) [(I 7)]))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 445450, + "memory": 2364, + "bytes": 37, + "result": "(constr 0\n (con data (List [I 7]))\n (con (list data) [(I 7)])\n (con (list data) [(I 7)]))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: list_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 47, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: list_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_oversaturated", + "before": { + "cpu": 59885, + "memory": 164, + "bytes": 16, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Data, [Data(Integer(7))])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Data, [Data(Integer(7))])))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_partial", + "before": { + "cpu": 139885, + "memory": 664, + "bytes": 14, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 74033, + "memory": 432, + "bytes": 13, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_direct", + "before": { + "cpu": 172969, + "memory": 664, + "bytes": 20, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 17, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_trace", + "before": { + "cpu": 344467, + "memory": 1396, + "bytes": 35, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 431844, + "memory": 2064, + "bytes": 41, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: map_decoded", + "before": { + "cpu": 229592, + "memory": 896, + "bytes": 16, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 17, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_reverse", + "before": { + "cpu": 172969, + "memory": 664, + "bytes": 15, + "result": "(con data (Map [(I 7, I 7)]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (Map [(I 7, I 7)]))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_cold", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 47, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 17, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_bound", + "before": { + "cpu": 659965, + "memory": 3028, + "bytes": 61, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 587342, + "memory": 2696, + "bytes": 59, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: map_captured", + "before": { + "cpu": 520467, + "memory": 2496, + "bytes": 40, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 431844, + "memory": 2064, + "bytes": 38, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: map_escaping", + "before": { + "cpu": 593090, + "memory": 2828, + "bytes": 46, + "result": "(constr 0\n (con data (Map [(I 7, I 7)]))\n (con (list (pair data data)) [((I 7), (I 7))])\n (con (list (pair data data)) [((I 7), (I 7))]))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 479844, + "memory": 2364, + "bytes": 43, + "result": "(constr 0\n (con data (Map [(I 7, I 7)]))\n (con (list (pair data data)) [((I 7), (I 7))])\n (con (list (pair data data)) [((I 7), (I 7))]))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: map_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 47, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: map_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_oversaturated", + "before": { + "cpu": 92969, + "memory": 164, + "bytes": 23, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Pair(Data, Data), [ProtoPair(Data, Data, Data(Integer(7)), Data(Integer(7)))])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 19, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Pair(Data, Data), [ProtoPair(Data, Data, Data(Integer(7)), Data(Integer(7)))])))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_partial", + "before": { + "cpu": 172969, + "memory": 664, + "bytes": 20, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 72723, + "memory": 432, + "bytes": 13, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_direct", + "before": { + "cpu": 215979, + "memory": 612, + "bytes": 18, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_trace", + "before": { + "cpu": 387477, + "memory": 1344, + "bytes": 32, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 407519, + "memory": 2038, + "bytes": 37, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: utf8_decoded", + "before": { + "cpu": 339937, + "memory": 818, + "bytes": 19, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_reverse", + "before": { + "cpu": 215979, + "memory": 612, + "bytes": 18, + "result": "(con bytestring #68c3a96c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con bytestring #68c3a96c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_cold", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 41, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_bound", + "before": { + "cpu": 702975, + "memory": 2976, + "bytes": 58, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 563017, + "memory": 2670, + "bytes": 55, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: utf8_captured", + "before": { + "cpu": 563477, + "memory": 2444, + "bytes": 37, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 407519, + "memory": 2038, + "bytes": 34, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: utf8_escaping", + "before": { + "cpu": 703435, + "memory": 2750, + "bytes": 43, + "result": "(constr 0\n (con bytestring #68c3a96c6c6f)\n (con string \"h\u00e9llo\")\n (con string \"h\u00e9llo\"))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 455519, + "memory": 2338, + "bytes": 39, + "result": "(constr 0\n (con bytestring #68c3a96c6c6f)\n (con string \"h\u00e9llo\")\n (con string \"h\u00e9llo\"))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: utf8_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 47, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: utf8_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_oversaturated", + "before": { + "cpu": 135979, + "memory": 112, + "bytes": 20, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(String(\"h\u00e9llo\")))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(String(\"h\u00e9llo\")))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_partial", + "before": { + "cpu": 215979, + "memory": 612, + "bytes": 18, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + }, + "after": { + "cpu": 140058, + "memory": 406, + "bytes": 16, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_reverse_invalid", + "before": { + "cpu": 92058, + "memory": 106, + "bytes": 13, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + }, + "after": { + "cpu": 92058, + "memory": 106, + "bytes": 15, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_wrong_tag", + "before": { + "cpu": 33952, + "memory": 132, + "bytes": 10, + "result": "error: Runtime(TypeMismatch(Data, ProtoList(Integer, [])))", + "logs": [] + }, + "after": { + "cpu": 33952, + "memory": 132, + "bytes": 12, + "result": "error: Runtime(TypeMismatch(Data, ProtoList(Integer, [])))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_wrong_tag", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 10, + "result": "error: Runtime(TypeMismatch(List(Pair(Data, Data)), ProtoList(Data, [])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 12, + "result": "error: Runtime(TypeMismatch(List(Pair(Data, Data)), ProtoList(Data, [])))", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_tag", + "before": { + "cpu": 556734, + "memory": 2496, + "bytes": 29, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_fields", + "before": { + "cpu": 556831, + "memory": 2496, + "bytes": 29, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_rebuild", + "before": { + "cpu": 848877, + "memory": 3360, + "bytes": 36, + "result": "(con data (Constr 0 [I 7]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con data (Constr 0 [I 7]))", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_known_reverse", + "before": { + "cpu": 838224, + "memory": 3060, + "bytes": 51, + "result": "(con data (Constr 3 [I 7]))", + "logs": [ + "after decoding" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 36, + "result": "(con data (Constr 3 [I 7]))", + "logs": [ + "after decoding" + ] + } + }, + { + "input": "representation cancellation: constructor_wrong_variant", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 47, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 55, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_bad_tag", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "fields evaluated" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 52, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "fields evaluated" + ] + } + }, + { + "input": "representation cancellation: constructor_bad_fields", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 22, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 19, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "constant folding: shared_prefix_distinct_results", + "before": { + "cpu": 1305326, + "memory": 1526, + "bytes": 64, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + }, + "after": { + "cpu": 48100, + "memory": 400, + "bytes": 87, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + } + }, + { + "input": "constant folding: repeated_literal_distinct_results", + "before": { + "cpu": 1257326, + "memory": 1226, + "bytes": 100, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + }, + "after": { + "cpu": 48100, + "memory": 400, + "bytes": 87, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + } + }, + { + "input": "constant folding: expanding_data_list", + "before": { + "cpu": 74033, + "memory": 432, + "bytes": 42, + "result": "(con (list data) [(I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 126, + "result": "(con (list data) [(I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7)])", + "logs": [] + } + }, + { + "input": "constant folding: addition", + "before": { + "cpu": 181308, + "memory": 602, + "bytes": 10, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "constant folding: nested_arithmetic", + "before": { + "cpu": 336261, + "memory": 1004, + "bytes": 15, + "result": "(con integer 84)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con integer 84)", + "logs": [] + } + }, + { + "input": "constant folding: bound_arithmetic", + "before": { + "cpu": 384261, + "memory": 1304, + "bytes": 18, + "result": "(con integer 84)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con integer 84)", + "logs": [] + } + }, + { + "input": "constant folding: division", + "before": { + "cpu": 212030, + "memory": 601, + "bytes": 10, + "result": "(con integer -3)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer -3)", + "logs": [] + } + }, + { + "input": "constant folding: division_zero", + "before": { + "cpu": 132030, + "memory": 101, + "bytes": 10, + "result": "error: Runtime(DivisionByZero(7, 0))", + "logs": [] + }, + "after": { + "cpu": 132030, + "memory": 101, + "bytes": 10, + "result": "error: Runtime(DivisionByZero(7, 0))", + "logs": [] + } + }, + { + "input": "constant folding: wrong_integer_shape", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([120])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([120])))", + "logs": [] + } + }, + { + "input": "constant folding: byte_append", + "before": { + "cpu": 81446, + "memory": 602, + "bytes": 18, + "result": "(con bytestring #61626364)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 12, + "result": "(con bytestring #61626364)", + "logs": [] + } + }, + { + "input": "constant folding: byte_slice", + "before": { + "cpu": 132568, + "memory": 804, + "bytes": 19, + "result": "(con bytestring #6263)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con bytestring #6263)", + "logs": [] + } + }, + { + "input": "constant folding: byte_length", + "before": { + "cpu": 70200, + "memory": 410, + "bytes": 14, + "result": "(con integer 4)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 4)", + "logs": [] + } + }, + { + "input": "constant folding: byte_compare", + "before": { + "cpu": 109173, + "memory": 601, + "bytes": 20, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: string_append", + "before": { + "cpu": 201014, + "memory": 606, + "bytes": 25, + "result": "(con string \"hello world\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 19, + "result": "(con string \"hello world\")", + "logs": [] + } + }, + { + "input": "constant folding: encode_utf8", + "before": { + "cpu": 220784, + "memory": 412, + "bytes": 28, + "result": "(con bytestring #e0b8aae0b8a7e0b8b1e0b8aae0b894e0b8b5)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 26, + "result": "(con bytestring #e0b8aae0b8a7e0b8b1e0b8aae0b894e0b8b5)", + "logs": [] + } + }, + { + "input": "constant folding: decode_utf8", + "before": { + "cpu": 140058, + "memory": 406, + "bytes": 16, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + } + }, + { + "input": "constant folding: invalid_utf8", + "before": { + "cpu": 92058, + "memory": 106, + "bytes": 11, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + }, + "after": { + "cpu": 92058, + "memory": 106, + "bytes": 11, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + } + }, + { + "input": "constant folding: integer_data", + "before": { + "cpu": 63399, + "memory": 432, + "bytes": 8, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "constant folding: decode_integer_data", + "before": { + "cpu": 68844, + "memory": 432, + "bytes": 11, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: wrong_data_variant", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "constant folding: list_data", + "before": { + "cpu": 81952, + "memory": 432, + "bytes": 12, + "result": "(con data (List [I 7]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (List [I 7]))", + "logs": [] + } + }, + { + "input": "constant folding: map_data", + "before": { + "cpu": 116346, + "memory": 432, + "bytes": 11, + "result": "(con data (Map []))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con data (Map []))", + "logs": [] + } + }, + { + "input": "constant folding: data_equal", + "before": { + "cpu": 1114643, + "memory": 601, + "bytes": 16, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: serialise_data", + "before": { + "cpu": 2070166, + "memory": 410, + "bytes": 11, + "result": "(con bytestring #07)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con bytestring #07)", + "logs": [] + } + }, + { + "input": "constant folding: list_head", + "before": { + "cpu": 147250, + "memory": 532, + "bytes": 11, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: list_tail", + "before": { + "cpu": 145763, + "memory": 532, + "bytes": 11, + "result": "(con (list integer) [8])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con (list integer) [8])", + "logs": [] + } + }, + { + "input": "constant folding: empty_head", + "before": { + "cpu": 83250, + "memory": 132, + "bytes": 9, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + }, + "after": { + "cpu": 83250, + "memory": 132, + "bytes": 11, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + } + }, + { + "input": "constant folding: empty_tail", + "before": { + "cpu": 81763, + "memory": 132, + "bytes": 9, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + }, + "after": { + "cpu": 81763, + "memory": 132, + "bytes": 11, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + } + }, + { + "input": "constant folding: list_null", + "before": { + "cpu": 138533, + "memory": 532, + "bytes": 9, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: pair_first", + "before": { + "cpu": 221995, + "memory": 632, + "bytes": 15, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: pair_second", + "before": { + "cpu": 222092, + "memory": 632, + "bytes": 15, + "result": "(con bytestring #61)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con bytestring #61)", + "logs": [] + } + }, + { + "input": "constant folding: trace_before", + "before": { + "cpu": 352806, + "memory": 1334, + "bytes": 24, + "result": "(con integer 42)", + "logs": [ + "before" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 22, + "result": "(con integer 42)", + "logs": [ + "before" + ] + } + }, + { + "input": "constant folding: trace_builtin", + "before": { + "cpu": 155598, + "memory": 732, + "bytes": 20, + "result": "(con integer 7)", + "logs": [ + "keep me" + ] + }, + "after": { + "cpu": 203598, + "memory": 1032, + "bytes": 22, + "result": "(con integer 7)", + "logs": [ + "keep me" + ] + } + }, + { + "input": "constant folding: cold_failure", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 15, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: selected_branch", + "before": { + "cpu": 501139, + "memory": 1935, + "bytes": 39, + "result": "(con integer 42)", + "logs": [ + "yes" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 19, + "result": "(con integer 42)", + "logs": [ + "yes" + ] + } + }, + { + "input": "constant folding: strict_failure_order", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 26, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 33, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + } + }, + { + "input": "constant folding: unsupported_hash", + "before": { + "cpu": 341340, + "memory": 404, + "bytes": 11, + "result": "(con bytestring #2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 40, + "result": "(con bytestring #2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881)", + "logs": [] + } + }, + { + "input": "constant folding: partial", + "before": { + "cpu": 181308, + "memory": 602, + "bytes": 10, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 229308, + "memory": 902, + "bytes": 13, + "result": "(con integer 8)", + "log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2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a7a)", + "logs": [] + } + }, + { + "input": "constant folding: repeated_call", + "before": { + "cpu": 559724, + "memory": 1706, + "bytes": 26, + "result": "(constr 0 (con integer 42) (con integer 42) (con integer 42))", + "logs": [] + }, + "after": { + "cpu": 64100, + "memory": 500, + "bytes": 12, + "result": "(constr 0 (con integer 42) (con integer 42) (con integer 42))", + "logs": [] + } + }, + { + "input": "pair projection: literal_first", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair projection: literal_second", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair projection: traced_first", + "before": { + "cpu": 251598, + "memory": 1332, + "bytes": 28, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: traced_second", + "before": { + "cpu": 251598, + "memory": 1332, + "bytes": 28, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: made_data_first", + "before": { + "cpu": 155646, + "memory": 1032, + "bytes": 19, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 18, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair projection: made_data_second", + "before": { + "cpu": 155646, + "memory": 1032, + "bytes": 19, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 18, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair projection: decoded_first", + "before": { + "cpu": 136688, + "memory": 832, + "bytes": 15, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "pair projection: decoded_second", + "before": { + "cpu": 136688, + "memory": 832, + "bytes": 15, + "result": "(con (list data) [])", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con (list data) [])", + "logs": [] + } + }, + { + "input": "pair projection: bad_decoder_first", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair projection: bad_decoder_second", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair projection: ignored_failure_first", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 34, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair projection: ignored_failure_second", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 34, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair projection: wrong_subject_first", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair projection: wrong_subject_second", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair projection: native_constructor_first", + "before": { + "cpu": 112100, + "memory": 800, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair projection: native_constructor_second", + "before": { + "cpu": 112100, + "memory": 800, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair projection: body", + "before": { + "cpu": 588304, + "memory": 2466, + "bytes": 44, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + }, + "after": { + "cpu": 668304, + "memory": 2966, + "bytes": 49, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + } + }, + { + "input": "pair projection: both", + "before": { + "cpu": 416806, + "memory": 1734, + "bytes": 31, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: neither", + "before": { + "cpu": 251598, + "memory": 1332, + "bytes": 28, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: delay", + "before": { + "cpu": 283598, + "memory": 1532, + "bytes": 28, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 427598, + "memory": 2432, + "bytes": 36, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: lambda", + "before": { + "cpu": 471096, + "memory": 2364, + "bytes": 46, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + }, + "after": { + "cpu": 647096, + "memory": 3464, + "bytes": 56, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + } + }, + { + "input": "pair projection: repeated", + "before": { + "cpu": 416806, + "memory": 1734, + "bytes": 31, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: two_projections_first", + "before": { + "cpu": 652304, + "memory": 2866, + "bytes": 51, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair projection: two_projections_second", + "before": { + "cpu": 652304, + "memory": 2866, + "bytes": 51, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair projection: unconsumed_lambda_failure", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 39, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair projection: unconsumed_delay_failure", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 39, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair projection: roundtrip_valid_first", + "before": { + "cpu": 962941, + "memory": 4692, + "bytes": 62, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 1074941, + "memory": 5392, + "bytes": 67, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair projection: roundtrip_valid_second", + "before": { + "cpu": 962941, + "memory": 4692, + "bytes": 62, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 1074941, + "memory": 5392, + "bytes": 67, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair projection: roundtrip_bad_tag_first", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 65, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair projection: roundtrip_bad_tag_second", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 65, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "recursive parameters: self_forwarding", + "before": { + "cpu": 1777056, + "memory": 8010, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1921056, + "memory": 8910, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mutual_forwarding", + "before": { + "cpu": 2049056, + "memory": 9710, + "bytes": 83, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 2209056, + "memory": 10710, + "bytes": 82, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mutual_consumed", + "before": { + "cpu": 2049056, + "memory": 9710, + "bytes": 82, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 2529056, + "memory": 12710, + "bytes": 99, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "recursive parameters: recursive_trace_order", + "before": { + "cpu": 3078044, + "memory": 14102, + "bytes": 149, + "result": "(con integer 42)", + "logs": [ + "retained", + "discarded", + "discarded", + "retained", + "retained", + "discarded" + ] + }, + "after": { + "cpu": 3318044, + "memory": 15602, + "bytes": 134, + "result": "(con integer 42)", + "logs": [ + "retained", + "discarded", + "discarded", + "retained", + "retained", + "discarded" + ] + } + }, + { + "input": "recursive parameters: recursive_failure_order", + "before": { + "cpu": 272637, + "memory": 167, + "bytes": 145, + "result": "error: ExplicitErrorTerm", + "logs": [ + "retained", + "discarded" + ] + }, + "after": { + "cpu": 272637, + "memory": 167, + "bytes": 130, + "result": "error: ExplicitErrorTerm", + "logs": [ + "retained", + "discarded" + ] + } + }, + { + "input": "recursive parameters: all_unused_self", + "before": { + "cpu": 1171300, + "memory": 5430, + "bytes": 70, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + }, + "after": { + "cpu": 1523300, + "memory": 7630, + "bytes": 75, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + } + }, + { + "input": "recursive parameters: all_unused_mutual", + "before": { + "cpu": 1603300, + "memory": 8130, + "bytes": 95, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + }, + "after": { + "cpu": 1635300, + "memory": 8330, + "bytes": 89, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + } + }, + { + "input": "recursive parameters: all_unused_cold", + "before": { + "cpu": 192100, + "memory": 1300, + "bytes": 100, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: entry_failure", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 63, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 70, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + } + }, + { + "input": "recursive parameters: partial", + "before": { + "cpu": 1319515, + "memory": 6107, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1415515, + "memory": 6707, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: escaping", + "before": { + "cpu": 1367515, + "memory": 6407, + "bytes": 41, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1415515, + "memory": 6707, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: oversaturated", + "before": { + "cpu": 304100, + "memory": 2000, + "bytes": 22, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 304100, + "memory": 2000, + "bytes": 22, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: compound_dependency", + "before": { + "cpu": 1649931, + "memory": 6911, + "bytes": 44, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 2081931, + "memory": 9611, + "bytes": 54, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mixed_delayed", + "before": { + "cpu": 3471636, + "memory": 16348, + "bytes": 95, + "result": "(con integer 84)", + "logs": [ + "delayed" + ] + }, + "after": { + "cpu": 3727636, + "memory": 17948, + "bytes": 89, + "result": "(con integer 84)", + "logs": [ + "delayed" + ] + } + } + ] + }, + "current_report": { + "settings": "v1; Plutus V3/PV11; UPLC 1.1.0; bundled V3 default cost model; CPU=100000000; memory=2000000; raw Flat bytes before ledger application; O0 vs static lift/unused-parameters(nonrecursive+recursive)/ANF once/rules1+2+3+4+dead-bindings+recursive-reachability+representation-inverse+force-delay+known-bool+int-bytes/bound-constr+known-fields+list+data+idata-bdata-listdata-mapdata-constrdata+restricted-pair-cleanup/static-lift+unused-parameters+constant-fold+cleanup(unbudgeted-fixed-point,all-pure-representable)/adjacent-application-fusion/recursion/hygiene/lower+forced-builtin-sharing+constant-prefix-sharing/late-value-binding-cleanup+native-value-application-packing", + "sources": { + "Cardano.Tx": "module Cardano.Tx exposing (validAfter, signedBy)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\n\n-- V3 TxInfo field 7 is the validity interval. Require a finite lower bound.\n-- Times are POSIX milliseconds, not slots or the current wall-clock time.\nvalidAfter : Data -> int\nvalidAfter tx =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, Constr pair(0, [ Constr pair(0, [ Constr pair(1, [ I time ]), _ ]), _ ]), _, _, _, _, _, _, _, _ ]) -> time\n _ -> fail\n\n-- V3 TxInfo field 8 contains every extra signatory.\nsignedBy : Data -> Bytes -> bool\nsignedBy tx owner =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, _, List signers, _, _, _, _, _, _, _ ]) -> hasSigner signers (lower owner)\n _ -> fail\n\nhasSigner : list Data -> bytes -> bool\nhasSigner signers owner =\n case signers of\n [] -> False\n B signer :: rest ->\n if Builtin.equalsByteString signer owner then True\n else hasSigner rest owner\n _ -> fail\n", + "ConstantInputs": "//! Shared inputs for the constant-evaluation trial and its explicit measurements.\nuse nash_ir::{\n build::Builder,\n core::{Binder, Core},\n ty::Ty,\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant as C, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(&'static str, &'a Core<'a>, bool)> {\n let a = b.arena;\n let bytes = |s| b.lit(C::byte_string(a, s));\n let string = |s| b.lit(C::string(a, s));\n let int = b.int(7);\n let data = b.lit(C::data(a, D::integer_from(a, 7)));\n let list = b.lit(C::proto_list(\n a,\n &Type::Integer,\n a.alloc([C::integer_from(a, 7), C::integer_from(a, 8)]),\n ));\n let empty = b.lit(C::proto_list(a, &Type::Integer, &[]));\n let pair = b.lit(C::proto_pair(\n a,\n &Type::Integer,\n &Type::ByteString,\n C::integer_from(a, 7),\n C::byte_string(a, b\"a\"),\n ));\n let call = |f, args: &[&'a Core<'a>]| b.builtin(f, args, Ty::Erased);\n let add = call(F::AddInteger, &[b.int(20), b.int(22)]);\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: add.ty,\n };\n let dlist = b.lit(C::proto_list(\n a,\n &Type::Data,\n a.alloc([C::data(a, D::integer_from(a, 7))]),\n ));\n let dmap = b.lit(C::proto_list(\n a,\n a.alloc(Type::Pair(&Type::Data, &Type::Data)),\n &[],\n ));\n let expanding = b.lit(C::data(\n a,\n D::list(a, a.alloc_slice_copy(&[D::integer_from(a, 7); 30])),\n ));\n let prefix = string(a.as_bump().alloc_str(&\"prefix\".repeat(6)));\n let shared = Binder {\n name: b.fresh(\"prefix\"),\n ty: prefix.ty,\n };\n let shared_prefix = b.let_(\n shared,\n prefix,\n b.constr(\n 0,\n &[\n call(\n F::AppendString,\n &[b.var(shared.name, shared.ty), string(\"x\")],\n ),\n call(\n F::AppendString,\n &[b.var(shared.name, shared.ty), string(\"y\")],\n ),\n ],\n Ty::Erased,\n ),\n );\n let distinct_results = b.constr(\n 0,\n &[\n call(F::AppendString, &[prefix, string(\"x\")]),\n call(F::AppendString, &[prefix, string(\"y\")]),\n ],\n Ty::Erased,\n );\n vec![\n (\"shared_prefix_distinct_results\", shared_prefix, false),\n (\"repeated_literal_distinct_results\", distinct_results, false),\n (\n \"expanding_data_list\",\n call(F::UnListData, &[expanding]),\n false,\n ),\n (\"addition\", add, false),\n (\n \"nested_arithmetic\",\n call(F::MultiplyInteger, &[add, b.int(2)]),\n false,\n ),\n (\n \"bound_arithmetic\",\n b.let_(\n x,\n add,\n call(F::MultiplyInteger, &[b.var(x.name, x.ty), b.int(2)]),\n ),\n false,\n ),\n (\n \"division\",\n call(F::DivideInteger, &[b.int(-7), b.int(3)]),\n false,\n ),\n (\n \"division_zero\",\n call(F::DivideInteger, &[int, b.int(0)]),\n true,\n ),\n (\n \"wrong_integer_shape\",\n call(F::AddInteger, &[bytes(b\"x\"), int]),\n true,\n ),\n (\n \"byte_append\",\n call(F::AppendByteString, &[bytes(b\"ab\"), bytes(b\"cd\")]),\n false,\n ),\n (\n \"byte_slice\",\n call(F::SliceByteString, &[b.int(1), b.int(2), bytes(b\"abcd\")]),\n false,\n ),\n (\n \"byte_length\",\n call(F::LengthOfByteString, &[bytes(b\"abcd\")]),\n false,\n ),\n (\n \"byte_compare\",\n call(F::LessThanByteString, &[bytes(b\"abc\"), bytes(b\"abd\")]),\n false,\n ),\n (\n \"string_append\",\n call(F::AppendString, &[string(\"hello \"), string(\"world\")]),\n false,\n ),\n (\"encode_utf8\", call(F::EncodeUtf8, &[string(\"\u0e2a\u0e27\u0e31\u0e2a\u0e14\u0e35\")]), false),\n (\n \"decode_utf8\",\n call(F::DecodeUtf8, &[bytes(\"h\u00e9llo\".as_bytes())]),\n false,\n ),\n (\"invalid_utf8\", call(F::DecodeUtf8, &[bytes(&[255])]), true),\n (\"integer_data\", call(F::IData, &[int]), false),\n (\"decode_integer_data\", call(F::UnIData, &[data]), false),\n (\"wrong_data_variant\", call(F::UnBData, &[data]), true),\n (\"list_data\", call(F::ListData, &[dlist]), false),\n (\"map_data\", call(F::MapData, &[dmap]), false),\n (\"data_equal\", call(F::EqualsData, &[data, data]), false),\n (\"serialise_data\", call(F::SerialiseData, &[data]), false),\n (\"list_head\", call(F::HeadList, &[list]), false),\n (\"list_tail\", call(F::TailList, &[list]), false),\n (\"empty_head\", call(F::HeadList, &[empty]), true),\n (\"empty_tail\", call(F::TailList, &[empty]), true),\n (\"list_null\", call(F::NullList, &[empty]), false),\n (\"pair_first\", call(F::FstPair, &[pair]), false),\n (\"pair_second\", call(F::SndPair, &[pair]), false),\n (\"trace_before\", b.trace(string(\"before\"), add), false),\n (\n \"trace_builtin\",\n call(F::Trace, &[string(\"keep me\"), int]),\n false,\n ),\n (\n \"cold_failure\",\n b.if_(\n b.lit(C::bool(a, true)),\n int,\n call(F::DivideInteger, &[int, b.int(0)]),\n ),\n false,\n ),\n (\n \"selected_branch\",\n b.if_(\n call(F::EqualsInteger, &[int, b.int(7)]),\n b.trace(string(\"yes\"), add),\n b.trace(string(\"no\"), b.error(Ty::Erased)),\n ),\n false,\n ),\n (\n \"strict_failure_order\",\n call(\n F::AddInteger,\n &[\n b.trace(string(\"first\"), b.error(int.ty)),\n call(F::DivideInteger, &[int, b.int(0)]),\n ],\n ),\n true,\n ),\n (\"unsupported_hash\", call(F::Sha2_256, &[bytes(b\"x\")]), false),\n (\n \"partial\",\n b.app(\n b.builtin(F::AddInteger, &[int], Ty::Erased),\n &[b.int(1)],\n Ty::Erased,\n ),\n false,\n ),\n (\n \"large_input\",\n call(\n F::AppendByteString,\n &[bytes(a.alloc_slice_copy(&[42; 4096])), bytes(b\"z\")],\n ),\n false,\n ),\n (\n \"repeated_call\",\n b.constr(0, &[add, add, add], Ty::Erased),\n false,\n ),\n ]\n}\n", + "Eq": "module Eq exposing ( Eq )\n\n\nimport Literal\nimport Logic exposing ( not, xor, (&&) )\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\n\n{-| Compare values for equality and inequality. -}\ntrait Eq 'a where\n eq : 'a -> 'a -> bool\n\n neq : 'a -> 'a -> bool\n neq a b = not (eq a b)\n\n\nimpl Eq int where\n eq = Builtin.equalsInteger\n\n\nimpl Eq bytes where\n eq = Builtin.equalsByteString\n\n\nimpl Eq string where\n eq = Builtin.equalsString\n\n\nimpl Eq bool where\n eq a b = not (xor a b)\n\n\nimpl Eq unit where\n eq _ _ = True\n\n\nimpl Eq (list ('a : Big)) where\n eq xs ys =\n eq (Builtin.listData xs) (Builtin.listData ys)\n\n\nimpl Eq 'a => Eq (list ('a : Little)) where\n eq xs ys =\n case xs of\n [] ->\n case ys of\n [] ->\n True\n\n _ :: _ ->\n False\n\n x :: restX ->\n case ys of\n [] ->\n False\n\n y :: restY ->\n eq x y && eq restX restY\n\n\nimpl ( Eq 'a, Eq 'b ) => Eq (pair 'a 'b) where\n eq a b =\n let\n pair(firstA, secondA) = a\n\n pair(firstB, secondB) = b\n in\n eq firstA firstB && eq secondA secondB\n\n\nimpl Eq (map ('k : Big) ('v : Big)) where\n eq xs ys = eq (Builtin.mapData xs) (Builtin.mapData ys)\n\n\nimpl ( Eq 'k, Eq 'v ) => Eq (map ('k : Little) 'v) where\n eq = eqMapEntries\n\n\nimpl Eq 'v => Eq (map ('k : Big) ('v : Little)) where\n eq = eqMapEntries\n\n\neqMapEntries : ( Eq 'k, Eq 'v ) => list (pair 'k 'v) -> list (pair 'k 'v) -> bool\neqMapEntries = eq\n\n\nimpl Eq value where\n eq a b = Builtin.equalsData (Builtin.valueData a) (Builtin.valueData b)\n", + "InverseInputs": "//! Shared semantic and explicit performance inputs for representation cancellation.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, Ty},\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(String, &'a Core<'a>, bool)> {\n let a = b.arena;\n let d = D::integer_from(a, 7);\n let data = Constant::data(a, d);\n let pair = Constant::proto_pair(a, &Type::Data, &Type::Data, data, data);\n let list = Constant::proto_list(a, &Type::Data, a.alloc([data]));\n let map = Constant::proto_list(\n a,\n a.alloc(Type::Pair(&Type::Data, &Type::Data)),\n a.alloc([pair]),\n );\n let mut cases = Vec::new();\n for (name, encode, decode, value, encoded) in [\n (\"integer\", F::IData, F::UnIData, b.int(7), b.lit(data)),\n (\n \"bytes\",\n F::BData,\n F::UnBData,\n b.lit(Constant::byte_string(a, b\"hello\")),\n b.lit(Constant::data(a, D::byte_string(a, b\"hello\"))),\n ),\n (\n \"list\",\n F::ListData,\n F::UnListData,\n b.lit(list),\n b.lit(Constant::data(a, D::list(a, a.alloc([d])))),\n ),\n (\n \"map\",\n F::MapData,\n F::UnMapData,\n b.lit(map),\n b.lit(Constant::data(a, D::map(a, a.alloc([(d, d)])))),\n ),\n (\n \"utf8\",\n F::EncodeUtf8,\n F::DecodeUtf8,\n b.lit(Constant::string(a, \"h\u00e9llo\")),\n b.lit(Constant::byte_string(a, \"h\u00e9llo\".as_bytes())),\n ),\n ] {\n let wrap = |x| b.builtin(decode, &[b.builtin(encode, &[x], encoded.ty)], value.ty);\n let trace = |s, x| b.trace(b.lit(Constant::string(a, s)), x);\n cases.push((format!(\"{name}_direct\"), wrap(value), false));\n cases.push((\n format!(\"{name}_trace\"),\n wrap(trace(\"operand\", value)),\n false,\n ));\n cases.push((\n format!(\"{name}_decoded\"),\n wrap(b.builtin(decode, &[encoded], value.ty)),\n false,\n ));\n cases.push((\n format!(\"{name}_decode_failure\"),\n wrap(b.builtin(decode, &[b.int(0)], value.ty)),\n true,\n ));\n cases.push((\n format!(\"{name}_reverse\"),\n b.builtin(\n encode,\n &[b.builtin(decode, &[encoded], value.ty)],\n encoded.ty,\n ),\n false,\n ));\n cases.push((\n format!(\"{name}_wrong_kind\"),\n wrap(b.with_type(b.lit(Constant::bool(a, false)), value.ty)),\n true,\n ));\n cases.push((\n format!(\"{name}_cold\"),\n b.if_(\n b.lit(Constant::bool(a, true)),\n value,\n wrap(trace(\"cold\", value)),\n ),\n false,\n ));\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: value.ty,\n };\n let y = Binder {\n name: b.fresh(\"encoded\"),\n ty: encoded.ty,\n };\n let z = Binder {\n name: b.fresh(\"alias\"),\n ty: encoded.ty,\n };\n let decoded = b.builtin(decode, &[b.var(z.name, z.ty)], value.ty);\n let bindings = |body| {\n b.let_(\n x,\n trace(\"once\", value),\n b.let_(\n y,\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n b.let_(z, b.var(y.name, y.ty), body),\n ),\n )\n };\n cases.push((\n format!(\"{name}_bound\"),\n bindings(trace(\"after encoding\", decoded)),\n false,\n ));\n cases.push((\n format!(\"{name}_captured\"),\n bindings(b.force(b.delay(decoded), decoded.ty)),\n false,\n ));\n cases.push((\n format!(\"{name}_escaping\"),\n bindings(b.constr(0, &[b.var(y.name, y.ty), decoded, decoded], Ty::Erased)),\n false,\n ));\n cases.push((\n format!(\"{name}_bound_invalid\"),\n b.let_(\n x,\n trace(\n \"operand\",\n b.with_type(b.lit(Constant::bool(a, false)), value.ty),\n ),\n b.let_(\n y,\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n trace(\n \"must not run\",\n b.builtin(decode, &[b.var(y.name, y.ty)], value.ty),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_reverse_bound_invalid\"),\n b.let_(\n y,\n b.with_type(b.int(0), encoded.ty),\n b.let_(\n x,\n b.builtin(decode, &[b.var(y.name, y.ty)], value.ty),\n trace(\n \"must not run\",\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_oversaturated\"),\n b.app(wrap(value), &[b.int(1)], value.ty),\n true,\n ));\n let unknown = Binder {\n name: b.fresh(\"unknown\"),\n ty: value.ty,\n };\n cases.push((\n format!(\"{name}_unknown_invalid\"),\n b.app(\n b.lam(&[unknown], wrap(b.var(unknown.name, unknown.ty))),\n &[b.lit(Constant::bool(a, false))],\n value.ty,\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_partial\"),\n b.app(\n b.builtin(decode, &[], Ty::Erased),\n &[b.builtin(encode, &[value], encoded.ty)],\n value.ty,\n ),\n false,\n ));\n }\n let bad_utf8 = b.lit(Constant::byte_string(a, &[255]));\n cases.push((\n \"utf8_reverse_invalid\".into(),\n b.builtin(\n F::EncodeUtf8,\n &[b.builtin(F::DecodeUtf8, &[bad_utf8], Ty::Const(&ConstTy::String))],\n bad_utf8.ty,\n ),\n true,\n ));\n for (name, encode, decode, typ) in [\n (\"list_wrong_tag\", F::ListData, F::UnListData, &Type::Integer),\n (\"map_wrong_tag\", F::MapData, F::UnMapData, &Type::Data),\n ] {\n let value = b.lit(Constant::proto_list(a, typ, &[]));\n cases.push((\n name.into(),\n b.builtin(decode, &[b.builtin(encode, &[value], Ty::Erased)], value.ty),\n true,\n ));\n }\n let data_ty = b.lit(data).ty;\n let fields = Binder {\n name: b.fresh(\"fields\"),\n ty: b.lit(list).ty,\n };\n let tag = Binder {\n name: b.fresh(\"tag\"),\n ty: b.int(0).ty,\n };\n let encoded = Binder {\n name: b.fresh(\"constructor\"),\n ty: data_ty,\n };\n let payload = Binder {\n name: b.fresh(\"payload\"),\n ty: Ty::Erased,\n };\n let p = b.var(payload.name, payload.ty);\n let fst = b.builtin(F::FstPair, &[p], tag.ty);\n let snd = b.builtin(F::SndPair, &[p], fields.ty);\n let constructor = b.builtin(\n F::ConstrData,\n &[b.var(tag.name, tag.ty), b.var(fields.name, fields.ty)],\n data_ty,\n );\n let bind = |body| {\n b.let_(\n tag,\n b.int(0),\n b.let_(\n fields,\n b.lit(list),\n b.let_(\n encoded,\n constructor,\n b.let_(\n payload,\n b.builtin(\n F::UnConstrData,\n &[b.var(encoded.name, encoded.ty)],\n Ty::Erased,\n ),\n body,\n ),\n ),\n ),\n )\n };\n cases.push((\"constructor_tag\".into(), bind(fst), false));\n cases.push((\"constructor_fields\".into(), bind(snd), false));\n cases.push((\n \"constructor_rebuild\".into(),\n bind(b.builtin(F::ConstrData, &[fst, snd], data_ty)),\n false,\n ));\n for (name, subject, fails) in [\n (\n \"constructor_known_reverse\",\n b.lit(Constant::data(a, D::constr(a, 3, a.alloc([d])))),\n false,\n ),\n (\"constructor_wrong_variant\", b.lit(data), true),\n ] {\n cases.push((\n name.into(),\n b.let_(\n encoded,\n subject,\n b.let_(\n payload,\n b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased),\n b.trace(\n b.lit(Constant::string(a, \"after decoding\")),\n b.builtin(F::ConstrData, &[fst, snd], data_ty),\n ),\n ),\n ),\n fails,\n ));\n }\n let bad_tag = b.with_type(b.lit(Constant::bool(a, false)), tag.ty);\n cases.push((\n \"constructor_bad_tag\".into(),\n b.let_(\n tag,\n bad_tag,\n b.let_(\n fields,\n b.trace(b.lit(Constant::string(a, \"fields evaluated\")), b.lit(list)),\n b.let_(\n encoded,\n constructor,\n b.builtin(\n F::FstPair,\n &[b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased)],\n tag.ty,\n ),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n \"constructor_bad_fields\".into(),\n b.let_(\n tag,\n b.int(0),\n b.let_(\n fields,\n b.with_type(b.lit(Constant::bool(a, false)), fields.ty),\n b.let_(\n encoded,\n constructor,\n b.builtin(\n F::SndPair,\n &[b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased)],\n fields.ty,\n ),\n ),\n ),\n ),\n true,\n ));\n cases\n}\n", + "Lift": "module Lift exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait Lift 'a 'b where\n lift : 'a -> 'b\n lower : 'b -> 'a\n\nimpl Lift int Int where\n lift value = Builtin.iData value\n lower value = Builtin.unIData value\n\nimpl Lift bytes Bytes where\n lift value = Builtin.bData value\n lower value = Builtin.unBData value\n", + "Literal": "module Literal exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait FromInt 'a where\n fromInt : int -> 'a\n\ntrait FromString 'a where\n fromString : string -> 'a\n\ntrait FromBytes 'a where\n fromBytes : bytes -> 'a\n\nimpl FromInt int where\n fromInt x = x\n\nimpl FromString string where\n fromString x = x\n\nimpl FromBytes bytes where\n fromBytes x = x\n\ntrait FromBool 'a where\n fromBool : bool -> 'a\n\ntrait FromUnit 'a where\n fromUnit : unit -> 'a\n\nimpl FromBool bool where\n fromBool value = value\n\nimpl FromUnit unit where\n fromUnit value = value\n", + "Logic": "module Logic exposing ( not, and, or, xor, (&&), (||) )\n\n\nimport Primitive\nimport Lift exposing ( Lift )\n\n\ninfix right 2 (||) = or\n\n\ninfix right 3 (&&) = and\n\n\n{-| Negate a Big or little Boolean, returning bool. -}\nnot : Lift bool 'a => 'a -> bool\nnot value =\n if lower value then\n Primitive.False\n else\n Primitive.True\n\n\n{-| Boolean conjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nand : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nand a b =\n if lower a then\n lower b\n else\n Primitive.False\n\n\n{-| Boolean disjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nor a b =\n if lower a then\n Primitive.True\n else\n lower b\n\n\n{-| Return True when the Boolean operands differ. -}\nxor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nxor a b =\n if lower a then\n not b\n else\n lower b\n", + "PairInputs": "//! Inputs shared by pair-projection snapshots and explicit measurements.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, Ty},\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant as C, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(String, &'a Core<'a>, bool)> {\n let a = b.arena;\n let int = b.int(0).ty;\n let pair = b.lit(C::proto_pair(\n a,\n &Type::Integer,\n &Type::Integer,\n C::integer_from(a, 7),\n C::integer_from(a, 8),\n ));\n let data = b.lit(C::data(a, D::integer_from(a, 7)));\n let made = b.builtin(\n F::MkPairData,\n &[data, data],\n Ty::Const(a.alloc(ConstTy::Pair(data.ty, data.ty))),\n );\n let unwrapped = b.builtin(\n F::UnConstrData,\n &[b.lit(C::data(a, D::constr(a, 0, &[])))],\n Ty::Const(a.alloc(ConstTy::Pair(\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n ))),\n );\n let trace = |s, x| b.trace(b.lit(C::string(a, s)), x);\n let mut cases = Vec::new();\n for (name, subject, left_ty, right_ty, fails) in [\n (\"literal\", pair, int, int, false),\n (\"traced\", trace(\"subject\", pair), int, int, false),\n (\"made_data\", made, data.ty, data.ty, false),\n (\n \"decoded\",\n unwrapped,\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n false,\n ),\n (\n \"bad_decoder\",\n b.builtin(F::UnConstrData, &[data], unwrapped.ty),\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n true,\n ),\n (\n \"ignored_failure\",\n b.builtin(\n F::MkPairData,\n &[data, trace(\"unused field\", b.error(data.ty))],\n made.ty,\n ),\n data.ty,\n data.ty,\n true,\n ),\n (\n \"wrong_subject\",\n b.with_type(b.int(1), pair.ty),\n int,\n int,\n true,\n ),\n // Generic UPLC case accepts this, whereas fstPair would reject it.\n (\n \"native_constructor\",\n b.with_type(b.constr(0, &[b.int(7), b.int(8)], Ty::Erased), pair.ty),\n int,\n int,\n false,\n ),\n ] {\n for second in [false, true] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: left_ty,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: right_ty,\n };\n let selected = if second { y } else { x };\n let value = b.var(selected.name, selected.ty);\n let core = b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: value,\n }],\n None,\n value.ty,\n );\n cases.push((\n format!(\"{name}_{}\", if second { \"second\" } else { \"first\" }),\n core,\n fails,\n ));\n }\n }\n for mode in [\"body\", \"both\", \"neither\", \"delay\", \"lambda\", \"repeated\"] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: int,\n };\n let xv = b.var(x.name, x.ty);\n let body = match mode {\n \"both\" => b.builtin(F::AddInteger, &[xv, b.var(y.name, y.ty)], int),\n \"neither\" => b.int(42),\n \"delay\" => b.delay(xv),\n \"lambda\" => b.lam(\n &[Binder {\n name: b.fresh(\"unused\"),\n ty: int,\n }],\n xv,\n ),\n \"repeated\" => b.builtin(F::AddInteger, &[xv, xv], int),\n _ => trace(\"body\", b.builtin(F::AddInteger, &[xv, b.int(1)], int)),\n };\n let core = b.case(\n CaseKind::Pair,\n trace(\"subject\", pair),\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body,\n }],\n None,\n body.ty,\n );\n // Force/application is after the case, exposing any misplaced strict work.\n let core = match mode {\n \"delay\" => b.force(core, int),\n \"lambda\" => b.app(core, &[trace(\"argument\", b.int(0))], int),\n _ => core,\n };\n cases.push((mode.into(), core, false));\n }\n for second in [false, true] {\n let select = |subject| {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: int,\n };\n let selected = if second { y } else { x };\n b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: b.var(selected.name, int),\n }],\n None,\n int,\n )\n };\n let first = select(trace(\"first\", pair));\n let second_core = select(trace(\"second\", pair));\n cases.push((\n format!(\n \"two_projections_{}\",\n if second { \"second\" } else { \"first\" }\n ),\n b.builtin(F::AddInteger, &[first, second_core], int),\n false,\n ));\n }\n for delayed in [false, true] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: Ty::Const(a.alloc(ConstTy::List(data.ty))),\n };\n let value = b.var(x.name, x.ty);\n let body = if delayed {\n b.delay(value)\n } else {\n b.lam(\n &[Binder {\n name: b.fresh(\"arg\"),\n ty: int,\n }],\n value,\n )\n };\n let subject = b.builtin(\n F::UnConstrData,\n &[trace(\"before failure\", data)],\n unwrapped.ty,\n );\n let case = b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body,\n }],\n None,\n body.ty,\n );\n let ignored = Binder {\n name: b.fresh(\"ignored closure\"),\n ty: case.ty,\n };\n cases.push((\n format!(\n \"unconsumed_{}_failure\",\n if delayed { \"delay\" } else { \"lambda\" }\n ),\n b.let_(ignored, case, b.int(0)),\n true,\n ));\n }\n for bad_tag in [false, true] {\n for second in [false, true] {\n let tag = Binder {\n name: b.fresh(\"tag\"),\n ty: int,\n };\n let fields_ty = Ty::Const(a.alloc(ConstTy::List(data.ty)));\n let fields = Binder {\n name: b.fresh(\"fields\"),\n ty: fields_ty,\n };\n let encoded = Binder {\n name: b.fresh(\"encoded\"),\n ty: data.ty,\n };\n let decoded = Binder {\n name: b.fresh(\"decoded\"),\n ty: unwrapped.ty,\n };\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: fields_ty,\n };\n let selected = if second { y } else { x };\n let body = b.case(\n CaseKind::Pair,\n b.var(decoded.name, decoded.ty),\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: b.var(selected.name, selected.ty),\n }],\n None,\n selected.ty,\n );\n let body = b.let_(\n decoded,\n b.builtin(\n F::UnConstrData,\n &[b.var(encoded.name, encoded.ty)],\n decoded.ty,\n ),\n body,\n );\n let body = b.let_(\n encoded,\n b.builtin(\n F::ConstrData,\n &[b.var(tag.name, tag.ty), b.var(fields.name, fields.ty)],\n encoded.ty,\n ),\n body,\n );\n let body = b.let_(\n fields,\n b.builtin(\n F::MkCons,\n &[\n trace(\"field\", data),\n b.lit(C::proto_list(a, &Type::Data, &[])),\n ],\n fields_ty,\n ),\n body,\n );\n let tag_value = if bad_tag {\n let bytes = b.lit(C::data(a, D::byte_string(a, b\"bad\")));\n b.with_type(\n b.builtin(\n F::UnBData,\n &[trace(\"tag\", bytes)],\n b.lit(C::byte_string(a, b\"bad\")).ty,\n ),\n int,\n )\n } else {\n let tag_data = b.lit(C::data(a, D::integer_from(a, 0)));\n b.builtin(F::UnIData, &[trace(\"tag\", tag_data)], int)\n };\n let body = b.let_(tag, tag_value, body);\n cases.push((\n format!(\n \"roundtrip_{}_{}\",\n if bad_tag { \"bad_tag\" } else { \"valid\" },\n if second { \"second\" } else { \"first\" }\n ),\n body,\n bad_tag,\n ));\n }\n }\n cases\n}\n", + "RecursiveParameterInputs": "//! Recursive parameter fixtures shared with the explicit performance workspace.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, TermTy, Ty},\n};\nuse nash_plutus::{builtin::DefaultFunction as F, constant::Constant};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(&'static str, &'a Core<'a>, bool)> {\n let a = b.arena;\n let int = b.int(0).ty;\n let bool_ = Ty::Const(&ConstTy::Bool);\n let fun = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int, int]), int)));\n let bind = |text, ty| Binder {\n name: b.fresh(text),\n ty,\n };\n let trace = |text, value| b.trace(b.lit(Constant::string(a, text)), value);\n let mut cases = Vec::new();\n for (name, mutual, consumed, effects, failure) in [\n (\"self_forwarding\", false, false, false, false),\n (\"mutual_forwarding\", true, false, false, false),\n (\"mutual_consumed\", true, true, false, false),\n (\"recursive_trace_order\", true, false, true, false),\n (\"recursive_failure_order\", true, false, true, true),\n ] {\n let f = bind(\"f\", fun);\n let g = bind(\"g\", fun);\n let x = bind(\"x\", int);\n let n = bind(\"n\", int);\n let m = bind(\"m\", int);\n let y = bind(\"y\", int);\n let step = |target: Binder<'a>, unused: Binder<'a>, count: Binder<'a>, swapped: bool| {\n let next = b.builtin(F::SubtractInteger, &[b.var(count.name, int), b.int(1)], int);\n let discarded = if failure {\n trace(\"discarded\", b.error(int))\n } else if effects {\n trace(\"discarded\", b.int(7))\n } else {\n b.var(unused.name, int)\n };\n let next = if effects {\n trace(\"retained\", next)\n } else {\n next\n };\n let args = if swapped {\n [next, discarded]\n } else {\n [discarded, next]\n };\n b.if_(\n b.builtin(F::EqualsInteger, &[b.var(count.name, int), b.int(0)], bool_),\n if consumed {\n b.var(unused.name, int)\n } else {\n b.int(42)\n },\n b.app(b.var(target.name, fun), &args, int),\n )\n };\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x, n]),\n static_params: &[],\n body: step(if mutual { g } else { f }, x, n, mutual),\n }];\n if mutual {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[m, y]),\n static_params: &[],\n body: step(f, y, m, false),\n });\n }\n cases.push((\n name,\n b.let_rec(\n &group,\n b.app(b.var(f.name, fun), &[b.int(7), b.int(3)], int),\n ),\n failure,\n ));\n }\n // Removing every parameter must keep definitions cold and execute each call.\n for (name, mutual, cold) in [\n (\"all_unused_self\", false, false),\n (\"all_unused_mutual\", true, false),\n (\"all_unused_cold\", true, true),\n ] {\n let unary = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int]), int)));\n let f = bind(\"f\", unary);\n let g = bind(\"g\", unary);\n let x = bind(\"x\", int);\n let y = bind(\"y\", int);\n let invoke = |target: Binder<'a>, arg| b.app(b.var(target.name, unary), &[arg], int);\n let body = b.if_(\n b.lit(Constant::bool(a, true)),\n trace(\"body\", b.int(21)),\n invoke(if mutual { g } else { f }, b.var(x.name, int)),\n );\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x]),\n static_params: &[],\n body,\n }];\n if mutual {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[y]),\n static_params: &[],\n body: invoke(f, b.var(y.name, int)),\n });\n }\n let calls = b.builtin(\n F::AddInteger,\n &[\n invoke(f, trace(\"entry1\", b.int(0))),\n invoke(if mutual { g } else { f }, trace(\"entry2\", b.int(1))),\n ],\n int,\n );\n let calls = if cold {\n b.if_(b.lit(Constant::bool(a, true)), b.int(42), calls)\n } else {\n calls\n };\n cases.push((name, b.let_rec(&group, calls), false));\n }\n\n for name in [\n \"entry_failure\",\n \"partial\",\n \"escaping\",\n \"oversaturated\",\n \"compound_dependency\",\n \"mixed_delayed\",\n ] {\n let f = bind(\"f\", fun);\n let g = bind(\"g\", fun);\n let x = bind(\"x\", int);\n let n = bind(\"n\", int);\n let y = bind(\"y\", int);\n let m = bind(\"m\", int);\n let unary = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int]), int)));\n let next = b.builtin(F::SubtractInteger, &[b.var(n.name, int), b.int(1)], int);\n let forwarded = if name == \"compound_dependency\" {\n b.builtin(F::AddInteger, &[b.var(x.name, int), b.int(1)], int)\n } else {\n b.var(x.name, int)\n };\n let body = b.if_(\n b.builtin(F::EqualsInteger, &[b.var(n.name, int), b.int(0)], bool_),\n b.int(42),\n b.app(b.var(f.name, fun), &[forwarded, next], int),\n );\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x, n]),\n static_params: &[],\n body,\n }];\n let invoke = b.app(b.var(f.name, fun), &[b.int(7), b.int(2)], int);\n let entry = match name {\n \"entry_failure\" => b.app(\n b.var(f.name, fun),\n &[trace(\"first\", b.error(int)), trace(\"later\", b.int(2))],\n int,\n ),\n \"partial\" => b.app(\n b.app(b.var(f.name, fun), &[b.int(7)], unary),\n &[b.int(2)],\n int,\n ),\n \"escaping\" => {\n let alias = bind(\"alias\", fun);\n b.let_(\n alias,\n b.var(f.name, fun),\n b.app(b.var(alias.name, fun), &[b.int(7), b.int(2)], int),\n )\n }\n \"oversaturated\" => {\n let z = bind(\"z\", int);\n let ty = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int, int]), unary)));\n group[0].binder.ty = ty;\n group[0].body = b.lam(&[z], b.var(z.name, int));\n b.app(b.var(f.name, ty), &[b.int(0), b.int(0), b.int(42)], int)\n }\n \"mixed_delayed\" => {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[y, m]),\n static_params: &[],\n body: trace(\n \"delayed\",\n b.app(b.var(f.name, fun), &[b.int(7), b.int(2)], int),\n ),\n });\n b.builtin(\n F::AddInteger,\n &[\n invoke,\n b.app(b.var(g.name, fun), &[b.int(0), b.int(0)], int),\n ],\n int,\n )\n }\n _ => invoke,\n };\n cases.push((name, b.let_rec(&group, entry), name == \"entry_failure\"));\n }\n cases\n}\n", + "Vesting": "validator module Vesting exposing (main)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\nimport Cardano.Tx exposing (validAfter, signedBy)\n\ntype Datum = Datum { owner : Bytes, deadline : Int }\n\ntype step 'a = Done 'a | Next int 'a\n\ntype alias acc = { total : int, seen : list Int }\n\ntype Redeemer = Claim | Cancel\n\n-- The ledger supplies one V3 ScriptContext; spending datum is in ScriptInfo.\nmain : Data -> unit\nmain ctx =\n case ctx of\n Constr pair(0, [ tx, action, Constr pair(1, [ _, Constr pair(0, [ datum ]) ]) ]) ->\n check (Primitive.coerce datum) (Primitive.coerce action) tx\n _ -> fail\n\ncheck : Datum -> Redeemer -> Data -> unit\ncheck datum redeemer tx =\n case redeemer of\n Claim -> assert (Builtin.lessThanInteger (lower datum.deadline) (validAfter tx))\n Cancel -> assert (signedBy tx datum.owner)\n", + "VestingContextInput": "//! Shared ledger input for the vesting snapshots, artifact tests and explicit perf runner.\nuse nash_plutus::{arena::Arena, data::PlutusData};\n\npub fn context<'a>(\n arena: &'a Arena,\n datum: &'a PlutusData<'a>,\n redeemer: &'a PlutusData<'a>,\n lower_time: i128,\n signer: &'a [u8],\n) -> &'a PlutusData<'a> {\n let constr = |tag, fields: &[&'a PlutusData<'a>]| {\n PlutusData::constr(arena, tag, arena.alloc_slice_copy(fields))\n };\n let empty_list = PlutusData::list(arena, &[]);\n let empty_map = PlutusData::map(arena, &[]);\n let zero = PlutusData::integer_from(arena, 0);\n let tx_id = PlutusData::byte_string(arena, &[0; 32]);\n let closed = constr(1, &[]);\n let lower = constr(\n 0,\n &[\n constr(1, &[PlutusData::integer_from(arena, lower_time)]),\n closed,\n ],\n );\n let upper = constr(0, &[constr(2, &[]), closed]);\n let signers = if signer.is_empty() {\n empty_list\n } else {\n // The owner is deliberately second: signedBy must search the whole list.\n PlutusData::list(\n arena,\n arena.alloc_slice_copy(&[\n PlutusData::byte_string(arena, &[0xbb]),\n PlutusData::byte_string(arena, signer),\n ]),\n )\n };\n let tx = constr(\n 0,\n &[\n empty_list, // inputs\n empty_list, // reference inputs\n empty_list, // outputs\n zero, // fee\n empty_map, // mint\n empty_list, // certificates\n empty_map, // withdrawals\n constr(0, &[lower, upper]), // validity range\n signers,\n empty_map, // redeemers\n empty_map, // datums\n tx_id,\n empty_map, // votes\n empty_list, // proposals\n constr(1, &[]), // current treasury\n constr(1, &[]), // treasury donation\n ],\n );\n let reference = constr(0, &[tx_id, zero]);\n let spending = constr(1, &[reference, constr(0, &[datum])]);\n constr(0, &[tx, redeemer, spending])\n}\n", + "VestingParam": "validator module VestingParam exposing (main)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\nimport Cardano.Tx exposing (validAfter, signedBy)\n\ntype Datum = Datum { owner : Bytes, deadline : Int }\n\ntype Redeemer = Claim | Cancel\n\n-- The ledger supplies one V3 ScriptContext; spending datum is in ScriptInfo.\nmain : int -> Data -> unit\nmain minimumLock ctx =\n case ctx of\n Constr pair(0, [ tx, action, Constr pair(1, [ _, Constr pair(0, [ datum ]) ]) ]) ->\n check minimumLock (Primitive.coerce datum) (Primitive.coerce action) tx\n _ -> fail\n\ncheck : int -> Datum -> Redeemer -> Data -> unit\ncheck minimumLock datum redeemer tx =\n case redeemer of\n Claim ->\n assert\n (Builtin.lessThanInteger\n (Builtin.addInteger (lower datum.deadline) minimumLock)\n (validAfter tx))\n Cancel -> assert (signedBy tx datum.owner)\n", + "Workloads": "module Workloads exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Logic exposing (..)\n\nsum : list int -> int\nsum xs =\n case xs of\n [] -> 0\n x :: rest -> Builtin.addInteger x (sum rest)\n\nlistTraversal : int\nlistTraversal = sum [1, 2, 3, 4, 5, 6, 7, 8]\n\ncountdown : int -> int -> int\ncountdown n result =\n if Builtin.equalsInteger n 0 then\n result\n else\n countdown (Builtin.subtractInteger n 1) result\n\nstaticRecursion : int\nstaticRecursion = countdown 8 42\n\nmatchData : Data -> int\nmatchData value =\n case value of\n I n -> n\n _ -> 0\n\ndataMatch : int\ndataMatch = matchData (I 42)\n\ndataMiss : int\ndataMiss = matchData (B #\"ab\")\n\ndecode : Data -> int\ndecode value =\n case value of\n Constr pair(_, [I n, _]) -> n\n _ -> 0\n\ndecoding : int\ndecoding = decode (Builtin.constrData 0 [I 42, I 7])\n\nvalidate : Data -> unit\nvalidate value =\n case value of\n I n -> assert (Builtin.lessThanInteger 0 n)\n _ -> fail\n\nvalidationPass : unit\nvalidationPass = validate (I 42)\n\nvalidationFail : unit\nvalidationFail = validate (I 0)\n\nbooleanHelpers : bool\nbooleanHelpers = (True && False) || (True && True)\n\nconstantPrefixTwice : int\nconstantPrefixTwice =\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nconstantPrefixCold : int\nconstantPrefixCold =\n if True then\n 42\n else\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nprefixLoop : int -> int\nprefixLoop n =\n if Builtin.equalsInteger n 0 then\n 0\n else\n Builtin.addInteger\n (Builtin.addInteger (Builtin.subtractInteger 100 n) (Builtin.subtractInteger 100 n))\n (prefixLoop (Builtin.subtractInteger n 1))\n\nconstantPrefixLoop : int\nconstantPrefixLoop = prefixLoop 8\n\nunusedSelf : int -> int -> int\nunusedSelf unused n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n unusedSelf unused (Builtin.subtractInteger n 1)\n\nrecursiveUnusedSelf : int\nrecursiveUnusedSelf = unusedSelf (Builtin.trace \"entry\" 7) 3\n\nunusedFirst : int -> int -> int\nunusedFirst unused n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n unusedSecond (Builtin.subtractInteger n 1) unused\n\nunusedSecond : int -> int -> int\nunusedSecond n unused = unusedFirst unused n\n\nrecursiveUnusedMutual : int\nrecursiveUnusedMutual = unusedFirst (Builtin.trace \"entry\" 7) 3\n\nhiddenStatic : int -> int -> int\nhiddenStatic x n =\n if Builtin.equalsInteger n 0 then\n x\n else\n let\n next = Builtin.subtractInteger n 1\n in\n hiddenStatic (if True then x else 0) next\n\ncleanupExposesStatic : int\ncleanupExposesStatic = hiddenStatic 42 3\n\npackingChoose : int -> int -> int -> int\npackingChoose n =\n if Builtin.equalsInteger n 0 then\n \\x y -> Builtin.addInteger x y\n else\n packingChoose (Builtin.subtractInteger n 1)\n\nstagedApplication : int\nstagedApplication =\n let\n p = packingChoose 3 20\n in\n p 22\n\npackingTraced : int -> int -> int -> int\npackingTraced n =\n if Builtin.equalsInteger n 0 then\n \\x -> trace \"first\" (\\y -> trace \"second\" (Builtin.addInteger x y))\n else\n packingTraced (Builtin.subtractInteger n 1)\n\nstagedApplicationTraces : int\nstagedApplicationTraces =\n let\n p = packingTraced 3 20\n in\n p 22\n\nstagedArgumentTrace : int\nstagedArgumentTrace =\n let\n p = packingTraced 3 20\n in\n p (trace \"argument\" 22)\n\npackingFailure : int -> int -> int -> int\npackingFailure n =\n if Builtin.equalsInteger n 0 then\n \\x -> trace \"first\" fail\n else\n packingFailure (Builtin.subtractInteger n 1)\n\nstagedApplicationFailure : int\nstagedApplicationFailure =\n let\n p = packingFailure 3 20\n in\n p (trace \"must not run\" 22)\n" + }, + "revision": "a0b88ebebc67fd04e5a062d74640a211d74d200b", + "rustc": "rustc 1.98.1 (48a229cea 2026-09-01)", + "rows": [ + { + "input": "Workloads.listTraversal (fixtures/Workloads.nash)", + "before": { + "cpu": 5788660, + "memory": 27872, + "bytes": 102, + "result": "(con integer 36)", + "logs": [] + }, + "after": { + "cpu": 3225764, + "memory": 15216, + "bytes": 41, + "result": "(con integer 36)", + "logs": [] + } + }, + { + "input": "Workloads.staticRecursion (fixtures/Workloads.nash)", + "before": { + "cpu": 4736761, + "memory": 21725, + "bytes": 52, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.cleanupExposesStatic (fixtures/Workloads.nash)", + "before": { + "cpu": 2737056, + "memory": 14010, + "bytes": 66, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1921056, + "memory": 8910, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.dataMatch (fixtures/Workloads.nash)", + "before": { + "cpu": 978518, + "memory": 5496, + "bytes": 58, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.dataMiss (fixtures/Workloads.nash)", + "before": { + "cpu": 953658, + "memory": 5464, + "bytes": 64, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "Workloads.decoding (fixtures/Workloads.nash)", + "before": { + "cpu": 2271655, + "memory": 11888, + "bytes": 125, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.validationPass (fixtures/Workloads.nash)", + "before": { + "cpu": 1215808, + "memory": 6697, + "bytes": 90, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Workloads.validationFail (fixtures/Workloads.nash)", + "before": { + "cpu": 235306, + "memory": 229, + "bytes": 90, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 30, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "Workloads.booleanHelpers (fixtures/Workloads.nash)", + "before": { + "cpu": 400100, + "memory": 2600, + "bytes": 29, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "Workloads.constantPrefixTwice (fixtures/Workloads.nash)", + "before": { + "cpu": 799724, + "memory": 3206, + "bytes": 35, + "result": "(con integer 197)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con integer 197)", + "logs": [] + } + }, + { + "input": "Workloads.constantPrefixCold (fixtures/Workloads.nash)", + "before": { + "cpu": 288100, + "memory": 1900, + "bytes": 47, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.constantPrefixLoop (fixtures/Workloads.nash)", + "before": { + "cpu": 10695417, + "memory": 38789, + "bytes": 70, + "result": "(con integer 1528)", + "logs": [] + }, + "after": { + "cpu": 10839417, + "memory": 39689, + "bytes": 67, + "result": "(con integer 1528)", + "logs": [] + } + }, + { + "input": "Workloads.recursiveUnusedSelf (fixtures/Workloads.nash)", + "before": { + "cpu": 2540554, + "memory": 12442, + "bytes": 75, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + }, + "after": { + "cpu": 2156554, + "memory": 10042, + "bytes": 56, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + } + }, + { + "input": "Workloads.recursiveUnusedMutual (fixtures/Workloads.nash)", + "before": { + "cpu": 3436554, + "memory": 18042, + "bytes": 104, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + }, + "after": { + "cpu": 2732554, + "memory": 13642, + "bytes": 67, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + } + }, + { + "input": "Workloads.stagedApplication (fixtures/Workloads.nash)", + "before": { + "cpu": 2470264, + "memory": 11712, + "bytes": 61, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 2166264, + "memory": 9812, + "bytes": 50, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.stagedApplicationTraces (fixtures/Workloads.nash)", + "before": { + "cpu": 3053260, + "memory": 14676, + "bytes": 100, + "result": "(con integer 42)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 2541260, + "memory": 11476, + "bytes": 79, + "result": "(con integer 42)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "Workloads.stagedArgumentTrace (fixtures/Workloads.nash)", + "before": { + "cpu": 3320758, + "memory": 16008, + "bytes": 121, + "result": "(con integer 42)", + "logs": [ + "first", + "argument", + "second" + ] + }, + "after": { + "cpu": 2856758, + "memory": 13108, + "bytes": 100, + "result": "(con integer 42)", + "logs": [ + "first", + "argument", + "second" + ] + } + }, + { + "input": "Workloads.stagedApplicationFailure (fixtures/Workloads.nash)", + "before": { + "cpu": 572554, + "memory": 142, + "bytes": 101, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + }, + "after": { + "cpu": 572554, + "memory": 142, + "bytes": 85, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + } + }, + { + "input": "Vesting: claim after deadline; deadline=10, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 10053501, + "memory": 54616, + "bytes": 886, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 8581501, + "memory": 45416, + "bytes": 822, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: claim before deadline; deadline=30, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7888999, + "memory": 40748, + "bytes": 886, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7888999, + "memory": 40748, + "bytes": 822, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "Vesting: cancel signed; deadline=10, action=1, signer=[170], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9243016, + "memory": 51150, + "bytes": 886, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 7467016, + "memory": 40050, + "bytes": 822, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: cancel unsigned; deadline=10, action=1, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7334408, + "memory": 40552, + "bytes": 886, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 4134408, + "memory": 20552, + "bytes": 822, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "Vesting: boundary zero minimum; deadline=18, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 10053501, + "memory": 54616, + "bytes": 886, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 8581501, + "memory": 45416, + "bytes": 822, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: boundary five minimum; deadline=18, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 10053501, + "memory": 54616, + "bytes": 886, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 8581501, + "memory": 45416, + "bytes": 822, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: claim after deadline; deadline=10, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 10314709, + "memory": 55618, + "bytes": 893, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 8842709, + "memory": 46418, + "bytes": 829, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: claim before deadline; deadline=30, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7990207, + "memory": 40750, + "bytes": 893, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7990207, + "memory": 40750, + "bytes": 829, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "VestingParam: cancel signed; deadline=10, action=1, signer=[170], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9339016, + "memory": 51750, + "bytes": 893, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 7515016, + "memory": 40350, + "bytes": 829, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: cancel unsigned; deadline=10, action=1, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7334408, + "memory": 40552, + "bytes": 893, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 4134408, + "memory": 20552, + "bytes": 829, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "VestingParam: boundary zero minimum; deadline=18, action=0, signer=[], minimum=0, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 10314709, + "memory": 55618, + "bytes": 893, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 8842709, + "memory": 46418, + "bytes": 829, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: boundary five minimum; deadline=18, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7990207, + "memory": 40750, + "bytes": 893, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7990207, + "memory": 40750, + "bytes": 829, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "representation cancellation: integer_direct", + "before": { + "cpu": 116143, + "memory": 664, + "bytes": 10, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_trace", + "before": { + "cpu": 287641, + "memory": 1396, + "bytes": 24, + "result": "(con integer 7)", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 378897, + "memory": 2064, + "bytes": 30, + "result": "(con integer 7)", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: integer_decoded", + "before": { + "cpu": 168887, + "memory": 896, + "bytes": 14, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_reverse", + "before": { + "cpu": 116143, + "memory": 664, + "bytes": 13, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_cold", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 26, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_bound", + "before": { + "cpu": 603139, + "memory": 3028, + "bytes": 50, + "result": "(con integer 7)", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 534395, + "memory": 2696, + "bytes": 48, + "result": "(con integer 7)", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: integer_captured", + "before": { + "cpu": 463641, + "memory": 2496, + "bytes": 29, + "result": "(con integer 7)", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 378897, + "memory": 2064, + "bytes": 27, + "result": "(con integer 7)", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: integer_escaping", + "before": { + "cpu": 532385, + "memory": 2828, + "bytes": 35, + "result": "(constr 0 (con data (I 7)) (con integer 7) (con integer 7))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 426897, + "memory": 2364, + "bytes": 32, + "result": "(constr 0 (con data (I 7)) (con integer 7) (con integer 7))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: integer_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 47, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: integer_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_oversaturated", + "before": { + "cpu": 36143, + "memory": 164, + "bytes": 12, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(Integer(7)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_partial", + "before": { + "cpu": 116143, + "memory": 664, + "bytes": 10, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 68844, + "memory": 432, + "bytes": 11, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_direct", + "before": { + "cpu": 111425, + "memory": 664, + "bytes": 17, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_trace", + "before": { + "cpu": 282923, + "memory": 1396, + "bytes": 31, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 374781, + "memory": 2064, + "bytes": 36, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: bytes_decoded", + "before": { + "cpu": 163567, + "memory": 896, + "bytes": 19, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_reverse", + "before": { + "cpu": 111425, + "memory": 664, + "bytes": 18, + "result": "(con data (B #68656c6c6f))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con data (B #68656c6c6f))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_cold", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 39, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_bound", + "before": { + "cpu": 598421, + "memory": 3028, + "bytes": 57, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 530279, + "memory": 2696, + "bytes": 54, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: bytes_captured", + "before": { + "cpu": 458923, + "memory": 2496, + "bytes": 36, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 374781, + "memory": 2064, + "bytes": 33, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: bytes_escaping", + "before": { + "cpu": 527065, + "memory": 2828, + "bytes": 42, + "result": "(constr 0\n (con data (B #68656c6c6f))\n (con bytestring #68656c6c6f)\n (con bytestring #68656c6c6f))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 422781, + "memory": 2364, + "bytes": 38, + "result": "(constr 0\n (con data (B #68656c6c6f))\n (con bytestring #68656c6c6f)\n (con bytestring #68656c6c6f))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: bytes_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 47, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: bytes_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_oversaturated", + "before": { + "cpu": 31425, + "memory": 164, + "bytes": 19, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ByteString([104, 101, 108, 108, 111])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ByteString([104, 101, 108, 108, 111])))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_partial", + "before": { + "cpu": 111425, + "memory": 664, + "bytes": 17, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 68242, + "memory": 432, + "bytes": 16, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: list_direct", + "before": { + "cpu": 139885, + "memory": 664, + "bytes": 14, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: list_trace", + "before": { + "cpu": 311383, + "memory": 1396, + "bytes": 29, + "result": "(con (list data) [(I 7)])", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 397450, + "memory": 2064, + "bytes": 35, + "result": "(con (list data) [(I 7)])", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: list_decoded", + "before": { + "cpu": 197818, + "memory": 896, + "bytes": 16, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: list_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_reverse", + "before": { + "cpu": 139885, + "memory": 664, + "bytes": 15, + "result": "(con data (List [I 7]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (List [I 7]))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_cold", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 34, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: list_bound", + "before": { + "cpu": 626881, + "memory": 3028, + "bytes": 55, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 552948, + "memory": 2696, + "bytes": 53, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: list_captured", + "before": { + "cpu": 487383, + "memory": 2496, + "bytes": 34, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 397450, + "memory": 2064, + "bytes": 32, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: list_escaping", + "before": { + "cpu": 561316, + "memory": 2828, + "bytes": 40, + "result": "(constr 0\n (con data (List [I 7]))\n (con (list data) [(I 7)])\n (con (list data) [(I 7)]))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 445450, + "memory": 2364, + "bytes": 37, + "result": "(constr 0\n (con data (List [I 7]))\n (con (list data) [(I 7)])\n (con (list data) [(I 7)]))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: list_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 47, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: list_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_oversaturated", + "before": { + "cpu": 59885, + "memory": 164, + "bytes": 16, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Data, [Data(Integer(7))])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Data, [Data(Integer(7))])))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_partial", + "before": { + "cpu": 139885, + "memory": 664, + "bytes": 14, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 74033, + "memory": 432, + "bytes": 13, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_direct", + "before": { + "cpu": 172969, + "memory": 664, + "bytes": 20, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 17, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_trace", + "before": { + "cpu": 344467, + "memory": 1396, + "bytes": 35, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 431844, + "memory": 2064, + "bytes": 41, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: map_decoded", + "before": { + "cpu": 229592, + "memory": 896, + "bytes": 16, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 17, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_reverse", + "before": { + "cpu": 172969, + "memory": 664, + "bytes": 15, + "result": "(con data (Map [(I 7, I 7)]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (Map [(I 7, I 7)]))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_cold", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 47, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 17, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_bound", + "before": { + "cpu": 659965, + "memory": 3028, + "bytes": 61, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 587342, + "memory": 2696, + "bytes": 59, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: map_captured", + "before": { + "cpu": 520467, + "memory": 2496, + "bytes": 40, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 431844, + "memory": 2064, + "bytes": 38, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: map_escaping", + "before": { + "cpu": 593090, + "memory": 2828, + "bytes": 46, + "result": "(constr 0\n (con data (Map [(I 7, I 7)]))\n (con (list (pair data data)) [((I 7), (I 7))])\n (con (list (pair data data)) [((I 7), (I 7))]))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 479844, + "memory": 2364, + "bytes": 43, + "result": "(constr 0\n (con data (Map [(I 7, I 7)]))\n (con (list (pair data data)) [((I 7), (I 7))])\n (con (list (pair data data)) [((I 7), (I 7))]))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: map_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 47, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: map_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_oversaturated", + "before": { + "cpu": 92969, + "memory": 164, + "bytes": 23, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Pair(Data, Data), [ProtoPair(Data, Data, Data(Integer(7)), Data(Integer(7)))])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 19, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Pair(Data, Data), [ProtoPair(Data, Data, Data(Integer(7)), Data(Integer(7)))])))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_partial", + "before": { + "cpu": 172969, + "memory": 664, + "bytes": 20, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 72723, + "memory": 432, + "bytes": 13, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_direct", + "before": { + "cpu": 215979, + "memory": 612, + "bytes": 18, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_trace", + "before": { + "cpu": 387477, + "memory": 1344, + "bytes": 32, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 407519, + "memory": 2038, + "bytes": 37, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: utf8_decoded", + "before": { + "cpu": 339937, + "memory": 818, + "bytes": 19, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_reverse", + "before": { + "cpu": 215979, + "memory": 612, + "bytes": 18, + "result": "(con bytestring #68c3a96c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con bytestring #68c3a96c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_cold", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 41, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_bound", + "before": { + "cpu": 702975, + "memory": 2976, + "bytes": 58, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 563017, + "memory": 2670, + "bytes": 55, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: utf8_captured", + "before": { + "cpu": 563477, + "memory": 2444, + "bytes": 37, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 407519, + "memory": 2038, + "bytes": 34, + "result": "(con string \"h\u00e9llo\")", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: utf8_escaping", + "before": { + "cpu": 703435, + "memory": 2750, + "bytes": 43, + "result": "(constr 0\n (con bytestring #68c3a96c6c6f)\n (con string \"h\u00e9llo\")\n (con string \"h\u00e9llo\"))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 455519, + "memory": 2338, + "bytes": 39, + "result": "(constr 0\n (con bytestring #68c3a96c6c6f)\n (con string \"h\u00e9llo\")\n (con string \"h\u00e9llo\"))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: utf8_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 47, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: utf8_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_oversaturated", + "before": { + "cpu": 135979, + "memory": 112, + "bytes": 20, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(String(\"h\u00e9llo\")))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(String(\"h\u00e9llo\")))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_partial", + "before": { + "cpu": 215979, + "memory": 612, + "bytes": 18, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + }, + "after": { + "cpu": 140058, + "memory": 406, + "bytes": 16, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_reverse_invalid", + "before": { + "cpu": 92058, + "memory": 106, + "bytes": 13, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + }, + "after": { + "cpu": 92058, + "memory": 106, + "bytes": 15, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_wrong_tag", + "before": { + "cpu": 33952, + "memory": 132, + "bytes": 10, + "result": "error: Runtime(TypeMismatch(Data, ProtoList(Integer, [])))", + "logs": [] + }, + "after": { + "cpu": 33952, + "memory": 132, + "bytes": 12, + "result": "error: Runtime(TypeMismatch(Data, ProtoList(Integer, [])))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_wrong_tag", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 10, + "result": "error: Runtime(TypeMismatch(List(Pair(Data, Data)), ProtoList(Data, [])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 12, + "result": "error: Runtime(TypeMismatch(List(Pair(Data, Data)), ProtoList(Data, [])))", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_tag", + "before": { + "cpu": 556734, + "memory": 2496, + "bytes": 29, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_fields", + "before": { + "cpu": 556831, + "memory": 2496, + "bytes": 29, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_rebuild", + "before": { + "cpu": 848877, + "memory": 3360, + "bytes": 36, + "result": "(con data (Constr 0 [I 7]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con data (Constr 0 [I 7]))", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_known_reverse", + "before": { + "cpu": 838224, + "memory": 3060, + "bytes": 51, + "result": "(con data (Constr 3 [I 7]))", + "logs": [ + "after decoding" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 36, + "result": "(con data (Constr 3 [I 7]))", + "logs": [ + "after decoding" + ] + } + }, + { + "input": "representation cancellation: constructor_wrong_variant", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 47, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 55, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_bad_tag", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "fields evaluated" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 52, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "fields evaluated" + ] + } + }, + { + "input": "representation cancellation: constructor_bad_fields", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 22, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 19, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "constant folding: shared_prefix_distinct_results", + "before": { + "cpu": 1305326, + "memory": 1526, + "bytes": 64, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + }, + "after": { + "cpu": 48100, + "memory": 400, + "bytes": 87, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + } + }, + { + "input": "constant folding: repeated_literal_distinct_results", + "before": { + "cpu": 1257326, + "memory": 1226, + "bytes": 100, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + }, + "after": { + "cpu": 48100, + "memory": 400, + "bytes": 87, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + } + }, + { + "input": "constant folding: expanding_data_list", + "before": { + "cpu": 74033, + "memory": 432, + "bytes": 42, + "result": "(con (list data) [(I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 126, + "result": "(con (list data) [(I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7)])", + "logs": [] + } + }, + { + "input": "constant folding: addition", + "before": { + "cpu": 181308, + "memory": 602, + "bytes": 10, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "constant folding: nested_arithmetic", + "before": { + "cpu": 336261, + "memory": 1004, + "bytes": 15, + "result": "(con integer 84)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con integer 84)", + "logs": [] + } + }, + { + "input": "constant folding: bound_arithmetic", + "before": { + "cpu": 384261, + "memory": 1304, + "bytes": 18, + "result": "(con integer 84)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con integer 84)", + "logs": [] + } + }, + { + "input": "constant folding: division", + "before": { + "cpu": 212030, + "memory": 601, + "bytes": 10, + "result": "(con integer -3)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer -3)", + "logs": [] + } + }, + { + "input": "constant folding: division_zero", + "before": { + "cpu": 132030, + "memory": 101, + "bytes": 10, + "result": "error: Runtime(DivisionByZero(7, 0))", + "logs": [] + }, + "after": { + "cpu": 132030, + "memory": 101, + "bytes": 10, + "result": "error: Runtime(DivisionByZero(7, 0))", + "logs": [] + } + }, + { + "input": "constant folding: wrong_integer_shape", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([120])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([120])))", + "logs": [] + } + }, + { + "input": "constant folding: byte_append", + "before": { + "cpu": 81446, + "memory": 602, + "bytes": 18, + "result": "(con bytestring #61626364)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 12, + "result": "(con bytestring #61626364)", + "logs": [] + } + }, + { + "input": "constant folding: byte_slice", + "before": { + "cpu": 132568, + "memory": 804, + "bytes": 19, + "result": "(con bytestring #6263)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con bytestring #6263)", + "logs": [] + } + }, + { + "input": "constant folding: byte_length", + "before": { + "cpu": 70200, + "memory": 410, + "bytes": 14, + "result": "(con integer 4)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 4)", + "logs": [] + } + }, + { + "input": "constant folding: byte_compare", + "before": { + "cpu": 109173, + "memory": 601, + "bytes": 20, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: string_append", + "before": { + "cpu": 201014, + "memory": 606, + "bytes": 25, + "result": "(con string \"hello world\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 19, + "result": "(con string \"hello world\")", + "logs": [] + } + }, + { + "input": "constant folding: encode_utf8", + "before": { + "cpu": 220784, + "memory": 412, + "bytes": 28, + "result": "(con bytestring #e0b8aae0b8a7e0b8b1e0b8aae0b894e0b8b5)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 26, + "result": "(con bytestring #e0b8aae0b8a7e0b8b1e0b8aae0b894e0b8b5)", + "logs": [] + } + }, + { + "input": "constant folding: decode_utf8", + "before": { + "cpu": 140058, + "memory": 406, + "bytes": 16, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"h\u00e9llo\")", + "logs": [] + } + }, + { + "input": "constant folding: invalid_utf8", + "before": { + "cpu": 92058, + "memory": 106, + "bytes": 11, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + }, + "after": { + "cpu": 92058, + "memory": 106, + "bytes": 11, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + } + }, + { + "input": "constant folding: integer_data", + "before": { + "cpu": 63399, + "memory": 432, + "bytes": 8, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "constant folding: decode_integer_data", + "before": { + "cpu": 68844, + "memory": 432, + "bytes": 11, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: wrong_data_variant", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "constant folding: list_data", + "before": { + "cpu": 81952, + "memory": 432, + "bytes": 12, + "result": "(con data (List [I 7]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (List [I 7]))", + "logs": [] + } + }, + { + "input": "constant folding: map_data", + "before": { + "cpu": 116346, + "memory": 432, + "bytes": 11, + "result": "(con data (Map []))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con data (Map []))", + "logs": [] + } + }, + { + "input": "constant folding: data_equal", + "before": { + "cpu": 1114643, + "memory": 601, + "bytes": 16, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: serialise_data", + "before": { + "cpu": 2070166, + "memory": 410, + "bytes": 11, + "result": "(con bytestring #07)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con bytestring #07)", + "logs": [] + } + }, + { + "input": "constant folding: list_head", + "before": { + "cpu": 147250, + "memory": 532, + "bytes": 11, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: list_tail", + "before": { + "cpu": 145763, + "memory": 532, + "bytes": 11, + "result": "(con (list integer) [8])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con (list integer) [8])", + "logs": [] + } + }, + { + "input": "constant folding: empty_head", + "before": { + "cpu": 83250, + "memory": 132, + "bytes": 9, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + }, + "after": { + "cpu": 83250, + "memory": 132, + "bytes": 11, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + } + }, + { + "input": "constant folding: empty_tail", + "before": { + "cpu": 81763, + "memory": 132, + "bytes": 9, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + }, + "after": { + "cpu": 81763, + "memory": 132, + "bytes": 11, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + } + }, + { + "input": "constant folding: list_null", + "before": { + "cpu": 138533, + "memory": 532, + "bytes": 9, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: pair_first", + "before": { + "cpu": 221995, + "memory": 632, + "bytes": 15, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: pair_second", + "before": { + "cpu": 222092, + "memory": 632, + "bytes": 15, + "result": "(con bytestring #61)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con bytestring #61)", + "logs": [] + } + }, + { + "input": "constant folding: trace_before", + "before": { + "cpu": 352806, + "memory": 1334, + "bytes": 24, + "result": "(con integer 42)", + "logs": [ + "before" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 22, + "result": "(con integer 42)", + "logs": [ + "before" + ] + } + }, + { + "input": "constant folding: trace_builtin", + "before": { + "cpu": 155598, + "memory": 732, + "bytes": 20, + "result": "(con integer 7)", + "logs": [ + "keep me" + ] + }, + "after": { + "cpu": 203598, + "memory": 1032, + "bytes": 22, + "result": "(con integer 7)", + "logs": [ + "keep me" + ] + } + }, + { + "input": "constant folding: cold_failure", + "before": { + "cpu": 48100, + "memory": 400, + "bytes": 15, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: selected_branch", + "before": { + "cpu": 501139, + "memory": 1935, + "bytes": 39, + "result": "(con integer 42)", + "logs": [ + "yes" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 19, + "result": "(con integer 42)", + "logs": [ + "yes" + ] + } + }, + { + "input": "constant folding: strict_failure_order", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 26, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 33, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + } + }, + { + "input": "constant folding: unsupported_hash", + "before": { + "cpu": 341340, + "memory": 404, + "bytes": 11, + "result": "(con bytestring #2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 40, + "result": "(con bytestring #2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881)", + "logs": [] + } + }, + { + "input": "constant folding: partial", + "before": { + "cpu": 181308, + "memory": 602, + "bytes": 10, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 229308, + "memory": 902, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "constant folding: large_input", + "before": { + "cpu": 169849, + "memory": 1113, + "bytes": 4127, + "result": "(con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a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a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a7a)", + "logs": [] + } + }, + { + "input": "constant folding: repeated_call", + "before": { + "cpu": 559724, + "memory": 1706, + "bytes": 26, + "result": "(constr 0 (con integer 42) (con integer 42) (con integer 42))", + "logs": [] + }, + "after": { + "cpu": 64100, + "memory": 500, + "bytes": 12, + "result": "(constr 0 (con integer 42) (con integer 42) (con integer 42))", + "logs": [] + } + }, + { + "input": "pair projection: literal_first", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair projection: literal_second", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair projection: traced_first", + "before": { + "cpu": 251598, + "memory": 1332, + "bytes": 28, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: traced_second", + "before": { + "cpu": 251598, + "memory": 1332, + "bytes": 28, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: made_data_first", + "before": { + "cpu": 155646, + "memory": 1032, + "bytes": 19, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 18, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair projection: made_data_second", + "before": { + "cpu": 155646, + "memory": 1032, + "bytes": 19, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 18, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair projection: decoded_first", + "before": { + "cpu": 136688, + "memory": 832, + "bytes": 15, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "pair projection: decoded_second", + "before": { + "cpu": 136688, + "memory": 832, + "bytes": 15, + "result": "(con (list data) [])", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con (list data) [])", + "logs": [] + } + }, + { + "input": "pair projection: bad_decoder_first", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair projection: bad_decoder_second", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair projection: ignored_failure_first", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 34, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair projection: ignored_failure_second", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 34, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair projection: wrong_subject_first", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair projection: wrong_subject_second", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair projection: native_constructor_first", + "before": { + "cpu": 112100, + "memory": 800, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair projection: native_constructor_second", + "before": { + "cpu": 112100, + "memory": 800, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair projection: body", + "before": { + "cpu": 588304, + "memory": 2466, + "bytes": 44, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + }, + "after": { + "cpu": 668304, + "memory": 2966, + "bytes": 49, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + } + }, + { + "input": "pair projection: both", + "before": { + "cpu": 416806, + "memory": 1734, + "bytes": 31, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: neither", + "before": { + "cpu": 251598, + "memory": 1332, + "bytes": 28, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: delay", + "before": { + "cpu": 283598, + "memory": 1532, + "bytes": 28, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 427598, + "memory": 2432, + "bytes": 36, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: lambda", + "before": { + "cpu": 471096, + "memory": 2364, + "bytes": 46, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + }, + "after": { + "cpu": 647096, + "memory": 3464, + "bytes": 56, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + } + }, + { + "input": "pair projection: repeated", + "before": { + "cpu": 416806, + "memory": 1734, + "bytes": 31, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair projection: two_projections_first", + "before": { + "cpu": 652304, + "memory": 2866, + "bytes": 51, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair projection: two_projections_second", + "before": { + "cpu": 652304, + "memory": 2866, + "bytes": 51, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair projection: unconsumed_lambda_failure", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 39, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair projection: unconsumed_delay_failure", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 39, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair projection: roundtrip_valid_first", + "before": { + "cpu": 962941, + "memory": 4692, + "bytes": 62, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 1074941, + "memory": 5392, + "bytes": 67, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair projection: roundtrip_valid_second", + "before": { + "cpu": 962941, + "memory": 4692, + "bytes": 62, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 1074941, + "memory": 5392, + "bytes": 67, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair projection: roundtrip_bad_tag_first", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 65, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair projection: roundtrip_bad_tag_second", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 65, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "recursive parameters: self_forwarding", + "before": { + "cpu": 1777056, + "memory": 8010, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1921056, + "memory": 8910, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mutual_forwarding", + "before": { + "cpu": 2049056, + "memory": 9710, + "bytes": 83, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 2065056, + "memory": 9810, + "bytes": 69, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mutual_consumed", + "before": { + "cpu": 2049056, + "memory": 9710, + "bytes": 82, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 2193056, + "memory": 10610, + "bytes": 74, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "recursive parameters: recursive_trace_order", + "before": { + "cpu": 3078044, + "memory": 14102, + "bytes": 149, + "result": "(con integer 42)", + "logs": [ + "retained", + "discarded", + "discarded", + "retained", + "retained", + "discarded" + ] + }, + "after": { + "cpu": 3174044, + "memory": 14702, + "bytes": 120, + "result": "(con integer 42)", + "logs": [ + "retained", + "discarded", + "discarded", + "retained", + "retained", + "discarded" + ] + } + }, + { + "input": "recursive parameters: recursive_failure_order", + "before": { + "cpu": 272637, + "memory": 167, + "bytes": 145, + "result": "error: ExplicitErrorTerm", + "logs": [ + "retained", + "discarded" + ] + }, + "after": { + "cpu": 272637, + "memory": 167, + "bytes": 117, + "result": "error: ExplicitErrorTerm", + "logs": [ + "retained", + "discarded" + ] + } + }, + { + "input": "recursive parameters: all_unused_self", + "before": { + "cpu": 1171300, + "memory": 5430, + "bytes": 70, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + }, + "after": { + "cpu": 1523300, + "memory": 7630, + "bytes": 75, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + } + }, + { + "input": "recursive parameters: all_unused_mutual", + "before": { + "cpu": 1603300, + "memory": 8130, + "bytes": 95, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + }, + "after": { + "cpu": 1443300, + "memory": 7130, + "bytes": 81, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + } + }, + { + "input": "recursive parameters: all_unused_cold", + "before": { + "cpu": 192100, + "memory": 1300, + "bytes": 100, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: entry_failure", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 63, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 70, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + } + }, + { + "input": "recursive parameters: partial", + "before": { + "cpu": 1319515, + "memory": 6107, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1415515, + "memory": 6707, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: escaping", + "before": { + "cpu": 1367515, + "memory": 6407, + "bytes": 41, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1415515, + "memory": 6707, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: oversaturated", + "before": { + "cpu": 304100, + "memory": 2000, + "bytes": 22, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 288100, + "memory": 1900, + "bytes": 24, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: compound_dependency", + "before": { + "cpu": 1649931, + "memory": 6911, + "bytes": 44, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 2081931, + "memory": 9611, + "bytes": 54, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mixed_delayed", + "before": { + "cpu": 3471636, + "memory": 16348, + "bytes": 95, + "result": "(con integer 84)", + "logs": [ + "delayed" + ] + }, + "after": { + "cpu": 3551636, + "memory": 16848, + "bytes": 80, + "result": "(con integer 84)", + "logs": [ + "delayed" + ] + } + } + ] + }, + "validation": "All results/logs equivalent to O0; all previous O0 rows unchanged. Complete O1 Flat is identical after one/two/three optimization runs across all 199 rows; late named output is pointer-idempotent." +} diff --git a/tools/optimizer-perf/trials/application-packing-case1.json b/tools/optimizer-perf/trials/application-packing-case1.json new file mode 100644 index 00000000..984a7eb7 --- /dev/null +++ b/tools/optimizer-perf/trials/application-packing-case1.json @@ -0,0 +1,91 @@ +{ + "status": "Case 1 measured only; not adopted into production O1 or O2", + "base_revision": "c2259d95", + "rustc": "rustc 1.98.1 (48a229cea 2026-09-01)", + "settings": "v1; Plutus V3/PV11; UPLC 1.1.0; bundled V3 default cost model; CPU=100000000; memory=2000000; raw Flat bytes before ledger application; O0 vs static lift/unused-parameters(nonrecursive+recursive)/ANF once/rules1+2+3+4+dead-bindings+recursive-reachability+representation-inverse+force-delay+known-bool+int-bytes/bound-constr+known-fields+list+data+idata-bdata-listdata-mapdata-constrdata+restricted-pair-cleanup/static-lift+unused-parameters+constant-fold+cleanup(unbudgeted-fixed-point,all-pure-representable)/recursion/hygiene/lower+forced-builtin-sharing+constant-prefix-sharing", + "trial_policy": "Adjacent single-use Core App fusion, exact intermediate type views, atomic operands; optional native Case(Constr(0,args),[function]) lowering for Core App with at least two UPLC value arguments and a UPLC value function. The two-argument minimum is an experimental setting, not an accepted production policy. This case packs exactly one three-argument call.", + "sources": { + "Cardano.Tx": "module Cardano.Tx exposing (validAfter, signedBy)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\n\n-- V3 TxInfo field 7 is the validity interval. Require a finite lower bound.\n-- Times are POSIX milliseconds, not slots or the current wall-clock time.\nvalidAfter : Data -> int\nvalidAfter tx =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, Constr pair(0, [ Constr pair(0, [ Constr pair(1, [ I time ]), _ ]), _ ]), _, _, _, _, _, _, _, _ ]) -> time\n _ -> fail\n\n-- V3 TxInfo field 8 contains every extra signatory.\nsignedBy : Data -> Bytes -> bool\nsignedBy tx owner =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, _, List signers, _, _, _, _, _, _, _ ]) -> hasSigner signers (lower owner)\n _ -> fail\n\nhasSigner : list Data -> bytes -> bool\nhasSigner signers owner =\n case signers of\n [] -> False\n B signer :: rest ->\n if Builtin.equalsByteString signer owner then True\n else hasSigner rest owner\n _ -> fail\n", + "Eq": "module Eq exposing ( Eq )\n\n\nimport Literal\nimport Logic exposing ( not, xor, (&&) )\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\n\n{-| Compare values for equality and inequality. -}\ntrait Eq 'a where\n eq : 'a -> 'a -> bool\n\n neq : 'a -> 'a -> bool\n neq a b = not (eq a b)\n\n\nimpl Eq int where\n eq = Builtin.equalsInteger\n\n\nimpl Eq bytes where\n eq = Builtin.equalsByteString\n\n\nimpl Eq string where\n eq = Builtin.equalsString\n\n\nimpl Eq bool where\n eq a b = not (xor a b)\n\n\nimpl Eq unit where\n eq _ _ = True\n\n\nimpl Eq (list ('a : Big)) where\n eq xs ys =\n eq (Builtin.listData xs) (Builtin.listData ys)\n\n\nimpl Eq 'a => Eq (list ('a : Little)) where\n eq xs ys =\n case xs of\n [] ->\n case ys of\n [] ->\n True\n\n _ :: _ ->\n False\n\n x :: restX ->\n case ys of\n [] ->\n False\n\n y :: restY ->\n eq x y && eq restX restY\n\n\nimpl ( Eq 'a, Eq 'b ) => Eq (pair 'a 'b) where\n eq a b =\n let\n pair(firstA, secondA) = a\n\n pair(firstB, secondB) = b\n in\n eq firstA firstB && eq secondA secondB\n\n\nimpl Eq (map ('k : Big) ('v : Big)) where\n eq xs ys = eq (Builtin.mapData xs) (Builtin.mapData ys)\n\n\nimpl ( Eq 'k, Eq 'v ) => Eq (map ('k : Little) 'v) where\n eq = eqMapEntries\n\n\nimpl Eq 'v => Eq (map ('k : Big) ('v : Little)) where\n eq = eqMapEntries\n\n\neqMapEntries : ( Eq 'k, Eq 'v ) => list (pair 'k 'v) -> list (pair 'k 'v) -> bool\neqMapEntries = eq\n\n\nimpl Eq value where\n eq a b = Builtin.equalsData (Builtin.valueData a) (Builtin.valueData b)\n", + "Lift": "module Lift exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait Lift 'a 'b where\n lift : 'a -> 'b\n lower : 'b -> 'a\n\nimpl Lift int Int where\n lift value = Builtin.iData value\n lower value = Builtin.unIData value\n\nimpl Lift bytes Bytes where\n lift value = Builtin.bData value\n lower value = Builtin.unBData value\n", + "Literal": "module Literal exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait FromInt 'a where\n fromInt : int -> 'a\n\ntrait FromString 'a where\n fromString : string -> 'a\n\ntrait FromBytes 'a where\n fromBytes : bytes -> 'a\n\nimpl FromInt int where\n fromInt x = x\n\nimpl FromString string where\n fromString x = x\n\nimpl FromBytes bytes where\n fromBytes x = x\n\ntrait FromBool 'a where\n fromBool : bool -> 'a\n\ntrait FromUnit 'a where\n fromUnit : unit -> 'a\n\nimpl FromBool bool where\n fromBool value = value\n\nimpl FromUnit unit where\n fromUnit value = value\n", + "Logic": "module Logic exposing ( not, and, or, xor, (&&), (||) )\n\n\nimport Primitive\nimport Lift exposing ( Lift )\n\n\ninfix right 2 (||) = or\n\n\ninfix right 3 (&&) = and\n\n\n{-| Negate a Big or little Boolean, returning bool. -}\nnot : Lift bool 'a => 'a -> bool\nnot value =\n if lower value then\n Primitive.False\n else\n Primitive.True\n\n\n{-| Boolean conjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nand : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nand a b =\n if lower a then\n lower b\n else\n Primitive.False\n\n\n{-| Boolean disjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nor a b =\n if lower a then\n Primitive.True\n else\n lower b\n\n\n{-| Return True when the Boolean operands differ. -}\nxor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nxor a b =\n if lower a then\n not b\n else\n lower b\n", + "experiment": "module Experiment exposing (main)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\n\nchoose : int -> int -> int -> int\nchoose n =\n if Builtin.equalsInteger n 0 then\n \\x y -> Builtin.addInteger x y\n else\n choose (Builtin.subtractInteger n 1)\n\nmain : int\nmain =\n let\n p = choose 3 20\n in\n p 22\n" + }, + "o0": { + "cpu": 2470264, + "memory": 11712, + "bytes": 61, + "result": "(con integer 42)", + "logs": [] + }, + "variants": { + "original": { + "measurement": { + "cpu": 2278264, + "memory": 10512, + "bytes": 53, + "result": "(con integer 42)", + "logs": [] + }, + "rendered_evidence": "--- accepted O1 Core\nletrec\n choose#11 : int -> int -> int -> int [static []] = \\n#12 : int -> let anf#18 : bool = equalsInteger n#12 0 in\n case@Bool anf#18 of\n True -> \\x#13 : int y#14 : int -> addInteger x#13 y#14\n False -> let anf#20 : int = subtractInteger n#12 1 in\n choose#11 anf#20\nin\nlet anf#22 : int -> int -> int = choose#11 3 in\nlet p#15 : int -> int = anf#22 20 in\np#15 22\n--- trial Core\nletrec\n choose#11 : int -> int -> int -> int [static []] = \\n#12 : int -> let anf#18 : bool = equalsInteger n#12 0 in\n case@Bool anf#18 of\n True -> \\x#13 : int y#14 : int -> addInteger x#13 y#14\n False -> let anf#20 : int = subtractInteger n#12 1 in\n choose#11 anf#20\nin\nlet anf#22 : int -> int -> int = choose#11 3 in\nlet p#15 : int -> int = anf#22 20 in\np#15 22\n--- UPLC sharing=false\n[(lam i0\n [(lam i1\n [(lam i2 [(lam i3 i3) [i2 [i0 (con integer 22)]]])\n [[i1 [i0 (con integer 3)]] [i0 (con integer 20)]]])\n [(lam i1 [i1 i1])\n (lam i1\n (lam i2\n (case\n [[(builtin equalsInteger) i2] [i0 (con integer 0)]]\n [[i1 i1] [[(builtin subtractInteger) i2] [i0 (con integer 1)]]]\n (lam i3 (lam i4 [[(builtin addInteger) i3] i4])))))]])\n (lam i0 i0)]\n--- UPLC sharing=true\n[(lam i0\n [(lam i1 [(lam i2 [i2 (con integer 22)]) [i1 (con integer 20)]])\n [i0 (con integer 3)]])\n [(lam i0 [i0 i0])\n (lam i0\n (lam i1\n [(lam i2\n (case\n i2\n [(lam i3 [[i0 i0] i3]) [[(builtin subtractInteger) i1] (con integer 1)]]\n (lam i3 (lam i4 [[(builtin addInteger) i3] i4]))))\n [[(builtin equalsInteger) i1] (con integer 0)]]))]]\n" + }, + "pack-only": { + "measurement": { + "cpu": 2278264, + "memory": 10512, + "bytes": 53, + "result": "(con integer 42)", + "logs": [] + }, + "rendered_evidence": "--- accepted O1 Core\nletrec\n choose#11 : int -> int -> int -> int [static []] = \\n#12 : int -> let anf#18 : bool = equalsInteger n#12 0 in\n case@Bool anf#18 of\n True -> \\x#13 : int y#14 : int -> addInteger x#13 y#14\n False -> let anf#20 : int = subtractInteger n#12 1 in\n choose#11 anf#20\nin\nlet anf#22 : int -> int -> int = choose#11 3 in\nlet p#15 : int -> int = anf#22 20 in\np#15 22\n--- trial Core\nletrec\n choose#11 : int -> int -> int -> int [static []] = \\n#12 : int -> let anf#18 : bool = equalsInteger n#12 0 in\n case@Bool anf#18 of\n True -> \\x#13 : int y#14 : int -> addInteger x#13 y#14\n False -> let anf#20 : int = subtractInteger n#12 1 in\n choose#11 anf#20\nin\nlet anf#22 : int -> int -> int = choose#11 3 in\nlet p#15 : int -> int = anf#22 20 in\np#15 22\n--- UPLC sharing=false\n[(lam i0\n [(lam i1\n [(lam i2 [(lam i3 i3) [i2 [i0 (con integer 22)]]])\n [[i1 [i0 (con integer 3)]] [i0 (con integer 20)]]])\n [(lam i1 [i1 i1])\n (lam i1\n (lam i2\n (case\n [[(builtin equalsInteger) i2] [i0 (con integer 0)]]\n [[i1 i1] [[(builtin subtractInteger) i2] [i0 (con integer 1)]]]\n (lam i3 (lam i4 [[(builtin addInteger) i3] i4])))))]])\n (lam i0 i0)]\n--- UPLC sharing=true\n[(lam i0\n [(lam i1 [(lam i2 [i2 (con integer 22)]) [i1 (con integer 20)]])\n [i0 (con integer 3)]])\n [(lam i0 [i0 i0])\n (lam i0\n (lam i1\n [(lam i2\n (case\n i2\n [(lam i3 [[i0 i0] i3]) [[(builtin subtractInteger) i1] (con integer 1)]]\n (lam i3 (lam i4 [[(builtin addInteger) i3] i4]))))\n [[(builtin equalsInteger) i1] (con integer 0)]]))]]\n" + }, + "fused": { + "measurement": { + "cpu": 2182264, + "memory": 9912, + "bytes": 48, + "result": "(con integer 42)", + "logs": [] + }, + "rendered_evidence": "--- accepted O1 Core\nletrec\n choose#11 : int -> int -> int -> int [static []] = \\n#12 : int -> let anf#18 : bool = equalsInteger n#12 0 in\n case@Bool anf#18 of\n True -> \\x#13 : int y#14 : int -> addInteger x#13 y#14\n False -> let anf#20 : int = subtractInteger n#12 1 in\n choose#11 anf#20\nin\nlet anf#22 : int -> int -> int = choose#11 3 in\nlet p#15 : int -> int = anf#22 20 in\np#15 22\nFUSED 2 arguments\nFUSED 3 arguments\n--- trial Core\nletrec\n choose#11 : int -> int -> int -> int [static []] = \\n#12 : int -> let anf#18 : bool = equalsInteger n#12 0 in\n case@Bool anf#18 of\n True -> \\x#13 : int y#14 : int -> addInteger x#13 y#14\n False -> let anf#20 : int = subtractInteger n#12 1 in\n choose#11 anf#20\nin\nchoose#11 3 20 22\nVERIFIED: one/two/three trial pipeline runs produce identical Flat bytes\n--- UPLC sharing=false\n[(lam i0\n [(lam i1\n [(lam i2 [(lam i3 i3) [i2 [i0 (con integer 22)]]])\n [[i1 [i0 (con integer 3)]] [i0 (con integer 20)]]])\n [(lam i1 [i1 i1])\n (lam i1\n (lam i2\n (case\n [[(builtin equalsInteger) i2] [i0 (con integer 0)]]\n [[i1 i1] [[(builtin subtractInteger) i2] [i0 (con integer 1)]]]\n (lam i3 (lam i4 [[(builtin addInteger) i3] i4])))))]])\n (lam i0 i0)]\n--- UPLC sharing=true\n[(lam i0 [[[i0 (con integer 3)] (con integer 20)] (con integer 22)])\n [(lam i0 [i0 i0])\n (lam i0\n (lam i1\n [(lam i2\n (case\n i2\n [(lam i3 [[i0 i0] i3]) [[(builtin subtractInteger) i1] (con integer 1)]]\n (lam i3 (lam i4 [[(builtin addInteger) i3] i4]))))\n [[(builtin equalsInteger) i1] (con integer 0)]]))]]\n" + }, + "packed": { + "measurement": { + "cpu": 2166264, + "memory": 9812, + "bytes": 50, + "result": "(con integer 42)", + "logs": [] + }, + "rendered_evidence": "--- accepted O1 Core\nletrec\n choose#11 : int -> int -> int -> int [static []] = \\n#12 : int -> let anf#18 : bool = equalsInteger n#12 0 in\n case@Bool anf#18 of\n True -> \\x#13 : int y#14 : int -> addInteger x#13 y#14\n False -> let anf#20 : int = subtractInteger n#12 1 in\n choose#11 anf#20\nin\nlet anf#22 : int -> int -> int = choose#11 3 in\nlet p#15 : int -> int = anf#22 20 in\np#15 22\nFUSED 2 arguments\nFUSED 3 arguments\n--- trial Core\nletrec\n choose#11 : int -> int -> int -> int [static []] = \\n#12 : int -> let anf#18 : bool = equalsInteger n#12 0 in\n case@Bool anf#18 of\n True -> \\x#13 : int y#14 : int -> addInteger x#13 y#14\n False -> let anf#20 : int = subtractInteger n#12 1 in\n choose#11 anf#20\nin\nchoose#11 3 20 22\nPACKED 3 value arguments\nPACKED 3 value arguments\nPACKED 3 value arguments\nVERIFIED: one/two/three trial pipeline runs produce identical Flat bytes\n--- UPLC sharing=false\n[(lam i0\n [(lam i1\n [(lam i2 [(lam i3 i3) [i2 [i0 (con integer 22)]]])\n [[i1 [i0 (con integer 3)]] [i0 (con integer 20)]]])\n [(lam i1 [i1 i1])\n (lam i1\n (lam i2\n (case\n [[(builtin equalsInteger) i2] [i0 (con integer 0)]]\n [[i1 i1] [[(builtin subtractInteger) i2] [i0 (con integer 1)]]]\n (lam i3 (lam i4 [[(builtin addInteger) i3] i4])))))]])\n (lam i0 i0)]\nPACKED 3 value arguments\n--- UPLC sharing=true\n[(lam i0 (case (constr 0 (con integer 3) (con integer 20) (con integer 22)) i0))\n [(lam i0 [i0 i0])\n (lam i0\n (lam i1\n [(lam i2\n (case\n i2\n [(lam i3 [[i0 i0] i3]) [[(builtin subtractInteger) i1] (con integer 1)]]\n (lam i3 (lam i4 [[(builtin addInteger) i3] i4]))))\n [[(builtin equalsInteger) i1] (con integer 0)]]))]]\n" + } + }, + "checks": [ + "All variants have identical O0 costs and output", + "All variants return integer 42 and no logs", + "Fusion preserves ANF, closed hygiene and result type", + "Fusion alone is pointer-idempotent", + "Fusion pipeline and fusion-plus-packing pipeline each produce identical closed Flat bytes after one, two and three runs on this source", + "With trial flags absent, all 195 performance rows match the unchanged baseline" + ], + "reproduction": { + "patch_base": "c2259d95", + "patch": "--- a/tools/optimizer-perf/src/main.rs\n+++ b/tools/optimizer-perf/src/main.rs\n@@ -210,6 +210,31 @@\n fn accepted<'a>(arena: &'a Arena, core: &'a Core<'a>) -> &'a Core<'a> {\n let b = Builder::new(arena);\n let core = nash_codegen::optimizer::optimize(arena, core);\n+ eprintln!(\"--- accepted O1 Core\\n{}\", nash_ir::pretty::pretty(core));\n+ let core = if std::env::var_os(\"NASH_TRIAL_FUSION\").is_some() {\n+ fuse(&b, core)\n+ } else { core };\n+ eprintln!(\"--- trial Core\\n{}\", nash_ir::pretty::pretty(core));\n+ if std::env::var_os(\"NASH_TRIAL_FUSION\").is_some() {\n+ assert!(std::ptr::eq(core, fuse(&b, core)));\n+ let encode = |c| {\n+ let c = nash_codegen::recursion::rewrite(&b, c).unwrap();\n+ let c = hygiene::freshen(&b, c);\n+ hygiene::validate(c, &[]).unwrap();\n+ nash_codegen::lower::TRIAL_PACK.set(std::env::var_os(\"NASH_TRIAL_PACK\").is_some());\n+ let term = nash_codegen::lower::lower_with_constant_sharing(arena, c).unwrap();\n+ nash_codegen::lower::TRIAL_PACK.set(false);\n+ let term = debruijn::to_debruijn(arena, term).unwrap();\n+ flat::encode(Program::new(arena, Version::plutus_v3(arena), term)).unwrap()\n+ };\n+ let once = encode(core);\n+ let mut repeated = core;\n+ for _ in 0..2 {\n+ repeated = fuse(&b, nash_codegen::optimizer::optimize(arena, repeated));\n+ assert_eq!(once, encode(repeated));\n+ }\n+ eprintln!(\"VERIFIED: one/two/three trial pipeline runs produce identical Flat bytes\");\n+ }\n anf::validate(core).expect(\"ANF before recursion rewriting\");\n let core = nash_codegen::recursion::rewrite(&b, core).expect(\"recursion rewrite\");\n let core = hygiene::freshen(&b, core);\n@@ -255,6 +280,7 @@\n args: &[&'a Term<'a, DeBruijn>],\n sharing: bool,\n ) -> Result {\n+ nash_codegen::lower::TRIAL_PACK.set(sharing && std::env::var_os(\"NASH_TRIAL_PACK\").is_some());\n let named = if sharing {\n nash_codegen::lower::lower_with_constant_sharing(arena, core)\n } else {\n@@ -262,6 +288,7 @@\n }\n .expect(\"lowering\");\n let term = debruijn::to_debruijn(arena, named).expect(\"closed UPLC\");\n+ eprintln!(\"--- UPLC sharing={sharing}\\n{}\", pretty::term(term));\n let mut program = Program::new(arena, Version::plutus_v3(arena), term);\n let bytes = flat::encode(program).expect(\"Flat encoding\").len();\n for arg in args {\n@@ -442,3 +469,31 @@\n }\n Ok(rows)\n }\n+\n+fn fuse<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> {\n+ use nash_ir::core::CoreKind;\n+ let mut uses = std::collections::HashMap::::new();\n+ core.walk(&mut |n| if let CoreKind::Var(v) = n.kind {\n+ *uses.entry(v.unique).or_default() += 1;\n+ });\n+ let result = core.map(b, &mut |n| {\n+ let CoreKind::Let { binder, value, body } = n.kind else { return None; };\n+ if uses.get(&binder.name.unique) != Some(&1) { return None; }\n+ let CoreKind::App { func, args } = value.kind else { return None; };\n+ let CoreKind::App { func: next, args: later } = body.kind else { return None; };\n+ if !matches!(next.kind, CoreKind::Var(v) if v.unique == binder.name.unique)\n+ || args.is_empty() || later.is_empty() || !anf::is_atom(func)\n+ || !args.iter().chain(later).all(|x| anf::is_atom(x)) {\n+ return None;\n+ }\n+ // Trial keeps exact intermediate type views; broader cases are untested.\n+ if value.ty != binder.ty || next.ty != binder.ty || body.ty != n.ty { return None; }\n+ let args = args.iter().chain(later).copied().collect::>();\n+ eprintln!(\"FUSED {} arguments\", args.len());\n+ Some(b.app(func, &args, n.ty))\n+ });\n+ anf::validate(result).unwrap();\n+ hygiene::validate(result, &[]).unwrap();\n+ assert_eq!(core.ty, result.ty);\n+ result\n+}\n--- a/crates/nash-codegen/src/lower.rs\n+++ b/crates/nash-codegen/src/lower.rs\n@@ -269,10 +269,20 @@\n }\n CoreKind::App { .. } => {\n let mut func = children.next().unwrap();\n- for arg in children.by_ref() {\n- func = func.apply(self.arena, arg);\n- }\n- func\n+ let args = children.by_ref().collect::>();\n+ let value = |t: &&Term<'_, _>| matches!(t,\n+ Term::Var(_) | Term::Constant(_) | Term::Lambda { .. }\n+ | Term::Delay(_) | Term::Builtin(_));\n+ if TRIAL_PACK.get()\n+ && args.len() >= 2 && value(&func) && args.iter().all(value) {\n+ eprintln!(\"PACKED {} value arguments\", args.len());\n+ Term::case(self.arena,\n+ Term::constr(self.arena, 0, self.arena.alloc_slice_copy(&args)),\n+ self.arena.alloc_slice_copy(&[func]))\n+ } else {\n+ for arg in args { func = func.apply(self.arena, arg); }\n+ func\n+ }\n }\n CoreKind::Let { binder, .. } => {\n let body = children.next().unwrap();\n@@ -607,3 +617,5 @@\n \n #[cfg(test)]\n mod tests;\n+\n+thread_local! { pub static TRIAL_PACK: std::cell::Cell = const { std::cell::Cell::new(false) }; }\n", + "source": "sources.experiment", + "command": "cargo run --locked --manifest-path tools/optimizer-perf/Cargo.toml -- experiment /tmp/Experiment.nash", + "variants": { + "original": {}, + "pack-only": { + "NASH_TRIAL_PACK": "1" + }, + "fused": { + "NASH_TRIAL_FUSION": "1" + }, + "packed": { + "NASH_TRIAL_FUSION": "1", + "NASH_TRIAL_PACK": "1" + } + } + } +} diff --git a/tools/optimizer-perf/trials/constant-fold.json b/tools/optimizer-perf/trials/constant-fold.json new file mode 100644 index 00000000..c68b7bb8 --- /dev/null +++ b/tools/optimizer-perf/trials/constant-fold.json @@ -0,0 +1,2694 @@ +{ + "settings": "v1; Plutus V3/PV11; UPLC 1.1.0; bundled V3 default cost model; measurement CPU=100000000 memory=2000000; raw Flat bytes; TRIAL: before=accepted O1; after=O1+constant folding/cleanup; calls=128; per-call CPU=1000000 memory=10000; payload bytes=4096 nodes=1024 depth=64; non-growing isolated Flat", + "sources": { + "Cardano.Tx": "module Cardano.Tx exposing (validAfter, signedBy)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\n\n-- V3 TxInfo field 7 is the validity interval. Require a finite lower bound.\n-- Times are POSIX milliseconds, not slots or the current wall-clock time.\nvalidAfter : Data -> int\nvalidAfter tx =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, Constr pair(0, [ Constr pair(0, [ Constr pair(1, [ I time ]), _ ]), _ ]), _, _, _, _, _, _, _, _ ]) -> time\n _ -> fail\n\n-- V3 TxInfo field 8 contains every extra signatory.\nsignedBy : Data -> Bytes -> bool\nsignedBy tx owner =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, _, List signers, _, _, _, _, _, _, _ ]) -> hasSigner signers (lower owner)\n _ -> fail\n\nhasSigner : list Data -> bytes -> bool\nhasSigner signers owner =\n case signers of\n [] -> False\n B signer :: rest ->\n if Builtin.equalsByteString signer owner then True\n else hasSigner rest owner\n _ -> fail\n", + "ConstantInputs": "//! Shared inputs for the constant-evaluation trial and its explicit measurements.\nuse nash_ir::{\n build::Builder,\n core::{Binder, Core},\n ty::Ty,\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant as C, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(&'static str, &'a Core<'a>, bool)> {\n let a = b.arena;\n let bytes = |s| b.lit(C::byte_string(a, s));\n let string = |s| b.lit(C::string(a, s));\n let int = b.int(7);\n let data = b.lit(C::data(a, D::integer_from(a, 7)));\n let list = b.lit(C::proto_list(\n a,\n &Type::Integer,\n a.alloc([C::integer_from(a, 7), C::integer_from(a, 8)]),\n ));\n let empty = b.lit(C::proto_list(a, &Type::Integer, &[]));\n let pair = b.lit(C::proto_pair(\n a,\n &Type::Integer,\n &Type::ByteString,\n C::integer_from(a, 7),\n C::byte_string(a, b\"a\"),\n ));\n let call = |f, args: &[&'a Core<'a>]| b.builtin(f, args, Ty::Erased);\n let add = call(F::AddInteger, &[b.int(20), b.int(22)]);\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: add.ty,\n };\n let dlist = b.lit(C::proto_list(\n a,\n &Type::Data,\n a.alloc([C::data(a, D::integer_from(a, 7))]),\n ));\n let dmap = b.lit(C::proto_list(\n a,\n a.alloc(Type::Pair(&Type::Data, &Type::Data)),\n &[],\n ));\n let expanding = b.lit(C::data(\n a,\n D::list(a, a.alloc_slice_copy(&[D::integer_from(a, 7); 30])),\n ));\n let prefix = string(a.as_bump().alloc_str(&\"prefix\".repeat(6)));\n let shared = Binder {\n name: b.fresh(\"prefix\"),\n ty: prefix.ty,\n };\n let shared_prefix = b.let_(\n shared,\n prefix,\n b.constr(\n 0,\n &[\n call(\n F::AppendString,\n &[b.var(shared.name, shared.ty), string(\"x\")],\n ),\n call(\n F::AppendString,\n &[b.var(shared.name, shared.ty), string(\"y\")],\n ),\n ],\n Ty::Erased,\n ),\n );\n let distinct_results = b.constr(\n 0,\n &[\n call(F::AppendString, &[prefix, string(\"x\")]),\n call(F::AppendString, &[prefix, string(\"y\")]),\n ],\n Ty::Erased,\n );\n vec![\n (\"shared_prefix_distinct_results\", shared_prefix, false),\n (\"repeated_literal_distinct_results\", distinct_results, false),\n (\n \"expanding_data_list\",\n call(F::UnListData, &[expanding]),\n false,\n ),\n (\"addition\", add, false),\n (\n \"nested_arithmetic\",\n call(F::MultiplyInteger, &[add, b.int(2)]),\n false,\n ),\n (\n \"bound_arithmetic\",\n b.let_(\n x,\n add,\n call(F::MultiplyInteger, &[b.var(x.name, x.ty), b.int(2)]),\n ),\n false,\n ),\n (\n \"division\",\n call(F::DivideInteger, &[b.int(-7), b.int(3)]),\n false,\n ),\n (\n \"division_zero\",\n call(F::DivideInteger, &[int, b.int(0)]),\n true,\n ),\n (\n \"wrong_integer_shape\",\n call(F::AddInteger, &[bytes(b\"x\"), int]),\n true,\n ),\n (\n \"byte_append\",\n call(F::AppendByteString, &[bytes(b\"ab\"), bytes(b\"cd\")]),\n false,\n ),\n (\n \"byte_slice\",\n call(F::SliceByteString, &[b.int(1), b.int(2), bytes(b\"abcd\")]),\n false,\n ),\n (\n \"byte_length\",\n call(F::LengthOfByteString, &[bytes(b\"abcd\")]),\n false,\n ),\n (\n \"byte_compare\",\n call(F::LessThanByteString, &[bytes(b\"abc\"), bytes(b\"abd\")]),\n false,\n ),\n (\n \"string_append\",\n call(F::AppendString, &[string(\"hello \"), string(\"world\")]),\n false,\n ),\n (\"encode_utf8\", call(F::EncodeUtf8, &[string(\"สวัสดี\")]), false),\n (\n \"decode_utf8\",\n call(F::DecodeUtf8, &[bytes(\"héllo\".as_bytes())]),\n false,\n ),\n (\"invalid_utf8\", call(F::DecodeUtf8, &[bytes(&[255])]), true),\n (\"integer_data\", call(F::IData, &[int]), false),\n (\"decode_integer_data\", call(F::UnIData, &[data]), false),\n (\"wrong_data_variant\", call(F::UnBData, &[data]), true),\n (\"list_data\", call(F::ListData, &[dlist]), false),\n (\"map_data\", call(F::MapData, &[dmap]), false),\n (\"data_equal\", call(F::EqualsData, &[data, data]), false),\n (\"serialise_data\", call(F::SerialiseData, &[data]), false),\n (\"list_head\", call(F::HeadList, &[list]), false),\n (\"list_tail\", call(F::TailList, &[list]), false),\n (\"empty_head\", call(F::HeadList, &[empty]), true),\n (\"empty_tail\", call(F::TailList, &[empty]), true),\n (\"list_null\", call(F::NullList, &[empty]), false),\n (\"pair_first\", call(F::FstPair, &[pair]), false),\n (\"pair_second\", call(F::SndPair, &[pair]), false),\n (\"trace_before\", b.trace(string(\"before\"), add), false),\n (\n \"trace_builtin\",\n call(F::Trace, &[string(\"keep me\"), int]),\n false,\n ),\n (\n \"cold_failure\",\n b.if_(\n b.lit(C::bool(a, true)),\n int,\n call(F::DivideInteger, &[int, b.int(0)]),\n ),\n false,\n ),\n (\n \"selected_branch\",\n b.if_(\n call(F::EqualsInteger, &[int, b.int(7)]),\n b.trace(string(\"yes\"), add),\n b.trace(string(\"no\"), b.error(Ty::Erased)),\n ),\n false,\n ),\n (\n \"strict_failure_order\",\n call(\n F::AddInteger,\n &[\n b.trace(string(\"first\"), b.error(int.ty)),\n call(F::DivideInteger, &[int, b.int(0)]),\n ],\n ),\n true,\n ),\n (\"unsupported_hash\", call(F::Sha2_256, &[bytes(b\"x\")]), false),\n (\n \"partial\",\n b.app(\n b.builtin(F::AddInteger, &[int], Ty::Erased),\n &[b.int(1)],\n Ty::Erased,\n ),\n false,\n ),\n (\n \"large_input\",\n call(\n F::AppendByteString,\n &[bytes(a.alloc_slice_copy(&[42; 4096])), bytes(b\"z\")],\n ),\n false,\n ),\n (\n \"repeated_call\",\n b.constr(0, &[add, add, add], Ty::Erased),\n false,\n ),\n ]\n}\n", + "Eq": "module Eq exposing ( Eq )\n\n\nimport Literal\nimport Logic exposing ( not, xor, (&&) )\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\n\n{-| Compare values for equality and inequality. -}\ntrait Eq 'a where\n eq : 'a -> 'a -> bool\n\n neq : 'a -> 'a -> bool\n neq a b = not (eq a b)\n\n\nimpl Eq int where\n eq = Builtin.equalsInteger\n\n\nimpl Eq bytes where\n eq = Builtin.equalsByteString\n\n\nimpl Eq string where\n eq = Builtin.equalsString\n\n\nimpl Eq bool where\n eq a b = not (xor a b)\n\n\nimpl Eq unit where\n eq _ _ = True\n\n\nimpl Eq (list ('a : Big)) where\n eq xs ys =\n eq (Builtin.listData xs) (Builtin.listData ys)\n\n\nimpl Eq 'a => Eq (list ('a : Little)) where\n eq xs ys =\n case xs of\n [] ->\n case ys of\n [] ->\n True\n\n _ :: _ ->\n False\n\n x :: restX ->\n case ys of\n [] ->\n False\n\n y :: restY ->\n eq x y && eq restX restY\n\n\nimpl ( Eq 'a, Eq 'b ) => Eq (pair 'a 'b) where\n eq a b =\n let\n pair(firstA, secondA) = a\n\n pair(firstB, secondB) = b\n in\n eq firstA firstB && eq secondA secondB\n\n\nimpl Eq (map ('k : Big) ('v : Big)) where\n eq xs ys = eq (Builtin.mapData xs) (Builtin.mapData ys)\n\n\nimpl ( Eq 'k, Eq 'v ) => Eq (map ('k : Little) 'v) where\n eq = eqMapEntries\n\n\nimpl Eq 'v => Eq (map ('k : Big) ('v : Little)) where\n eq = eqMapEntries\n\n\neqMapEntries : ( Eq 'k, Eq 'v ) => list (pair 'k 'v) -> list (pair 'k 'v) -> bool\neqMapEntries = eq\n\n\nimpl Eq value where\n eq a b = Builtin.equalsData (Builtin.valueData a) (Builtin.valueData b)\n", + "InverseInputs": "//! Shared semantic and explicit performance inputs for representation cancellation.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, Ty},\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(String, &'a Core<'a>, bool)> {\n let a = b.arena;\n let d = D::integer_from(a, 7);\n let data = Constant::data(a, d);\n let pair = Constant::proto_pair(a, &Type::Data, &Type::Data, data, data);\n let list = Constant::proto_list(a, &Type::Data, a.alloc([data]));\n let map = Constant::proto_list(\n a,\n a.alloc(Type::Pair(&Type::Data, &Type::Data)),\n a.alloc([pair]),\n );\n let mut cases = Vec::new();\n for (name, encode, decode, value, encoded) in [\n (\"integer\", F::IData, F::UnIData, b.int(7), b.lit(data)),\n (\n \"bytes\",\n F::BData,\n F::UnBData,\n b.lit(Constant::byte_string(a, b\"hello\")),\n b.lit(Constant::data(a, D::byte_string(a, b\"hello\"))),\n ),\n (\n \"list\",\n F::ListData,\n F::UnListData,\n b.lit(list),\n b.lit(Constant::data(a, D::list(a, a.alloc([d])))),\n ),\n (\n \"map\",\n F::MapData,\n F::UnMapData,\n b.lit(map),\n b.lit(Constant::data(a, D::map(a, a.alloc([(d, d)])))),\n ),\n (\n \"utf8\",\n F::EncodeUtf8,\n F::DecodeUtf8,\n b.lit(Constant::string(a, \"héllo\")),\n b.lit(Constant::byte_string(a, \"héllo\".as_bytes())),\n ),\n ] {\n let wrap = |x| b.builtin(decode, &[b.builtin(encode, &[x], encoded.ty)], value.ty);\n let trace = |s, x| b.trace(b.lit(Constant::string(a, s)), x);\n cases.push((format!(\"{name}_direct\"), wrap(value), false));\n cases.push((\n format!(\"{name}_trace\"),\n wrap(trace(\"operand\", value)),\n false,\n ));\n cases.push((\n format!(\"{name}_decoded\"),\n wrap(b.builtin(decode, &[encoded], value.ty)),\n false,\n ));\n cases.push((\n format!(\"{name}_decode_failure\"),\n wrap(b.builtin(decode, &[b.int(0)], value.ty)),\n true,\n ));\n cases.push((\n format!(\"{name}_reverse\"),\n b.builtin(\n encode,\n &[b.builtin(decode, &[encoded], value.ty)],\n encoded.ty,\n ),\n false,\n ));\n cases.push((\n format!(\"{name}_wrong_kind\"),\n wrap(b.with_type(b.lit(Constant::bool(a, false)), value.ty)),\n true,\n ));\n cases.push((\n format!(\"{name}_cold\"),\n b.if_(\n b.lit(Constant::bool(a, true)),\n value,\n wrap(trace(\"cold\", value)),\n ),\n false,\n ));\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: value.ty,\n };\n let y = Binder {\n name: b.fresh(\"encoded\"),\n ty: encoded.ty,\n };\n let z = Binder {\n name: b.fresh(\"alias\"),\n ty: encoded.ty,\n };\n let decoded = b.builtin(decode, &[b.var(z.name, z.ty)], value.ty);\n let bindings = |body| {\n b.let_(\n x,\n trace(\"once\", value),\n b.let_(\n y,\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n b.let_(z, b.var(y.name, y.ty), body),\n ),\n )\n };\n cases.push((\n format!(\"{name}_bound\"),\n bindings(trace(\"after encoding\", decoded)),\n false,\n ));\n cases.push((\n format!(\"{name}_captured\"),\n bindings(b.force(b.delay(decoded), decoded.ty)),\n false,\n ));\n cases.push((\n format!(\"{name}_escaping\"),\n bindings(b.constr(0, &[b.var(y.name, y.ty), decoded, decoded], Ty::Erased)),\n false,\n ));\n cases.push((\n format!(\"{name}_bound_invalid\"),\n b.let_(\n x,\n trace(\n \"operand\",\n b.with_type(b.lit(Constant::bool(a, false)), value.ty),\n ),\n b.let_(\n y,\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n trace(\n \"must not run\",\n b.builtin(decode, &[b.var(y.name, y.ty)], value.ty),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_reverse_bound_invalid\"),\n b.let_(\n y,\n b.with_type(b.int(0), encoded.ty),\n b.let_(\n x,\n b.builtin(decode, &[b.var(y.name, y.ty)], value.ty),\n trace(\n \"must not run\",\n b.builtin(encode, &[b.var(x.name, x.ty)], encoded.ty),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_oversaturated\"),\n b.app(wrap(value), &[b.int(1)], value.ty),\n true,\n ));\n let unknown = Binder {\n name: b.fresh(\"unknown\"),\n ty: value.ty,\n };\n cases.push((\n format!(\"{name}_unknown_invalid\"),\n b.app(\n b.lam(&[unknown], wrap(b.var(unknown.name, unknown.ty))),\n &[b.lit(Constant::bool(a, false))],\n value.ty,\n ),\n true,\n ));\n cases.push((\n format!(\"{name}_partial\"),\n b.app(\n b.builtin(decode, &[], Ty::Erased),\n &[b.builtin(encode, &[value], encoded.ty)],\n value.ty,\n ),\n false,\n ));\n }\n let bad_utf8 = b.lit(Constant::byte_string(a, &[255]));\n cases.push((\n \"utf8_reverse_invalid\".into(),\n b.builtin(\n F::EncodeUtf8,\n &[b.builtin(F::DecodeUtf8, &[bad_utf8], Ty::Const(&ConstTy::String))],\n bad_utf8.ty,\n ),\n true,\n ));\n for (name, encode, decode, typ) in [\n (\"list_wrong_tag\", F::ListData, F::UnListData, &Type::Integer),\n (\"map_wrong_tag\", F::MapData, F::UnMapData, &Type::Data),\n ] {\n let value = b.lit(Constant::proto_list(a, typ, &[]));\n cases.push((\n name.into(),\n b.builtin(decode, &[b.builtin(encode, &[value], Ty::Erased)], value.ty),\n true,\n ));\n }\n let data_ty = b.lit(data).ty;\n let fields = Binder {\n name: b.fresh(\"fields\"),\n ty: b.lit(list).ty,\n };\n let tag = Binder {\n name: b.fresh(\"tag\"),\n ty: b.int(0).ty,\n };\n let encoded = Binder {\n name: b.fresh(\"constructor\"),\n ty: data_ty,\n };\n let payload = Binder {\n name: b.fresh(\"payload\"),\n ty: Ty::Erased,\n };\n let p = b.var(payload.name, payload.ty);\n let fst = b.builtin(F::FstPair, &[p], tag.ty);\n let snd = b.builtin(F::SndPair, &[p], fields.ty);\n let constructor = b.builtin(\n F::ConstrData,\n &[b.var(tag.name, tag.ty), b.var(fields.name, fields.ty)],\n data_ty,\n );\n let bind = |body| {\n b.let_(\n tag,\n b.int(0),\n b.let_(\n fields,\n b.lit(list),\n b.let_(\n encoded,\n constructor,\n b.let_(\n payload,\n b.builtin(\n F::UnConstrData,\n &[b.var(encoded.name, encoded.ty)],\n Ty::Erased,\n ),\n body,\n ),\n ),\n ),\n )\n };\n cases.push((\"constructor_tag\".into(), bind(fst), false));\n cases.push((\"constructor_fields\".into(), bind(snd), false));\n cases.push((\n \"constructor_rebuild\".into(),\n bind(b.builtin(F::ConstrData, &[fst, snd], data_ty)),\n false,\n ));\n for (name, subject, fails) in [\n (\n \"constructor_known_reverse\",\n b.lit(Constant::data(a, D::constr(a, 3, a.alloc([d])))),\n false,\n ),\n (\"constructor_wrong_variant\", b.lit(data), true),\n ] {\n cases.push((\n name.into(),\n b.let_(\n encoded,\n subject,\n b.let_(\n payload,\n b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased),\n b.trace(\n b.lit(Constant::string(a, \"after decoding\")),\n b.builtin(F::ConstrData, &[fst, snd], data_ty),\n ),\n ),\n ),\n fails,\n ));\n }\n let bad_tag = b.with_type(b.lit(Constant::bool(a, false)), tag.ty);\n cases.push((\n \"constructor_bad_tag\".into(),\n b.let_(\n tag,\n bad_tag,\n b.let_(\n fields,\n b.trace(b.lit(Constant::string(a, \"fields evaluated\")), b.lit(list)),\n b.let_(\n encoded,\n constructor,\n b.builtin(\n F::FstPair,\n &[b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased)],\n tag.ty,\n ),\n ),\n ),\n ),\n true,\n ));\n cases.push((\n \"constructor_bad_fields\".into(),\n b.let_(\n tag,\n b.int(0),\n b.let_(\n fields,\n b.with_type(b.lit(Constant::bool(a, false)), fields.ty),\n b.let_(\n encoded,\n constructor,\n b.builtin(\n F::SndPair,\n &[b.builtin(F::UnConstrData, &[b.var(encoded.name, data_ty)], Ty::Erased)],\n fields.ty,\n ),\n ),\n ),\n ),\n true,\n ));\n cases\n}\n", + "Lift": "module Lift exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait Lift 'a 'b where\n lift : 'a -> 'b\n lower : 'b -> 'a\n\nimpl Lift int Int where\n lift value = Builtin.iData value\n lower value = Builtin.unIData value\n\nimpl Lift bytes Bytes where\n lift value = Builtin.bData value\n lower value = Builtin.unBData value\n", + "Literal": "module Literal exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait FromInt 'a where\n fromInt : int -> 'a\n\ntrait FromString 'a where\n fromString : string -> 'a\n\ntrait FromBytes 'a where\n fromBytes : bytes -> 'a\n\nimpl FromInt int where\n fromInt x = x\n\nimpl FromString string where\n fromString x = x\n\nimpl FromBytes bytes where\n fromBytes x = x\n\ntrait FromBool 'a where\n fromBool : bool -> 'a\n\ntrait FromUnit 'a where\n fromUnit : unit -> 'a\n\nimpl FromBool bool where\n fromBool value = value\n\nimpl FromUnit unit where\n fromUnit value = value\n", + "Logic": "module Logic exposing ( not, and, or, xor, (&&), (||) )\n\n\nimport Primitive\nimport Lift exposing ( Lift )\n\n\ninfix right 2 (||) = or\n\n\ninfix right 3 (&&) = and\n\n\n{-| Negate a Big or little Boolean, returning bool. -}\nnot : Lift bool 'a => 'a -> bool\nnot value =\n if lower value then\n Primitive.False\n else\n Primitive.True\n\n\n{-| Boolean conjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nand : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nand a b =\n if lower a then\n lower b\n else\n Primitive.False\n\n\n{-| Boolean disjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nor a b =\n if lower a then\n Primitive.True\n else\n lower b\n\n\n{-| Return True when the Boolean operands differ. -}\nxor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nxor a b =\n if lower a then\n not b\n else\n lower b\n", + "Vesting": "validator module Vesting exposing (main)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\nimport Cardano.Tx exposing (validAfter, signedBy)\n\ntype Datum = Datum { owner : Bytes, deadline : Int }\n\ntype step 'a = Done 'a | Next int 'a\n\ntype alias acc = { total : int, seen : list Int }\n\ntype Redeemer = Claim | Cancel\n\n-- The ledger supplies one V3 ScriptContext; spending datum is in ScriptInfo.\nmain : Data -> unit\nmain ctx =\n case ctx of\n Constr pair(0, [ tx, action, Constr pair(1, [ _, Constr pair(0, [ datum ]) ]) ]) ->\n check (Primitive.coerce datum) (Primitive.coerce action) tx\n _ -> fail\n\ncheck : Datum -> Redeemer -> Data -> unit\ncheck datum redeemer tx =\n case redeemer of\n Claim -> assert (Builtin.lessThanInteger (lower datum.deadline) (validAfter tx))\n Cancel -> assert (signedBy tx datum.owner)\n", + "VestingContextInput": "//! Shared ledger input for the vesting snapshots, artifact tests and explicit perf runner.\nuse nash_plutus::{arena::Arena, data::PlutusData};\n\npub fn context<'a>(\n arena: &'a Arena,\n datum: &'a PlutusData<'a>,\n redeemer: &'a PlutusData<'a>,\n lower_time: i128,\n signer: &'a [u8],\n) -> &'a PlutusData<'a> {\n let constr = |tag, fields: &[&'a PlutusData<'a>]| {\n PlutusData::constr(arena, tag, arena.alloc_slice_copy(fields))\n };\n let empty_list = PlutusData::list(arena, &[]);\n let empty_map = PlutusData::map(arena, &[]);\n let zero = PlutusData::integer_from(arena, 0);\n let tx_id = PlutusData::byte_string(arena, &[0; 32]);\n let closed = constr(1, &[]);\n let lower = constr(\n 0,\n &[\n constr(1, &[PlutusData::integer_from(arena, lower_time)]),\n closed,\n ],\n );\n let upper = constr(0, &[constr(2, &[]), closed]);\n let signers = if signer.is_empty() {\n empty_list\n } else {\n // The owner is deliberately second: signedBy must search the whole list.\n PlutusData::list(\n arena,\n arena.alloc_slice_copy(&[\n PlutusData::byte_string(arena, &[0xbb]),\n PlutusData::byte_string(arena, signer),\n ]),\n )\n };\n let tx = constr(\n 0,\n &[\n empty_list, // inputs\n empty_list, // reference inputs\n empty_list, // outputs\n zero, // fee\n empty_map, // mint\n empty_list, // certificates\n empty_map, // withdrawals\n constr(0, &[lower, upper]), // validity range\n signers,\n empty_map, // redeemers\n empty_map, // datums\n tx_id,\n empty_map, // votes\n empty_list, // proposals\n constr(1, &[]), // current treasury\n constr(1, &[]), // treasury donation\n ],\n );\n let reference = constr(0, &[tx_id, zero]);\n let spending = constr(1, &[reference, constr(0, &[datum])]);\n constr(0, &[tx, redeemer, spending])\n}\n", + "VestingParam": "validator module VestingParam exposing (main)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\nimport Cardano.Tx exposing (validAfter, signedBy)\n\ntype Datum = Datum { owner : Bytes, deadline : Int }\n\ntype Redeemer = Claim | Cancel\n\n-- The ledger supplies one V3 ScriptContext; spending datum is in ScriptInfo.\nmain : int -> Data -> unit\nmain minimumLock ctx =\n case ctx of\n Constr pair(0, [ tx, action, Constr pair(1, [ _, Constr pair(0, [ datum ]) ]) ]) ->\n check minimumLock (Primitive.coerce datum) (Primitive.coerce action) tx\n _ -> fail\n\ncheck : int -> Datum -> Redeemer -> Data -> unit\ncheck minimumLock datum redeemer tx =\n case redeemer of\n Claim ->\n assert\n (Builtin.lessThanInteger\n (Builtin.addInteger (lower datum.deadline) minimumLock)\n (validAfter tx))\n Cancel -> assert (signedBy tx datum.owner)\n", + "Workloads": "module Workloads exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Logic exposing (..)\n\nsum : list int -> int\nsum xs =\n case xs of\n [] -> 0\n x :: rest -> Builtin.addInteger x (sum rest)\n\nlistTraversal : int\nlistTraversal = sum [1, 2, 3, 4, 5, 6, 7, 8]\n\ncountdown : int -> int -> int\ncountdown n result =\n if Builtin.equalsInteger n 0 then\n result\n else\n countdown (Builtin.subtractInteger n 1) result\n\nstaticRecursion : int\nstaticRecursion = countdown 8 42\n\nmatchData : Data -> int\nmatchData value =\n case value of\n I n -> n\n _ -> 0\n\ndataMatch : int\ndataMatch = matchData (I 42)\n\ndataMiss : int\ndataMiss = matchData (B #\"ab\")\n\ndecode : Data -> int\ndecode value =\n case value of\n Constr pair(_, [I n, _]) -> n\n _ -> 0\n\ndecoding : int\ndecoding = decode (Builtin.constrData 0 [I 42, I 7])\n\nvalidate : Data -> unit\nvalidate value =\n case value of\n I n -> assert (Builtin.lessThanInteger 0 n)\n _ -> fail\n\nvalidationPass : unit\nvalidationPass = validate (I 42)\n\nvalidationFail : unit\nvalidationFail = validate (I 0)\n\nbooleanHelpers : bool\nbooleanHelpers = (True && False) || (True && True)\n\nconstantPrefixTwice : int\nconstantPrefixTwice =\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nconstantPrefixCold : int\nconstantPrefixCold =\n if True then\n 42\n else\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nprefixLoop : int -> int\nprefixLoop n =\n if Builtin.equalsInteger n 0 then\n 0\n else\n Builtin.addInteger\n (Builtin.addInteger (Builtin.subtractInteger 100 n) (Builtin.subtractInteger 100 n))\n (prefixLoop (Builtin.subtractInteger n 1))\n\nconstantPrefixLoop : int\nconstantPrefixLoop = prefixLoop 8\n" + }, + "revision": "eae2bdad131dddd8bad56716bc2f6c057c457385", + "rustc": "rustc 1.98.1 (48a229cea 2026-09-01)", + "rows": [ + { + "input": "Workloads.listTraversal (fixtures/Workloads.nash)", + "before": { + "cpu": 4764660, + "memory": 21472, + "bytes": 93, + "result": "(con integer 36)", + "logs": [] + }, + "after": { + "cpu": 3225764, + "memory": 15216, + "bytes": 41, + "result": "(con integer 36)", + "logs": [] + } + }, + { + "input": "Workloads.staticRecursion (fixtures/Workloads.nash)", + "before": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.dataMatch (fixtures/Workloads.nash)", + "before": { + "cpu": 111399, + "memory": 732, + "bytes": 11, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 111399, + "memory": 732, + "bytes": 11, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.dataMiss (fixtures/Workloads.nash)", + "before": { + "cpu": 107283, + "memory": 732, + "bytes": 14, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "Workloads.decoding (fixtures/Workloads.nash)", + "before": { + "cpu": 1681280, + "memory": 8756, + "bytes": 94, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 1681280, + "memory": 8756, + "bytes": 94, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.validationPass (fixtures/Workloads.nash)", + "before": { + "cpu": 364689, + "memory": 2033, + "bytes": 47, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 111399, + "memory": 732, + "bytes": 10, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Workloads.validationFail (fixtures/Workloads.nash)", + "before": { + "cpu": 120187, + "memory": 165, + "bytes": 47, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 74897, + "memory": 164, + "bytes": 36, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "Workloads.booleanHelpers (fixtures/Workloads.nash)", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "Workloads.constantPrefixTwice (fixtures/Workloads.nash)", + "before": { + "cpu": 623724, + "memory": 2106, + "bytes": 26, + "result": "(con integer 197)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con integer 197)", + "logs": [] + } + }, + { + "input": "Workloads.constantPrefixCold (fixtures/Workloads.nash)", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "Workloads.constantPrefixLoop (fixtures/Workloads.nash)", + "before": { + "cpu": 10839417, + "memory": 39689, + "bytes": 67, + "result": "(con integer 1528)", + "logs": [] + }, + "after": { + "cpu": 10839417, + "memory": 39689, + "bytes": 67, + "result": "(con integer 1528)", + "logs": [] + } + }, + { + "input": "Vesting: claim after deadline; deadline=10, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: claim before deadline; deadline=30, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7888999, + "memory": 40748, + "bytes": 821, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7888999, + "memory": 40748, + "bytes": 821, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "Vesting: cancel signed; deadline=10, action=1, signer=[170], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7915016, + "memory": 42850, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 7915016, + "memory": 42850, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: cancel unsigned; deadline=10, action=1, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 4134408, + "memory": 20552, + "bytes": 821, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 4134408, + "memory": 20552, + "bytes": 821, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "Vesting: boundary zero minimum; deadline=18, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "Vesting: boundary five minimum; deadline=18, action=0, signer=[], minimum=none, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 9093501, + "memory": 48616, + "bytes": 821, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: claim after deadline; deadline=10, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9354709, + "memory": 49618, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 9354709, + "memory": 49618, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: claim before deadline; deadline=30, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7990207, + "memory": 40750, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7990207, + "memory": 40750, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "VestingParam: cancel signed; deadline=10, action=1, signer=[170], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7963016, + "memory": 43150, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 7963016, + "memory": 43150, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: cancel unsigned; deadline=10, action=1, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 4134408, + "memory": 20552, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 4134408, + "memory": 20552, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "VestingParam: boundary zero minimum; deadline=18, action=0, signer=[], minimum=0, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 9354709, + "memory": 49618, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 9354709, + "memory": 49618, + "bytes": 827, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "VestingParam: boundary five minimum; deadline=18, action=0, signer=[], minimum=5, V3 context, lower_time=20, owner=[170]", + "before": { + "cpu": 7990207, + "memory": 40750, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 7990207, + "memory": 40750, + "bytes": 827, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "representation cancellation: integer_direct", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_trace", + "before": { + "cpu": 235598, + "memory": 1232, + "bytes": 23, + "result": "(con integer 7)", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 23, + "result": "(con integer 7)", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: integer_decoded", + "before": { + "cpu": 68844, + "memory": 432, + "bytes": 11, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 8, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 8, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_reverse", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_cold", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_bound", + "before": { + "cpu": 534395, + "memory": 2696, + "bytes": 48, + "result": "(con integer 7)", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 534395, + "memory": 2696, + "bytes": 48, + "result": "(con integer 7)", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: integer_captured", + "before": { + "cpu": 378897, + "memory": 2064, + "bytes": 27, + "result": "(con integer 7)", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 378897, + "memory": 2064, + "bytes": 27, + "result": "(con integer 7)", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: integer_escaping", + "before": { + "cpu": 426897, + "memory": 2364, + "bytes": 32, + "result": "(constr 0 (con data (I 7)) (con integer 7) (con integer 7))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 426897, + "memory": 2364, + "bytes": 32, + "result": "(constr 0 (con data (I 7)) (con integer 7) (con integer 7))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: integer_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: integer_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_oversaturated", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(Integer(7)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: integer_partial", + "before": { + "cpu": 164143, + "memory": 964, + "bytes": 12, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 164143, + "memory": 964, + "bytes": 12, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_direct", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_trace", + "before": { + "cpu": 235598, + "memory": 1232, + "bytes": 29, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 29, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: bytes_decoded", + "before": { + "cpu": 68242, + "memory": 432, + "bytes": 16, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 8, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 8, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_reverse", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con data (B #68656c6c6f))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con data (B #68656c6c6f))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_cold", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 13, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_bound", + "before": { + "cpu": 530279, + "memory": 2696, + "bytes": 54, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 530279, + "memory": 2696, + "bytes": 54, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: bytes_captured", + "before": { + "cpu": 374781, + "memory": 2064, + "bytes": 33, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 374781, + "memory": 2064, + "bytes": 33, + "result": "(con bytestring #68656c6c6f)", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: bytes_escaping", + "before": { + "cpu": 422781, + "memory": 2364, + "bytes": 38, + "result": "(constr 0\n (con data (B #68656c6c6f))\n (con bytestring #68656c6c6f)\n (con bytestring #68656c6c6f))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 422781, + "memory": 2364, + "bytes": 38, + "result": "(constr 0\n (con data (B #68656c6c6f))\n (con bytestring #68656c6c6f)\n (con bytestring #68656c6c6f))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: bytes_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: bytes_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_oversaturated", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ByteString([104, 101, 108, 108, 111])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ByteString([104, 101, 108, 108, 111])))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(ByteString, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: bytes_partial", + "before": { + "cpu": 159425, + "memory": 964, + "bytes": 19, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + }, + "after": { + "cpu": 68242, + "memory": 432, + "bytes": 16, + "result": "(con bytestring #68656c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: list_direct", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: list_trace", + "before": { + "cpu": 235598, + "memory": 1232, + "bytes": 28, + "result": "(con (list data) [(I 7)])", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 28, + "result": "(con (list data) [(I 7)])", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: list_decoded", + "before": { + "cpu": 74033, + "memory": 432, + "bytes": 13, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: list_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 8, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 8, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_reverse", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (List [I 7]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (List [I 7]))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_cold", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: list_bound", + "before": { + "cpu": 552948, + "memory": 2696, + "bytes": 53, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 552948, + "memory": 2696, + "bytes": 53, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: list_captured", + "before": { + "cpu": 397450, + "memory": 2064, + "bytes": 32, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 397450, + "memory": 2064, + "bytes": 32, + "result": "(con (list data) [(I 7)])", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: list_escaping", + "before": { + "cpu": 445450, + "memory": 2364, + "bytes": 37, + "result": "(constr 0\n (con data (List [I 7]))\n (con (list data) [(I 7)])\n (con (list data) [(I 7)]))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 445450, + "memory": 2364, + "bytes": 37, + "result": "(constr 0\n (con data (List [I 7]))\n (con (list data) [(I 7)])\n (con (list data) [(I 7)]))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: list_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: list_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_oversaturated", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Data, [Data(Integer(7))])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Data, [Data(Integer(7))])))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_partial", + "before": { + "cpu": 187885, + "memory": 964, + "bytes": 16, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 74033, + "memory": 432, + "bytes": 13, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_direct", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 17, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 17, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_trace", + "before": { + "cpu": 235598, + "memory": 1232, + "bytes": 34, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 34, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: map_decoded", + "before": { + "cpu": 72723, + "memory": 432, + "bytes": 13, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 72723, + "memory": 432, + "bytes": 13, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 8, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 8, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_reverse", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (Map [(I 7, I 7)]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (Map [(I 7, I 7)]))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_cold", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 17, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 17, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: map_bound", + "before": { + "cpu": 587342, + "memory": 2696, + "bytes": 59, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 587342, + "memory": 2696, + "bytes": 59, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: map_captured", + "before": { + "cpu": 431844, + "memory": 2064, + "bytes": 38, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 431844, + "memory": 2064, + "bytes": 38, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: map_escaping", + "before": { + "cpu": 479844, + "memory": 2364, + "bytes": 43, + "result": "(constr 0\n (con data (Map [(I 7, I 7)]))\n (con (list (pair data data)) [((I 7), (I 7))])\n (con (list (pair data data)) [((I 7), (I 7))]))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 479844, + "memory": 2364, + "bytes": 43, + "result": "(constr 0\n (con data (Map [(I 7, I 7)]))\n (con (list (pair data data)) [((I 7), (I 7))])\n (con (list (pair data data)) [((I 7), (I 7))]))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: map_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: map_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(NotData(Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_oversaturated", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 19, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Pair(Data, Data), [ProtoPair(Data, Data, Data(Integer(7)), Data(Integer(7)))])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 19, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(ProtoList(Pair(Data, Data), [ProtoPair(Data, Data, Data(Integer(7)), Data(Integer(7)))])))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_partial", + "before": { + "cpu": 220969, + "memory": 964, + "bytes": 23, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + }, + "after": { + "cpu": 72723, + "memory": 432, + "bytes": 13, + "result": "(con (list (pair data data)) [((I 7), (I 7))])", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_direct", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"héllo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"héllo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_trace", + "before": { + "cpu": 235598, + "memory": 1232, + "bytes": 30, + "result": "(con string \"héllo\")", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 30, + "result": "(con string \"héllo\")", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: utf8_decoded", + "before": { + "cpu": 140058, + "memory": 406, + "bytes": 16, + "result": "(con string \"héllo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"héllo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_decode_failure", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 8, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 8, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_reverse", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con bytestring #68c3a96c6c6f)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con bytestring #68c3a96c6c6f)", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_wrong_kind", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_cold", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"héllo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"héllo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_bound", + "before": { + "cpu": 563017, + "memory": 2670, + "bytes": 55, + "result": "(con string \"héllo\")", + "logs": [ + "once", + "after encoding" + ] + }, + "after": { + "cpu": 563017, + "memory": 2670, + "bytes": 55, + "result": "(con string \"héllo\")", + "logs": [ + "once", + "after encoding" + ] + } + }, + { + "input": "representation cancellation: utf8_captured", + "before": { + "cpu": 407519, + "memory": 2038, + "bytes": 34, + "result": "(con string \"héllo\")", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 407519, + "memory": 2038, + "bytes": 34, + "result": "(con string \"héllo\")", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: utf8_escaping", + "before": { + "cpu": 455519, + "memory": 2338, + "bytes": 39, + "result": "(constr 0\n (con bytestring #68c3a96c6c6f)\n (con string \"héllo\")\n (con string \"héllo\"))", + "logs": [ + "once" + ] + }, + "after": { + "cpu": 455519, + "memory": 2338, + "bytes": 39, + "result": "(constr 0\n (con bytestring #68c3a96c6c6f)\n (con string \"héllo\")\n (con string \"héllo\"))", + "logs": [ + "once" + ] + } + }, + { + "input": "representation cancellation: utf8_bound_invalid", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [ + "operand" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 50, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [ + "operand" + ] + } + }, + { + "input": "representation cancellation: utf8_reverse_bound_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 34, + "result": "error: Runtime(TypeMismatch(ByteString, Integer(0)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_oversaturated", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(String(\"héllo\")))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: NonFunctionApplication(Con(Integer(1)), Con(String(\"héllo\")))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_unknown_invalid", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(TypeMismatch(String, Boolean(false)))", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_partial", + "before": { + "cpu": 263979, + "memory": 912, + "bytes": 20, + "result": "(con string \"héllo\")", + "logs": [] + }, + "after": { + "cpu": 140058, + "memory": 406, + "bytes": 16, + "result": "(con string \"héllo\")", + "logs": [] + } + }, + { + "input": "representation cancellation: utf8_reverse_invalid", + "before": { + "cpu": 92058, + "memory": 106, + "bytes": 15, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + }, + "after": { + "cpu": 92058, + "memory": 106, + "bytes": 15, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + } + }, + { + "input": "representation cancellation: list_wrong_tag", + "before": { + "cpu": 33952, + "memory": 132, + "bytes": 12, + "result": "error: Runtime(TypeMismatch(Data, ProtoList(Integer, [])))", + "logs": [] + }, + "after": { + "cpu": 33952, + "memory": 132, + "bytes": 12, + "result": "error: Runtime(TypeMismatch(Data, ProtoList(Integer, [])))", + "logs": [] + } + }, + { + "input": "representation cancellation: map_wrong_tag", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 12, + "result": "error: Runtime(TypeMismatch(List(Pair(Data, Data)), ProtoList(Data, [])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 12, + "result": "error: Runtime(TypeMismatch(List(Pair(Data, Data)), ProtoList(Data, [])))", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_tag", + "before": { + "cpu": 254839, + "memory": 1464, + "bytes": 22, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 254839, + "memory": 1464, + "bytes": 22, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_fields", + "before": { + "cpu": 302839, + "memory": 1764, + "bytes": 24, + "result": "(con (list data) [(I 7)])", + "logs": [] + }, + "after": { + "cpu": 302839, + "memory": 1764, + "bytes": 24, + "result": "(con (list data) [(I 7)])", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_rebuild", + "before": { + "cpu": 404990, + "memory": 2296, + "bytes": 29, + "result": "(con data (Constr 0 [I 7]))", + "logs": [] + }, + "after": { + "cpu": 404990, + "memory": 2296, + "bytes": 29, + "result": "(con data (Constr 0 [I 7]))", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_known_reverse", + "before": { + "cpu": 388186, + "memory": 2064, + "bytes": 43, + "result": "(con data (Constr 3 [I 7]))", + "logs": [ + "after decoding" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 36, + "result": "(con data (Constr 3 [I 7]))", + "logs": [ + "after decoding" + ] + } + }, + { + "input": "representation cancellation: constructor_wrong_variant", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 39, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 39, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "representation cancellation: constructor_bad_tag", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 48, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "fields evaluated" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 48, + "result": "error: Runtime(TypeMismatch(Integer, Boolean(false)))", + "logs": [ + "fields evaluated" + ] + } + }, + { + "input": "representation cancellation: constructor_bad_fields", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 15, + "result": "error: Runtime(ExpectedList(Boolean(false)))", + "logs": [] + } + }, + { + "input": "constant folding: shared_prefix_distinct_results", + "before": { + "cpu": 1401326, + "memory": 2126, + "bytes": 70, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + }, + "after": { + "cpu": 48100, + "memory": 400, + "bytes": 87, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + } + }, + { + "input": "constant folding: repeated_literal_distinct_results", + "before": { + "cpu": 1369326, + "memory": 1926, + "bytes": 68, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + }, + "after": { + "cpu": 48100, + "memory": 400, + "bytes": 87, + "result": "(constr 0\n (con string \"prefixprefixprefixprefixprefixprefixx\")\n (con string \"prefixprefixprefixprefixprefixprefixy\"))", + "logs": [] + } + }, + { + "input": "constant folding: expanding_data_list", + "before": { + "cpu": 74033, + "memory": 432, + "bytes": 42, + "result": "(con (list data) [(I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7)])", + "logs": [] + }, + "after": { + "cpu": 74033, + "memory": 432, + "bytes": 42, + "result": "(con (list data) [(I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7), (I 7)])", + "logs": [] + } + }, + { + "input": "constant folding: addition", + "before": { + "cpu": 181308, + "memory": 602, + "bytes": 10, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "constant folding: nested_arithmetic", + "before": { + "cpu": 384261, + "memory": 1304, + "bytes": 18, + "result": "(con integer 84)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con integer 84)", + "logs": [] + } + }, + { + "input": "constant folding: bound_arithmetic", + "before": { + "cpu": 384261, + "memory": 1304, + "bytes": 18, + "result": "(con integer 84)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con integer 84)", + "logs": [] + } + }, + { + "input": "constant folding: division", + "before": { + "cpu": 212030, + "memory": 601, + "bytes": 10, + "result": "(con integer -3)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer -3)", + "logs": [] + } + }, + { + "input": "constant folding: division_zero", + "before": { + "cpu": 132030, + "memory": 101, + "bytes": 10, + "result": "error: Runtime(DivisionByZero(7, 0))", + "logs": [] + }, + "after": { + "cpu": 132030, + "memory": 101, + "bytes": 10, + "result": "error: Runtime(DivisionByZero(7, 0))", + "logs": [] + } + }, + { + "input": "constant folding: wrong_integer_shape", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([120])))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 13, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([120])))", + "logs": [] + } + }, + { + "input": "constant folding: byte_append", + "before": { + "cpu": 81446, + "memory": 602, + "bytes": 18, + "result": "(con bytestring #61626364)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 12, + "result": "(con bytestring #61626364)", + "logs": [] + } + }, + { + "input": "constant folding: byte_slice", + "before": { + "cpu": 132568, + "memory": 804, + "bytes": 19, + "result": "(con bytestring #6263)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 10, + "result": "(con bytestring #6263)", + "logs": [] + } + }, + { + "input": "constant folding: byte_length", + "before": { + "cpu": 70200, + "memory": 410, + "bytes": 14, + "result": "(con integer 4)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 4)", + "logs": [] + } + }, + { + "input": "constant folding: byte_compare", + "before": { + "cpu": 109173, + "memory": 601, + "bytes": 20, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: string_append", + "before": { + "cpu": 201014, + "memory": 606, + "bytes": 25, + "result": "(con string \"hello world\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 19, + "result": "(con string \"hello world\")", + "logs": [] + } + }, + { + "input": "constant folding: encode_utf8", + "before": { + "cpu": 220784, + "memory": 412, + "bytes": 28, + "result": "(con bytestring #e0b8aae0b8a7e0b8b1e0b8aae0b894e0b8b5)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 26, + "result": "(con bytestring #e0b8aae0b8a7e0b8b1e0b8aae0b894e0b8b5)", + "logs": [] + } + }, + { + "input": "constant folding: decode_utf8", + "before": { + "cpu": 140058, + "memory": 406, + "bytes": 16, + "result": "(con string \"héllo\")", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 14, + "result": "(con string \"héllo\")", + "logs": [] + } + }, + { + "input": "constant folding: invalid_utf8", + "before": { + "cpu": 92058, + "memory": 106, + "bytes": 11, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + }, + "after": { + "cpu": 92058, + "memory": 106, + "bytes": 11, + "result": "error: Runtime(DecodeUtf8(Utf8Error { valid_up_to: 0, error_len: Some(1) }))", + "logs": [] + } + }, + { + "input": "constant folding: integer_data", + "before": { + "cpu": 63399, + "memory": 432, + "bytes": 8, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 63399, + "memory": 432, + "bytes": 8, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "constant folding: decode_integer_data", + "before": { + "cpu": 68844, + "memory": 432, + "bytes": 11, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: wrong_data_variant", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 11, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "constant folding: list_data", + "before": { + "cpu": 81952, + "memory": 432, + "bytes": 12, + "result": "(con data (List [I 7]))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 11, + "result": "(con data (List [I 7]))", + "logs": [] + } + }, + { + "input": "constant folding: map_data", + "before": { + "cpu": 116346, + "memory": 432, + "bytes": 11, + "result": "(con data (Map []))", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con data (Map []))", + "logs": [] + } + }, + { + "input": "constant folding: data_equal", + "before": { + "cpu": 1114643, + "memory": 601, + "bytes": 16, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 1114643, + "memory": 601, + "bytes": 16, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: serialise_data", + "before": { + "cpu": 2070166, + "memory": 410, + "bytes": 11, + "result": "(con bytestring #07)", + "logs": [] + }, + "after": { + "cpu": 2070166, + "memory": 410, + "bytes": 11, + "result": "(con bytestring #07)", + "logs": [] + } + }, + { + "input": "constant folding: list_head", + "before": { + "cpu": 195250, + "memory": 832, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: list_tail", + "before": { + "cpu": 193763, + "memory": 832, + "bytes": 13, + "result": "(con (list integer) [8])", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 7, + "result": "(con (list integer) [8])", + "logs": [] + } + }, + { + "input": "constant folding: empty_head", + "before": { + "cpu": 83250, + "memory": 132, + "bytes": 11, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + }, + "after": { + "cpu": 83250, + "memory": 132, + "bytes": 11, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + } + }, + { + "input": "constant folding: empty_tail", + "before": { + "cpu": 81763, + "memory": 132, + "bytes": 11, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + }, + "after": { + "cpu": 81763, + "memory": 132, + "bytes": 11, + "result": "error: Runtime(EmptyList([]))", + "logs": [] + } + }, + { + "input": "constant folding: list_null", + "before": { + "cpu": 186533, + "memory": 832, + "bytes": 11, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "constant folding: pair_first", + "before": { + "cpu": 269995, + "memory": 932, + "bytes": 17, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: pair_second", + "before": { + "cpu": 270092, + "memory": 932, + "bytes": 17, + "result": "(con bytestring #61)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 9, + "result": "(con bytestring #61)", + "logs": [] + } + }, + { + "input": "constant folding: trace_before", + "before": { + "cpu": 400806, + "memory": 1634, + "bytes": 27, + "result": "(con integer 42)", + "logs": [ + "before" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 22, + "result": "(con integer 42)", + "logs": [ + "before" + ] + } + }, + { + "input": "constant folding: trace_builtin", + "before": { + "cpu": 203598, + "memory": 1032, + "bytes": 22, + "result": "(con integer 7)", + "logs": [ + "keep me" + ] + }, + "after": { + "cpu": 203598, + "memory": 1032, + "bytes": 22, + "result": "(con integer 7)", + "logs": [ + "keep me" + ] + } + }, + { + "input": "constant folding: cold_failure", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "constant folding: selected_branch", + "before": { + "cpu": 597139, + "memory": 2535, + "bytes": 44, + "result": "(con integer 42)", + "logs": [ + "yes" + ] + }, + "after": { + "cpu": 235598, + "memory": 1232, + "bytes": 19, + "result": "(con integer 42)", + "logs": [ + "yes" + ] + } + }, + { + "input": "constant folding: strict_failure_order", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 33, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 33, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + } + }, + { + "input": "constant folding: unsupported_hash", + "before": { + "cpu": 341340, + "memory": 404, + "bytes": 11, + "result": "(con bytestring #2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881)", + "logs": [] + }, + "after": { + "cpu": 341340, + "memory": 404, + "bytes": 11, + "result": "(con bytestring #2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881)", + "logs": [] + } + }, + { + "input": "constant folding: partial", + "before": { + "cpu": 229308, + "memory": 902, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 229308, + "memory": 902, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "constant folding: large_input", + "before": { + "cpu": 169849, + "memory": 1113, + "bytes": 4127, + "result": "(con bytestring #2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a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2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a7a)", + "logs": [] + } + }, + { + "input": "constant folding: repeated_call", + "before": { + "cpu": 687724, + "memory": 2506, + "bytes": 31, + "result": "(constr 0 (con integer 42) (con integer 42) (con integer 42))", + "logs": [] + }, + "after": { + "cpu": 64100, + "memory": 500, + "bytes": 12, + "result": "(constr 0 (con integer 42) (con integer 42) (con integer 42))", + "logs": [] + } + } + ] +} diff --git a/tools/optimizer-perf/trials/o2-silence.json b/tools/optimizer-perf/trials/o2-silence.json new file mode 100644 index 00000000..b7e9edbb --- /dev/null +++ b/tools/optimizer-perf/trials/o2-silence.json @@ -0,0 +1,186 @@ +{ + "source": { + "revision": "400a5f98e632f8889a79c363f252b7cc2d32089c", + "rows": [ + { + "core": "letrec\n loop#14 : int -> int [static []] = \\n#15 : int -> let anf#18 : bool = equalsInteger n#15 0 in\n case@Bool anf#18 of\n True -> 42\n False -> trace \"step\" in let anf#21 : int = subtractInteger n#15 1 in\n loop#14 anf#21\nin\nloop#14 3", + "measurement": { + "bytes": 53, + "cpu": 2451550, + "logs": [ + "step", + "step", + "step" + ], + "memory": 11206, + "result": "(con integer 42)" + }, + "mode": "O1 verbose", + "uplc": "[(lam builtin_9\n [(lam loop_8 [loop_8 (con integer 3)])\n [(lam self_3 [self_3 self_3])\n (lam self_4\n (lam n_5\n [(lam anf_6\n (case\n anf_6\n (force\n [[builtin_9 (con string \"step\")]\n (delay\n [(lam anf_7 [[self_4 self_4] anf_7])\n [[(builtin subtractInteger) n_5] (con integer 1)]])])\n (con integer 42)))\n [[(builtin equalsInteger) n_5] (con integer 0)]]))]])\n (force (builtin trace))]" + }, + { + "core": "let fromInt#3 : int -> int = \\x#5 : int -> x#5 in\nletrec\n loop#2 : int -> int [static []] = \\n#4 : int -> case@Bool equalsInteger n#4 (fromInt#3 0) of\n True -> fromInt#3 42\n False -> loop#2 (subtractInteger n#4 (fromInt#3 1))\nin\nlet main#1 : int = loop#2 (fromInt#3 3) in\nmain#1", + "measurement": { + "bytes": 47, + "cpu": 2113056, + "logs": [], + "memory": 10110, + "result": "(con integer 42)" + }, + "mode": "O0 silent", + "uplc": "[(lam fromInt_3\n [(lam loop_2 [(lam main_1 main_1) [loop_2 [fromInt_3 (con integer 3)]]])\n [(lam self_6 [self_6 self_6])\n (lam self_6\n (lam n_4\n (case\n [[(builtin equalsInteger) n_4] [fromInt_3 (con integer 0)]]\n [[self_6 self_6] [[(builtin subtractInteger) n_4] [fromInt_3 (con integer 1)]]]\n [fromInt_3 (con integer 42)])))]])\n (lam x_5 x_5)]" + }, + { + "core": "letrec\n loop#8 : int -> int [static []] = \\n#9 : int -> let anf#12 : bool = equalsInteger n#9 0 in\n case@Bool anf#12 of\n True -> 42\n False -> let anf#14 : int = subtractInteger n#9 1 in\n loop#8 anf#14\nin\nloop#8 3", + "measurement": { + "bytes": 39, + "cpu": 1921056, + "logs": [], + "memory": 8910, + "result": "(con integer 42)" + }, + "mode": "O1 silent", + "uplc": "[(lam loop_10 [loop_10 (con integer 3)])\n [(lam self_3 [self_3 self_3])\n (lam self_4\n (lam n_5\n [(lam anf_6\n (case\n anf_6\n [(lam anf_7 [[self_4 self_4] anf_7])\n [[(builtin subtractInteger) n_5] (con integer 1)]]\n (con integer 42)))\n [[(builtin equalsInteger) n_5] (con integer 0)]]))]]" + }, + { + "core": "letrec\n loop#3 : int -> int [static []] = \\n#4 : int -> let anf#7 : bool = equalsInteger n#4 0 in\n case@Bool anf#7 of\n True -> 42\n False -> let anf#9 : int = subtractInteger n#4 1 in\n loop#3 anf#9\nin\nloop#3 3", + "measurement": { + "bytes": 39, + "cpu": 1921056, + "logs": [], + "memory": 8910, + "result": "(con integer 42)" + }, + "mode": "O2 silent", + "uplc": "[(lam loop_12 [loop_12 (con integer 3)])\n [(lam self_5 [self_5 self_5])\n (lam self_6\n (lam n_8\n [(lam anf_10\n (case\n anf_10\n [(lam anf_11 [[self_6 self_6] anf_11])\n [[(builtin subtractInteger) n_8] (con integer 1)]]\n (con integer 42)))\n [[(builtin equalsInteger) n_8] (con integer 0)]]))]]" + } + ], + "rustc": "rustc 1.98.1 (48a229cea 2026-09-01)", + "settings": "Plutus V3/PV11; UPLC 1.1.0; bundled cost model; CPU=100000000; memory=2000000; raw Flat bytes; O2 erases trace messages even if they fail or diverge, then runs O1", + "source": "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nloop : int -> int\nloop n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n trace \"step\" (loop (Builtin.subtractInteger n 1))\nmain : int\nmain = loop 3\n" + }, + "builtin": { + "revision": "3007d7030b72ccaa8b99657f85df907c29107ae4", + "rows": [ + { + "core": "let log#13 : string -> int -> int = trace in\nletrec\n loop#16 : int -> int [static []] = \\n#17 : int -> let anf#20 : bool = equalsInteger n#17 0 in\n case@Bool anf#20 of\n True -> 42\n False -> let anf#22 : int -> int = log#13 \"step\" in\n let anf#24 : int = subtractInteger n#17 1 in\n let anf#25 : int = loop#16 anf#24 in\n anf#22 anf#25\nin\nloop#16 3", + "measurement": { + "bytes": 57, + "cpu": 2643550, + "logs": [ + "step", + "step", + "step" + ], + "memory": 12406, + "result": "(con integer 42)" + }, + "mode": "O1 verbose", + "uplc": "[(lam builtin_12\n [(lam loop_11 [loop_11 (con integer 3)])\n [(lam self_4 [self_4 self_4])\n (lam self_5\n (lam n_6\n [(lam anf_7\n (case\n anf_7\n [(lam anf_8\n [(lam anf_9 [(lam anf_10 [anf_8 anf_10]) [[self_5 self_5] anf_9]])\n [[(builtin subtractInteger) n_6] (con integer 1)]])\n [builtin_12 (con string \"step\")]]\n (con integer 42)))\n [[(builtin equalsInteger) n_6] (con integer 0)]]))]])\n (force (builtin trace))]" + }, + { + "core": "let message#9 : string = \"step\" in\nlet fromInt#3 : int -> int = \\x#7 : int -> x#7 in\nlet log#5 : string -> int -> int = trace in\nlet fromString#6 : string -> string = \\x#8 : string -> x#8 in\nletrec\n loop#2 : int -> int [static []] = \\n#4 : int -> case@Bool equalsInteger n#4 (fromInt#3 0) of\n True -> fromInt#3 42\n False -> log#5 (fromString#6 message#9) (loop#2 (subtractInteger n#4 (fromInt#3 1)))\nin\nlet main#1 : int = loop#2 (fromInt#3 3) in\nmain#1", + "measurement": { + "bytes": 68, + "cpu": 2787550, + "logs": [ + "step", + "step", + "step" + ], + "memory": 13306, + "result": "(con integer 42)" + }, + "mode": "O0 silent", + "uplc": "[(lam message_9\n [(lam fromInt_3\n [(lam log_5\n [(lam fromString_6\n [(lam loop_2 [(lam main_1 main_1) [loop_2 [fromInt_3 (con integer 3)]]])\n [(lam self_10 [self_10 self_10])\n (lam self_10\n (lam n_4\n (case\n [[(builtin equalsInteger) n_4] [fromInt_3 (con integer 0)]]\n [[log_5 [fromString_6 message_9]]\n [[self_10 self_10]\n [[(builtin subtractInteger) n_4] [fromInt_3 (con integer 1)]]]]\n [fromInt_3 (con integer 42)])))]])\n (lam x_8 x_8)])\n (force (builtin trace))])\n (lam x_7 x_7)])\n (con string \"step\")]" + }, + { + "core": "let log#13 : string -> int -> int = trace in\nletrec\n loop#16 : int -> int [static []] = \\n#17 : int -> let anf#20 : bool = equalsInteger n#17 0 in\n case@Bool anf#20 of\n True -> 42\n False -> let anf#22 : int -> int = log#13 \"step\" in\n let anf#24 : int = subtractInteger n#17 1 in\n let anf#25 : int = loop#16 anf#24 in\n anf#22 anf#25\nin\nloop#16 3", + "measurement": { + "bytes": 57, + "cpu": 2643550, + "logs": [ + "step", + "step", + "step" + ], + "memory": 12406, + "result": "(con integer 42)" + }, + "mode": "O1 silent", + "uplc": "[(lam builtin_12\n [(lam loop_11 [loop_11 (con integer 3)])\n [(lam self_4 [self_4 self_4])\n (lam self_5\n (lam n_6\n [(lam anf_7\n (case\n anf_7\n [(lam anf_8\n [(lam anf_9 [(lam anf_10 [anf_8 anf_10]) [[self_5 self_5] anf_9]])\n [[(builtin subtractInteger) n_6] (con integer 1)]])\n [builtin_12 (con string \"step\")]]\n (con integer 42)))\n [[(builtin equalsInteger) n_6] (con integer 0)]]))]])\n (force (builtin trace))]" + }, + { + "core": "letrec\n loop#9 : int -> int [static []] = \\n#21 : int -> let anf#24 : bool = equalsInteger n#21 0 in\n case@Bool anf#24 of\n True -> 42\n False -> let anf#26 : int = subtractInteger n#21 1 in\n loop#9 anf#26\nin\nloop#9 3", + "measurement": { + "bytes": 39, + "cpu": 1921056, + "logs": [], + "memory": 8910, + "result": "(con integer 42)" + }, + "mode": "O2 silent", + "uplc": "[(lam loop_8 [loop_8 (con integer 3)])\n [(lam self_3 [self_3 self_3])\n (lam self_4\n (lam n_5\n [(lam anf_6\n (case\n anf_6\n [(lam anf_7 [[self_4 self_4] anf_7])\n [[(builtin subtractInteger) n_5] (con integer 1)]]\n (con integer 42)))\n [[(builtin equalsInteger) n_5] (con integer 0)]]))]]" + } + ], + "rustc": "rustc 1.98.1 (48a229cea 2026-09-01)", + "settings": "Plutus V3/PV11; UPLC 1.1.0; bundled cost model; CPU=100000000; memory=2000000; raw Flat bytes; O2 erases trace messages even if they fail or diverge, then runs O1", + "source": "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nlog : string -> int -> int\nlog = Builtin.trace\nloop : int -> int\nloop n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n log \"step\" (loop (Builtin.subtractInteger n 1))\nmain : int\nmain = loop 3\n" + }, + "failure": { + "revision": "3007d7030b72ccaa8b99657f85df907c29107ae4", + "rows": [ + { + "core": "let log#5 : string -> int -> int = trace in\nlet anf#9 : string = error in\nlog#5 anf#9 42", + "measurement": { + "bytes": 14, + "cpu": 100, + "logs": [], + "memory": 100, + "result": "error: ExplicitErrorTerm" + }, + "mode": "O1 verbose", + "uplc": "[(lam builtin_3 [(lam anf_2 [[builtin_3 anf_2] (con integer 42)]) (error)])\n (force (builtin trace))]" + }, + { + "core": "let log#2 : string -> int -> int = trace in\nlet fromInt#3 : int -> int = \\x#4 : int -> x#4 in\nlet main#1 : int = log#2 error (fromInt#3 42) in\nmain#1", + "measurement": { + "bytes": 19, + "cpu": 100, + "logs": [], + "memory": 100, + "result": "error: ExplicitErrorTerm" + }, + "mode": "O0 silent", + "uplc": "[(lam log_2\n [(lam fromInt_3\n [(lam main_1 main_1) [[log_2 (error)] [fromInt_3 (con integer 42)]]])\n (lam x_4 x_4)])\n (force (builtin trace))]" + }, + { + "core": "let log#5 : string -> int -> int = trace in\nlet anf#9 : string = error in\nlog#5 anf#9 42", + "measurement": { + "bytes": 14, + "cpu": 100, + "logs": [], + "memory": 100, + "result": "error: ExplicitErrorTerm" + }, + "mode": "O1 silent", + "uplc": "[(lam builtin_3 [(lam anf_2 [[builtin_3 anf_2] (con integer 42)]) (error)])\n (force (builtin trace))]" + }, + { + "core": "42", + "measurement": { + "bytes": 6, + "cpu": 16100, + "logs": [], + "memory": 200, + "result": "(con integer 42)" + }, + "mode": "O2 silent", + "uplc": "(con integer 42)" + } + ], + "rustc": "rustc 1.98.1 (48a229cea 2026-09-01)", + "settings": "Plutus V3/PV11; UPLC 1.1.0; bundled cost model; CPU=100000000; memory=2000000; raw Flat bytes; O2 erases trace messages even if they fail or diverge, then runs O1", + "source": "module Main exposing (..)\nimport Primitive exposing (..)\nimport Builtin\nlog : string -> int -> int\nlog = Builtin.trace\nmain : int\nmain = log (fail) 42\n" + } +} diff --git a/tools/optimizer-perf/trials/pair-projection.json b/tools/optimizer-perf/trials/pair-projection.json new file mode 100644 index 00000000..6ff98487 --- /dev/null +++ b/tools/optimizer-perf/trials/pair-projection.json @@ -0,0 +1,3174 @@ +{ + "settings": "v1; Plutus V3/PV11; UPLC 1.1.0; bundled V3 cost model; CPU=100000000 memory=2000000; raw Flat bytes; before=current O1; after=O1+single-field pair projection+cleanup; general proven-pair and cancelling-only variants; each input with ordinary lowering and builtin/constant sharing", + "sources": { + "Cardano.Tx": "module Cardano.Tx exposing (validAfter, signedBy)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Eq exposing (Eq)\nimport Lift exposing (lower)\n\n-- V3 TxInfo field 7 is the validity interval. Require a finite lower bound.\n-- Times are POSIX milliseconds, not slots or the current wall-clock time.\nvalidAfter : Data -> int\nvalidAfter tx =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, Constr pair(0, [ Constr pair(0, [ Constr pair(1, [ I time ]), _ ]), _ ]), _, _, _, _, _, _, _, _ ]) -> time\n _ -> fail\n\n-- V3 TxInfo field 8 contains every extra signatory.\nsignedBy : Data -> Bytes -> bool\nsignedBy tx owner =\n case tx of\n Constr pair(0, [ _, _, _, _, _, _, _, _, List signers, _, _, _, _, _, _, _ ]) -> hasSigner signers (lower owner)\n _ -> fail\n\nhasSigner : list Data -> bytes -> bool\nhasSigner signers owner =\n case signers of\n [] -> False\n B signer :: rest ->\n if Builtin.equalsByteString signer owner then True\n else hasSigner rest owner\n _ -> fail\n", + "Eq": "module Eq exposing ( Eq )\n\n\nimport Literal\nimport Logic exposing ( not, xor, (&&) )\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\n\n{-| Compare values for equality and inequality. -}\ntrait Eq 'a where\n eq : 'a -> 'a -> bool\n\n neq : 'a -> 'a -> bool\n neq a b = not (eq a b)\n\n\nimpl Eq int where\n eq = Builtin.equalsInteger\n\n\nimpl Eq bytes where\n eq = Builtin.equalsByteString\n\n\nimpl Eq string where\n eq = Builtin.equalsString\n\n\nimpl Eq bool where\n eq a b = not (xor a b)\n\n\nimpl Eq unit where\n eq _ _ = True\n\n\nimpl Eq (list ('a : Big)) where\n eq xs ys =\n eq (Builtin.listData xs) (Builtin.listData ys)\n\n\nimpl Eq 'a => Eq (list ('a : Little)) where\n eq xs ys =\n case xs of\n [] ->\n case ys of\n [] ->\n True\n\n _ :: _ ->\n False\n\n x :: restX ->\n case ys of\n [] ->\n False\n\n y :: restY ->\n eq x y && eq restX restY\n\n\nimpl ( Eq 'a, Eq 'b ) => Eq (pair 'a 'b) where\n eq a b =\n let\n pair(firstA, secondA) = a\n\n pair(firstB, secondB) = b\n in\n eq firstA firstB && eq secondA secondB\n\n\nimpl Eq (map ('k : Big) ('v : Big)) where\n eq xs ys = eq (Builtin.mapData xs) (Builtin.mapData ys)\n\n\nimpl ( Eq 'k, Eq 'v ) => Eq (map ('k : Little) 'v) where\n eq = eqMapEntries\n\n\nimpl Eq 'v => Eq (map ('k : Big) ('v : Little)) where\n eq = eqMapEntries\n\n\neqMapEntries : ( Eq 'k, Eq 'v ) => list (pair 'k 'v) -> list (pair 'k 'v) -> bool\neqMapEntries = eq\n\n\nimpl Eq value where\n eq a b = Builtin.equalsData (Builtin.valueData a) (Builtin.valueData b)\n", + "Lift": "module Lift exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait Lift 'a 'b where\n lift : 'a -> 'b\n lower : 'b -> 'a\n\nimpl Lift int Int where\n lift value = Builtin.iData value\n lower value = Builtin.unIData value\n\nimpl Lift bytes Bytes where\n lift value = Builtin.bData value\n lower value = Builtin.unBData value\n", + "Literal": "module Literal exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\n\ntrait FromInt 'a where\n fromInt : int -> 'a\n\ntrait FromString 'a where\n fromString : string -> 'a\n\ntrait FromBytes 'a where\n fromBytes : bytes -> 'a\n\nimpl FromInt int where\n fromInt x = x\n\nimpl FromString string where\n fromString x = x\n\nimpl FromBytes bytes where\n fromBytes x = x\n\ntrait FromBool 'a where\n fromBool : bool -> 'a\n\ntrait FromUnit 'a where\n fromUnit : unit -> 'a\n\nimpl FromBool bool where\n fromBool value = value\n\nimpl FromUnit unit where\n fromUnit value = value\n", + "Logic": "module Logic exposing ( not, and, or, xor, (&&), (||) )\n\n\nimport Primitive\nimport Lift exposing ( Lift )\n\n\ninfix right 2 (||) = or\n\n\ninfix right 3 (&&) = and\n\n\n{-| Negate a Big or little Boolean, returning bool. -}\nnot : Lift bool 'a => 'a -> bool\nnot value =\n if lower value then\n Primitive.False\n else\n Primitive.True\n\n\n{-| Boolean conjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nand : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nand a b =\n if lower a then\n lower b\n else\n Primitive.False\n\n\n{-| Boolean disjunction. Fully applied calls short-circuit; partial and indirect calls are strict. -}\nor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nor a b =\n if lower a then\n Primitive.True\n else\n lower b\n\n\n{-| Return True when the Boolean operands differ. -}\nxor : ( Lift bool 'a, Lift bool 'b ) => 'a -> 'b -> bool\nxor a b =\n if lower a then\n not b\n else\n lower b\n", + "Optimizer": "//! Accepted O1 Core pipeline. Trace policy is decided by codegen, not optimization.\nuse nash_ir::{anf, build::Builder, core::Core, hygiene};\nuse nash_plutus::arena::Arena;\n\npub fn optimize<'a>(arena: &'a Arena, core: &'a Core<'a>) -> &'a Core<'a> {\n optimize_with(&Builder::new(arena), core)\n}\n\npub fn optimize_with<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> {\n let original_ty = core.ty;\n let core = hygiene::freshen(b, core);\n debug_assert!(hygiene::validate(core, &[]).is_ok());\n let core = nash_ir::static_lift::lift(b, core);\n debug_assert!(hygiene::validate(core, &[]).is_ok());\n let core = nash_ir::unused_params::reduce(b, core);\n debug_assert!(hygiene::validate(core, &[]).is_ok());\n let core = anf::normalize(b, core);\n debug_assert!(hygiene::validate(core, &[]).is_ok());\n debug_assert!(anf::validate(core).is_ok());\n // Fold representations and constructors through ANF bindings in the cleanup\n // loops, including opportunities exposed by inlining and propagation.\n let core = nash_ir::small_inline::simplify(b, core);\n debug_assert!(hygiene::validate(core, &[]).is_ok());\n let core = nash_ir::known_case::simplify_constr_data(b, core);\n debug_assert!(hygiene::validate(core, &[]).is_ok());\n debug_assert!(anf::validate(core).is_ok());\n debug_assert_eq!(original_ty, core.ty);\n core\n}\n", + "PairInputs": "//! Inputs shared by pair-projection snapshots and explicit measurements.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, Ty},\n};\nuse nash_plutus::{\n builtin::DefaultFunction as F, constant::Constant as C, data::PlutusData as D, typ::Type,\n};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(String, &'a Core<'a>, bool)> {\n let a = b.arena;\n let int = b.int(0).ty;\n let pair = b.lit(C::proto_pair(\n a,\n &Type::Integer,\n &Type::Integer,\n C::integer_from(a, 7),\n C::integer_from(a, 8),\n ));\n let data = b.lit(C::data(a, D::integer_from(a, 7)));\n let made = b.builtin(\n F::MkPairData,\n &[data, data],\n Ty::Const(a.alloc(ConstTy::Pair(data.ty, data.ty))),\n );\n let unwrapped = b.builtin(\n F::UnConstrData,\n &[b.lit(C::data(a, D::constr(a, 0, &[])))],\n Ty::Const(a.alloc(ConstTy::Pair(\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n ))),\n );\n let trace = |s, x| b.trace(b.lit(C::string(a, s)), x);\n let mut cases = Vec::new();\n for (name, subject, left_ty, right_ty, fails) in [\n (\"literal\", pair, int, int, false),\n (\"traced\", trace(\"subject\", pair), int, int, false),\n (\"made_data\", made, data.ty, data.ty, false),\n (\n \"decoded\",\n unwrapped,\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n false,\n ),\n (\n \"bad_decoder\",\n b.builtin(F::UnConstrData, &[data], unwrapped.ty),\n int,\n Ty::Const(a.alloc(ConstTy::List(data.ty))),\n true,\n ),\n (\n \"ignored_failure\",\n b.builtin(\n F::MkPairData,\n &[data, trace(\"unused field\", b.error(data.ty))],\n made.ty,\n ),\n data.ty,\n data.ty,\n true,\n ),\n (\n \"wrong_subject\",\n b.with_type(b.int(1), pair.ty),\n int,\n int,\n true,\n ),\n // Generic UPLC case accepts this, whereas fstPair would reject it.\n (\n \"native_constructor\",\n b.with_type(b.constr(0, &[b.int(7), b.int(8)], Ty::Erased), pair.ty),\n int,\n int,\n false,\n ),\n ] {\n for second in [false, true] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: left_ty,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: right_ty,\n };\n let selected = if second { y } else { x };\n let value = b.var(selected.name, selected.ty);\n let core = b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: value,\n }],\n None,\n value.ty,\n );\n cases.push((\n format!(\"{name}_{}\", if second { \"second\" } else { \"first\" }),\n core,\n fails,\n ));\n }\n }\n for mode in [\"body\", \"both\", \"neither\", \"delay\", \"lambda\", \"repeated\"] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: int,\n };\n let xv = b.var(x.name, x.ty);\n let body = match mode {\n \"both\" => b.builtin(F::AddInteger, &[xv, b.var(y.name, y.ty)], int),\n \"neither\" => b.int(42),\n \"delay\" => b.delay(xv),\n \"lambda\" => b.lam(\n &[Binder {\n name: b.fresh(\"unused\"),\n ty: int,\n }],\n xv,\n ),\n \"repeated\" => b.builtin(F::AddInteger, &[xv, xv], int),\n _ => trace(\"body\", b.builtin(F::AddInteger, &[xv, b.int(1)], int)),\n };\n let core = b.case(\n CaseKind::Pair,\n trace(\"subject\", pair),\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body,\n }],\n None,\n body.ty,\n );\n // Force/application is after the case, exposing any misplaced strict work.\n let core = match mode {\n \"delay\" => b.force(core, int),\n \"lambda\" => b.app(core, &[trace(\"argument\", b.int(0))], int),\n _ => core,\n };\n cases.push((mode.into(), core, false));\n }\n for second in [false, true] {\n let select = |subject| {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: int,\n };\n let selected = if second { y } else { x };\n b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: b.var(selected.name, int),\n }],\n None,\n int,\n )\n };\n let first = select(trace(\"first\", pair));\n let second_core = select(trace(\"second\", pair));\n cases.push((\n format!(\n \"two_projections_{}\",\n if second { \"second\" } else { \"first\" }\n ),\n b.builtin(F::AddInteger, &[first, second_core], int),\n false,\n ));\n }\n for delayed in [false, true] {\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: Ty::Const(a.alloc(ConstTy::List(data.ty))),\n };\n let value = b.var(x.name, x.ty);\n let body = if delayed {\n b.delay(value)\n } else {\n b.lam(\n &[Binder {\n name: b.fresh(\"arg\"),\n ty: int,\n }],\n value,\n )\n };\n let subject = b.builtin(\n F::UnConstrData,\n &[trace(\"before failure\", data)],\n unwrapped.ty,\n );\n let case = b.case(\n CaseKind::Pair,\n subject,\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body,\n }],\n None,\n body.ty,\n );\n let ignored = Binder {\n name: b.fresh(\"ignored closure\"),\n ty: case.ty,\n };\n cases.push((\n format!(\n \"unconsumed_{}_failure\",\n if delayed { \"delay\" } else { \"lambda\" }\n ),\n b.let_(ignored, case, b.int(0)),\n true,\n ));\n }\n for bad_tag in [false, true] {\n for second in [false, true] {\n let tag = Binder {\n name: b.fresh(\"tag\"),\n ty: int,\n };\n let fields_ty = Ty::Const(a.alloc(ConstTy::List(data.ty)));\n let fields = Binder {\n name: b.fresh(\"fields\"),\n ty: fields_ty,\n };\n let encoded = Binder {\n name: b.fresh(\"encoded\"),\n ty: data.ty,\n };\n let decoded = Binder {\n name: b.fresh(\"decoded\"),\n ty: unwrapped.ty,\n };\n let x = Binder {\n name: b.fresh(\"x\"),\n ty: int,\n };\n let y = Binder {\n name: b.fresh(\"y\"),\n ty: fields_ty,\n };\n let selected = if second { y } else { x };\n let body = b.case(\n CaseKind::Pair,\n b.var(decoded.name, decoded.ty),\n &[Branch {\n test: Test::Pair,\n binders: a.alloc([x, y]),\n body: b.var(selected.name, selected.ty),\n }],\n None,\n selected.ty,\n );\n let body = b.let_(\n decoded,\n b.builtin(\n F::UnConstrData,\n &[b.var(encoded.name, encoded.ty)],\n decoded.ty,\n ),\n body,\n );\n let body = b.let_(\n encoded,\n b.builtin(\n F::ConstrData,\n &[b.var(tag.name, tag.ty), b.var(fields.name, fields.ty)],\n encoded.ty,\n ),\n body,\n );\n let body = b.let_(\n fields,\n b.builtin(\n F::MkCons,\n &[\n trace(\"field\", data),\n b.lit(C::proto_list(a, &Type::Data, &[])),\n ],\n fields_ty,\n ),\n body,\n );\n let tag_value = if bad_tag {\n let bytes = b.lit(C::data(a, D::byte_string(a, b\"bad\")));\n b.with_type(\n b.builtin(\n F::UnBData,\n &[trace(\"tag\", bytes)],\n b.lit(C::byte_string(a, b\"bad\")).ty,\n ),\n int,\n )\n } else {\n let tag_data = b.lit(C::data(a, D::integer_from(a, 0)));\n b.builtin(F::UnIData, &[trace(\"tag\", tag_data)], int)\n };\n let body = b.let_(tag, tag_value, body);\n cases.push((\n format!(\n \"roundtrip_{}_{}\",\n if bad_tag { \"bad_tag\" } else { \"valid\" },\n if second { \"second\" } else { \"first\" }\n ),\n body,\n bad_tag,\n ));\n }\n }\n cases\n}\n", + "PairProjection": "//! Experimental single-field native pair projection; not in production O1.\nuse crate::{\n build::Builder,\n core::{CaseKind, Core, CoreKind, Test},\n ty::{ConstTy, Ty},\n};\nuse nash_plutus::{builtin::DefaultFunction as F, constant::Constant};\nuse std::collections::{HashMap, HashSet};\n\n/// Requires globally unique, scoped names. Keep pair production and projection\n/// strict at the original case point, including fields captured by closures.\npub fn reduce<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> {\n reduce_with(b, core, false)\n}\n\n/// Trial restriction: introduce only projections that the existing constructor\n/// inverse rule can cancel through retained strict bindings.\npub fn reduce_cancelling<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> {\n reduce_with(b, core, true)\n}\n\nfn resolve<'a>(mut node: &'a Core<'a>, bindings: &HashMap>) -> &'a Core<'a> {\n while let CoreKind::Var(name) = node.kind {\n let Some(value) = bindings.get(&name.unique) else {\n break;\n };\n node = value;\n }\n node\n}\n\nfn reduce_with<'a>(b: &Builder<'a>, core: &'a Core<'a>, cancelling: bool) -> &'a Core<'a> {\n let mut bindings = HashMap::new();\n let mut used = HashSet::new();\n core.walk(&mut |node| match node.kind {\n CoreKind::Let { binder, value, .. } => {\n bindings.insert(binder.name.unique, value);\n }\n CoreKind::Var(name) => {\n used.insert(name.unique);\n }\n _ => {}\n });\n core.map(b, &mut |node| {\n let CoreKind::Case {\n kind: CaseKind::Pair,\n scrutinee,\n branches: [branch],\n default: None,\n } = node.kind\n else {\n return None;\n };\n let [left, right] = branch.binders else {\n return None;\n };\n if branch.test != Test::Pair || left.name.unique == right.name.unique {\n return None;\n }\n let Ty::Const(ConstTy::Pair(a, c)) = scrutinee.ty else {\n return None;\n };\n if left.ty != *a || right.ty != *c {\n return None;\n }\n let selected = match (\n used.contains(&left.name.unique),\n used.contains(&right.name.unique),\n ) {\n (true, false) => (left, F::FstPair),\n (false, true) => (right, F::SndPair),\n _ => return None,\n };\n let mut producer = scrutinee;\n loop {\n producer = match producer.kind {\n CoreKind::Var(name) => *bindings.get(&name.unique)?,\n CoreKind::Trace { body, .. } => body,\n _ => break,\n };\n }\n if !matches!(\n producer.kind,\n CoreKind::Lit(Constant::ProtoPair(..))\n | CoreKind::Builtin {\n func: F::UnConstrData,\n args: [_]\n }\n | CoreKind::Builtin {\n func: F::MkPairData,\n args: [_, _]\n }\n ) {\n return None;\n }\n if cancelling {\n // Match inverse::constructor's exact proof. Trace wrappers are not\n // skipped here, and neither decoder nor constructor is discarded.\n if !matches!(scrutinee.kind, CoreKind::Var(_)) {\n return None;\n }\n let CoreKind::Builtin {\n func: F::UnConstrData,\n args: [data],\n } = resolve(scrutinee, &bindings).kind\n else {\n return None;\n };\n if !matches!(data.kind, CoreKind::Var(_)) {\n return None;\n }\n let CoreKind::Builtin {\n func: F::ConstrData,\n args: [tag, fields],\n } = resolve(data, &bindings).kind\n else {\n return None;\n };\n let field = if selected.1 == F::FstPair {\n tag\n } else {\n fields\n };\n if !matches!(field.kind, CoreKind::Var(_)) {\n return None;\n }\n }\n let projection = b.builtin(selected.1, &[scrutinee], selected.0.ty);\n Some(b.with_type(b.let_(*selected.0, projection, branch.body), node.ty))\n })\n}\n", + "Workloads": "module Workloads exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Logic exposing (..)\n\nsum : list int -> int\nsum xs =\n case xs of\n [] -> 0\n x :: rest -> Builtin.addInteger x (sum rest)\n\nlistTraversal : int\nlistTraversal = sum [1, 2, 3, 4, 5, 6, 7, 8]\n\ncountdown : int -> int -> int\ncountdown n result =\n if Builtin.equalsInteger n 0 then\n result\n else\n countdown (Builtin.subtractInteger n 1) result\n\nstaticRecursion : int\nstaticRecursion = countdown 8 42\n\nmatchData : Data -> int\nmatchData value =\n case value of\n I n -> n\n _ -> 0\n\ndataMatch : int\ndataMatch = matchData (I 42)\n\ndataMiss : int\ndataMiss = matchData (B #\"ab\")\n\ndecode : Data -> int\ndecode value =\n case value of\n Constr pair(_, [I n, _]) -> n\n _ -> 0\n\ndecoding : int\ndecoding = decode (Builtin.constrData 0 [I 42, I 7])\n\nvalidate : Data -> unit\nvalidate value =\n case value of\n I n -> assert (Builtin.lessThanInteger 0 n)\n _ -> fail\n\nvalidationPass : unit\nvalidationPass = validate (I 42)\n\nvalidationFail : unit\nvalidationFail = validate (I 0)\n\nbooleanHelpers : bool\nbooleanHelpers = (True && False) || (True && True)\n\nconstantPrefixTwice : int\nconstantPrefixTwice =\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nconstantPrefixCold : int\nconstantPrefixCold =\n if True then\n 42\n else\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nprefixLoop : int -> int\nprefixLoop n =\n if Builtin.equalsInteger n 0 then\n 0\n else\n Builtin.addInteger\n (Builtin.addInteger (Builtin.subtractInteger 100 n) (Builtin.subtractInteger 100 n))\n (prefixLoop (Builtin.subtractInteger n 1))\n\nconstantPrefixLoop : int\nconstantPrefixLoop = prefixLoop 8\n" + }, + "revision": "ac3bdf5ab20bd91ba6b636ee4c53f44a73908769", + "rustc": "rustc 1.98.1 (48a229cea 2026-09-01)", + "rows": [ + { + "input": "pair/literal_first/cancelling=false/sharing=false\n--- accepted Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#3 y#4 -> x#3\n--- trial Core\nfstPair (con (pair integer integer) (7, 8))", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 221995, + "memory": 632, + "bytes": 12, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair/literal_first/cancelling=false/sharing=true\n--- accepted Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#3 y#4 -> x#3\n--- trial Core\nfstPair (con (pair integer integer) (7, 8))", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 269995, + "memory": 932, + "bytes": 15, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair/literal_first/cancelling=true/sharing=false\n--- accepted Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#3 y#4 -> x#3\n--- trial Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#3 y#4 -> x#3", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair/literal_first/cancelling=true/sharing=true\n--- accepted Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#3 y#4 -> x#3\n--- trial Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#3 y#4 -> x#3", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair/literal_second/cancelling=false/sharing=false\n--- accepted Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#1 y#2 -> y#2\n--- trial Core\nsndPair (con (pair integer integer) (7, 8))", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 222092, + "memory": 632, + "bytes": 12, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair/literal_second/cancelling=false/sharing=true\n--- accepted Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#1 y#2 -> y#2\n--- trial Core\nsndPair (con (pair integer integer) (7, 8))", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 270092, + "memory": 932, + "bytes": 15, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair/literal_second/cancelling=true/sharing=false\n--- accepted Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#1 y#2 -> y#2\n--- trial Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair/literal_second/cancelling=true/sharing=true\n--- accepted Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#1 y#2 -> y#2\n--- trial Core\ncase@Pair (con (pair integer integer) (7, 8)) of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 80100, + "memory": 600, + "bytes": 13, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair/traced_first/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nfstPair anf#3", + "before": { + "cpu": 299598, + "memory": 1632, + "bytes": 30, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 441493, + "memory": 1664, + "bytes": 30, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/traced_first/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nfstPair anf#3", + "before": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 537493, + "memory": 2264, + "bytes": 34, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/traced_first/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 299598, + "memory": 1632, + "bytes": 30, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 299598, + "memory": 1632, + "bytes": 30, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/traced_first/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/traced_second/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nsndPair anf#3", + "before": { + "cpu": 299598, + "memory": 1632, + "bytes": 30, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 441590, + "memory": 1664, + "bytes": 30, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/traced_second/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nsndPair anf#3", + "before": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 537590, + "memory": 2264, + "bytes": 34, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/traced_second/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 299598, + "memory": 1632, + "bytes": 30, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 299598, + "memory": 1632, + "bytes": 30, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/traced_second/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 8)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/made_data_first/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\nfstPair anf#3", + "before": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 345541, + "memory": 1364, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair/made_data_first/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\nfstPair anf#3", + "before": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 393541, + "memory": 1664, + "bytes": 24, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair/made_data_first/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair/made_data_first/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair/made_data_second/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\nsndPair anf#3", + "before": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 345638, + "memory": 1364, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair/made_data_second/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\nsndPair anf#3", + "before": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 393638, + "memory": 1664, + "bytes": 24, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair/made_data_second/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair/made_data_second/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair Data Data = mkPairData (con data (I 7)) (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + }, + "after": { + "cpu": 203646, + "memory": 1332, + "bytes": 22, + "result": "(con data (I 7))", + "logs": [] + } + }, + { + "input": "pair/decoded_first/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\nfstPair anf#3", + "before": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 326583, + "memory": 1164, + "bytes": 18, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "pair/decoded_first/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\nfstPair anf#3", + "before": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 374583, + "memory": 1464, + "bytes": 20, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "pair/decoded_first/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "pair/decoded_first/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "pair/decoded_second/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\nsndPair anf#3", + "before": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con (list data) [])", + "logs": [] + }, + "after": { + "cpu": 326680, + "memory": 1164, + "bytes": 18, + "result": "(con (list data) [])", + "logs": [] + } + }, + { + "input": "pair/decoded_second/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\nsndPair anf#3", + "before": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con (list data) [])", + "logs": [] + }, + "after": { + "cpu": 374680, + "memory": 1464, + "bytes": 20, + "result": "(con (list data) [])", + "logs": [] + } + }, + { + "input": "pair/decoded_second/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con (list data) [])", + "logs": [] + }, + "after": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con (list data) [])", + "logs": [] + } + }, + { + "input": "pair/decoded_second/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (Constr 0 [])) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con (list data) [])", + "logs": [] + }, + "after": { + "cpu": 184688, + "memory": 1132, + "bytes": 18, + "result": "(con (list data) [])", + "logs": [] + } + }, + { + "input": "pair/bad_decoder_first/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\nfstPair anf#3", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair/bad_decoder_first/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\nfstPair anf#3", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 18, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair/bad_decoder_first/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair/bad_decoder_first/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair/bad_decoder_second/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\nsndPair anf#3", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair/bad_decoder_second/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\nsndPair anf#3", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 18, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair/bad_decoder_second/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair/bad_decoder_second/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int (list Data) = unConstrData (con data (I 7)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 16, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [] + } + }, + { + "input": "pair/ignored_failure_first/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\nfstPair anf#4", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 40, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 40, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair/ignored_failure_first/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\nfstPair anf#4", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 44, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair/ignored_failure_first/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 40, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 40, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair/ignored_failure_first/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair/ignored_failure_second/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\nsndPair anf#4", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 40, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 40, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair/ignored_failure_second/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\nsndPair anf#4", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 44, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair/ignored_failure_second/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 40, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 40, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair/ignored_failure_second/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : Data = trace \"unused field\" in error in\nlet anf#4 : pair Data Data = mkPairData (con data (I 7)) anf#3 in\ncase@Pair anf#4 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 41, + "result": "error: ExplicitErrorTerm", + "logs": [ + "unused field" + ] + } + }, + { + "input": "pair/wrong_subject_first/cancelling=false/sharing=false\n--- accepted Core\ncase@Pair 1 of\n Pair x#1 y#2 -> x#1\n--- trial Core\ncase@Pair 1 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair/wrong_subject_first/cancelling=false/sharing=true\n--- accepted Core\ncase@Pair 1 of\n Pair x#1 y#2 -> x#1\n--- trial Core\ncase@Pair 1 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair/wrong_subject_first/cancelling=true/sharing=false\n--- accepted Core\ncase@Pair 1 of\n Pair x#1 y#2 -> x#1\n--- trial Core\ncase@Pair 1 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair/wrong_subject_first/cancelling=true/sharing=true\n--- accepted Core\ncase@Pair 1 of\n Pair x#1 y#2 -> x#1\n--- trial Core\ncase@Pair 1 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair/wrong_subject_second/cancelling=false/sharing=false\n--- accepted Core\ncase@Pair 1 of\n Pair x#1 y#2 -> y#2\n--- trial Core\ncase@Pair 1 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair/wrong_subject_second/cancelling=false/sharing=true\n--- accepted Core\ncase@Pair 1 of\n Pair x#1 y#2 -> y#2\n--- trial Core\ncase@Pair 1 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair/wrong_subject_second/cancelling=true/sharing=false\n--- accepted Core\ncase@Pair 1 of\n Pair x#1 y#2 -> y#2\n--- trial Core\ncase@Pair 1 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair/wrong_subject_second/cancelling=true/sharing=true\n--- accepted Core\ncase@Pair 1 of\n Pair x#1 y#2 -> y#2\n--- trial Core\ncase@Pair 1 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + }, + "after": { + "cpu": 100, + "memory": 100, + "bytes": 9, + "result": "error: NonConstrScrutinized(Con(Integer(1)))", + "logs": [] + } + }, + { + "input": "pair/native_constructor_first/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair/native_constructor_first/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair/native_constructor_first/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair/native_constructor_first/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1\n--- trial Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> x#1", + "before": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 7)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "pair/native_constructor_second/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair/native_constructor_second/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair/native_constructor_second/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair/native_constructor_second/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2\n--- trial Core\nlet anf#3 : pair int int = constr 0 7 8 in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> y#2", + "before": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 8)", + "logs": [] + }, + "after": { + "cpu": 160100, + "memory": 1100, + "bytes": 16, + "result": "(con integer 8)", + "logs": [] + } + }, + { + "input": "pair/body/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> trace \"body\" in addInteger x#1 1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet x#1 : int = fstPair anf#3 in\ntrace \"body\" in addInteger x#1 1", + "before": { + "cpu": 636304, + "memory": 2766, + "bytes": 46, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + }, + "after": { + "cpu": 826199, + "memory": 3098, + "bytes": 48, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + } + }, + { + "input": "pair/body/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> trace \"body\" in addInteger x#1 1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet x#1 : int = fstPair anf#3 in\ntrace \"body\" in addInteger x#1 1", + "before": { + "cpu": 668304, + "memory": 2966, + "bytes": 49, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + }, + "after": { + "cpu": 906199, + "memory": 3598, + "bytes": 53, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + } + }, + { + "input": "pair/body/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> trace \"body\" in addInteger x#1 1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> trace \"body\" in addInteger x#1 1", + "before": { + "cpu": 636304, + "memory": 2766, + "bytes": 46, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + }, + "after": { + "cpu": 636304, + "memory": 2766, + "bytes": 46, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + } + }, + { + "input": "pair/body/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> trace \"body\" in addInteger x#1 1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> trace \"body\" in addInteger x#1 1", + "before": { + "cpu": 668304, + "memory": 2966, + "bytes": 49, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + }, + "after": { + "cpu": 668304, + "memory": 2966, + "bytes": 49, + "result": "(con integer 8)", + "logs": [ + "subject", + "body" + ] + } + }, + { + "input": "pair/both/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 y#2\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 y#2", + "before": { + "cpu": 464806, + "memory": 2034, + "bytes": 34, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 464806, + "memory": 2034, + "bytes": 34, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/both/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 y#2\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 y#2", + "before": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/both/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 y#2\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 y#2", + "before": { + "cpu": 464806, + "memory": 2034, + "bytes": 34, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 464806, + "memory": 2034, + "bytes": 34, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/both/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 y#2\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 y#2", + "before": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 15)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/neither/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> 42\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> 42", + "before": { + "cpu": 299598, + "memory": 1632, + "bytes": 31, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 299598, + "memory": 1632, + "bytes": 31, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/neither/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> 42\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> 42", + "before": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/neither/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> 42\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> 42", + "before": { + "cpu": 299598, + "memory": 1632, + "bytes": 31, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 299598, + "memory": 1632, + "bytes": 31, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/neither/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> 42\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> 42", + "before": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 347598, + "memory": 1932, + "bytes": 33, + "result": "(con integer 42)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/delay/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#4 : @delay int = case@Pair anf#3 of\n Pair x#1 y#2 -> delay x#1 in\nforce anf#4\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nfstPair anf#3", + "before": { + "cpu": 379598, + "memory": 2132, + "bytes": 33, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 441493, + "memory": 1664, + "bytes": 30, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/delay/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#4 : @delay int = case@Pair anf#3 of\n Pair x#1 y#2 -> delay x#1 in\nforce anf#4\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nfstPair anf#3", + "before": { + "cpu": 427598, + "memory": 2432, + "bytes": 36, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 537493, + "memory": 2264, + "bytes": 34, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/delay/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#4 : @delay int = case@Pair anf#3 of\n Pair x#1 y#2 -> delay x#1 in\nforce anf#4\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#4 : @delay int = case@Pair anf#3 of\n Pair x#1 y#2 -> delay x#1 in\nforce anf#4", + "before": { + "cpu": 379598, + "memory": 2132, + "bytes": 33, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 379598, + "memory": 2132, + "bytes": 33, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/delay/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#4 : @delay int = case@Pair anf#3 of\n Pair x#1 y#2 -> delay x#1 in\nforce anf#4\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#4 : @delay int = case@Pair anf#3 of\n Pair x#1 y#2 -> delay x#1 in\nforce anf#4", + "before": { + "cpu": 427598, + "memory": 2432, + "bytes": 36, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 427598, + "memory": 2432, + "bytes": 36, + "result": "(con integer 7)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/lambda/cancelling=false/sharing=false\n--- accepted Core\nlet anf#4 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#5 : int -> int = case@Pair anf#4 of\n Pair x#1 y#2 -> \\unused#3 : int -> x#1 in\nlet anf#6 : int = trace \"argument\" in 0 in\nanf#5 anf#6\n--- trial Core\nlet anf#4 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet x#1 : int = fstPair anf#4 in\nlet anf#6 : int = trace \"argument\" in 0 in\nx#1", + "before": { + "cpu": 615096, + "memory": 3264, + "bytes": 54, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + }, + "after": { + "cpu": 708991, + "memory": 2996, + "bytes": 51, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + } + }, + { + "input": "pair/lambda/cancelling=false/sharing=true\n--- accepted Core\nlet anf#4 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#5 : int -> int = case@Pair anf#4 of\n Pair x#1 y#2 -> \\unused#3 : int -> x#1 in\nlet anf#6 : int = trace \"argument\" in 0 in\nanf#5 anf#6\n--- trial Core\nlet anf#4 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet x#1 : int = fstPair anf#4 in\nlet anf#6 : int = trace \"argument\" in 0 in\nx#1", + "before": { + "cpu": 647096, + "memory": 3464, + "bytes": 56, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + }, + "after": { + "cpu": 788991, + "memory": 3496, + "bytes": 55, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + } + }, + { + "input": "pair/lambda/cancelling=true/sharing=false\n--- accepted Core\nlet anf#4 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#5 : int -> int = case@Pair anf#4 of\n Pair x#1 y#2 -> \\unused#3 : int -> x#1 in\nlet anf#6 : int = trace \"argument\" in 0 in\nanf#5 anf#6\n--- trial Core\nlet anf#4 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#5 : int -> int = case@Pair anf#4 of\n Pair x#1 y#2 -> \\unused#3 : int -> x#1 in\nlet anf#6 : int = trace \"argument\" in 0 in\nanf#5 anf#6", + "before": { + "cpu": 615096, + "memory": 3264, + "bytes": 54, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + }, + "after": { + "cpu": 615096, + "memory": 3264, + "bytes": 54, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + } + }, + { + "input": "pair/lambda/cancelling=true/sharing=true\n--- accepted Core\nlet anf#4 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#5 : int -> int = case@Pair anf#4 of\n Pair x#1 y#2 -> \\unused#3 : int -> x#1 in\nlet anf#6 : int = trace \"argument\" in 0 in\nanf#5 anf#6\n--- trial Core\nlet anf#4 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet anf#5 : int -> int = case@Pair anf#4 of\n Pair x#1 y#2 -> \\unused#3 : int -> x#1 in\nlet anf#6 : int = trace \"argument\" in 0 in\nanf#5 anf#6", + "before": { + "cpu": 647096, + "memory": 3464, + "bytes": 56, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + }, + "after": { + "cpu": 647096, + "memory": 3464, + "bytes": 56, + "result": "(con integer 7)", + "logs": [ + "subject", + "argument" + ] + } + }, + { + "input": "pair/repeated/cancelling=false/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 x#1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet x#1 : int = fstPair anf#3 in\naddInteger x#1 x#1", + "before": { + "cpu": 464806, + "memory": 2034, + "bytes": 34, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 654701, + "memory": 2366, + "bytes": 36, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/repeated/cancelling=false/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 x#1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\nlet x#1 : int = fstPair anf#3 in\naddInteger x#1 x#1", + "before": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 750701, + "memory": 2966, + "bytes": 41, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/repeated/cancelling=true/sharing=false\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 x#1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 x#1", + "before": { + "cpu": 464806, + "memory": 2034, + "bytes": 34, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 464806, + "memory": 2034, + "bytes": 34, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/repeated/cancelling=true/sharing=true\n--- accepted Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 x#1\n--- trial Core\nlet anf#3 : pair int int = trace \"subject\" in (con (pair integer integer) (7, 8)) in\ncase@Pair anf#3 of\n Pair x#1 y#2 -> addInteger x#1 x#1", + "before": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + }, + "after": { + "cpu": 512806, + "memory": 2334, + "bytes": 36, + "result": "(con integer 14)", + "logs": [ + "subject" + ] + } + }, + { + "input": "pair/two_projections_first/cancelling=false/sharing=false\n--- accepted Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> x#1 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> x#3 in\naddInteger anf#6 anf#8\n--- trial Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet x#1 : int = fstPair anf#5 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet x#3 : int = fstPair anf#7 in\naddInteger x#1 x#3", + "before": { + "cpu": 844304, + "memory": 4066, + "bytes": 60, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 1128094, + "memory": 4130, + "bytes": 60, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair/two_projections_first/cancelling=false/sharing=true\n--- accepted Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> x#1 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> x#3 in\naddInteger anf#6 anf#8\n--- trial Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet x#1 : int = fstPair anf#5 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet x#3 : int = fstPair anf#7 in\naddInteger x#1 x#3", + "before": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 1176094, + "memory": 4430, + "bytes": 64, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair/two_projections_first/cancelling=true/sharing=false\n--- accepted Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> x#1 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> x#3 in\naddInteger anf#6 anf#8\n--- trial Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> x#1 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> x#3 in\naddInteger anf#6 anf#8", + "before": { + "cpu": 844304, + "memory": 4066, + "bytes": 60, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 844304, + "memory": 4066, + "bytes": 60, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair/two_projections_first/cancelling=true/sharing=true\n--- accepted Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> x#1 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> x#3 in\naddInteger anf#6 anf#8\n--- trial Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> x#1 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> x#3 in\naddInteger anf#6 anf#8", + "before": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 14)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair/two_projections_second/cancelling=false/sharing=false\n--- accepted Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> y#2 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> y#4 in\naddInteger anf#6 anf#8\n--- trial Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet y#2 : int = sndPair anf#5 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet y#4 : int = sndPair anf#7 in\naddInteger y#2 y#4", + "before": { + "cpu": 844304, + "memory": 4066, + "bytes": 60, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 1128288, + "memory": 4130, + "bytes": 60, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair/two_projections_second/cancelling=false/sharing=true\n--- accepted Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> y#2 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> y#4 in\naddInteger anf#6 anf#8\n--- trial Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet y#2 : int = sndPair anf#5 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet y#4 : int = sndPair anf#7 in\naddInteger y#2 y#4", + "before": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 1176288, + "memory": 4430, + "bytes": 64, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair/two_projections_second/cancelling=true/sharing=false\n--- accepted Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> y#2 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> y#4 in\naddInteger anf#6 anf#8\n--- trial Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> y#2 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> y#4 in\naddInteger anf#6 anf#8", + "before": { + "cpu": 844304, + "memory": 4066, + "bytes": 60, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 844304, + "memory": 4066, + "bytes": 60, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair/two_projections_second/cancelling=true/sharing=true\n--- accepted Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> y#2 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> y#4 in\naddInteger anf#6 anf#8\n--- trial Core\nlet anf#5 : pair int int = trace \"first\" in (con (pair integer integer) (7, 8)) in\nlet anf#6 : int = case@Pair anf#5 of\n Pair x#1 y#2 -> y#2 in\nlet anf#7 : pair int int = trace \"second\" in (con (pair integer integer) (7, 8)) in\nlet anf#8 : int = case@Pair anf#7 of\n Pair x#3 y#4 -> y#4 in\naddInteger anf#6 anf#8", + "before": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + }, + "after": { + "cpu": 876304, + "memory": 4266, + "bytes": 63, + "result": "(con integer 16)", + "logs": [ + "first", + "second" + ] + } + }, + { + "input": "pair/unconsumed_lambda_failure/cancelling=false/sharing=false\n--- accepted Core\nlet anf#5 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#6 : pair int (list Data) = unConstrData anf#5 in\nlet ignored closure#4 : int -> int = case@Pair anf#6 of\n Pair x#1 y#2 -> \\arg#3 : int -> x#1 in\n0\n--- trial Core\nlet anf#5 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#6 : pair int (list Data) = unConstrData anf#5 in\nlet x#1 : int = fstPair anf#6 in\n0", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 44, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 43, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair/unconsumed_lambda_failure/cancelling=false/sharing=true\n--- accepted Core\nlet anf#5 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#6 : pair int (list Data) = unConstrData anf#5 in\nlet ignored closure#4 : int -> int = case@Pair anf#6 of\n Pair x#1 y#2 -> \\arg#3 : int -> x#1 in\n0\n--- trial Core\nlet anf#5 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#6 : pair int (list Data) = unConstrData anf#5 in\nlet x#1 : int = fstPair anf#6 in\n0", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 48, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair/unconsumed_lambda_failure/cancelling=true/sharing=false\n--- accepted Core\nlet anf#5 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#6 : pair int (list Data) = unConstrData anf#5 in\nlet ignored closure#4 : int -> int = case@Pair anf#6 of\n Pair x#1 y#2 -> \\arg#3 : int -> x#1 in\n0\n--- trial Core\nlet anf#5 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#6 : pair int (list Data) = unConstrData anf#5 in\nlet ignored closure#4 : int -> int = case@Pair anf#6 of\n Pair x#1 y#2 -> \\arg#3 : int -> x#1 in\n0", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 44, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 44, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair/unconsumed_lambda_failure/cancelling=true/sharing=true\n--- accepted Core\nlet anf#5 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#6 : pair int (list Data) = unConstrData anf#5 in\nlet ignored closure#4 : int -> int = case@Pair anf#6 of\n Pair x#1 y#2 -> \\arg#3 : int -> x#1 in\n0\n--- trial Core\nlet anf#5 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#6 : pair int (list Data) = unConstrData anf#5 in\nlet ignored closure#4 : int -> int = case@Pair anf#6 of\n Pair x#1 y#2 -> \\arg#3 : int -> x#1 in\n0", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair/unconsumed_delay_failure/cancelling=false/sharing=false\n--- accepted Core\nlet anf#4 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#5 : pair int (list Data) = unConstrData anf#4 in\nlet ignored closure#3 : @delay int = case@Pair anf#5 of\n Pair x#1 y#2 -> delay x#1 in\n0\n--- trial Core\nlet anf#4 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#5 : pair int (list Data) = unConstrData anf#4 in\nlet x#1 : int = fstPair anf#5 in\n0", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 44, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 43, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair/unconsumed_delay_failure/cancelling=false/sharing=true\n--- accepted Core\nlet anf#4 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#5 : pair int (list Data) = unConstrData anf#4 in\nlet ignored closure#3 : @delay int = case@Pair anf#5 of\n Pair x#1 y#2 -> delay x#1 in\n0\n--- trial Core\nlet anf#4 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#5 : pair int (list Data) = unConstrData anf#4 in\nlet x#1 : int = fstPair anf#5 in\n0", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 48, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair/unconsumed_delay_failure/cancelling=true/sharing=false\n--- accepted Core\nlet anf#4 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#5 : pair int (list Data) = unConstrData anf#4 in\nlet ignored closure#3 : @delay int = case@Pair anf#5 of\n Pair x#1 y#2 -> delay x#1 in\n0\n--- trial Core\nlet anf#4 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#5 : pair int (list Data) = unConstrData anf#4 in\nlet ignored closure#3 : @delay int = case@Pair anf#5 of\n Pair x#1 y#2 -> delay x#1 in\n0", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 44, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 44, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair/unconsumed_delay_failure/cancelling=true/sharing=true\n--- accepted Core\nlet anf#4 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#5 : pair int (list Data) = unConstrData anf#4 in\nlet ignored closure#3 : @delay int = case@Pair anf#5 of\n Pair x#1 y#2 -> delay x#1 in\n0\n--- trial Core\nlet anf#4 : Data = trace \"before failure\" in (con data (I 7)) in\nlet anf#5 : pair int (list Data) = unConstrData anf#4 in\nlet ignored closure#3 : @delay int = case@Pair anf#5 of\n Pair x#1 y#2 -> delay x#1 in\n0", + "before": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + }, + "after": { + "cpu": 59598, + "memory": 132, + "bytes": 46, + "result": "error: Runtime(MalFormedData(Integer(7)))", + "logs": [ + "before failure" + ] + } + }, + { + "input": "pair/roundtrip_valid_first/cancelling=false/sharing=false\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> x#5\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ntag#1", + "before": { + "cpu": 1058941, + "memory": 5292, + "bytes": 67, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 994941, + "memory": 4892, + "bytes": 63, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_valid_first/cancelling=false/sharing=true\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> x#5\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ntag#1", + "before": { + "cpu": 1138941, + "memory": 5792, + "bytes": 70, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 1074941, + "memory": 5392, + "bytes": 67, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_valid_first/cancelling=true/sharing=false\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> x#5\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ntag#1", + "before": { + "cpu": 1058941, + "memory": 5292, + "bytes": 67, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 994941, + "memory": 4892, + "bytes": 63, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_valid_first/cancelling=true/sharing=true\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> x#5\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ntag#1", + "before": { + "cpu": 1138941, + "memory": 5792, + "bytes": 70, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 1074941, + "memory": 5392, + "bytes": 67, + "result": "(con integer 0)", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_valid_second/cancelling=false/sharing=false\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> y#6\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\nfields#2", + "before": { + "cpu": 1058941, + "memory": 5292, + "bytes": 67, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 994941, + "memory": 4892, + "bytes": 63, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_valid_second/cancelling=false/sharing=true\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> y#6\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\nfields#2", + "before": { + "cpu": 1138941, + "memory": 5792, + "bytes": 70, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 1074941, + "memory": 5392, + "bytes": 67, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_valid_second/cancelling=true/sharing=false\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> y#6\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\nfields#2", + "before": { + "cpu": 1058941, + "memory": 5292, + "bytes": 67, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 994941, + "memory": 4892, + "bytes": 63, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_valid_second/cancelling=true/sharing=true\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> y#6\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (I 0)) in\nlet tag#1 : int = unIData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\nfields#2", + "before": { + "cpu": 1138941, + "memory": 5792, + "bytes": 70, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 1074941, + "memory": 5392, + "bytes": 67, + "result": "(con (list data) [(I 7)])", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_bad_tag_first/cancelling=false/sharing=false\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> x#5\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ntag#1", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 66, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_bad_tag_first/cancelling=false/sharing=true\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> x#5\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ntag#1", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 73, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_bad_tag_first/cancelling=true/sharing=false\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> x#5\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ntag#1", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 66, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_bad_tag_first/cancelling=true/sharing=true\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> x#5\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ntag#1", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 73, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_bad_tag_second/cancelling=false/sharing=false\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> y#6\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\nfields#2", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 66, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_bad_tag_second/cancelling=false/sharing=true\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> y#6\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\nfields#2", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 73, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_bad_tag_second/cancelling=true/sharing=false\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> y#6\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\nfields#2", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 66, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/roundtrip_bad_tag_second/cancelling=true/sharing=true\n--- accepted Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\ncase@Pair decoded#4 of\n Pair x#5 y#6 -> y#6\n--- trial Core\nlet anf#7 : Data = trace \"tag\" in (con data (B #626164)) in\nlet tag#1 : int = unBData anf#7 in\nlet anf#8 : Data = trace \"field\" in (con data (I 7)) in\nlet fields#2 : list Data = mkCons anf#8 (con (list data) []) in\nlet encoded#3 : Data = constrData tag#1 fields#2 in\nlet decoded#4 : pair int (list Data) = unConstrData encoded#3 in\nfields#2", + "before": { + "cpu": 211600, + "memory": 228, + "bytes": 73, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + }, + "after": { + "cpu": 211600, + "memory": 228, + "bytes": 70, + "result": "error: Runtime(TypeMismatch(Integer, ByteString([98, 97, 100])))", + "logs": [ + "tag", + "field" + ] + } + }, + { + "input": "pair/source/listTraversal/cancelling=false/sharing=false\n--- accepted Core\nletrec\n sum#13 : list int -> int [static []] = \\xs#14 : list int -> case@List xs#14 of\n Nil -> 0\n Cons field#16 field#17 -> let anf#21 : int = sum#13 field#17 in\n addInteger field#16 anf#21\nin\nlet anf#30 : list int = mkCons 8 (con (list integer) []) in\nlet anf#31 : list int = mkCons 7 anf#30 in\nlet anf#32 : list int = mkCons 6 anf#31 in\nlet anf#33 : list int = mkCons 5 anf#32 in\nlet anf#34 : list int = mkCons 4 anf#33 in\nlet anf#35 : list int = mkCons 3 anf#34 in\nlet anf#36 : list int = mkCons 2 anf#35 in\nlet anf#37 : list int = mkCons 1 anf#36 in\nsum#13 anf#37\n--- trial Core\nletrec\n sum#13 : list int -> int [static []] = \\xs#14 : list int -> case@List xs#14 of\n Nil -> 0\n Cons field#16 field#17 -> let anf#21 : int = sum#13 field#17 in\n addInteger field#16 anf#21\nin\nlet anf#30 : list int = mkCons 8 (con (list integer) []) in\nlet anf#31 : list int = mkCons 7 anf#30 in\nlet anf#32 : list int = mkCons 6 anf#31 in\nlet anf#33 : list int = mkCons 5 anf#32 in\nlet anf#34 : list int = mkCons 4 anf#33 in\nlet anf#35 : list int = mkCons 3 anf#34 in\nlet anf#36 : list int = mkCons 2 anf#35 in\nlet anf#37 : list int = mkCons 1 anf#36 in\nsum#13 anf#37", + "before": { + "cpu": 4828660, + "memory": 21872, + "bytes": 93, + "result": "(con integer 36)", + "logs": [] + }, + "after": { + "cpu": 4828660, + "memory": 21872, + "bytes": 93, + "result": "(con integer 36)", + "logs": [] + } + }, + { + "input": "pair/source/listTraversal/cancelling=false/sharing=true\n--- accepted Core\nletrec\n sum#13 : list int -> int [static []] = \\xs#14 : list int -> case@List xs#14 of\n Nil -> 0\n Cons field#16 field#17 -> let anf#21 : int = sum#13 field#17 in\n addInteger field#16 anf#21\nin\nlet anf#30 : list int = mkCons 8 (con (list integer) []) in\nlet anf#31 : list int = mkCons 7 anf#30 in\nlet anf#32 : list int = mkCons 6 anf#31 in\nlet anf#33 : list int = mkCons 5 anf#32 in\nlet anf#34 : list int = mkCons 4 anf#33 in\nlet anf#35 : list int = mkCons 3 anf#34 in\nlet anf#36 : list int = mkCons 2 anf#35 in\nlet anf#37 : list int = mkCons 1 anf#36 in\nsum#13 anf#37\n--- trial Core\nletrec\n sum#13 : list int -> int [static []] = \\xs#14 : list int -> case@List xs#14 of\n Nil -> 0\n Cons field#16 field#17 -> let anf#21 : int = sum#13 field#17 in\n addInteger field#16 anf#21\nin\nlet anf#30 : list int = mkCons 8 (con (list integer) []) in\nlet anf#31 : list int = mkCons 7 anf#30 in\nlet anf#32 : list int = mkCons 6 anf#31 in\nlet anf#33 : list int = mkCons 5 anf#32 in\nlet anf#34 : list int = mkCons 4 anf#33 in\nlet anf#35 : list int = mkCons 3 anf#34 in\nlet anf#36 : list int = mkCons 2 anf#35 in\nlet anf#37 : list int = mkCons 1 anf#36 in\nsum#13 anf#37", + "before": { + "cpu": 4764660, + "memory": 21472, + "bytes": 93, + "result": "(con integer 36)", + "logs": [] + }, + "after": { + "cpu": 4764660, + "memory": 21472, + "bytes": 93, + "result": "(con integer 36)", + "logs": [] + } + }, + { + "input": "pair/source/listTraversal/cancelling=true/sharing=false\n--- accepted Core\nletrec\n sum#13 : list int -> int [static []] = \\xs#14 : list int -> case@List xs#14 of\n Nil -> 0\n Cons field#16 field#17 -> let anf#21 : int = sum#13 field#17 in\n addInteger field#16 anf#21\nin\nlet anf#30 : list int = mkCons 8 (con (list integer) []) in\nlet anf#31 : list int = mkCons 7 anf#30 in\nlet anf#32 : list int = mkCons 6 anf#31 in\nlet anf#33 : list int = mkCons 5 anf#32 in\nlet anf#34 : list int = mkCons 4 anf#33 in\nlet anf#35 : list int = mkCons 3 anf#34 in\nlet anf#36 : list int = mkCons 2 anf#35 in\nlet anf#37 : list int = mkCons 1 anf#36 in\nsum#13 anf#37\n--- trial Core\nletrec\n sum#13 : list int -> int [static []] = \\xs#14 : list int -> case@List xs#14 of\n Nil -> 0\n Cons field#16 field#17 -> let anf#21 : int = sum#13 field#17 in\n addInteger field#16 anf#21\nin\nlet anf#30 : list int = mkCons 8 (con (list integer) []) in\nlet anf#31 : list int = mkCons 7 anf#30 in\nlet anf#32 : list int = mkCons 6 anf#31 in\nlet anf#33 : list int = mkCons 5 anf#32 in\nlet anf#34 : list int = mkCons 4 anf#33 in\nlet anf#35 : list int = mkCons 3 anf#34 in\nlet anf#36 : list int = mkCons 2 anf#35 in\nlet anf#37 : list int = mkCons 1 anf#36 in\nsum#13 anf#37", + "before": { + "cpu": 4828660, + "memory": 21872, + "bytes": 93, + "result": "(con integer 36)", + "logs": [] + }, + "after": { + "cpu": 4828660, + "memory": 21872, + "bytes": 93, + "result": "(con integer 36)", + "logs": [] + } + }, + { + "input": "pair/source/listTraversal/cancelling=true/sharing=true\n--- accepted Core\nletrec\n sum#13 : list int -> int [static []] = \\xs#14 : list int -> case@List xs#14 of\n Nil -> 0\n Cons field#16 field#17 -> let anf#21 : int = sum#13 field#17 in\n addInteger field#16 anf#21\nin\nlet anf#30 : list int = mkCons 8 (con (list integer) []) in\nlet anf#31 : list int = mkCons 7 anf#30 in\nlet anf#32 : list int = mkCons 6 anf#31 in\nlet anf#33 : list int = mkCons 5 anf#32 in\nlet anf#34 : list int = mkCons 4 anf#33 in\nlet anf#35 : list int = mkCons 3 anf#34 in\nlet anf#36 : list int = mkCons 2 anf#35 in\nlet anf#37 : list int = mkCons 1 anf#36 in\nsum#13 anf#37\n--- trial Core\nletrec\n sum#13 : list int -> int [static []] = \\xs#14 : list int -> case@List xs#14 of\n Nil -> 0\n Cons field#16 field#17 -> let anf#21 : int = sum#13 field#17 in\n addInteger field#16 anf#21\nin\nlet anf#30 : list int = mkCons 8 (con (list integer) []) in\nlet anf#31 : list int = mkCons 7 anf#30 in\nlet anf#32 : list int = mkCons 6 anf#31 in\nlet anf#33 : list int = mkCons 5 anf#32 in\nlet anf#34 : list int = mkCons 4 anf#33 in\nlet anf#35 : list int = mkCons 3 anf#34 in\nlet anf#36 : list int = mkCons 2 anf#35 in\nlet anf#37 : list int = mkCons 1 anf#36 in\nsum#13 anf#37", + "before": { + "cpu": 4764660, + "memory": 21472, + "bytes": 93, + "result": "(con integer 36)", + "logs": [] + }, + "after": { + "cpu": 4764660, + "memory": 21472, + "bytes": 93, + "result": "(con integer 36)", + "logs": [] + } + }, + { + "input": "pair/source/staticRecursion/cancelling=false/sharing=false\n--- accepted Core\nletrec\n worker#14 : int -> int [static []] = \\n#13 : int -> let anf#16 : bool = equalsInteger n#13 0 in\n case@Bool anf#16 of\n True -> 42\n False -> let anf#18 : int = subtractInteger n#13 1 in\n worker#14 anf#18\nin\nworker#14 8\n--- trial Core\nletrec\n worker#14 : int -> int [static []] = \\n#13 : int -> let anf#16 : bool = equalsInteger n#13 0 in\n case@Bool anf#16 of\n True -> 42\n False -> let anf#18 : int = subtractInteger n#13 1 in\n worker#14 anf#18\nin\nworker#14 8", + "before": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/staticRecursion/cancelling=false/sharing=true\n--- accepted Core\nletrec\n worker#14 : int -> int [static []] = \\n#13 : int -> let anf#16 : bool = equalsInteger n#13 0 in\n case@Bool anf#16 of\n True -> 42\n False -> let anf#18 : int = subtractInteger n#13 1 in\n worker#14 anf#18\nin\nworker#14 8\n--- trial Core\nletrec\n worker#14 : int -> int [static []] = \\n#13 : int -> let anf#16 : bool = equalsInteger n#13 0 in\n case@Bool anf#16 of\n True -> 42\n False -> let anf#18 : int = subtractInteger n#13 1 in\n worker#14 anf#18\nin\nworker#14 8", + "before": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/staticRecursion/cancelling=true/sharing=false\n--- accepted Core\nletrec\n worker#14 : int -> int [static []] = \\n#13 : int -> let anf#16 : bool = equalsInteger n#13 0 in\n case@Bool anf#16 of\n True -> 42\n False -> let anf#18 : int = subtractInteger n#13 1 in\n worker#14 anf#18\nin\nworker#14 8\n--- trial Core\nletrec\n worker#14 : int -> int [static []] = \\n#13 : int -> let anf#16 : bool = equalsInteger n#13 0 in\n case@Bool anf#16 of\n True -> 42\n False -> let anf#18 : int = subtractInteger n#13 1 in\n worker#14 anf#18\nin\nworker#14 8", + "before": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/staticRecursion/cancelling=true/sharing=true\n--- accepted Core\nletrec\n worker#14 : int -> int [static []] = \\n#13 : int -> let anf#16 : bool = equalsInteger n#13 0 in\n case@Bool anf#16 of\n True -> 42\n False -> let anf#18 : int = subtractInteger n#13 1 in\n worker#14 anf#18\nin\nworker#14 8\n--- trial Core\nletrec\n worker#14 : int -> int [static []] = \\n#13 : int -> let anf#16 : bool = equalsInteger n#13 0 in\n case@Bool anf#16 of\n True -> 42\n False -> let anf#18 : int = subtractInteger n#13 1 in\n worker#14 anf#18\nin\nworker#14 8", + "before": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 4448761, + "memory": 19925, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/dataMatch/cancelling=false/sharing=false\n--- accepted Core\nlet anf#30 : Data = iData 42 in\n42\n--- trial Core\nlet anf#30 : Data = iData 42 in\n42", + "before": { + "cpu": 111399, + "memory": 732, + "bytes": 11, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 111399, + "memory": 732, + "bytes": 11, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/dataMatch/cancelling=false/sharing=true\n--- accepted Core\nlet anf#30 : Data = iData 42 in\n42\n--- trial Core\nlet anf#30 : Data = iData 42 in\n42", + "before": { + "cpu": 111399, + "memory": 732, + "bytes": 11, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 111399, + "memory": 732, + "bytes": 11, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/dataMatch/cancelling=true/sharing=false\n--- accepted Core\nlet anf#30 : Data = iData 42 in\n42\n--- trial Core\nlet anf#30 : Data = iData 42 in\n42", + "before": { + "cpu": 111399, + "memory": 732, + "bytes": 11, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 111399, + "memory": 732, + "bytes": 11, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/dataMatch/cancelling=true/sharing=true\n--- accepted Core\nlet anf#30 : Data = iData 42 in\n42\n--- trial Core\nlet anf#30 : Data = iData 42 in\n42", + "before": { + "cpu": 111399, + "memory": 732, + "bytes": 11, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 111399, + "memory": 732, + "bytes": 11, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/dataMiss/cancelling=false/sharing=false\n--- accepted Core\nlet anf#34 : Data = bData (con bytestring #ab) in\n0\n--- trial Core\nlet anf#34 : Data = bData (con bytestring #ab) in\n0", + "before": { + "cpu": 107283, + "memory": 732, + "bytes": 14, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 107283, + "memory": 732, + "bytes": 14, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "pair/source/dataMiss/cancelling=false/sharing=true\n--- accepted Core\nlet anf#34 : Data = bData (con bytestring #ab) in\n0\n--- trial Core\nlet anf#34 : Data = bData (con bytestring #ab) in\n0", + "before": { + "cpu": 107283, + "memory": 732, + "bytes": 14, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 107283, + "memory": 732, + "bytes": 14, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "pair/source/dataMiss/cancelling=true/sharing=false\n--- accepted Core\nlet anf#34 : Data = bData (con bytestring #ab) in\n0\n--- trial Core\nlet anf#34 : Data = bData (con bytestring #ab) in\n0", + "before": { + "cpu": 107283, + "memory": 732, + "bytes": 14, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 107283, + "memory": 732, + "bytes": 14, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "pair/source/dataMiss/cancelling=true/sharing=true\n--- accepted Core\nlet anf#34 : Data = bData (con bytestring #ab) in\n0\n--- trial Core\nlet anf#34 : Data = bData (con bytestring #ab) in\n0", + "before": { + "cpu": 107283, + "memory": 732, + "bytes": 14, + "result": "(con integer 0)", + "logs": [] + }, + "after": { + "cpu": 107283, + "memory": 732, + "bytes": 14, + "result": "(con integer 0)", + "logs": [] + } + }, + { + "input": "pair/source/decoding/cancelling=false/sharing=false\n--- accepted Core\nlet anf#59 : Data = iData 42 in\nlet anf#61 : Data = iData 7 in\nlet anf#62 : list Data = mkCons anf#61 (con (list data) []) in\nlet anf#63 : list Data = mkCons anf#59 anf#62 in\nlet anf#64 : Data = constrData 0 anf#63 in\nlet leaf#13 : @delay int = delay 0 in\nlet field#14 : pair int (list Data) = unConstrData anf#64 in\ncase@Pair field#14 of\n Pair field#15 field#16 -> case@List field#16 of\n Nil -> force leaf#13\n Cons field#17 field#18 -> case@Data field#17 of\n DataConstr field#19 -> force leaf#13\n DataMap field#20 -> force leaf#13\n DataList field#21 -> force leaf#13\n DataI field#22 -> case@List field#18 of\n Nil -> force leaf#13\n Cons field#23 field#24 -> case@List field#24 of\n Nil -> field#22\n Cons field#26 field#47 -> force leaf#13\n DataB field#48 -> force leaf#13\n--- trial Core\nlet anf#59 : Data = iData 42 in\nlet anf#61 : Data = iData 7 in\nlet anf#62 : list Data = mkCons anf#61 (con (list data) []) in\nlet anf#63 : list Data = mkCons anf#59 anf#62 in\nlet anf#64 : Data = constrData 0 anf#63 in\nlet field#14 : pair int (list Data) = unConstrData anf#64 in\n42", + "before": { + "cpu": 1601280, + "memory": 8256, + "bytes": 89, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 846161, + "memory": 4192, + "bytes": 42, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/decoding/cancelling=false/sharing=true\n--- accepted Core\nlet anf#59 : Data = iData 42 in\nlet anf#61 : Data = iData 7 in\nlet anf#62 : list Data = mkCons anf#61 (con (list data) []) in\nlet anf#63 : list Data = mkCons anf#59 anf#62 in\nlet anf#64 : Data = constrData 0 anf#63 in\nlet leaf#13 : @delay int = delay 0 in\nlet field#14 : pair int (list Data) = unConstrData anf#64 in\ncase@Pair field#14 of\n Pair field#15 field#16 -> case@List field#16 of\n Nil -> force leaf#13\n Cons field#17 field#18 -> case@Data field#17 of\n DataConstr field#19 -> force leaf#13\n DataMap field#20 -> force leaf#13\n DataList field#21 -> force leaf#13\n DataI field#22 -> case@List field#18 of\n Nil -> force leaf#13\n Cons field#23 field#24 -> case@List field#24 of\n Nil -> field#22\n Cons field#26 field#47 -> force leaf#13\n DataB field#48 -> force leaf#13\n--- trial Core\nlet anf#59 : Data = iData 42 in\nlet anf#61 : Data = iData 7 in\nlet anf#62 : list Data = mkCons anf#61 (con (list data) []) in\nlet anf#63 : list Data = mkCons anf#59 anf#62 in\nlet anf#64 : Data = constrData 0 anf#63 in\nlet field#14 : pair int (list Data) = unConstrData anf#64 in\n42", + "before": { + "cpu": 1681280, + "memory": 8756, + "bytes": 94, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 878161, + "memory": 4392, + "bytes": 45, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/decoding/cancelling=true/sharing=false\n--- accepted Core\nlet anf#59 : Data = iData 42 in\nlet anf#61 : Data = iData 7 in\nlet anf#62 : list Data = mkCons anf#61 (con (list data) []) in\nlet anf#63 : list Data = mkCons anf#59 anf#62 in\nlet anf#64 : Data = constrData 0 anf#63 in\nlet leaf#13 : @delay int = delay 0 in\nlet field#14 : pair int (list Data) = unConstrData anf#64 in\ncase@Pair field#14 of\n Pair field#15 field#16 -> case@List field#16 of\n Nil -> force leaf#13\n Cons field#17 field#18 -> case@Data field#17 of\n DataConstr field#19 -> force leaf#13\n DataMap field#20 -> force leaf#13\n DataList field#21 -> force leaf#13\n DataI field#22 -> case@List field#18 of\n Nil -> force leaf#13\n Cons field#23 field#24 -> case@List field#24 of\n Nil -> field#22\n Cons field#26 field#47 -> force leaf#13\n DataB field#48 -> force leaf#13\n--- trial Core\nlet anf#59 : Data = iData 42 in\nlet anf#61 : Data = iData 7 in\nlet anf#62 : list Data = mkCons anf#61 (con (list data) []) in\nlet anf#63 : list Data = mkCons anf#59 anf#62 in\nlet anf#64 : Data = constrData 0 anf#63 in\nlet field#14 : pair int (list Data) = unConstrData anf#64 in\n42", + "before": { + "cpu": 1601280, + "memory": 8256, + "bytes": 89, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 846161, + "memory": 4192, + "bytes": 42, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/decoding/cancelling=true/sharing=true\n--- accepted Core\nlet anf#59 : Data = iData 42 in\nlet anf#61 : Data = iData 7 in\nlet anf#62 : list Data = mkCons anf#61 (con (list data) []) in\nlet anf#63 : list Data = mkCons anf#59 anf#62 in\nlet anf#64 : Data = constrData 0 anf#63 in\nlet leaf#13 : @delay int = delay 0 in\nlet field#14 : pair int (list Data) = unConstrData anf#64 in\ncase@Pair field#14 of\n Pair field#15 field#16 -> case@List field#16 of\n Nil -> force leaf#13\n Cons field#17 field#18 -> case@Data field#17 of\n DataConstr field#19 -> force leaf#13\n DataMap field#20 -> force leaf#13\n DataList field#21 -> force leaf#13\n DataI field#22 -> case@List field#18 of\n Nil -> force leaf#13\n Cons field#23 field#24 -> case@List field#24 of\n Nil -> field#22\n Cons field#26 field#47 -> force leaf#13\n DataB field#48 -> force leaf#13\n--- trial Core\nlet anf#59 : Data = iData 42 in\nlet anf#61 : Data = iData 7 in\nlet anf#62 : list Data = mkCons anf#61 (con (list data) []) in\nlet anf#63 : list Data = mkCons anf#59 anf#62 in\nlet anf#64 : Data = constrData 0 anf#63 in\nlet field#14 : pair int (list Data) = unConstrData anf#64 in\n42", + "before": { + "cpu": 1681280, + "memory": 8756, + "bytes": 94, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 878161, + "memory": 4392, + "bytes": 45, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/validationPass/cancelling=false/sharing=false\n--- accepted Core\nlet anf#34 : Data = iData 42 in\nlet anf#32 : bool = lessThanInteger 0 42 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error\n--- trial Core\nlet anf#34 : Data = iData 42 in\nlet anf#32 : bool = lessThanInteger 0 42 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error", + "before": { + "cpu": 300689, + "memory": 1633, + "bytes": 44, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 300689, + "memory": 1633, + "bytes": 44, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "pair/source/validationPass/cancelling=false/sharing=true\n--- accepted Core\nlet anf#34 : Data = iData 42 in\nlet anf#32 : bool = lessThanInteger 0 42 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error\n--- trial Core\nlet anf#34 : Data = iData 42 in\nlet anf#32 : bool = lessThanInteger 0 42 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error", + "before": { + "cpu": 364689, + "memory": 2033, + "bytes": 47, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 364689, + "memory": 2033, + "bytes": 47, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "pair/source/validationPass/cancelling=true/sharing=false\n--- accepted Core\nlet anf#34 : Data = iData 42 in\nlet anf#32 : bool = lessThanInteger 0 42 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error\n--- trial Core\nlet anf#34 : Data = iData 42 in\nlet anf#32 : bool = lessThanInteger 0 42 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error", + "before": { + "cpu": 300689, + "memory": 1633, + "bytes": 44, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 300689, + "memory": 1633, + "bytes": 44, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "pair/source/validationPass/cancelling=true/sharing=true\n--- accepted Core\nlet anf#34 : Data = iData 42 in\nlet anf#32 : bool = lessThanInteger 0 42 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error\n--- trial Core\nlet anf#34 : Data = iData 42 in\nlet anf#32 : bool = lessThanInteger 0 42 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error", + "before": { + "cpu": 364689, + "memory": 2033, + "bytes": 47, + "result": "(con unit ())", + "logs": [] + }, + "after": { + "cpu": 364689, + "memory": 2033, + "bytes": 47, + "result": "(con unit ())", + "logs": [] + } + }, + { + "input": "pair/source/validationFail/cancelling=false/sharing=false\n--- accepted Core\nlet anf#34 : Data = iData 0 in\nlet anf#32 : bool = lessThanInteger 0 0 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error\n--- trial Core\nlet anf#34 : Data = iData 0 in\nlet anf#32 : bool = lessThanInteger 0 0 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error", + "before": { + "cpu": 120187, + "memory": 165, + "bytes": 44, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 120187, + "memory": 165, + "bytes": 44, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "pair/source/validationFail/cancelling=false/sharing=true\n--- accepted Core\nlet anf#34 : Data = iData 0 in\nlet anf#32 : bool = lessThanInteger 0 0 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error\n--- trial Core\nlet anf#34 : Data = iData 0 in\nlet anf#32 : bool = lessThanInteger 0 0 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error", + "before": { + "cpu": 120187, + "memory": 165, + "bytes": 47, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 120187, + "memory": 165, + "bytes": 47, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "pair/source/validationFail/cancelling=true/sharing=false\n--- accepted Core\nlet anf#34 : Data = iData 0 in\nlet anf#32 : bool = lessThanInteger 0 0 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error\n--- trial Core\nlet anf#34 : Data = iData 0 in\nlet anf#32 : bool = lessThanInteger 0 0 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error", + "before": { + "cpu": 120187, + "memory": 165, + "bytes": 44, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 120187, + "memory": 165, + "bytes": 44, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "pair/source/validationFail/cancelling=true/sharing=true\n--- accepted Core\nlet anf#34 : Data = iData 0 in\nlet anf#32 : bool = lessThanInteger 0 0 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error\n--- trial Core\nlet anf#34 : Data = iData 0 in\nlet anf#32 : bool = lessThanInteger 0 0 in\ncase@Bool anf#32 of\n True -> ()\n False -> trace \"assertion failed\" in error", + "before": { + "cpu": 120187, + "memory": 165, + "bytes": 47, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + }, + "after": { + "cpu": 120187, + "memory": 165, + "bytes": 47, + "result": "error: ExplicitErrorTerm", + "logs": [ + "assertion failed" + ] + } + }, + { + "input": "pair/source/booleanHelpers/cancelling=false/sharing=false\n--- accepted Core\ntrue\n--- trial Core\ntrue", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "pair/source/booleanHelpers/cancelling=false/sharing=true\n--- accepted Core\ntrue\n--- trial Core\ntrue", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "pair/source/booleanHelpers/cancelling=true/sharing=false\n--- accepted Core\ntrue\n--- trial Core\ntrue", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "pair/source/booleanHelpers/cancelling=true/sharing=true\n--- accepted Core\ntrue\n--- trial Core\ntrue", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 5, + "result": "(con bool True)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixTwice/cancelling=false/sharing=false\n--- accepted Core\nlet anf#9 : int = subtractInteger 100 1 in\nlet anf#12 : int = subtractInteger 100 2 in\naddInteger anf#9 anf#12\n--- trial Core\nlet anf#9 : int = subtractInteger 100 1 in\nlet anf#12 : int = subtractInteger 100 2 in\naddInteger anf#9 anf#12", + "before": { + "cpu": 607724, + "memory": 2006, + "bytes": 27, + "result": "(con integer 197)", + "logs": [] + }, + "after": { + "cpu": 607724, + "memory": 2006, + "bytes": 27, + "result": "(con integer 197)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixTwice/cancelling=false/sharing=true\n--- accepted Core\nlet anf#9 : int = subtractInteger 100 1 in\nlet anf#12 : int = subtractInteger 100 2 in\naddInteger anf#9 anf#12\n--- trial Core\nlet anf#9 : int = subtractInteger 100 1 in\nlet anf#12 : int = subtractInteger 100 2 in\naddInteger anf#9 anf#12", + "before": { + "cpu": 623724, + "memory": 2106, + "bytes": 26, + "result": "(con integer 197)", + "logs": [] + }, + "after": { + "cpu": 623724, + "memory": 2106, + "bytes": 26, + "result": "(con integer 197)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixTwice/cancelling=true/sharing=false\n--- accepted Core\nlet anf#9 : int = subtractInteger 100 1 in\nlet anf#12 : int = subtractInteger 100 2 in\naddInteger anf#9 anf#12\n--- trial Core\nlet anf#9 : int = subtractInteger 100 1 in\nlet anf#12 : int = subtractInteger 100 2 in\naddInteger anf#9 anf#12", + "before": { + "cpu": 607724, + "memory": 2006, + "bytes": 27, + "result": "(con integer 197)", + "logs": [] + }, + "after": { + "cpu": 607724, + "memory": 2006, + "bytes": 27, + "result": "(con integer 197)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixTwice/cancelling=true/sharing=true\n--- accepted Core\nlet anf#9 : int = subtractInteger 100 1 in\nlet anf#12 : int = subtractInteger 100 2 in\naddInteger anf#9 anf#12\n--- trial Core\nlet anf#9 : int = subtractInteger 100 1 in\nlet anf#12 : int = subtractInteger 100 2 in\naddInteger anf#9 anf#12", + "before": { + "cpu": 623724, + "memory": 2106, + "bytes": 26, + "result": "(con integer 197)", + "logs": [] + }, + "after": { + "cpu": 623724, + "memory": 2106, + "bytes": 26, + "result": "(con integer 197)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixCold/cancelling=false/sharing=false\n--- accepted Core\n42\n--- trial Core\n42", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixCold/cancelling=false/sharing=true\n--- accepted Core\n42\n--- trial Core\n42", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixCold/cancelling=true/sharing=false\n--- accepted Core\n42\n--- trial Core\n42", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixCold/cancelling=true/sharing=true\n--- accepted Core\n42\n--- trial Core\n42", + "before": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + }, + "after": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixLoop/cancelling=false/sharing=false\n--- accepted Core\nletrec\n prefixLoop#8 : int -> int [static []] = \\n#9 : int -> let anf#12 : bool = equalsInteger n#9 0 in\n case@Bool anf#12 of\n True -> 0\n False -> let anf#14 : int = subtractInteger 100 n#9 in\n let anf#16 : int = subtractInteger 100 n#9 in\n let anf#17 : int = addInteger anf#14 anf#16 in\n let anf#19 : int = subtractInteger n#9 1 in\n let anf#20 : int = prefixLoop#8 anf#19 in\n addInteger anf#17 anf#20\nin\nprefixLoop#8 8\n--- trial Core\nletrec\n prefixLoop#8 : int -> int [static []] = \\n#9 : int -> let anf#12 : bool = equalsInteger n#9 0 in\n case@Bool anf#12 of\n True -> 0\n False -> let anf#14 : int = subtractInteger 100 n#9 in\n let anf#16 : int = subtractInteger 100 n#9 in\n let anf#17 : int = addInteger anf#14 anf#16 in\n let anf#19 : int = subtractInteger n#9 1 in\n let anf#20 : int = prefixLoop#8 anf#19 in\n addInteger anf#17 anf#20\nin\nprefixLoop#8 8", + "before": { + "cpu": 11271417, + "memory": 42389, + "bytes": 68, + "result": "(con integer 1528)", + "logs": [] + }, + "after": { + "cpu": 11271417, + "memory": 42389, + "bytes": 68, + "result": "(con integer 1528)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixLoop/cancelling=false/sharing=true\n--- accepted Core\nletrec\n prefixLoop#8 : int -> int [static []] = \\n#9 : int -> let anf#12 : bool = equalsInteger n#9 0 in\n case@Bool anf#12 of\n True -> 0\n False -> let anf#14 : int = subtractInteger 100 n#9 in\n let anf#16 : int = subtractInteger 100 n#9 in\n let anf#17 : int = addInteger anf#14 anf#16 in\n let anf#19 : int = subtractInteger n#9 1 in\n let anf#20 : int = prefixLoop#8 anf#19 in\n addInteger anf#17 anf#20\nin\nprefixLoop#8 8\n--- trial Core\nletrec\n prefixLoop#8 : int -> int [static []] = \\n#9 : int -> let anf#12 : bool = equalsInteger n#9 0 in\n case@Bool anf#12 of\n True -> 0\n False -> let anf#14 : int = subtractInteger 100 n#9 in\n let anf#16 : int = subtractInteger 100 n#9 in\n let anf#17 : int = addInteger anf#14 anf#16 in\n let anf#19 : int = subtractInteger n#9 1 in\n let anf#20 : int = prefixLoop#8 anf#19 in\n addInteger anf#17 anf#20\nin\nprefixLoop#8 8", + "before": { + "cpu": 10839417, + "memory": 39689, + "bytes": 67, + "result": "(con integer 1528)", + "logs": [] + }, + "after": { + "cpu": 10839417, + "memory": 39689, + "bytes": 67, + "result": "(con integer 1528)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixLoop/cancelling=true/sharing=false\n--- accepted Core\nletrec\n prefixLoop#8 : int -> int [static []] = \\n#9 : int -> let anf#12 : bool = equalsInteger n#9 0 in\n case@Bool anf#12 of\n True -> 0\n False -> let anf#14 : int = subtractInteger 100 n#9 in\n let anf#16 : int = subtractInteger 100 n#9 in\n let anf#17 : int = addInteger anf#14 anf#16 in\n let anf#19 : int = subtractInteger n#9 1 in\n let anf#20 : int = prefixLoop#8 anf#19 in\n addInteger anf#17 anf#20\nin\nprefixLoop#8 8\n--- trial Core\nletrec\n prefixLoop#8 : int -> int [static []] = \\n#9 : int -> let anf#12 : bool = equalsInteger n#9 0 in\n case@Bool anf#12 of\n True -> 0\n False -> let anf#14 : int = subtractInteger 100 n#9 in\n let anf#16 : int = subtractInteger 100 n#9 in\n let anf#17 : int = addInteger anf#14 anf#16 in\n let anf#19 : int = subtractInteger n#9 1 in\n let anf#20 : int = prefixLoop#8 anf#19 in\n addInteger anf#17 anf#20\nin\nprefixLoop#8 8", + "before": { + "cpu": 11271417, + "memory": 42389, + "bytes": 68, + "result": "(con integer 1528)", + "logs": [] + }, + "after": { + "cpu": 11271417, + "memory": 42389, + "bytes": 68, + "result": "(con integer 1528)", + "logs": [] + } + }, + { + "input": "pair/source/constantPrefixLoop/cancelling=true/sharing=true\n--- accepted Core\nletrec\n prefixLoop#8 : int -> int [static []] = \\n#9 : int -> let anf#12 : bool = equalsInteger n#9 0 in\n case@Bool anf#12 of\n True -> 0\n False -> let anf#14 : int = subtractInteger 100 n#9 in\n let anf#16 : int = subtractInteger 100 n#9 in\n let anf#17 : int = addInteger anf#14 anf#16 in\n let anf#19 : int = subtractInteger n#9 1 in\n let anf#20 : int = prefixLoop#8 anf#19 in\n addInteger anf#17 anf#20\nin\nprefixLoop#8 8\n--- trial Core\nletrec\n prefixLoop#8 : int -> int [static []] = \\n#9 : int -> let anf#12 : bool = equalsInteger n#9 0 in\n case@Bool anf#12 of\n True -> 0\n False -> let anf#14 : int = subtractInteger 100 n#9 in\n let anf#16 : int = subtractInteger 100 n#9 in\n let anf#17 : int = addInteger anf#14 anf#16 in\n let anf#19 : int = subtractInteger n#9 1 in\n let anf#20 : int = prefixLoop#8 anf#19 in\n addInteger anf#17 anf#20\nin\nprefixLoop#8 8", + "before": { + "cpu": 10839417, + "memory": 39689, + "bytes": 67, + "result": "(con integer 1528)", + "logs": [] + }, + "after": { + "cpu": 10839417, + "memory": 39689, + "bytes": 67, + "result": "(con integer 1528)", + "logs": [] + } + } + ] +} diff --git a/tools/optimizer-perf/trials/recursive-parameters.json b/tools/optimizer-perf/trials/recursive-parameters.json new file mode 100644 index 00000000..cc780305 --- /dev/null +++ b/tools/optimizer-perf/trials/recursive-parameters.json @@ -0,0 +1,484 @@ +{ + "comparison": "Previous O1 versus recursive unused-parameter removal; unchanged cost model and limits", + "previous_revision": "db358b8c", + "settings": "v1; Plutus V3/PV11; UPLC 1.1.0; bundled V3 default cost model; CPU=100000000; memory=2000000; raw Flat bytes before ledger application; O0 vs static lift/unused-parameters/ANF once/rules1+2+3+4+dead-bindings+recursive-reachability+representation-inverse+force-delay+known-bool+int-bytes/bound-constr+known-fields+list+data+idata-bdata-listdata-mapdata-constrdata+restricted-pair-cleanup/constant-fold+cleanup(calls128,cpu1000000,mem10000,bytes4096,nodes1024,depth64)/recursion/hygiene/lower+forced-builtin-sharing+constant-prefix-sharing", + "rustc": "rustc 1.98.1 (48a229cea 2026-09-01)", + "unchanged_original_cases": 178, + "rows": [ + { + "input": "Workloads.recursiveUnusedSelf (fixtures/Workloads.nash)", + "o0": { + "cpu": 2540554, + "memory": 12442, + "bytes": 75, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + }, + "previous_o1": { + "cpu": 2156554, + "memory": 10042, + "bytes": 56, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + }, + "recursive_o1": { + "cpu": 2156554, + "memory": 10042, + "bytes": 56, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + } + }, + { + "input": "Workloads.recursiveUnusedMutual (fixtures/Workloads.nash)", + "o0": { + "cpu": 3436554, + "memory": 18042, + "bytes": 104, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + }, + "previous_o1": { + "cpu": 3196554, + "memory": 16542, + "bytes": 93, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + }, + "recursive_o1": { + "cpu": 2876554, + "memory": 14542, + "bytes": 81, + "result": "(con integer 42)", + "logs": [ + "entry" + ] + } + }, + { + "input": "recursive parameters: self_forwarding", + "o0": { + "cpu": 1777056, + "memory": 8010, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "previous_o1": { + "cpu": 1921056, + "memory": 8910, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "recursive_o1": { + "cpu": 1921056, + "memory": 8910, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mutual_forwarding", + "o0": { + "cpu": 2049056, + "memory": 9710, + "bytes": 83, + "result": "(con integer 42)", + "logs": [] + }, + "previous_o1": { + "cpu": 2529056, + "memory": 12710, + "bytes": 101, + "result": "(con integer 42)", + "logs": [] + }, + "recursive_o1": { + "cpu": 2209056, + "memory": 10710, + "bytes": 82, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mutual_consumed", + "o0": { + "cpu": 2049056, + "memory": 9710, + "bytes": 82, + "result": "(con integer 7)", + "logs": [] + }, + "previous_o1": { + "cpu": 2529056, + "memory": 12710, + "bytes": 99, + "result": "(con integer 7)", + "logs": [] + }, + "recursive_o1": { + "cpu": 2529056, + "memory": 12710, + "bytes": 99, + "result": "(con integer 7)", + "logs": [] + } + }, + { + "input": "recursive parameters: recursive_trace_order", + "o0": { + "cpu": 3078044, + "memory": 14102, + "bytes": 149, + "result": "(con integer 42)", + "logs": [ + "retained", + "discarded", + "discarded", + "retained", + "retained", + "discarded" + ] + }, + "previous_o1": { + "cpu": 3926044, + "memory": 19402, + "bytes": 160, + "result": "(con integer 42)", + "logs": [ + "retained", + "discarded", + "discarded", + "retained", + "retained", + "discarded" + ] + }, + "recursive_o1": { + "cpu": 3318044, + "memory": 15602, + "bytes": 134, + "result": "(con integer 42)", + "logs": [ + "retained", + "discarded", + "discarded", + "retained", + "retained", + "discarded" + ] + } + }, + { + "input": "recursive parameters: recursive_failure_order", + "o0": { + "cpu": 272637, + "memory": 167, + "bytes": 145, + "result": "error: ExplicitErrorTerm", + "logs": [ + "retained", + "discarded" + ] + }, + "previous_o1": { + "cpu": 272637, + "memory": 167, + "bytes": 156, + "result": "error: ExplicitErrorTerm", + "logs": [ + "retained", + "discarded" + ] + }, + "recursive_o1": { + "cpu": 272637, + "memory": 167, + "bytes": 130, + "result": "error: ExplicitErrorTerm", + "logs": [ + "retained", + "discarded" + ] + } + }, + { + "input": "recursive parameters: all_unused_self", + "o0": { + "cpu": 1171300, + "memory": 5430, + "bytes": 70, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + }, + "previous_o1": { + "cpu": 1523300, + "memory": 7630, + "bytes": 75, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + }, + "recursive_o1": { + "cpu": 1523300, + "memory": 7630, + "bytes": 75, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + } + }, + { + "input": "recursive parameters: all_unused_mutual", + "o0": { + "cpu": 1603300, + "memory": 8130, + "bytes": 95, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + }, + "previous_o1": { + "cpu": 1731300, + "memory": 8930, + "bytes": 97, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + }, + "recursive_o1": { + "cpu": 1635300, + "memory": 8330, + "bytes": 89, + "result": "(con integer 42)", + "logs": [ + "entry1", + "body", + "entry2", + "body" + ] + } + }, + { + "input": "recursive parameters: all_unused_cold", + "o0": { + "cpu": 192100, + "memory": 1300, + "bytes": 100, + "result": "(con integer 42)", + "logs": [] + }, + "previous_o1": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + }, + "recursive_o1": { + "cpu": 16100, + "memory": 200, + "bytes": 6, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: entry_failure", + "o0": { + "cpu": 59598, + "memory": 132, + "bytes": 63, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + }, + "previous_o1": { + "cpu": 59598, + "memory": 132, + "bytes": 70, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + }, + "recursive_o1": { + "cpu": 59598, + "memory": 132, + "bytes": 70, + "result": "error: ExplicitErrorTerm", + "logs": [ + "first" + ] + } + }, + { + "input": "recursive parameters: partial", + "o0": { + "cpu": 1319515, + "memory": 6107, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "previous_o1": { + "cpu": 1415515, + "memory": 6707, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "recursive_o1": { + "cpu": 1415515, + "memory": 6707, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: escaping", + "o0": { + "cpu": 1367515, + "memory": 6407, + "bytes": 41, + "result": "(con integer 42)", + "logs": [] + }, + "previous_o1": { + "cpu": 1415515, + "memory": 6707, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + }, + "recursive_o1": { + "cpu": 1415515, + "memory": 6707, + "bytes": 39, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: oversaturated", + "o0": { + "cpu": 304100, + "memory": 2000, + "bytes": 22, + "result": "(con integer 42)", + "logs": [] + }, + "previous_o1": { + "cpu": 304100, + "memory": 2000, + "bytes": 22, + "result": "(con integer 42)", + "logs": [] + }, + "recursive_o1": { + "cpu": 304100, + "memory": 2000, + "bytes": 22, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: compound_dependency", + "o0": { + "cpu": 1649931, + "memory": 6911, + "bytes": 44, + "result": "(con integer 42)", + "logs": [] + }, + "previous_o1": { + "cpu": 2081931, + "memory": 9611, + "bytes": 54, + "result": "(con integer 42)", + "logs": [] + }, + "recursive_o1": { + "cpu": 2081931, + "memory": 9611, + "bytes": 54, + "result": "(con integer 42)", + "logs": [] + } + }, + { + "input": "recursive parameters: mixed_delayed", + "o0": { + "cpu": 3471636, + "memory": 16348, + "bytes": 95, + "result": "(con integer 84)", + "logs": [ + "delayed" + ] + }, + "previous_o1": { + "cpu": 4671636, + "memory": 23848, + "bytes": 115, + "result": "(con integer 84)", + "logs": [ + "delayed" + ] + }, + "recursive_o1": { + "cpu": 3727636, + "memory": 17948, + "bytes": 89, + "result": "(con integer 84)", + "logs": [ + "delayed" + ] + } + } + ], + "sources": { + "Core fixtures": "//! Recursive parameter fixtures shared with the explicit performance workspace.\nuse nash_ir::{\n build::Builder,\n core::*,\n ty::{ConstTy, TermTy, Ty},\n};\nuse nash_plutus::{builtin::DefaultFunction as F, constant::Constant};\n\npub fn cases<'a>(b: &Builder<'a>) -> Vec<(&'static str, &'a Core<'a>, bool)> {\n let a = b.arena;\n let int = b.int(0).ty;\n let bool_ = Ty::Const(&ConstTy::Bool);\n let fun = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int, int]), int)));\n let bind = |text, ty| Binder {\n name: b.fresh(text),\n ty,\n };\n let trace = |text, value| b.trace(b.lit(Constant::string(a, text)), value);\n let mut cases = Vec::new();\n for (name, mutual, consumed, effects, failure) in [\n (\"self_forwarding\", false, false, false, false),\n (\"mutual_forwarding\", true, false, false, false),\n (\"mutual_consumed\", true, true, false, false),\n (\"recursive_trace_order\", true, false, true, false),\n (\"recursive_failure_order\", true, false, true, true),\n ] {\n let f = bind(\"f\", fun);\n let g = bind(\"g\", fun);\n let x = bind(\"x\", int);\n let n = bind(\"n\", int);\n let m = bind(\"m\", int);\n let y = bind(\"y\", int);\n let step = |target: Binder<'a>, unused: Binder<'a>, count: Binder<'a>, swapped: bool| {\n let next = b.builtin(F::SubtractInteger, &[b.var(count.name, int), b.int(1)], int);\n let discarded = if failure {\n trace(\"discarded\", b.error(int))\n } else if effects {\n trace(\"discarded\", b.int(7))\n } else {\n b.var(unused.name, int)\n };\n let next = if effects {\n trace(\"retained\", next)\n } else {\n next\n };\n let args = if swapped {\n [next, discarded]\n } else {\n [discarded, next]\n };\n b.if_(\n b.builtin(F::EqualsInteger, &[b.var(count.name, int), b.int(0)], bool_),\n if consumed {\n b.var(unused.name, int)\n } else {\n b.int(42)\n },\n b.app(b.var(target.name, fun), &args, int),\n )\n };\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x, n]),\n static_params: &[],\n body: step(if mutual { g } else { f }, x, n, mutual),\n }];\n if mutual {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[m, y]),\n static_params: &[],\n body: step(f, y, m, false),\n });\n }\n cases.push((\n name,\n b.let_rec(\n &group,\n b.app(b.var(f.name, fun), &[b.int(7), b.int(3)], int),\n ),\n failure,\n ));\n }\n // Removing every parameter must keep definitions cold and execute each call.\n for (name, mutual, cold) in [\n (\"all_unused_self\", false, false),\n (\"all_unused_mutual\", true, false),\n (\"all_unused_cold\", true, true),\n ] {\n let unary = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int]), int)));\n let f = bind(\"f\", unary);\n let g = bind(\"g\", unary);\n let x = bind(\"x\", int);\n let y = bind(\"y\", int);\n let invoke = |target: Binder<'a>, arg| b.app(b.var(target.name, unary), &[arg], int);\n let body = b.if_(\n b.lit(Constant::bool(a, true)),\n trace(\"body\", b.int(21)),\n invoke(if mutual { g } else { f }, b.var(x.name, int)),\n );\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x]),\n static_params: &[],\n body,\n }];\n if mutual {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[y]),\n static_params: &[],\n body: invoke(f, b.var(y.name, int)),\n });\n }\n let calls = b.builtin(\n F::AddInteger,\n &[\n invoke(f, trace(\"entry1\", b.int(0))),\n invoke(if mutual { g } else { f }, trace(\"entry2\", b.int(1))),\n ],\n int,\n );\n let calls = if cold {\n b.if_(b.lit(Constant::bool(a, true)), b.int(42), calls)\n } else {\n calls\n };\n cases.push((name, b.let_rec(&group, calls), false));\n }\n\n for name in [\n \"entry_failure\",\n \"partial\",\n \"escaping\",\n \"oversaturated\",\n \"compound_dependency\",\n \"mixed_delayed\",\n ] {\n let f = bind(\"f\", fun);\n let g = bind(\"g\", fun);\n let x = bind(\"x\", int);\n let n = bind(\"n\", int);\n let y = bind(\"y\", int);\n let m = bind(\"m\", int);\n let unary = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int]), int)));\n let next = b.builtin(F::SubtractInteger, &[b.var(n.name, int), b.int(1)], int);\n let forwarded = if name == \"compound_dependency\" {\n b.builtin(F::AddInteger, &[b.var(x.name, int), b.int(1)], int)\n } else {\n b.var(x.name, int)\n };\n let body = b.if_(\n b.builtin(F::EqualsInteger, &[b.var(n.name, int), b.int(0)], bool_),\n b.int(42),\n b.app(b.var(f.name, fun), &[forwarded, next], int),\n );\n let mut group = vec![RecBinder {\n binder: f,\n params: a.alloc_slice_copy(&[x, n]),\n static_params: &[],\n body,\n }];\n let invoke = b.app(b.var(f.name, fun), &[b.int(7), b.int(2)], int);\n let entry = match name {\n \"entry_failure\" => b.app(\n b.var(f.name, fun),\n &[trace(\"first\", b.error(int)), trace(\"later\", b.int(2))],\n int,\n ),\n \"partial\" => b.app(\n b.app(b.var(f.name, fun), &[b.int(7)], unary),\n &[b.int(2)],\n int,\n ),\n \"escaping\" => {\n let alias = bind(\"alias\", fun);\n b.let_(\n alias,\n b.var(f.name, fun),\n b.app(b.var(alias.name, fun), &[b.int(7), b.int(2)], int),\n )\n }\n \"oversaturated\" => {\n let z = bind(\"z\", int);\n let ty = Ty::Term(a.alloc(TermTy::Fun(a.alloc_slice_copy(&[int, int]), unary)));\n group[0].binder.ty = ty;\n group[0].body = b.lam(&[z], b.var(z.name, int));\n b.app(b.var(f.name, ty), &[b.int(0), b.int(0), b.int(42)], int)\n }\n \"mixed_delayed\" => {\n group.push(RecBinder {\n binder: g,\n params: a.alloc_slice_copy(&[y, m]),\n static_params: &[],\n body: trace(\n \"delayed\",\n b.app(b.var(f.name, fun), &[b.int(7), b.int(2)], int),\n ),\n });\n b.builtin(\n F::AddInteger,\n &[\n invoke,\n b.app(b.var(g.name, fun), &[b.int(0), b.int(0)], int),\n ],\n int,\n )\n }\n _ => invoke,\n };\n cases.push((name, b.let_rec(&group, entry), name == \"entry_failure\"));\n }\n cases\n}\n", + "Workloads": "module Workloads exposing (..)\n\nimport Primitive exposing (..)\nimport Builtin exposing (..)\nimport Literal exposing (..)\nimport Logic exposing (..)\n\nsum : list int -> int\nsum xs =\n case xs of\n [] -> 0\n x :: rest -> Builtin.addInteger x (sum rest)\n\nlistTraversal : int\nlistTraversal = sum [1, 2, 3, 4, 5, 6, 7, 8]\n\ncountdown : int -> int -> int\ncountdown n result =\n if Builtin.equalsInteger n 0 then\n result\n else\n countdown (Builtin.subtractInteger n 1) result\n\nstaticRecursion : int\nstaticRecursion = countdown 8 42\n\nmatchData : Data -> int\nmatchData value =\n case value of\n I n -> n\n _ -> 0\n\ndataMatch : int\ndataMatch = matchData (I 42)\n\ndataMiss : int\ndataMiss = matchData (B #\"ab\")\n\ndecode : Data -> int\ndecode value =\n case value of\n Constr pair(_, [I n, _]) -> n\n _ -> 0\n\ndecoding : int\ndecoding = decode (Builtin.constrData 0 [I 42, I 7])\n\nvalidate : Data -> unit\nvalidate value =\n case value of\n I n -> assert (Builtin.lessThanInteger 0 n)\n _ -> fail\n\nvalidationPass : unit\nvalidationPass = validate (I 42)\n\nvalidationFail : unit\nvalidationFail = validate (I 0)\n\nbooleanHelpers : bool\nbooleanHelpers = (True && False) || (True && True)\n\nconstantPrefixTwice : int\nconstantPrefixTwice =\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nconstantPrefixCold : int\nconstantPrefixCold =\n if True then\n 42\n else\n Builtin.addInteger (Builtin.subtractInteger 100 1) (Builtin.subtractInteger 100 2)\n\nprefixLoop : int -> int\nprefixLoop n =\n if Builtin.equalsInteger n 0 then\n 0\n else\n Builtin.addInteger\n (Builtin.addInteger (Builtin.subtractInteger 100 n) (Builtin.subtractInteger 100 n))\n (prefixLoop (Builtin.subtractInteger n 1))\n\nconstantPrefixLoop : int\nconstantPrefixLoop = prefixLoop 8\n\nunusedSelf : int -> int -> int\nunusedSelf unused n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n unusedSelf unused (Builtin.subtractInteger n 1)\n\nrecursiveUnusedSelf : int\nrecursiveUnusedSelf = unusedSelf (Builtin.trace \"entry\" 7) 3\n\nunusedFirst : int -> int -> int\nunusedFirst unused n =\n if Builtin.equalsInteger n 0 then\n 42\n else\n unusedSecond (Builtin.subtractInteger n 1) unused\n\nunusedSecond : int -> int -> int\nunusedSecond n unused = unusedFirst unused n\n\nrecursiveUnusedMutual : int\nrecursiveUnusedMutual = unusedFirst (Builtin.trace \"entry\" 7) 3\n", + "previous unused_params": "//! Shorten nonrecursive helper signatures before ANF, with exact direct calls only.\nuse crate::{\n analysis, anf,\n build::Builder,\n core::{Binder, Core, CoreKind},\n ty::{RuntimeTy, TermTy, Ty},\n};\nuse std::collections::HashSet;\n\nfn signature<'a>(b: &Builder<'a>, ty: Ty<'a>, keep: &[bool]) -> Option> {\n let Ty::Term(TermTy::Fun(params, result)) = ty else {\n return None;\n };\n if params.len() != keep.len() {\n return None;\n }\n let params: Vec<_> = params\n .iter()\n .zip(keep)\n .filter_map(|(p, keep)| keep.then_some(*p))\n .collect();\n Some(if params.is_empty() {\n Ty::Runtime(b.arena.alloc(RuntimeTy::Delay(*result)))\n } else {\n Ty::Term(\n b.arena\n .alloc(TermTy::Fun(b.arena.alloc_slice_copy(¶ms), *result)),\n )\n })\n}\n\n/// Requires typed Core and globally unique, well-scoped binders. Every use must\n/// be a direct application with exactly the original arity. Partial, escaping,\n/// oversaturated or unsupported signature views leave the helper unchanged.\n/// Every non-atomic argument gets a strict binding in source order before the\n/// shortened call, including discarded arguments. Exact calls to a known lambda\n/// cannot run its body during partial application. Atoms are safe to discard.\n/// Bindings stay call-local; this pass does not remove them or change LetRec\n/// parameters. All-unused helpers become delays, forced separately at each call.\n/// Use the enclosing program Builder when optimizing a subtree for reinsertion.\npub fn reduce<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> {\n let report = analysis::occurrences(core);\n let mut occupied: HashSet<_> = report\n .bindings\n .iter()\n .map(|x| x.name.unique)\n .chain(report.uses.iter().map(|x| x.name.unique))\n .collect();\n core.map(b, &mut |node| {\n let CoreKind::Let {\n binder,\n value,\n body,\n } = node.kind\n else {\n return None;\n };\n let CoreKind::Lam {\n params,\n body: lambda_body,\n } = value.kind\n else {\n return None;\n };\n let mut used = HashSet::new();\n lambda_body.walk(&mut |node| {\n if let CoreKind::Var(name) = node.kind {\n used.insert(name.unique);\n }\n });\n let keep: Vec<_> = params\n .iter()\n .map(|p| used.contains(&p.name.unique))\n .collect();\n if keep.iter().all(|keep| *keep) {\n return None;\n }\n let (mut uses, mut calls) = (0usize, 0usize);\n body.walk(&mut |node| match node.kind {\n CoreKind::Var(name) if name.unique == binder.name.unique => uses += 1,\n CoreKind::App { func, args }\n if matches!(func.kind, CoreKind::Var(name) if name.unique == binder.name.unique)\n && args.len() == params.len()\n && matches!(func.ty, Ty::Term(TermTy::Fun(types, _)) if types.len() == keep.len()) =>\n {\n calls += 1\n }\n _ => {}\n });\n if calls == 0 || calls != uses {\n return None;\n }\n let binder_ty = signature(b, binder.ty, &keep)?;\n let value_ty = signature(b, value.ty, &keep)?;\n let params: Vec<_> = params\n .iter()\n .zip(&keep)\n .filter_map(|(p, keep)| keep.then_some(*p))\n .collect();\n let value = b.with_type(\n if params.is_empty() {\n b.delay(lambda_body)\n } else {\n b.lam(¶ms, lambda_body)\n },\n value_ty,\n );\n let body = body.map(b, &mut |call| {\n let CoreKind::App { func, args } = call.kind else {\n return None;\n };\n let CoreKind::Var(name) = func.kind else {\n return None;\n };\n if name.unique != binder.name.unique {\n return None;\n }\n let func = b.var(\n name,\n signature(b, func.ty, &keep).expect(\"prechecked signature\"),\n );\n let mut prefix = Vec::new();\n let mut retained = Vec::new();\n for (arg, keep) in args.iter().zip(&keep) {\n let argument = if anf::is_atom(arg) {\n *arg\n } else {\n let name = loop {\n let name = b.fresh(\"arg\");\n if occupied.insert(name.unique) { break name; }\n };\n let binder = Binder { name, ty: arg.ty };\n prefix.push((binder, *arg));\n b.var(name, arg.ty)\n };\n if *keep { retained.push(argument); }\n }\n let mut result = if retained.is_empty() {\n b.force(func, call.ty)\n } else {\n b.app(func, &retained, call.ty)\n };\n for (binder, value) in prefix.into_iter().rev() {\n result = b.let_(binder, value, result);\n }\n Some(result)\n });\n Some(b.with_type(\n b.let_(\n Binder {\n ty: binder_ty,\n ..binder\n },\n value,\n body,\n ),\n node.ty,\n ))\n })\n}\n", + "unused_params": "//! Shorten helper signatures before ANF, with exact direct calls only.\nuse crate::{\n analysis, anf,\n build::Builder,\n core::{Binder, Core, CoreKind, RecBinder},\n ty::{RuntimeTy, TermTy, Ty},\n};\nuse std::collections::{HashMap, HashSet};\n\nfn signature<'a>(b: &Builder<'a>, ty: Ty<'a>, keep: &[bool]) -> Option> {\n let Ty::Term(TermTy::Fun(params, result)) = ty else {\n return None;\n };\n if params.len() != keep.len() {\n return None;\n }\n let params: Vec<_> = params\n .iter()\n .zip(keep)\n .filter_map(|(p, keep)| keep.then_some(*p))\n .collect();\n Some(if params.is_empty() {\n Ty::Runtime(b.arena.alloc(RuntimeTy::Delay(*result)))\n } else {\n Ty::Term(\n b.arena\n .alloc(TermTy::Fun(b.arena.alloc_slice_copy(¶ms), *result)),\n )\n })\n}\n\n/// Requires typed Core and globally unique, well-scoped binders. Every use must\n/// be a direct application with exactly the original arity. Partial, escaping,\n/// oversaturated or unsupported signature views leave the helper unchanged.\n/// Every non-atomic argument gets a strict binding in source order before the\n/// shortened call, including discarded arguments. Exact calls to a known lambda\n/// cannot run its body during partial application. Atoms are safe to discard.\n/// Bindings stay call-local. Recursive parameter liveness follows bare-variable\n/// forwarding dependencies to a fixed point; compound arguments stay strict.\n/// All-unused helpers become delays, forced separately at each call.\n/// Use the enclosing program Builder when optimizing a subtree for reinsertion.\npub fn reduce<'a>(b: &Builder<'a>, core: &'a Core<'a>) -> &'a Core<'a> {\n let report = analysis::occurrences(core);\n let mut occupied: HashSet<_> = report\n .bindings\n .iter()\n .map(|x| x.name.unique)\n .chain(report.uses.iter().map(|x| x.name.unique))\n .collect();\n core.map(b, &mut |node| {\n if let CoreKind::LetRec { binders, body } = node.kind {\n return recursive(b, node, binders, body, &mut occupied);\n }\n let CoreKind::Let {\n binder,\n value,\n body,\n } = node.kind\n else {\n return None;\n };\n let CoreKind::Lam {\n params,\n body: lambda_body,\n } = value.kind\n else {\n return None;\n };\n let mut used = HashSet::new();\n lambda_body.walk(&mut |node| {\n if let CoreKind::Var(name) = node.kind {\n used.insert(name.unique);\n }\n });\n let keep: Vec<_> = params\n .iter()\n .map(|p| used.contains(&p.name.unique))\n .collect();\n if keep.iter().all(|keep| *keep) {\n return None;\n }\n let (mut uses, mut calls) = (0usize, 0usize);\n body.walk(&mut |node| match node.kind {\n CoreKind::Var(name) if name.unique == binder.name.unique => uses += 1,\n CoreKind::App { func, args }\n if matches!(func.kind, CoreKind::Var(name) if name.unique == binder.name.unique)\n && args.len() == params.len()\n && matches!(func.ty, Ty::Term(TermTy::Fun(types, _)) if types.len() == keep.len()) =>\n {\n calls += 1\n }\n _ => {}\n });\n if calls == 0 || calls != uses {\n return None;\n }\n let binder_ty = signature(b, binder.ty, &keep)?;\n let value_ty = signature(b, value.ty, &keep)?;\n let params: Vec<_> = params\n .iter()\n .zip(&keep)\n .filter_map(|(p, keep)| keep.then_some(*p))\n .collect();\n let value = b.with_type(\n if params.is_empty() {\n b.delay(lambda_body)\n } else {\n b.lam(¶ms, lambda_body)\n },\n value_ty,\n );\n let body = body.map(b, &mut |call| {\n let CoreKind::App { func, args } = call.kind else {\n return None;\n };\n let CoreKind::Var(name) = func.kind else {\n return None;\n };\n if name.unique != binder.name.unique {\n return None;\n }\n Some(shorten_call(b, call, func, args, &keep, &mut occupied))\n });\n Some(b.with_type(\n b.let_(\n Binder {\n ty: binder_ty,\n ..binder\n },\n value,\n body,\n ),\n node.ty,\n ))\n })\n}\n\nfn shorten_call<'a>(\n b: &Builder<'a>,\n call: &'a Core<'a>,\n func: &'a Core<'a>,\n args: &[&'a Core<'a>],\n keep: &[bool],\n occupied: &mut HashSet,\n) -> &'a Core<'a> {\n let CoreKind::Var(name) = func.kind else {\n unreachable!(\"prechecked direct call\")\n };\n let func = b.var(\n name,\n signature(b, func.ty, keep).expect(\"prechecked signature\"),\n );\n let mut prefix = Vec::new();\n let mut retained = Vec::new();\n for (arg, keep) in args.iter().zip(keep) {\n let argument = if anf::is_atom(arg) {\n *arg\n } else {\n let name = loop {\n let name = b.fresh(\"arg\");\n if occupied.insert(name.unique) {\n break name;\n }\n };\n let binder = Binder { name, ty: arg.ty };\n prefix.push((binder, *arg));\n b.var(name, arg.ty)\n };\n if *keep {\n retained.push(argument);\n }\n }\n let mut result = if retained.is_empty() {\n b.force(func, call.ty)\n } else {\n b.app(func, &retained, call.ty)\n };\n for (binder, value) in prefix.into_iter().rev() {\n result = b.let_(binder, value, result);\n }\n result\n}\n\nfn recursive<'a>(\n b: &Builder<'a>,\n node: &'a Core<'a>,\n binders: &'a [RecBinder<'a>],\n body: &'a Core<'a>,\n occupied: &mut HashSet,\n) -> Option<&'a Core<'a>> {\n // Existing delayed workers and unsupported views are left alone. This also\n // makes a group containing a newly delayed worker stable on a second pass.\n if binders.is_empty()\n || binders.iter().any(|r| {\n r.params.is_empty()\n || !matches!(r.binder.ty, Ty::Term(TermTy::Fun(ps,_)) if ps.len() == r.params.len())\n })\n {\n return None;\n }\n let members: HashMap<_, _> = binders\n .iter()\n .enumerate()\n .map(|(i, r)| (r.binder.name.unique, i))\n .collect();\n let mut offsets = Vec::new();\n let mut slots = HashMap::new();\n for r in binders {\n offsets.push(slots.len());\n for p in r.params {\n slots.insert(p.name.unique, slots.len());\n }\n }\n let mut live = vec![false; slots.len()];\n let mut dependencies = vec![Vec::new(); slots.len()];\n let mut uses = vec![0; binders.len()];\n let mut calls = vec![0; binders.len()];\n // A bare variable argument is the only evaluation we can remove outright.\n // Every variable inside other arguments remains live because their strict\n // evaluation is retained, even when the receiving parameter is removed.\n let mut pending: Vec<_> = binders.iter().map(|r| r.body).chain([body]).collect();\n while let Some(term) = pending.pop() {\n match term.kind {\n CoreKind::Var(name) => {\n if let Some(&i) = members.get(&name.unique) {\n uses[i] += 1;\n }\n if let Some(&i) = slots.get(&name.unique) {\n live[i] = true;\n }\n }\n CoreKind::App { func, args } if matches!(func.kind,CoreKind::Var(name) if members.contains_key(&name.unique)) =>\n {\n let CoreKind::Var(name) = func.kind else {\n unreachable!()\n };\n let i = members[&name.unique];\n uses[i] += 1;\n if args.len() != binders[i].params.len()\n || !matches!(func.ty,Ty::Term(TermTy::Fun(ps,_)) if ps.len()==args.len())\n {\n return None;\n }\n calls[i] += 1;\n for (slot, arg) in args.iter().enumerate() {\n if let CoreKind::Var(name) = arg.kind\n && let Some(&source) = slots.get(&name.unique)\n {\n dependencies[offsets[i] + slot].push(source);\n continue;\n }\n pending.push(arg);\n }\n }\n _ => term.push_children_reversed(&mut pending),\n }\n }\n if uses != calls || calls.iter().all(|n| *n == 0) {\n return None;\n }\n let mut pending: Vec<_> = live\n .iter()\n .enumerate()\n .filter_map(|(i, v)| v.then_some(i))\n .collect();\n while let Some(target) = pending.pop() {\n for &source in &dependencies[target] {\n if !live[source] {\n live[source] = true;\n pending.push(source);\n }\n }\n }\n if live.iter().all(|v| *v) {\n return None;\n }\n let masks: Vec<_> = binders\n .iter()\n .enumerate()\n .map(|(i, r)| &live[offsets[i]..offsets[i] + r.params.len()])\n .collect();\n let mut rewrite = |core: &'a Core<'a>| {\n core.map(b, &mut |call| {\n let CoreKind::App { func, args } = call.kind else {\n return None;\n };\n let CoreKind::Var(name) = func.kind else {\n return None;\n };\n let &i = members.get(&name.unique)?;\n let keep = masks[i];\n if keep.iter().all(|v| *v) {\n return None;\n }\n Some(shorten_call(b, call, func, args, keep, occupied))\n })\n };\n let mut group = Vec::new();\n for (i, r) in binders.iter().enumerate() {\n let keep = masks[i];\n let params: Vec<_> = r\n .params\n .iter()\n .zip(keep)\n .filter_map(|(p, k)| k.then_some(*p))\n .collect();\n let statics: Vec<_> = r\n .static_params\n .iter()\n .filter_map(|&old| {\n let old = usize::from(old);\n keep.get(old)\n .copied()\n .unwrap_or(false)\n .then(|| u16::try_from(keep[..old].iter().filter(|v| **v).count()).ok())\n .flatten()\n })\n .collect();\n let body = rewrite(r.body);\n group.push(RecBinder {\n binder: Binder {\n ty: signature(b, r.binder.ty, keep)?,\n ..r.binder\n },\n params: b.arena.alloc_slice_copy(¶ms),\n static_params: b.arena.alloc_slice_copy(&statics),\n body: if params.is_empty() {\n b.delay(body)\n } else {\n body\n },\n });\n }\n let body = rewrite(body);\n Some(b.with_type(b.let_rec(&group, body), node.ty))\n}\n", + "recursion lowering diff": "diff --git a/crates/nash-codegen/src/recursion.rs b/crates/nash-codegen/src/recursion.rs\nindex a7363579..704e1b54 100644\n--- a/crates/nash-codegen/src/recursion.rs\n+++ b/crates/nash-codegen/src/recursion.rs\n@@ -373,7 +373,10 @@ impl<'a> Rewriter<'_, 'a> {\n tasks.push(Task::Visit(single.body, inner_env));\n return Ok(());\n }\n- if binders.iter().any(|r| r.params.is_empty()) {\n+ if binders\n+ .iter()\n+ .any(|r| r.params.is_empty() && !matches!(r.body.kind, CoreKind::Delay(_)))\n+ {\n return Err(Error::RecursiveValue);\n }\n let names: HashSet<_> = binders.iter().map(|r| r.binder.name).collect();\n@@ -502,7 +505,11 @@ impl<'a> Rewriter<'_, 'a> {\n let params = rb.params.iter().map(|p| p.ty).collect::>();\n DispatchArm {\n params: b.arena.alloc_slice_copy(¶ms),\n- result: rb.body.ty,\n+ result: if let ([], CoreKind::Delay(body)) = (rb.params, rb.body.kind) {\n+ body.ty\n+ } else {\n+ rb.body.ty\n+ },\n }\n })\n .collect::>();\n@@ -554,7 +561,12 @@ impl<'a> Rewriter<'_, 'a> {\n this.mutual(state, tasks)?;\n Ok(None)\n })));\n- tasks.push(Task::Visit(rb.body, env));\n+ let body = if let ([], CoreKind::Delay(body)) = (rb.params, rb.body.kind) {\n+ body\n+ } else {\n+ rb.body\n+ };\n+ tasks.push(Task::Visit(body, env));\n } else {\n let results_ty = Ty::Runtime(b.arena.alloc(RuntimeTy::Results(state.arms)));\n let dispatch = b.lam(\n@@ -598,14 +610,16 @@ impl<'a> Rewriter<'_, 'a> {\n let mut fields = vec![b.var(dispatcher.name, dispatcher.ty)];\n fields.extend(params.iter().map(|p| b.var(p.name, p.ty)));\n let packet_ty = Ty::Runtime(b.arena.alloc(RuntimeTy::Packet { arms, tag }));\n- b.lam(\n- ¶ms,\n- b.app(\n- b.var(dispatcher.name, dispatcher.ty),\n- &[b.constr(tag, &fields, packet_ty)],\n- arms[usize::from(tag)].result,\n- ),\n- )\n+ let call = b.app(\n+ b.var(dispatcher.name, dispatcher.ty),\n+ &[b.constr(tag, &fields, packet_ty)],\n+ arms[usize::from(tag)].result,\n+ );\n+ if params.is_empty() {\n+ b.delay(call)\n+ } else {\n+ b.lam(¶ms, call)\n+ }\n }\n }\n fn without<'a>(\n" + } +}