diff --git a/.cargo/config.toml b/.cargo/config.toml index 81e24566c4..f57d96eaf7 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -30,7 +30,7 @@ rustflags = ["-Clink-args=/FORCE:UNRESOLVED"] # https://github.com/rust-lang/cargo/issues/3946#issuecomment-973132993 ROC_WORKSPACE_DIR = { value = "", relative = true } -# Debug flags. Keep this up-to-date with compiler/debug_flags/src/lib.rs. +# Debug flags. Explanations for these are in compiler/debug_flags/src/lib.rs. # Set = "1" to turn a debug flag on. ROC_PRETTY_PRINT_ALIAS_CONTENTS = "0" ROC_PRINT_UNIFICATIONS = "0" @@ -49,6 +49,7 @@ ROC_PRINT_IR_AFTER_TRMC = "0" ROC_PRINT_IR_AFTER_DROP_SPECIALIZATION = "0" ROC_DEBUG_ALIAS_ANALYSIS = "0" ROC_PRINT_RUNTIME_ERROR_GEN = "0" +ROC_NO_UNBOUND_LAYOUT = "0" ROC_PRINT_LLVM_FN_VERIFICATION = "0" ROC_WRITE_FINAL_WASM = "0" ROC_LOG_WASM_INTERP = "0" diff --git a/.github/workflows/ci_manager.yml b/.github/workflows/ci_manager.yml index 8d18f8dc99..f0548533f3 100644 --- a/.github/workflows/ci_manager.yml +++ b/.github/workflows/ci_manager.yml @@ -104,10 +104,10 @@ jobs: if: needs.check-changes.outputs.run_tests == 'full' uses: ./.github/workflows/ubuntu_x86_64.yml - start-ubuntu-x86-64-tests-debug: + start-ubuntu-x86-64-nix-tests-debug: needs: check-changes if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/ubuntu_x86_64_debug.yml + uses: ./.github/workflows/ubuntu_x86_64_nix_debug.yml start-windows-release-build-test: needs: check-changes @@ -133,7 +133,7 @@ jobs: start-nix-macos-apple-silicon-tests, start-macos-x86-64-tests, start-ubuntu-x86-64-tests, - start-ubuntu-x86-64-tests-debug, + start-ubuntu-x86-64-nix-tests-debug, start-windows-release-build-test, start-windows-tests, start-roc-benchmarks diff --git a/.github/workflows/ubuntu_x86_64_debug.yml b/.github/workflows/ubuntu_x86_64_debug.yml deleted file mode 100644 index 2ad30f0752..0000000000 --- a/.github/workflows/ubuntu_x86_64_debug.yml +++ /dev/null @@ -1,38 +0,0 @@ -on: - workflow_call: - -name: cargo test debug - -env: - RUST_BACKTRACE: 1 - -jobs: - cargo-test-debug: - name: cargo test debug - runs-on: [ubuntu-22.04] - timeout-minutes: 90 - steps: - - uses: actions/checkout@v4 - - - uses: goto-bus-stop/setup-zig@v2 - with: - version: 0.11.0 - - - run: zig version - - - name: Install dependencies - run: | - sudo apt -y install build-essential libunwind-dev pkg-config zlib1g-dev valgrind - wget https://apt.llvm.org/llvm.sh - chmod +x llvm.sh - sudo ./llvm.sh 16 - sudo rm /usr/bin/clang - sudo ln -s /usr/bin/clang-16 /usr/bin/clang - sudo ln -s /usr/bin/lld-16 /usr/bin/ld.lld - sudo apt -y install libpolly-16-dev - - # for skipped tests; see #6946, #6947 - - name: cargo test without --release - env: - RUSTFLAGS: -C link-arg=-fuse-ld=lld - run: cargo test -- --skip tests/exhaustive/match_on_result_with_uninhabited_error_destructuring_in_lambda_syntax.txt --skip tests::identity_lambda --skip tests::issue_2300 --skip tests::issue_2582_specialize_result_value --skip tests::sum_lambda diff --git a/.github/workflows/ubuntu_x86_64_nix_debug.yml b/.github/workflows/ubuntu_x86_64_nix_debug.yml new file mode 100644 index 0000000000..05835bb932 --- /dev/null +++ b/.github/workflows/ubuntu_x86_64_nix_debug.yml @@ -0,0 +1,27 @@ +on: + workflow_call: + +name: cargo test debug nix + +env: + RUST_BACKTRACE: 1 + +jobs: + cargo-test-debug-nix: + name: cargo test debug nix + runs-on: [ubuntu-22.04] + timeout-minutes: 90 + steps: + - uses: actions/checkout@v4 + + # install nix + - uses: cachix/install-nix-action@v23 + with: + nix_path: nixpkgs=channel:nixos-unstable + + - name: Check if debug flag files are in sync + run: ./ci/check_debug_vars.sh + + # for skipped tests; see #6946, #6947 + - name: cargo test without --release + run: nix develop -c sh -c 'export ROC_CHECK_MONO_IR=1 && cargo test -- --skip tests/exhaustive/match_on_result_with_uninhabited_error_destructuring_in_lambda_syntax.txt --skip tests::identity_lambda --skip tests::issue_2300 --skip tests::issue_2582_specialize_result_value --skip tests::sum_lambda' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7b85d55191..0c6dab5572 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,20 +43,9 @@ Execute `cargo fmt --all` to fix the formatting. - The [compiler's README](https://github.com/roc-lang/roc/tree/main/crates/compiler) contains important info. - The AI chat in the [cursor editor](https://www.cursor.com/) can also help you find your way in the codebase. -
-:beetle: Debugging Tips -- Use a debug build of the compiler. We have many asserts enabled in the debug compiler that can alert you to something going wrong. When building from source, build the debug compiler with `cargo build --bin roc`, the binary is at roc/target/debug/roc. When using roc through a nix flake like in [basic-cli](https://github.com/roc-lang/basic-cli), use `rocPkgs.cli-debug` instead of `rocPkgs.cli`. -- At the bottom of [.cargo/config.toml](https://github.com/roc-lang/roc/blob/main/.cargo/config.toml) we have useful debug flags that activate certain debug prints. -- For Roc code; minimize the code that produces the issue. -- If you plan to look at the data used and produced inside the compiler, try to reproduce your issue with a very simple platform like our [minimal Rust platform](https://github.com/roc-lang/roc/tree/main/examples/platform-switching/rust-platform) instead of for example basic-cli. -- For segmentation faults: - + In general we recommend using linux to investigate, it has better tools for this. - + Use `roc build myApp.roc --linker=legacy` followed by `valgrind ./myApp`. - + Use gdb to step through the code, [this gdb script](https://roc.zulipchat.com/#narrow/stream/395097-compiler-development/topic/gdb.20script/near/424422545) can be helpful. - + Inspect the generated LLVM IR (`roc build myApp.roc --emit-llvm-ir`) between Roc code that encounters the segfault and code that doesn't. - +### Debugging tips -
+If you need to do some debugging, check out [our tips](devtools/debug_tips.md). ### Commit signing diff --git a/ci/check_debug_vars.sh b/ci/check_debug_vars.sh new file mode 100755 index 0000000000..0d54a3d7ce --- /dev/null +++ b/ci/check_debug_vars.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euo pipefail + +# Extract vars from .cargo/config.toml +config_vars=$(grep -E "^ROC_.*= \"[01]\"" .cargo/config.toml | cut -d'=' -f1 | tr -d ' ') + +# Extract vars from crates/compiler/debug_flags/src/lib.rs +lib_vars=$(grep -E "^ ROC_.*" crates/compiler/debug_flags/src/lib.rs | tr -d ' ') + +# Sort both lists +sorted_config_vars=$(echo "$config_vars" | sort) +sorted_lib_vars=$(echo "$lib_vars" | sort) + +# Compare the sorted lists +if diff <(echo "$sorted_config_vars") <(echo "$sorted_lib_vars") > /dev/null; then + echo "The flags in both files are identical." +else + echo "Looks like some flags are out of sync between .cargo/config.toml and crates/compiler/debug_flags/src/lib.rs:" + diff <(echo "$sorted_config_vars") <(echo "$sorted_lib_vars") +fi \ No newline at end of file diff --git a/crates/cli/src/format.rs b/crates/cli/src/format.rs index 7d33833fb4..6cd649a5ee 100644 --- a/crates/cli/src/format.rs +++ b/crates/cli/src/format.rs @@ -5,11 +5,12 @@ use std::path::{Path, PathBuf}; use bumpalo::Bump; use roc_error_macros::{internal_error, user_error}; use roc_fmt::def::fmt_defs; -use roc_fmt::module::fmt_module; -use roc_fmt::{Ast, Buf}; -use roc_parse::module::parse_module_defs; -use roc_parse::remove_spaces::RemoveSpaces; -use roc_parse::{module, parser::SyntaxError, state::State}; +use roc_fmt::header::fmt_header; +use roc_fmt::Buf; +use roc_parse::ast::{FullAst, SpacesBefore}; +use roc_parse::header::parse_module_defs; +use roc_parse::normalize::Normalize; +use roc_parse::{header, parser::SyntaxError, state::State}; #[derive(Copy, Clone, Debug)] pub enum FormatMode { @@ -199,8 +200,8 @@ pub fn format_src(arena: &Bump, src: &str) -> Result { } }; - let ast_normalized = ast.remove_spaces(arena); - let reparsed_ast_normalized = reparsed_ast.remove_spaces(arena); + let ast_normalized = ast.normalize(arena); + let reparsed_ast_normalized = reparsed_ast.normalize(arena); // HACK! // We compare the debug format strings of the ASTs, because I'm finding in practice that _somewhere_ deep inside the ast, @@ -230,19 +231,25 @@ pub fn format_src(arena: &Bump, src: &str) -> Result { Ok(buf.as_str().to_string()) } -fn parse_all<'a>(arena: &'a Bump, src: &'a str) -> Result, SyntaxError<'a>> { - let (module, state) = module::parse_header(arena, State::new(src.as_bytes())) +fn parse_all<'a>(arena: &'a Bump, src: &'a str) -> Result, SyntaxError<'a>> { + let (header, state) = header::parse_header(arena, State::new(src.as_bytes())) .map_err(|e| SyntaxError::Header(e.problem))?; - let (module, defs) = module.upgrade_header_imports(arena); + let (h, defs) = header.item.upgrade_header_imports(arena); let defs = parse_module_defs(arena, state, defs)?; - Ok(Ast { module, defs }) + Ok(FullAst { + header: SpacesBefore { + before: header.before, + item: h, + }, + defs, + }) } -fn fmt_all<'a>(buf: &mut Buf<'a>, ast: &'a Ast) { - fmt_module(buf, &ast.module); +fn fmt_all<'a>(buf: &mut Buf<'a>, ast: &'a FullAst) { + fmt_header(buf, &ast.header); fmt_defs(buf, &ast.defs, 0); diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 982358d03a..b0b2e08e1d 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -432,6 +432,14 @@ pub fn build_app() -> Command { .action(ArgAction::SetTrue) .required(false) ) + .arg( + Arg::new(FLAG_TARGET) + .long(FLAG_TARGET) + .help("Choose a different target") + .default_value(Into::<&'static str>::into(Target::default())) + .value_parser(build_target_values_parser.clone()) + .required(false), + ) ) .arg(flag_optimize) .arg(flag_max_threads) diff --git a/crates/cli/tests/cli/combine-tasks.roc b/crates/cli/tests/cli/combine-tasks.roc index 70778a21d4..0e081c4644 100644 --- a/crates/cli/tests/cli/combine-tasks.roc +++ b/crates/cli/tests/cli/combine-tasks.roc @@ -9,8 +9,8 @@ main = a: Task.ok 123, b: Task.ok "abc", c: Task.ok [123], - d: Task.ok ["abc"], - e: Task.ok (Dict.single "a" "b"), + _d: Task.ok ["abc"], + _: Task.ok (Dict.single "a" "b"), }! Stdout.line! "For multiple tasks: $(Inspect.toStr multipleIn)" diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index dfe61bd5ad..25237266f2 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -711,6 +711,17 @@ mod cli_run { ) } + #[test] + #[cfg_attr(windows, ignore)] + fn platform_requires_pkg() { + test_roc_app_slim( + "crates/cli/tests/platform_requires_pkg", + "app.roc", + "from app from package", + UseValgrind::No, + ) + } + #[test] #[cfg_attr(windows, ignore)] fn transitive_expects() { @@ -947,7 +958,7 @@ mod cli_run { &[], &[], &[], - "For multiple tasks: {a: 123, b: \"abc\", c: [123], d: [\"abc\"], e: {\"a\": \"b\"}}\n", + "For multiple tasks: {a: 123, b: \"abc\", c: [123]}\n", UseValgrind::No, TestCliCommands::Run, ) diff --git a/crates/cli/tests/platform_requires_pkg/app.roc b/crates/cli/tests/platform_requires_pkg/app.roc new file mode 100644 index 0000000000..b90d12b1fa --- /dev/null +++ b/crates/cli/tests/platform_requires_pkg/app.roc @@ -0,0 +1,6 @@ +app [main] { + pf: platform "./platform/main.roc" +} + +main = + "from app" diff --git a/crates/cli/tests/platform_requires_pkg/foo/Foo.roc b/crates/cli/tests/platform_requires_pkg/foo/Foo.roc new file mode 100644 index 0000000000..d0591d9f27 --- /dev/null +++ b/crates/cli/tests/platform_requires_pkg/foo/Foo.roc @@ -0,0 +1,3 @@ +module [foo] + +foo = "from package" diff --git a/crates/cli/tests/platform_requires_pkg/foo/main.roc b/crates/cli/tests/platform_requires_pkg/foo/main.roc new file mode 100644 index 0000000000..ac9841cb5d --- /dev/null +++ b/crates/cli/tests/platform_requires_pkg/foo/main.roc @@ -0,0 +1 @@ +package [Foo] {} diff --git a/crates/cli/tests/platform_requires_pkg/platform/host.zig b/crates/cli/tests/platform_requires_pkg/platform/host.zig new file mode 100644 index 0000000000..1ac9ce6dbe --- /dev/null +++ b/crates/cli/tests/platform_requires_pkg/platform/host.zig @@ -0,0 +1,129 @@ +const std = @import("std"); +const builtin = @import("builtin"); +const str = @import("glue").str; +const RocStr = str.RocStr; +const testing = std.testing; +const expectEqual = testing.expectEqual; +const expect = testing.expect; + +const Align = 2 * @alignOf(usize); +extern fn malloc(size: usize) callconv(.C) ?*align(Align) anyopaque; +extern fn realloc(c_ptr: [*]align(Align) u8, size: usize) callconv(.C) ?*anyopaque; +extern fn free(c_ptr: [*]align(Align) u8) callconv(.C) void; +extern fn memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void; +extern fn memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void; + +const DEBUG: bool = false; + +export fn roc_alloc(size: usize, alignment: u32) callconv(.C) ?*anyopaque { + if (DEBUG) { + var ptr = malloc(size); + const stdout = std.io.getStdOut().writer(); + stdout.print("alloc: {d} (alignment {d}, size {d})\n", .{ ptr, alignment, size }) catch unreachable; + return ptr; + } else { + return malloc(size); + } +} + +export fn roc_realloc(c_ptr: *anyopaque, new_size: usize, old_size: usize, alignment: u32) callconv(.C) ?*anyopaque { + if (DEBUG) { + const stdout = std.io.getStdOut().writer(); + stdout.print("realloc: {d} (alignment {d}, old_size {d})\n", .{ c_ptr, alignment, old_size }) catch unreachable; + } + + return realloc(@as([*]align(Align) u8, @alignCast(@ptrCast(c_ptr))), new_size); +} + +export fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void { + if (DEBUG) { + const stdout = std.io.getStdOut().writer(); + stdout.print("dealloc: {d} (alignment {d})\n", .{ c_ptr, alignment }) catch unreachable; + } + + free(@as([*]align(Align) u8, @alignCast(@ptrCast(c_ptr)))); +} + +export fn roc_panic(msg: *RocStr, tag_id: u32) callconv(.C) void { + _ = tag_id; + + const stderr = std.io.getStdErr().writer(); + stderr.print("Application crashed with message\n\n {s}\n\nShutting down\n", .{msg.asSlice()}) catch unreachable; + std.process.exit(1); +} + +export fn roc_dbg(loc: *RocStr, msg: *RocStr, src: *RocStr) callconv(.C) void { + // This platform uses stdout for testing purposes instead of the normal stderr. + const stdout = std.io.getStdOut().writer(); + stdout.print("[{s}] {s} = {s}\n", .{ loc.asSlice(), src.asSlice(), msg.asSlice() }) catch unreachable; +} + +export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { + return memset(dst, value, size); +} + +extern fn kill(pid: c_int, sig: c_int) c_int; +extern fn shm_open(name: *const i8, oflag: c_int, mode: c_uint) c_int; +extern fn mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int, fd: c_int, offset: c_uint) *anyopaque; +extern fn getppid() c_int; + +fn roc_getppid() callconv(.C) c_int { + return getppid(); +} + +fn roc_getppid_windows_stub() callconv(.C) c_int { + return 0; +} + +fn roc_send_signal(pid: c_int, sig: c_int) callconv(.C) c_int { + return kill(pid, sig); +} +fn roc_shm_open(name: *const i8, oflag: c_int, mode: c_uint) callconv(.C) c_int { + return shm_open(name, oflag, mode); +} +fn roc_mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int, fd: c_int, offset: c_uint) callconv(.C) *anyopaque { + return mmap(addr, length, prot, flags, fd, offset); +} + +comptime { + if (builtin.os.tag == .macos or builtin.os.tag == .linux) { + @export(roc_getppid, .{ .name = "roc_getppid", .linkage = .Strong }); + @export(roc_mmap, .{ .name = "roc_mmap", .linkage = .Strong }); + @export(roc_send_signal, .{ .name = "roc_send_signal", .linkage = .Strong }); + @export(roc_shm_open, .{ .name = "roc_shm_open", .linkage = .Strong }); + } + + if (builtin.os.tag == .windows) { + @export(roc_getppid_windows_stub, .{ .name = "roc_getppid", .linkage = .Strong }); + } +} + +const mem = std.mem; +const Allocator = mem.Allocator; + +extern fn roc__mainForHost_1_exposed_generic(*RocStr) void; + +const Unit = extern struct {}; + +pub fn main() u8 { + const stdout = std.io.getStdOut().writer(); + const stderr = std.io.getStdErr().writer(); + + var timer = std.time.Timer.start() catch unreachable; + + // actually call roc to populate the callresult + var callresult = RocStr.empty(); + roc__mainForHost_1_exposed_generic(&callresult); + + const nanos = timer.read(); + const seconds = (@as(f64, @floatFromInt(nanos)) / 1_000_000_000.0); + + // stdout the result + stdout.print("{s}", .{callresult.asSlice()}) catch unreachable; + + callresult.decref(); + + stderr.print("runtime: {d:.3}ms\n", .{seconds * 1000}) catch unreachable; + + return 0; +} diff --git a/crates/cli/tests/platform_requires_pkg/platform/main.roc b/crates/cli/tests/platform_requires_pkg/platform/main.roc new file mode 100644 index 0000000000..b8c40ae927 --- /dev/null +++ b/crates/cli/tests/platform_requires_pkg/platform/main.roc @@ -0,0 +1,14 @@ +platform "test" + requires {} { main : _ } + exposes [] + packages { + foo: "../foo/main.roc", + } + imports [] + provides [mainForHost] + +import foo.Foo + +mainForHost : Str +mainForHost = + "$(main) $(Foo.foo)" diff --git a/crates/compiler/builtins/roc/Result.roc b/crates/compiler/builtins/roc/Result.roc index 58aecb1d76..9e7a2b9104 100644 --- a/crates/compiler/builtins/roc/Result.roc +++ b/crates/compiler/builtins/roc/Result.roc @@ -1,4 +1,15 @@ -module [Result, isOk, isErr, map, mapErr, try, onErr, withDefault] +module [ + Result, + isOk, + isErr, + map, + mapErr, + mapBoth, + map2, + try, + onErr, + withDefault, +] import Bool exposing [Bool] @@ -67,6 +78,22 @@ mapErr = \result, transform -> Ok v -> Ok v Err e -> Err (transform e) +## Maps both the `Ok` and `Err` values of a `Result` to new values. +mapBoth : Result ok1 err1, (ok1 -> ok2), (err1 -> err2) -> Result ok2 err2 +mapBoth = \result, okTransform, errTransform -> + when result is + Ok val -> Ok (okTransform val) + Err err -> Err (errTransform err) + +## Maps the `Ok` values of two `Result`s to a new value using a given transformation, +## or returns the first `Err` value encountered. +map2 : Result a err, Result b err, (a, b -> c) -> Result c err +map2 = \firstResult, secondResult, transform -> + when (firstResult, secondResult) is + (Ok first, Ok second) -> Ok (transform first second) + (Err err, _) -> Err err + (_, Err err) -> Err err + ## If the result is `Ok`, transforms the entire result by running a conversion ## function on the value the `Ok` holds. Then returns that new result. If the ## result is `Err`, this has no effect. Use `onErr` to transform an `Err`. diff --git a/crates/compiler/can/src/annotation.rs b/crates/compiler/can/src/annotation.rs index 2118faf72f..5279f9f7a9 100644 --- a/crates/compiler/can/src/annotation.rs +++ b/crates/compiler/can/src/annotation.rs @@ -1,6 +1,6 @@ use crate::env::Env; use crate::procedure::{QualifiedReference, References}; -use crate::scope::{PendingAbilitiesInScope, Scope}; +use crate::scope::{PendingAbilitiesInScope, Scope, SymbolLookup}; use roc_collections::{ImMap, MutSet, SendMap, VecMap, VecSet}; use roc_module::ident::{Ident, Lowercase, TagName}; use roc_module::symbol::Symbol; @@ -386,7 +386,10 @@ pub(crate) fn make_apply_symbol( // Look it up in scope! match scope.lookup_str(ident, region) { - Ok(symbol) => { + Ok(SymbolLookup { + symbol, + module_params: _, + }) => { references.insert_type_lookup(symbol, QualifiedReference::Unqualified); Ok(symbol) } @@ -398,7 +401,10 @@ pub(crate) fn make_apply_symbol( } } else { match env.qualified_lookup(scope, module_name, ident, region) { - Ok(symbol) => { + Ok(SymbolLookup { + symbol, + module_params: _, + }) => { references.insert_type_lookup(symbol, QualifiedReference::Qualified); Ok(symbol) } @@ -467,7 +473,8 @@ pub fn find_type_def_symbols( while let Some(assigned_field) = inner_stack.pop() { match assigned_field { AssignedField::RequiredValue(_, _, t) - | AssignedField::OptionalValue(_, _, t) => { + | AssignedField::OptionalValue(_, _, t) + | AssignedField::IgnoredValue(_, _, t) => { stack.push(&t.value); } AssignedField::LabelOnly(_) => {} @@ -1386,6 +1393,7 @@ fn can_assigned_fields<'a>( break 'inner label; } + IgnoredValue(_, _, _) => unreachable!(), LabelOnly(loc_field_name) => { // Interpret { a, b } as { a : a, b : b } let field_name = Lowercase::from(loc_field_name.value); diff --git a/crates/compiler/can/src/constraint.rs b/crates/compiler/can/src/constraint.rs index 0f594d31a8..e10815bc87 100644 --- a/crates/compiler/can/src/constraint.rs +++ b/crates/compiler/can/src/constraint.rs @@ -602,7 +602,8 @@ impl Constraints { | Constraint::Exhaustive { .. } | Constraint::Resolve(..) | Constraint::IngestedFile(..) - | Constraint::CheckCycle(..) => false, + | Constraint::CheckCycle(..) + | Constraint::ImportParams(..) => false, } } @@ -685,6 +686,15 @@ impl Constraints { ) -> Constraint { Constraint::IngestedFile(type_index, file_path, bytes) } + + pub fn import_params( + &mut self, + opt_type_index: Option, + module_id: ModuleId, + region: Region, + ) -> Constraint { + Constraint::ImportParams(opt_type_index, module_id, region) + } } roc_error_macros::assert_sizeof_default!(Constraint, 3 * 8); @@ -787,6 +797,7 @@ pub enum Constraint { CheckCycle(Index, IllegalCycleMark), IngestedFile(TypeOrVar, Box, Arc>), + ImportParams(Option, ModuleId, Region), } #[derive(Debug, Clone, Copy, Default)] @@ -865,6 +876,9 @@ impl std::fmt::Debug for Constraint { Self::IngestedFile(arg0, arg1, arg2) => { write!(f, "IngestedFile({arg0:?}, {arg1:?}, {arg2:?})") } + Self::ImportParams(arg0, arg1, arg2) => { + write!(f, "ImportParams({arg0:?}, {arg1:?}, {arg2:?})") + } } } } diff --git a/crates/compiler/can/src/copy.rs b/crates/compiler/can/src/copy.rs index 5be29af2cd..c8d3b63267 100644 --- a/crates/compiler/can/src/copy.rs +++ b/crates/compiler/can/src/copy.rs @@ -288,6 +288,22 @@ fn deep_copy_expr_help(env: &mut C, copied: &mut Vec, expr loc_elems: loc_elems.iter().map(|le| le.map(|e| go_help!(e))).collect(), }, Var(sym, var) => Var(*sym, sub!(*var)), + ParamsVar { + symbol, + params, + var, + } => ParamsVar { + symbol: *symbol, + params: *params, + var: sub!(*var), + }, + ImportParams(module_id, region, opt_provided) => ImportParams( + *module_id, + *region, + opt_provided + .as_ref() + .map(|(var, expr)| (sub!(*var), Box::new(go_help!(&expr)))), + ), &AbilityMember(sym, specialization, specialization_var) => { AbilityMember(sym, specialization, sub!(specialization_var)) } diff --git a/crates/compiler/can/src/debug/pretty_print.rs b/crates/compiler/can/src/debug/pretty_print.rs index 03467c9bde..ad1f01f0ee 100644 --- a/crates/compiler/can/src/debug/pretty_print.rs +++ b/crates/compiler/can/src/debug/pretty_print.rs @@ -206,7 +206,13 @@ fn expr<'a>(c: &Ctx, p: EPrec, f: &'a Arena<'a>, e: &'a Expr) -> DocBuilder<'a, .append("]") .group(), ), - Var(sym, _) | AbilityMember(sym, _, _) => pp_sym(c, f, *sym), + Var(sym, _) | ParamsVar { symbol: sym, .. } | AbilityMember(sym, _, _) => { + pp_sym(c, f, *sym) + } + ImportParams(_, _, Some((_, params_expr))) => expr(c, p, f, params_expr), + ImportParams(module_id, _, None) => { + text!(f, "", module_id) + } When { loc_cond, branches, .. } => maybe_paren!( diff --git a/crates/compiler/can/src/def.rs b/crates/compiler/can/src/def.rs index 70d95a72ec..0779a9e82d 100644 --- a/crates/compiler/can/src/def.rs +++ b/crates/compiler/can/src/def.rs @@ -10,6 +10,7 @@ use crate::annotation::IntroducedVariables; use crate::annotation::OwnedNamedOrAble; use crate::derive; use crate::env::Env; +use crate::expr::canonicalize_record; use crate::expr::get_lookup_symbols; use crate::expr::AnnotatedMark; use crate::expr::ClosureData; @@ -18,6 +19,7 @@ use crate::expr::Expr::{self, *}; use crate::expr::StructAccessorData; use crate::expr::{canonicalize_expr, Output, Recursive}; use crate::pattern::{canonicalize_def_header_pattern, BindingsFromPattern, Pattern}; +use crate::procedure::QualifiedReference; use crate::procedure::References; use crate::scope::create_alias; use crate::scope::{PendingAbilitiesInScope, Scope}; @@ -160,6 +162,13 @@ enum PendingValueDef<'a> { &'a Loc>, &'a Loc>, ), + /// Module params from an import + ImportParams { + symbol: Symbol, + loc_pattern: Loc, + module_id: ModuleId, + opt_provided: Option>>>>, + }, /// Ingested file IngestedFile( Loc, @@ -174,6 +183,12 @@ impl PendingValueDef<'_> { PendingValueDef::AnnotationOnly(loc_pattern, _) => loc_pattern, PendingValueDef::Body(loc_pattern, _) => loc_pattern, PendingValueDef::TypedBody(_, loc_pattern, _, _) => loc_pattern, + PendingValueDef::ImportParams { + loc_pattern, + symbol: _, + module_id: _, + opt_provided: _, + } => loc_pattern, PendingValueDef::IngestedFile(loc_pattern, _, _) => loc_pattern, } } @@ -485,6 +500,16 @@ fn canonicalize_alias<'a>( } } +#[macro_export] +macro_rules! params_in_abilities_unimplemented { + ($lookup:expr) => { + match $lookup.module_params { + None => $lookup.symbol, + Some(_) => unimplemented!("params in abilities"), + } + }; +} + /// Canonicalizes a claimed ability implementation like `{ eq }` or `{ eq: myEq }`. /// Returns a mapping of the ability member to the implementation symbol. /// If there was an error, a problem will be recorded and nothing is returned. @@ -503,7 +528,7 @@ fn canonicalize_claimed_ability_impl<'a>( let member_symbol = match env.qualified_lookup_with_module_id(scope, ability_home, label_str, region) { - Ok(symbol) => symbol, + Ok(lookup) => params_in_abilities_unimplemented!(lookup), Err(_) => { env.problem(Problem::NotAnAbilityMember { ability, @@ -546,8 +571,13 @@ fn canonicalize_claimed_ability_impl<'a>( // To handle both cases, try checking for a shadow first, then check for a direct // reference. We want to check for a direct reference second so that if there is a // shadow, we won't accidentally grab the imported symbol. - let opt_impl_symbol = (scope.lookup_ability_member_shadow(member_symbol)) - .or_else(|| scope.lookup_str(label_str, region).ok()); + let opt_impl_symbol = + (scope.lookup_ability_member_shadow(member_symbol)).or_else(|| { + scope + .lookup_str(label_str, region) + .map(|s| params_in_abilities_unimplemented!(s)) + .ok() + }); match opt_impl_symbol { // It's possible that even if we find a symbol it is still only the member @@ -599,7 +629,7 @@ fn canonicalize_claimed_ability_impl<'a>( label.value, label.region, ) { - Ok(symbol) => symbol, + Ok(lookup) => params_in_abilities_unimplemented!(lookup), Err(_) => { env.problem(Problem::NotAnAbilityMember { ability, @@ -611,7 +641,7 @@ fn canonicalize_claimed_ability_impl<'a>( }; let impl_symbol = match scope.lookup(&impl_ident.into(), impl_region) { - Ok(symbol) => symbol, + Ok(symbol) => params_in_abilities_unimplemented!(symbol), Err(err) => { env.problem(Problem::RuntimeError(err)); return Err(()); @@ -631,7 +661,9 @@ fn canonicalize_claimed_ability_impl<'a>( // An error will already have been reported Err(()) } - AssignedField::SpaceBefore(_, _) | AssignedField::SpaceAfter(_, _) => { + AssignedField::SpaceBefore(_, _) + | AssignedField::SpaceAfter(_, _) + | AssignedField::IgnoredValue(_, _, _) => { internal_error!("unreachable") } } @@ -1107,8 +1139,24 @@ fn canonicalize_value_defs<'a>( PendingValue::ExpectFx(pending_expect) => { pending_expect_fx.push(pending_expect); } - PendingValue::ModuleImport(introduced_import) => { - imports_introduced.push(introduced_import); + PendingValue::ModuleImport(PendingModuleImport { + module_id, + region, + exposed_symbols, + params, + }) => { + imports_introduced.push(IntroducedImport { + module_id, + region, + exposed_symbols, + }); + + pending_value_defs.push(PendingValueDef::ImportParams { + symbol: params.symbol, + loc_pattern: params.loc_pattern, + opt_provided: params.opt_provided, + module_id, + }); } PendingValue::InvalidIngestedFile => { /* skip */ } PendingValue::ImportNameConflict => { /* skip */ } @@ -1556,7 +1604,7 @@ impl DefOrdering { fn insert_symbol_references(&mut self, def_id: u32, def_references: &DefReferences) { match def_references { DefReferences::Value(references) => { - let it = references.value_lookups().chain(references.calls()); + let it = references.value_lookups(); for referenced in it { if let Some(ref_id) = self.get_id(*referenced) { @@ -2350,6 +2398,50 @@ fn canonicalize_pending_value_def<'a>( None, ) } + ImportParams { + symbol, + loc_pattern, + module_id, + opt_provided, + } => { + // Insert a reference to the record so that we don't report it as unused + // If the whole module is unused, we'll report that separately + output + .references + .insert_value_lookup(symbol, QualifiedReference::Unqualified); + + let (opt_var_record, references) = match opt_provided { + Some(params) => { + let (record, can_output) = + canonicalize_record(env, var_store, scope, loc_pattern.region, params); + + let references = can_output.references.clone(); + output.union(can_output); + + (Some((var_store.fresh(), Box::new(record))), references) + } + None => (None, References::new()), + }; + + let loc_expr = Loc::at( + loc_pattern.region, + Expr::ImportParams(module_id, loc_pattern.region, opt_var_record), + ); + + let def = single_can_def( + loc_pattern, + loc_expr, + var_store.fresh(), + None, + SendMap::default(), + ); + + DefOutput { + output, + references: DefReferences::Value(references), + def, + } + } IngestedFile(loc_pattern, opt_loc_ann, path_literal) => { let relative_path = if let ast::StrLiteral::PlainLine(ingested_path) = path_literal.value { @@ -2891,7 +2983,7 @@ enum PendingValue<'a> { Dbg(PendingExpectOrDbg<'a>), Expect(PendingExpectOrDbg<'a>), ExpectFx(PendingExpectOrDbg<'a>), - ModuleImport(IntroducedImport), + ModuleImport(PendingModuleImport<'a>), SignatureDefMismatch, InvalidIngestedFile, ImportNameConflict, @@ -2902,6 +2994,19 @@ struct PendingExpectOrDbg<'a> { preceding_comment: Region, } +struct PendingModuleImport<'a> { + module_id: ModuleId, + region: Region, + exposed_symbols: Vec<(Symbol, Region)>, + params: PendingModuleImportParams<'a>, +} + +struct PendingModuleImportParams<'a> { + symbol: Symbol, + loc_pattern: Loc, + opt_provided: Option>>>>, +} + pub struct IntroducedImport { module_id: ModuleId, region: Region, @@ -3051,10 +3156,27 @@ fn to_pending_value_def<'a>( None => module_name.clone(), }; + // Generate a symbol for the module params def + // We do this even if params weren't provided so that solve can report if they are missing + let params_sym = scope.gen_unique_symbol(); + let params_region = module_import.params.map(|p| p.params.region).unwrap_or(region); + let params = + PendingModuleImportParams { + symbol: params_sym, + loc_pattern: Loc::at(params_region, Pattern::Identifier(params_sym)), + opt_provided: module_import.params.map(|p| p.params.value), + }; + let provided_params_sym = if module_import.params.is_some() { + // Only add params to scope if they are provided + Some(params_sym) + } else { + None + }; + if let Err(existing_import) = scope .modules - .insert(name_with_alias.clone(), module_id, region) + .insert(name_with_alias.clone(), module_id, provided_params_sym, region) { env.problems.push(Problem::ImportNameConflict { name: name_with_alias, @@ -3065,7 +3187,7 @@ fn to_pending_value_def<'a>( }); return PendingValue::ImportNameConflict; - } + }; let exposed_names = module_import .exposed @@ -3117,13 +3239,13 @@ fn to_pending_value_def<'a>( })) } } - } - PendingValue::ModuleImport(IntroducedImport { + PendingValue::ModuleImport(PendingModuleImport { module_id, region, exposed_symbols, + params, }) } IngestedFileImport(ingested_file) => { diff --git a/crates/compiler/can/src/desugar.rs b/crates/compiler/can/src/desugar.rs index cba1b7df4d..bb4affaf72 100644 --- a/crates/compiler/can/src/desugar.rs +++ b/crates/compiler/can/src/desugar.rs @@ -140,7 +140,9 @@ fn desugar_value_def<'a>( let desugared_params = params.map(|ModuleImportParams { before, params }| ModuleImportParams { before, - params: desugar_field_collection(arena, params, src, line_info, module_path), + params: params.map(|params| { + desugar_field_collection(arena, *params, src, line_info, module_path) + }), }); ModuleImport(roc_parse::ast::ModuleImport { @@ -521,44 +523,68 @@ pub fn desugar_expr<'a>( }); } - let mut field_names = Vec::with_capacity_in(fields.len(), arena); - let mut field_vals = Vec::with_capacity_in(fields.len(), arena); - - for field in fields.items { - match desugar_field(arena, &field.value, src, line_info, module_path) { - AssignedField::RequiredValue(loc_name, _, loc_val) => { - field_names.push(loc_name); - field_vals.push(loc_val); - } - AssignedField::LabelOnly(loc_name) => { - field_names.push(loc_name); - field_vals.push(arena.alloc(Loc { - region: loc_name.region, - value: Expr::Var { - module_name: "", - ident: loc_name.value, - }, - })); - } - AssignedField::OptionalValue(loc_name, _, loc_val) => { - return arena.alloc(Loc { - region: loc_expr.region, - value: OptionalFieldInRecordBuilder(arena.alloc(loc_name), loc_val), - }); - } - AssignedField::SpaceBefore(_, _) | AssignedField::SpaceAfter(_, _) => { - unreachable!("Should have been desugared in `desugar_field`") - } - AssignedField::Malformed(_name) => {} - } + struct FieldData<'d> { + name: Loc<&'d str>, + value: &'d Loc>, + ignored: bool, } - let closure_arg_from_field = |field: Loc<&'a str>| Loc { - region: field.region, - value: Pattern::Identifier { - ident: arena.alloc_str(&format!("#{}", field.value)), - }, - }; + let mut field_data = Vec::with_capacity_in(fields.len(), arena); + + for field in fields.items { + let (name, value, ignored) = + match desugar_field(arena, &field.value, src, line_info, module_path) { + AssignedField::RequiredValue(loc_name, _, loc_val) => { + (loc_name, loc_val, false) + } + AssignedField::IgnoredValue(loc_name, _, loc_val) => { + (loc_name, loc_val, true) + } + AssignedField::LabelOnly(loc_name) => ( + loc_name, + &*arena.alloc(Loc { + region: loc_name.region, + value: Expr::Var { + module_name: "", + ident: loc_name.value, + }, + }), + false, + ), + AssignedField::OptionalValue(loc_name, _, loc_val) => { + return arena.alloc(Loc { + region: loc_expr.region, + value: OptionalFieldInRecordBuilder(arena.alloc(loc_name), loc_val), + }); + } + AssignedField::SpaceBefore(_, _) | AssignedField::SpaceAfter(_, _) => { + unreachable!("Should have been desugared in `desugar_field`") + } + AssignedField::Malformed(_name) => continue, + }; + + field_data.push(FieldData { + name, + value, + ignored, + }); + } + + let closure_arg_from_field = + |FieldData { + name, + value: _, + ignored, + }: &FieldData<'a>| Loc { + region: name.region, + value: if *ignored { + Pattern::Underscore(name.value) + } else { + Pattern::Identifier { + ident: arena.alloc_str(&format!("#{}", name.value)), + } + }, + }; let combiner_closure_in_region = |region| { let closure_body = Tuple(Collection::with_items( @@ -607,15 +633,15 @@ pub fn desugar_expr<'a>( }; let closure_args = { - if field_names.len() == 2 { + if field_data.len() == 2 { arena.alloc_slice_copy(&[ - closure_arg_from_field(field_names[0]), - closure_arg_from_field(field_names[1]), + closure_arg_from_field(&field_data[0]), + closure_arg_from_field(&field_data[1]), ]) } else { let second_to_last_arg = - closure_arg_from_field(field_names[field_names.len() - 2]); - let last_arg = closure_arg_from_field(field_names[field_names.len() - 1]); + closure_arg_from_field(&field_data[field_data.len() - 2]); + let last_arg = closure_arg_from_field(&field_data[field_data.len() - 1]); let mut second_arg = Pattern::Tuple(Collection::with_items( arena.alloc_slice_copy(&[second_to_last_arg, last_arg]), @@ -623,18 +649,18 @@ pub fn desugar_expr<'a>( let mut second_arg_region = Region::span_across(&second_to_last_arg.region, &last_arg.region); - for index in (1..(field_names.len() - 2)).rev() { + for index in (1..(field_data.len() - 2)).rev() { second_arg = Pattern::Tuple(Collection::with_items(arena.alloc_slice_copy(&[ - closure_arg_from_field(field_names[index]), + closure_arg_from_field(&field_data[index]), Loc::at(second_arg_region, second_arg), ]))); second_arg_region = - Region::span_across(&field_names[index].region, &second_arg_region); + Region::span_across(&field_data[index].name.region, &second_arg_region); } arena.alloc_slice_copy(&[ - closure_arg_from_field(field_names[0]), + closure_arg_from_field(&field_data[0]), Loc::at(second_arg_region, second_arg), ]) } @@ -642,22 +668,26 @@ pub fn desugar_expr<'a>( let record_val = Record(Collection::with_items( Vec::from_iter_in( - field_names.iter().map(|field_name| { - Loc::at( - field_name.region, - AssignedField::RequiredValue( - Loc::at(field_name.region, field_name.value), - &[], - arena.alloc(Loc::at( - field_name.region, - Expr::Var { - module_name: "", - ident: arena.alloc_str(&format!("#{}", field_name.value)), - }, - )), - ), - ) - }), + field_data + .iter() + .filter(|field| !field.ignored) + .map(|field| { + Loc::at( + field.name.region, + AssignedField::RequiredValue( + field.name, + &[], + arena.alloc(Loc::at( + field.name.region, + Expr::Var { + module_name: "", + ident: arena + .alloc_str(&format!("#{}", field.name.value)), + }, + )), + ), + ) + }), arena, ) .into_bump_slice(), @@ -671,14 +701,14 @@ pub fn desugar_expr<'a>( ), }); - if field_names.len() == 2 { + if field_data.len() == 2 { return arena.alloc(Loc { region: loc_expr.region, value: Apply( new_mapper, arena.alloc_slice_copy(&[ - field_vals[0], - field_vals[1], + field_data[0].value, + field_data[1].value, record_combiner_closure, ]), CalledVia::RecordBuilder, @@ -688,27 +718,30 @@ pub fn desugar_expr<'a>( let mut inner_combined = arena.alloc(Loc { region: Region::span_across( - &field_vals[field_names.len() - 2].region, - &field_vals[field_names.len() - 1].region, + &field_data[field_data.len() - 2].value.region, + &field_data[field_data.len() - 1].value.region, ), value: Apply( new_mapper, arena.alloc_slice_copy(&[ - field_vals[field_names.len() - 2], - field_vals[field_names.len() - 1], + field_data[field_data.len() - 2].value, + field_data[field_data.len() - 1].value, combiner_closure_in_region(loc_expr.region), ]), CalledVia::RecordBuilder, ), }); - for index in (1..(field_names.len() - 2)).rev() { + for index in (1..(field_data.len() - 2)).rev() { inner_combined = arena.alloc(Loc { - region: Region::span_across(&field_vals[index].region, &inner_combined.region), + region: Region::span_across( + &field_data[index].value.region, + &inner_combined.region, + ), value: Apply( new_mapper, arena.alloc_slice_copy(&[ - field_vals[index], + field_data[index].value, inner_combined, combiner_closure_in_region(loc_expr.region), ]), @@ -722,7 +755,7 @@ pub fn desugar_expr<'a>( value: Apply( new_mapper, arena.alloc_slice_copy(&[ - field_vals[0], + field_data[0].value, inner_combined, record_combiner_closure, ]), @@ -1095,6 +1128,14 @@ fn desugar_field<'a>( spaces, desugar_expr(arena, loc_expr, src, line_info, module_path), ), + IgnoredValue(loc_str, spaces, loc_expr) => IgnoredValue( + Loc { + value: loc_str.value, + region: loc_str.region, + }, + spaces, + desugar_expr(arena, loc_expr, src, line_info, module_path), + ), LabelOnly(loc_str) => { // Desugar { x } into { x: x } let loc_expr = Loc { diff --git a/crates/compiler/can/src/env.rs b/crates/compiler/can/src/env.rs index e2f6d2ee23..a5f72fd906 100644 --- a/crates/compiler/can/src/env.rs +++ b/crates/compiler/can/src/env.rs @@ -1,7 +1,7 @@ use std::path::Path; use crate::procedure::References; -use crate::scope::Scope; +use crate::scope::{ModuleLookup, Scope, SymbolLookup}; use bumpalo::Bump; use roc_collections::{MutMap, VecSet}; use roc_module::ident::{Ident, ModuleName}; @@ -74,7 +74,7 @@ impl<'a> Env<'a> { module_name_str: &str, ident: &str, region: Region, - ) -> Result { + ) -> Result { debug_assert!( !module_name_str.is_empty(), "Called env.qualified_lookup with an unqualified ident: {ident:?}" @@ -82,8 +82,10 @@ impl<'a> Env<'a> { let module_name = ModuleName::from(module_name_str); - match scope.modules.get_id(&module_name) { - Some(module_id) => self.qualified_lookup_help(scope, module_id, ident, region), + match scope.modules.lookup(&module_name) { + Some(lookedup_module) => { + self.qualified_lookup_help(scope, lookedup_module, ident, region) + } None => Err(RuntimeError::ModuleNotImported { module_name: module_name.clone(), imported_modules: scope @@ -106,11 +108,11 @@ impl<'a> Env<'a> { module_id: ModuleId, ident: &str, region: Region, - ) -> Result { - if !scope.modules.has_id(module_id) { - Err(self.module_exists_but_not_imported(scope, module_id, region)) + ) -> Result { + if let Some(module) = scope.modules.lookup_by_id(&module_id) { + self.qualified_lookup_help(scope, module, ident, region) } else { - self.qualified_lookup_help(scope, module_id, ident, region) + Err(self.module_exists_but_not_imported(scope, module_id, region)) } } @@ -118,18 +120,18 @@ impl<'a> Env<'a> { fn qualified_lookup_help( &mut self, scope: &Scope, - module_id: ModuleId, + module: ModuleLookup, ident: &str, region: Region, - ) -> Result { + ) -> Result { let is_type_name = ident.starts_with(|c: char| c.is_uppercase()); // You can do qualified lookups on your own module, e.g. // if I'm in the Foo module, I can do a `Foo.bar` lookup. - if module_id == self.home { + if module.id == self.home { match scope.locals.ident_ids.get_id(ident) { Some(ident_id) => { - let symbol = Symbol::new(module_id, ident_id); + let symbol = Symbol::new(module.id, ident_id); if is_type_name { self.qualified_type_lookups.insert(symbol); @@ -137,7 +139,7 @@ impl<'a> Env<'a> { self.qualified_value_lookups.insert(symbol); } - Ok(symbol) + Ok(SymbolLookup::no_params(symbol)) } None => { let error = RuntimeError::LookupNotInScope { @@ -157,10 +159,10 @@ impl<'a> Env<'a> { } } } else { - match self.dep_idents.get(&module_id) { + match self.dep_idents.get(&module.id) { Some(exposed_ids) => match exposed_ids.get_id(ident) { Some(ident_id) => { - let symbol = Symbol::new(module_id, ident_id); + let symbol = Symbol::new(module.id, ident_id); if is_type_name { self.qualified_type_lookups.insert(symbol); @@ -168,12 +170,12 @@ impl<'a> Env<'a> { self.qualified_value_lookups.insert(symbol); } - Ok(symbol) + Ok(module.into_symbol(symbol)) } None => Err(RuntimeError::ValueNotExposed { module_name: self .qualified_module_ids - .get_name(module_id) + .get_name(module.id) .expect("Module ID known, but not in the module IDs somehow") .as_inner() .clone(), @@ -182,7 +184,7 @@ impl<'a> Env<'a> { exposed_values: exposed_ids.exposed_values(), }), }, - _ => Err(self.module_exists_but_not_imported(scope, module_id, region)), + _ => Err(self.module_exists_but_not_imported(scope, module.id, region)), } } } diff --git a/crates/compiler/can/src/expr.rs b/crates/compiler/can/src/expr.rs index 5d3f3e18eb..86c372d700 100644 --- a/crates/compiler/can/src/expr.rs +++ b/crates/compiler/can/src/expr.rs @@ -7,9 +7,10 @@ use crate::num::{ finish_parsing_base, finish_parsing_float, finish_parsing_num, float_expr_from_result, int_expr_from_result, num_expr_from_result, FloatBound, IntBound, NumBound, }; +use crate::params_in_abilities_unimplemented; use crate::pattern::{canonicalize_pattern, BindingsFromPattern, Pattern, PermitShadows}; use crate::procedure::{QualifiedReference, References}; -use crate::scope::Scope; +use crate::scope::{Scope, SymbolLookup}; use crate::traverse::{walk_expr, Visitor}; use roc_collections::soa::Index; use roc_collections::{SendMap, VecMap, VecSet}; @@ -17,7 +18,7 @@ use roc_error_macros::internal_error; use roc_module::called_via::CalledVia; use roc_module::ident::{ForeignSymbol, Lowercase, TagName}; use roc_module::low_level::LowLevel; -use roc_module::symbol::Symbol; +use roc_module::symbol::{ModuleId, Symbol}; use roc_parse::ast::{self, Defs, PrecedenceConflict, StrLiteral}; use roc_parse::ident::Accessor; use roc_parse::pattern::PatternType::*; @@ -107,6 +108,12 @@ pub enum Expr { // Lookups Var(Symbol, Variable), + /// Like Var, but from a module with params + ParamsVar { + symbol: Symbol, + params: Symbol, + var: Variable, + }, AbilityMember( /// Actual member name Symbol, @@ -177,6 +184,9 @@ pub enum Expr { elems: Vec<(Variable, Box>)>, }, + /// Module params expression in import + ImportParams(ModuleId, Region, Option<(Variable, Box)>), + /// The "crash" keyword Crash { msg: Box>, @@ -308,6 +318,11 @@ impl Expr { Self::SingleQuote(..) => Category::Character, Self::List { .. } => Category::List, &Self::Var(sym, _) => Category::Lookup(sym), + &Self::ParamsVar { + symbol, + params: _, + var: _, + } => Category::Lookup(symbol), &Self::AbilityMember(sym, _, _) => Category::Lookup(sym), Self::When { .. } => Category::When, Self::If { .. } => Category::If, @@ -324,6 +339,8 @@ impl Expr { Self::RecordAccessor(data) => Category::Accessor(data.field.clone()), Self::TupleAccess { index, .. } => Category::TupleAccess(*index), Self::RecordUpdate { .. } => Category::Record, + Self::ImportParams(_, _, Some((_, expr))) => expr.category(), + Self::ImportParams(_, _, None) => Category::Unknown, Self::Tag { name, arguments, .. } => Category::TagApply { @@ -632,33 +649,8 @@ pub fn canonicalize_expr<'a>( (answer, Output::default()) } ast::Expr::Record(fields) => { - if fields.is_empty() { - (EmptyRecord, Output::default()) - } else { - match canonicalize_fields(env, var_store, scope, region, fields.items) { - Ok((can_fields, output)) => ( - Record { - record_var: var_store.fresh(), - fields: can_fields, - }, - output, - ), - Err(CanonicalizeRecordProblem::InvalidOptionalValue { - field_name, - field_region, - record_region, - }) => ( - Expr::RuntimeError(roc_problem::can::RuntimeError::InvalidOptionalValue { - field_name, - field_region, - record_region, - }), - Output::default(), - ), - } - } + canonicalize_record(env, var_store, scope, region, *fields) } - ast::Expr::RecordUpdate { fields, update: loc_update, @@ -1452,6 +1444,42 @@ pub fn canonicalize_expr<'a>( ) } +pub fn canonicalize_record<'a>( + env: &mut Env<'a>, + var_store: &mut VarStore, + scope: &mut Scope, + region: Region, + fields: ast::Collection<'a, Loc>>>, +) -> (Expr, Output) { + use Expr::*; + + if fields.is_empty() { + (EmptyRecord, Output::default()) + } else { + match canonicalize_fields(env, var_store, scope, region, fields.items) { + Ok((can_fields, output)) => ( + Record { + record_var: var_store.fresh(), + fields: can_fields, + }, + output, + ), + Err(CanonicalizeRecordProblem::InvalidOptionalValue { + field_name, + field_region, + record_region, + }) => ( + Expr::RuntimeError(roc_problem::can::RuntimeError::InvalidOptionalValue { + field_name, + field_region, + record_region, + }), + Output::default(), + ), + } + } +} + pub fn canonicalize_closure<'a>( env: &mut Env<'a>, var_store: &mut VarStore, @@ -1846,6 +1874,11 @@ fn canonicalize_field<'a>( field_region: Region::span_across(&label.region, &loc_expr.region), }), + // An ignored value, e.g. `{ _name: 123 }` + IgnoredValue(_, _, _) => { + internal_error!("Somehow an IgnoredValue record field was not desugared!"); + } + // A label with no value, e.g. `{ name }` (this is sugar for { name: name }) LabelOnly(_) => { internal_error!("Somehow a LabelOnly record field was not desugared!"); @@ -1876,19 +1909,19 @@ fn canonicalize_var_lookup( // Since module_name was empty, this is an unqualified var. // Look it up in scope! match scope.lookup_str(ident, region) { - Ok(symbol) => { + Ok(lookup) => { output .references - .insert_value_lookup(symbol, QualifiedReference::Unqualified); + .insert_value_lookup(lookup.symbol, QualifiedReference::Unqualified); - if scope.abilities_store.is_ability_member_name(symbol) { + if scope.abilities_store.is_ability_member_name(lookup.symbol) { AbilityMember( - symbol, + params_in_abilities_unimplemented!(lookup), Some(scope.abilities_store.fresh_specialization_id()), var_store.fresh(), ) } else { - Var(symbol, var_store.fresh()) + lookup_to_expr(lookup, var_store.fresh()) } } Err(problem) => { @@ -1901,19 +1934,19 @@ fn canonicalize_var_lookup( // Since module_name was nonempty, this is a qualified var. // Look it up in the env! match env.qualified_lookup(scope, module_name, ident, region) { - Ok(symbol) => { + Ok(lookup) => { output .references - .insert_value_lookup(symbol, QualifiedReference::Qualified); + .insert_value_lookup(lookup.symbol, QualifiedReference::Qualified); - if scope.abilities_store.is_ability_member_name(symbol) { + if scope.abilities_store.is_ability_member_name(lookup.symbol) { AbilityMember( - symbol, + params_in_abilities_unimplemented!(lookup), Some(scope.abilities_store.fresh_specialization_id()), var_store.fresh(), ) } else { - Var(symbol, var_store.fresh()) + lookup_to_expr(lookup, var_store.fresh()) } } Err(problem) => { @@ -1931,6 +1964,24 @@ fn canonicalize_var_lookup( (can_expr, output) } +fn lookup_to_expr( + SymbolLookup { + symbol, + module_params: params, + }: SymbolLookup, + var: Variable, +) -> Expr { + if let Some(params) = params { + Expr::ParamsVar { + symbol, + params, + var, + } + } else { + Expr::Var(symbol, var) + } +} + /// Currently uses the heuristic of "only inline if it's a builtin" pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr { use Expr::*; @@ -1949,6 +2000,7 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr { | other @ RecordAccessor { .. } | other @ RecordUpdate { .. } | other @ Var(..) + | other @ ParamsVar { .. } | other @ AbilityMember(..) | other @ RunLowLevel { .. } | other @ TypedHole { .. } @@ -2212,6 +2264,14 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr { ); } + ImportParams(module_id, region, Some((var, expr))) => ImportParams( + module_id, + region, + Some((var, Box::new(inline_calls(var_store, *expr)))), + ), + + ImportParams(module_id, region, None) => ImportParams(module_id, region, None), + RecordAccess { record_var, ext_var, @@ -2433,7 +2493,8 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool { } ast::Expr::Record(fields) => fields.iter().all(|loc_field| match loc_field.value { ast::AssignedField::RequiredValue(_label, loc_comments, loc_val) - | ast::AssignedField::OptionalValue(_label, loc_comments, loc_val) => { + | ast::AssignedField::OptionalValue(_label, loc_comments, loc_val) + | ast::AssignedField::IgnoredValue(_label, loc_comments, loc_val) => { loc_comments.is_empty() && is_valid_interpolation(&loc_val.value) } ast::AssignedField::Malformed(_) | ast::AssignedField::LabelOnly(_) => true, @@ -2481,7 +2542,8 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool { is_valid_interpolation(&update.value) && fields.iter().all(|loc_field| match loc_field.value { ast::AssignedField::RequiredValue(_label, loc_comments, loc_val) - | ast::AssignedField::OptionalValue(_label, loc_comments, loc_val) => { + | ast::AssignedField::OptionalValue(_label, loc_comments, loc_val) + | ast::AssignedField::IgnoredValue(_label, loc_comments, loc_val) => { loc_comments.is_empty() && is_valid_interpolation(&loc_val.value) } ast::AssignedField::Malformed(_) | ast::AssignedField::LabelOnly(_) => true, @@ -2514,7 +2576,8 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool { is_valid_interpolation(&mapper.value) && fields.iter().all(|loc_field| match loc_field.value { ast::AssignedField::RequiredValue(_label, loc_comments, loc_val) - | ast::AssignedField::OptionalValue(_label, loc_comments, loc_val) => { + | ast::AssignedField::OptionalValue(_label, loc_comments, loc_val) + | ast::AssignedField::IgnoredValue(_label, loc_comments, loc_val) => { loc_comments.is_empty() && is_valid_interpolation(&loc_val.value) } ast::AssignedField::Malformed(_) | ast::AssignedField::LabelOnly(_) => true, @@ -3133,6 +3196,11 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec { while let Some(expr) = stack.pop() { match expr { Expr::Var(symbol, var) + | Expr::ParamsVar { + symbol, + params: _, + var, + } | Expr::RecordUpdate { symbol, record_var: var, @@ -3237,6 +3305,9 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec { Expr::Tuple { elems, .. } => { stack.extend(elems.iter().map(|(_, elem)| &elem.value)); } + Expr::ImportParams(_, _, Some((_, expr))) => { + stack.push(expr); + } Expr::Expect { loc_continuation, .. } @@ -3263,6 +3334,7 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec { | Expr::EmptyRecord | Expr::TypedHole(_) | Expr::RuntimeError(_) + | Expr::ImportParams(_, _, None) | Expr::OpaqueWrapFunction(_) => {} } } diff --git a/crates/compiler/can/src/module.rs b/crates/compiler/can/src/module.rs index d866a04386..ddcbcf4361 100644 --- a/crates/compiler/can/src/module.rs +++ b/crates/compiler/can/src/module.rs @@ -6,9 +6,11 @@ use crate::def::{canonicalize_defs, report_unused_imports, Def}; use crate::effect_module::HostedGeneratedFunctions; use crate::env::Env; use crate::expr::{ - ClosureData, DbgLookup, Declarations, ExpectLookup, Expr, Output, PendingDerives, + AnnotatedMark, ClosureData, DbgLookup, Declarations, ExpectLookup, Expr, Output, PendingDerives, +}; +use crate::pattern::{ + canonicalize_record_destructure, BindingsFromPattern, Pattern, PermitShadows, }; -use crate::pattern::{BindingsFromPattern, Pattern}; use crate::procedure::References; use crate::scope::Scope; use bumpalo::Bump; @@ -18,7 +20,7 @@ use roc_module::ident::Ident; use roc_module::ident::Lowercase; use roc_module::symbol::{IdentIds, IdentIdsByModule, ModuleId, PackageModuleIds, Symbol}; use roc_parse::ast::{Defs, TypeAnnotation}; -use roc_parse::header::HeaderType; +use roc_parse::header::{HeaderType, ModuleParams}; use roc_parse::pattern::PatternType; use roc_problem::can::{Problem, RuntimeError}; use roc_region::all::{Loc, Region}; @@ -136,6 +138,7 @@ pub struct Module { pub abilities_store: PendingAbilitiesStore, pub loc_expects: VecMap>, pub loc_dbgs: VecMap, + pub params_pattern: Option<(Variable, AnnotatedMark, Loc)>, } #[derive(Debug, Default)] @@ -149,6 +152,7 @@ pub struct RigidVariables { pub struct ModuleOutput { pub aliases: MutMap, pub rigid_variables: RigidVariables, + pub params_pattern: Option<(Variable, AnnotatedMark, Loc)>, pub declarations: Declarations, pub exposed_imports: MutMap, pub exposed_symbols: VecSet, @@ -244,6 +248,7 @@ impl GeneratedInfo { generates_with, name: _, exposes: _, + opt_params: _, } => { debug_assert!(generates_with.is_empty()); GeneratedInfo::Builtin @@ -274,7 +279,7 @@ fn has_no_implementation(expr: &Expr) -> bool { pub fn canonicalize_module_defs<'a>( arena: &'a Bump, loc_defs: &'a mut Defs<'a>, - header_type: &roc_parse::header::HeaderType, + header_type: &'a roc_parse::header::HeaderType, home: ModuleId, module_path: &'a str, src: &'a str, @@ -290,6 +295,7 @@ pub fn canonicalize_module_defs<'a>( opt_shorthand: Option<&'a str>, ) -> ModuleOutput { let mut can_exposed_imports = MutMap::default(); + let mut scope = Scope::new( home, qualified_module_ids @@ -382,9 +388,42 @@ pub fn canonicalize_module_defs<'a>( } } + let mut output = Output::default(); + + let params_pattern = header_type.get_params().as_ref().map( + |ModuleParams { + pattern, + before_arrow: _, + after_arrow: _, + }| { + let can_pattern = canonicalize_record_destructure( + &mut env, + var_store, + &mut scope, + &mut output, + PatternType::ModuleParams, + &pattern.value, + pattern.region, + PermitShadows(false), + ); + + let loc_pattern = Loc::at(pattern.region, can_pattern); + + for (symbol, _) in BindingsFromPattern::new(&loc_pattern) { + env.top_level_symbols.insert(symbol); + } + + ( + var_store.fresh(), + AnnotatedMark::new(var_store), + loc_pattern, + ) + }, + ); + let (defs, output, symbols_introduced, imports_introduced) = canonicalize_defs( &mut env, - Output::default(), + output, var_store, &mut scope, loc_defs, @@ -812,6 +851,7 @@ pub fn canonicalize_module_defs<'a>( scope, aliases, rigid_variables, + params_pattern, declarations, referenced_values, exposed_imports: can_exposed_imports, @@ -1105,6 +1145,7 @@ fn fix_values_captured_in_closure_expr( | SingleQuote(..) | IngestedFile(..) | Var(..) + | ParamsVar { .. } | AbilityMember(..) | EmptyRecord | TypedHole { .. } @@ -1216,6 +1257,12 @@ fn fix_values_captured_in_closure_expr( } } + ImportParams(_, _, Some((_, expr))) => { + fix_values_captured_in_closure_expr(expr, no_capture_symbols, closure_captures); + } + + ImportParams(_, _, None) => {} + Tuple { elems, .. } => { for (_var, expr) in elems.iter_mut() { fix_values_captured_in_closure_expr( diff --git a/crates/compiler/can/src/pattern.rs b/crates/compiler/can/src/pattern.rs index dc3a7d7dfe..129236bb46 100644 --- a/crates/compiler/can/src/pattern.rs +++ b/crates/compiler/can/src/pattern.rs @@ -623,132 +623,16 @@ pub fn canonicalize_pattern<'a>( } } - RecordDestructure(patterns) => { - let ext_var = var_store.fresh(); - let whole_var = var_store.fresh(); - let mut destructs = Vec::with_capacity(patterns.len()); - let mut opt_erroneous = None; - - for loc_pattern in patterns.iter() { - match loc_pattern.value { - Identifier { ident: label } => { - match scope.introduce(label.into(), region) { - Ok(symbol) => { - output.references.insert_bound(symbol); - - destructs.push(Loc { - region: loc_pattern.region, - value: RecordDestruct { - var: var_store.fresh(), - label: Lowercase::from(label), - symbol, - typ: DestructType::Required, - }, - }); - } - Err((shadowed_symbol, shadow, new_symbol)) => { - env.problem(Problem::RuntimeError(RuntimeError::Shadowing { - original_region: shadowed_symbol.region, - shadow: shadow.clone(), - kind: ShadowKind::Variable, - })); - - // No matter what the other patterns - // are, we're definitely shadowed and will - // get a runtime exception as soon as we - // encounter the first bad pattern. - opt_erroneous = Some(Pattern::Shadowed( - shadowed_symbol.region, - shadow, - new_symbol, - )); - } - }; - } - - RequiredField(label, loc_guard) => { - // a guard does not introduce the label into scope! - let symbol = - scope.scopeless_symbol(&Ident::from(label), loc_pattern.region); - let can_guard = canonicalize_pattern( - env, - var_store, - scope, - output, - pattern_type, - &loc_guard.value, - loc_guard.region, - permit_shadows, - ); - - destructs.push(Loc { - region: loc_pattern.region, - value: RecordDestruct { - var: var_store.fresh(), - label: Lowercase::from(label), - symbol, - typ: DestructType::Guard(var_store.fresh(), can_guard), - }, - }); - } - OptionalField(label, loc_default) => { - // an optional DOES introduce the label into scope! - match scope.introduce(label.into(), region) { - Ok(symbol) => { - let (can_default, expr_output) = canonicalize_expr( - env, - var_store, - scope, - loc_default.region, - &loc_default.value, - ); - - // an optional field binds the symbol! - output.references.insert_bound(symbol); - - output.union(expr_output); - - destructs.push(Loc { - region: loc_pattern.region, - value: RecordDestruct { - var: var_store.fresh(), - label: Lowercase::from(label), - symbol, - typ: DestructType::Optional(var_store.fresh(), can_default), - }, - }); - } - Err((shadowed_symbol, shadow, new_symbol)) => { - env.problem(Problem::RuntimeError(RuntimeError::Shadowing { - original_region: shadowed_symbol.region, - shadow: shadow.clone(), - kind: ShadowKind::Variable, - })); - - // No matter what the other patterns - // are, we're definitely shadowed and will - // get a runtime exception as soon as we - // encounter the first bad pattern. - opt_erroneous = Some(Pattern::Shadowed( - shadowed_symbol.region, - shadow, - new_symbol, - )); - } - }; - } - _ => unreachable!("Any other pattern should have given a parse error"), - } - } - - // If we encountered an erroneous pattern (e.g. one with shadowing), - // use the resulting RuntimeError. Otherwise, return a successful record destructure. - opt_erroneous.unwrap_or(Pattern::RecordDestructure { - whole_var, - ext_var, - destructs, - }) - } + RecordDestructure(patterns) => canonicalize_record_destructure( + env, + var_store, + scope, + output, + pattern_type, + patterns, + region, + permit_shadows, + ), RequiredField(_name, _loc_pattern) => { unreachable!("should have been handled in RecordDestructure"); @@ -894,6 +778,144 @@ pub fn canonicalize_pattern<'a>( } } +#[allow(clippy::too_many_arguments)] +pub fn canonicalize_record_destructure<'a>( + env: &mut Env<'a>, + var_store: &mut VarStore, + scope: &mut Scope, + output: &mut Output, + pattern_type: PatternType, + patterns: &ast::Collection>>, + region: Region, + permit_shadows: PermitShadows, +) -> Pattern { + use ast::Pattern::*; + + let ext_var = var_store.fresh(); + let whole_var = var_store.fresh(); + let mut destructs = Vec::with_capacity(patterns.len()); + let mut opt_erroneous = None; + + for loc_pattern in patterns.iter() { + match loc_pattern.value { + Identifier { ident: label } => { + match scope.introduce(label.into(), region) { + Ok(symbol) => { + output.references.insert_bound(symbol); + + destructs.push(Loc { + region: loc_pattern.region, + value: RecordDestruct { + var: var_store.fresh(), + label: Lowercase::from(label), + symbol, + typ: DestructType::Required, + }, + }); + } + Err((shadowed_symbol, shadow, new_symbol)) => { + env.problem(Problem::RuntimeError(RuntimeError::Shadowing { + original_region: shadowed_symbol.region, + shadow: shadow.clone(), + kind: ShadowKind::Variable, + })); + + // No matter what the other patterns + // are, we're definitely shadowed and will + // get a runtime exception as soon as we + // encounter the first bad pattern. + opt_erroneous = Some(Pattern::Shadowed( + shadowed_symbol.region, + shadow, + new_symbol, + )); + } + }; + } + + RequiredField(label, loc_guard) => { + // a guard does not introduce the label into scope! + let symbol = scope.scopeless_symbol(&Ident::from(label), loc_pattern.region); + let can_guard = canonicalize_pattern( + env, + var_store, + scope, + output, + pattern_type, + &loc_guard.value, + loc_guard.region, + permit_shadows, + ); + + destructs.push(Loc { + region: loc_pattern.region, + value: RecordDestruct { + var: var_store.fresh(), + label: Lowercase::from(label), + symbol, + typ: DestructType::Guard(var_store.fresh(), can_guard), + }, + }); + } + OptionalField(label, loc_default) => { + // an optional DOES introduce the label into scope! + match scope.introduce(label.into(), region) { + Ok(symbol) => { + let (can_default, expr_output) = canonicalize_expr( + env, + var_store, + scope, + loc_default.region, + &loc_default.value, + ); + + // an optional field binds the symbol! + output.references.insert_bound(symbol); + + output.union(expr_output); + + destructs.push(Loc { + region: loc_pattern.region, + value: RecordDestruct { + var: var_store.fresh(), + label: Lowercase::from(label), + symbol, + typ: DestructType::Optional(var_store.fresh(), can_default), + }, + }); + } + Err((shadowed_symbol, shadow, new_symbol)) => { + env.problem(Problem::RuntimeError(RuntimeError::Shadowing { + original_region: shadowed_symbol.region, + shadow: shadow.clone(), + kind: ShadowKind::Variable, + })); + + // No matter what the other patterns + // are, we're definitely shadowed and will + // get a runtime exception as soon as we + // encounter the first bad pattern. + opt_erroneous = Some(Pattern::Shadowed( + shadowed_symbol.region, + shadow, + new_symbol, + )); + } + }; + } + _ => unreachable!("Any other pattern should have given a parse error"), + } + } + + // If we encountered an erroneous pattern (e.g. one with shadowing), + // use the resulting RuntimeError. Otherwise, return a successful record destructure. + opt_erroneous.unwrap_or(Pattern::RecordDestructure { + whole_var, + ext_var, + destructs, + }) +} + /// When we detect an unsupported pattern type (e.g. 5 = 1 + 2 is unsupported because you can't /// assign to Int patterns), report it to Env and return an UnsupportedPattern runtime error pattern. fn unsupported_pattern(env: &mut Env, pattern_type: PatternType, region: Region) -> Pattern { diff --git a/crates/compiler/can/src/scope.rs b/crates/compiler/can/src/scope.rs index c157659c37..6de854fa80 100644 --- a/crates/compiler/can/src/scope.rs +++ b/crates/compiler/can/src/scope.rs @@ -1,8 +1,8 @@ use roc_collections::{VecMap, VecSet}; use roc_error_macros::internal_error; use roc_module::ident::{Ident, ModuleName}; -use roc_module::symbol::{IdentId, IdentIds, ModuleId, ScopeModules, Symbol}; -use roc_problem::can::RuntimeError; +use roc_module::symbol::{IdentId, IdentIds, ModuleId, ModuleIds, Symbol}; +use roc_problem::can::{RuntimeError, ScopeModuleSource}; use roc_region::all::{Loc, Region}; use roc_types::subs::Variable; use roc_types::types::{Alias, AliasKind, AliasVar, Type}; @@ -76,7 +76,7 @@ impl Scope { } } - pub fn lookup(&self, ident: &Ident, region: Region) -> Result { + pub fn lookup(&self, ident: &Ident, region: Region) -> Result { self.lookup_str(ident.as_str(), region) } @@ -91,7 +91,7 @@ impl Scope { .push(("Set".into(), Symbol::SET_SET, Region::zero())); } - pub fn lookup_str(&self, ident: &str, region: Region) -> Result { + pub fn lookup_str(&self, ident: &str, region: Region) -> Result { use ContainsIdent::*; match self.scope_contains_ident(ident) { @@ -205,14 +205,19 @@ impl Scope { } } - fn has_imported_symbol(&self, ident: &str) -> Option<(Symbol, Region)> { - for (import, shadow, original_region) in self.imported_symbols.iter() { - if ident == import.as_str() { - return Some((*shadow, *original_region)); - } - } - - None + fn has_imported_symbol(&self, ident: &str) -> Option<(SymbolLookup, Region)> { + self.imported_symbols + .iter() + .find_map(|(import, symbol, original_region)| { + if ident == import.as_str() { + match self.modules.lookup_by_id(&symbol.module_id()) { + Some(module) => Some((module.into_symbol(*symbol), *original_region)), + None => Some((SymbolLookup::no_params(*symbol), *original_region)), + } + } else { + None + } + }) } /// Is an identifier in scope, either in the locals or imports @@ -229,7 +234,7 @@ impl Scope { ContainsIdent::InScope(original_symbol, original_region) => { // the ident is already in scope; up to the caller how to handle that // (usually it's shadowing, but it is valid to shadow ability members) - Err((original_symbol, original_region)) + Err((original_symbol.symbol, original_region)) } ContainsIdent::NotPresent => { // We know nothing about this ident yet; introduce it to the scope @@ -389,7 +394,13 @@ impl Scope { region: Region, ) -> Result<(), (Symbol, Region)> { match self.scope_contains_ident(ident.as_str()) { - ContainsIdent::InScope(symbol, region) => Err((symbol, region)), + ContainsIdent::InScope( + SymbolLookup { + symbol, + module_params: _, + }, + region, + ) => Err((symbol, region)), ContainsIdent::NotPresent | ContainsIdent::NotInScope(_) => { self.imported_symbols.push((ident, symbol, region)); Ok(()) @@ -534,7 +545,7 @@ pub fn create_alias( #[derive(Debug)] enum ContainsIdent { - InScope(Symbol, Region), + InScope(SymbolLookup, Region), NotInScope(IdentId), NotPresent, } @@ -561,7 +572,7 @@ impl ScopedIdentIds { fn has_in_scope(&self, ident: &Ident) -> Option<(Symbol, Region)> { match self.contains_ident(ident.as_str()) { - ContainsIdent::InScope(symbol, region) => Some((symbol, region)), + ContainsIdent::InScope(symbol, region) => Some((symbol.symbol, region)), ContainsIdent::NotInScope(_) | ContainsIdent::NotPresent => None, } } @@ -574,7 +585,10 @@ impl ScopedIdentIds { for ident_id in self.ident_ids.get_id_many(ident) { let index = ident_id.index(); if self.in_scope[index] { - return InScope(Symbol::new(self.home, ident_id), self.regions[index]); + return InScope( + SymbolLookup::no_params(Symbol::new(self.home, ident_id)), + self.regions[index], + ); } else { result = NotInScope(ident_id) } @@ -646,6 +660,149 @@ impl ScopedIdentIds { } } +#[derive(Debug, Clone)] +pub struct ScopeModules { + /// The ids of all modules in scope + ids: Vec, + /// The alias or original name of each module in scope + names: Vec, + /// Why is this module in scope? + sources: Vec, + /// The params of a module if any + params: Vec>, +} + +impl ScopeModules { + pub fn new(home_id: ModuleId, home_name: ModuleName) -> Self { + let builtins = ModuleIds::default(); + let builtins_iter = builtins.iter(); + let count = builtins_iter.len(); + + let mut ids = Vec::with_capacity(count + 1); + let mut names = Vec::with_capacity(count + 1); + let mut sources = vec![ScopeModuleSource::Builtin; count]; + let mut params = vec![None; count]; + + for (module_id, module_name) in builtins_iter { + ids.push(module_id); + names.push(module_name.clone()); + } + + if !home_id.is_builtin() { + ids.push(home_id); + names.push(home_name); + sources.push(ScopeModuleSource::Current); + params.push(None); + } + + Self { + ids, + names, + sources, + params, + } + } + + pub fn lookup(&self, module_name: &ModuleName) -> Option { + self.names + .iter() + .position(|name| name == module_name) + .map(|index| ModuleLookup { + id: self.ids[index], + params: self.params[index], + }) + } + + pub fn lookup_by_id(&self, module_id: &ModuleId) -> Option { + self.ids + .iter() + .position(|id| id == module_id) + .map(|index| ModuleLookup { + id: self.ids[index], + params: self.params[index], + }) + } + + pub fn available_names(&self) -> impl Iterator { + self.names.iter() + } + + pub fn insert( + &mut self, + module_name: ModuleName, + module_id: ModuleId, + params_symbol: Option, + region: Region, + ) -> Result<(), ScopeModuleSource> { + if let Some(index) = self.names.iter().position(|name| name == &module_name) { + if self.ids[index] == module_id { + return Ok(()); + } + + return Err(self.sources[index]); + } + + self.ids.push(module_id); + self.names.push(module_name); + self.sources.push(ScopeModuleSource::Import(region)); + self.params.push(params_symbol); + Ok(()) + } + + pub fn len(&self) -> usize { + debug_assert_eq!(self.ids.len(), self.names.len()); + debug_assert_eq!(self.ids.len(), self.sources.len()); + debug_assert_eq!(self.ids.len(), self.params.len()); + self.ids.len() + } + + pub fn is_empty(&self) -> bool { + self.ids.is_empty() + } + + pub fn truncate(&mut self, len: usize) { + self.ids.truncate(len); + self.names.truncate(len); + self.sources.truncate(len); + self.params.truncate(len); + } +} + +#[derive(Debug, Clone)] +pub struct SymbolLookup { + pub symbol: Symbol, + pub module_params: Option, +} + +impl SymbolLookup { + pub fn new(symbol: Symbol, params: Option) -> Self { + Self { + symbol, + module_params: params, + } + } + + pub fn no_params(symbol: Symbol) -> Self { + Self::new(symbol, None) + } +} + +pub struct ModuleLookup { + pub id: ModuleId, + pub params: Option, +} + +impl ModuleLookup { + pub fn into_symbol(&self, symbol: Symbol) -> SymbolLookup { + debug_assert_eq!(symbol.module_id(), self.id); + + SymbolLookup { + symbol, + module_params: self.params, + } + } +} + #[cfg(test)] mod test { use super::*; @@ -701,7 +858,7 @@ mod test { let lookup = scope.lookup(&ident, Region::zero()).unwrap(); - assert_eq!(first, lookup); + assert_eq!(first, lookup.symbol); } #[test] @@ -857,6 +1014,6 @@ mod test { let lookup = scope.lookup(&ident, Region::zero()).unwrap(); - assert_eq!(symbol, lookup); + assert_eq!(symbol, lookup.symbol); } } diff --git a/crates/compiler/can/src/traverse.rs b/crates/compiler/can/src/traverse.rs index 3f044eed37..9293f457ab 100644 --- a/crates/compiler/can/src/traverse.rs +++ b/crates/compiler/can/src/traverse.rs @@ -266,6 +266,7 @@ pub fn walk_expr(visitor: &mut V, expr: &Expr, var: Variable) { walk_list(visitor, *elem_var, loc_elems); } Expr::Var(..) => { /* terminal */ } + Expr::ParamsVar { .. } => { /* terminal */ } Expr::AbilityMember(..) => { /* terminal */ } Expr::If { cond_var, @@ -317,6 +318,8 @@ pub fn walk_expr(visitor: &mut V, expr: &Expr, var: Variable) { .iter() .for_each(|(var, elem)| visitor.visit_expr(&elem.value, elem.region, *var)), Expr::EmptyRecord => { /* terminal */ } + Expr::ImportParams(_, region, Some((_, expr))) => visitor.visit_expr(expr, *region, var), + Expr::ImportParams(_, _, None) => { /* terminal */ } Expr::RecordAccess { field_var, loc_expr, diff --git a/crates/compiler/constrain/src/expr.rs b/crates/compiler/constrain/src/expr.rs index 5ec8153eb8..2b7448925b 100644 --- a/crates/compiler/constrain/src/expr.rs +++ b/crates/compiler/constrain/src/expr.rs @@ -566,7 +566,12 @@ pub fn constrain_expr( constraints.exists([*ret_var], and) } - Var(symbol, variable) => { + Var(symbol, variable) + | ParamsVar { + symbol, + params: _, + var: variable, + } => { // Save the expectation in the variable, then lookup the symbol's type in the environment let expected_type = *constraints[expected].get_type_ref(); let store_expected = constraints.store(expected_type, *variable, file!(), line!()); @@ -575,6 +580,22 @@ pub fn constrain_expr( constraints.and_constraint([store_expected, lookup_constr]) } + ImportParams(module_id, region, Some((var, params))) => { + let index = constraints.push_variable(*var); + let expected_params = constraints.push_expected_type(Expected::ForReason( + Reason::ImportParams(*module_id), + index, + *region, + )); + let expr_con = + constrain_expr(types, constraints, env, *region, params, expected_params); + let params_con = constraints.import_params(Some(index), *module_id, *region); + let expr_and_params = constraints.and_constraint([expr_con, params_con]); + constraints.exists([*var], expr_and_params) + } + ImportParams(module_id, region, None) => { + constraints.import_params(None, *module_id, *region) + } &AbilityMember(symbol, specialization_id, specialization_var) => { // Save the expectation in the `specialization_var` so we know what to specialize, then // lookup the member in the environment. @@ -4089,6 +4110,8 @@ fn is_generalizable_expr(mut expr: &Expr) -> bool { return true; } OpaqueRef { argument, .. } => expr = &argument.1.value, + ImportParams(_, _, Some((_, params))) => expr = params, + ImportParams(_, _, None) => return false, Str(_) | IngestedFile(..) | List { .. } @@ -4115,7 +4138,8 @@ fn is_generalizable_expr(mut expr: &Expr) -> bool { | ZeroArgumentTag { .. } | Tag { .. } | AbilityMember(..) - | Var(..) => return false, + | Var(..) + | ParamsVar { .. } => return false, } } } diff --git a/crates/compiler/constrain/src/module.rs b/crates/compiler/constrain/src/module.rs index 545aa9d5a9..f1742216b8 100644 --- a/crates/compiler/constrain/src/module.rs +++ b/crates/compiler/constrain/src/module.rs @@ -1,11 +1,15 @@ use crate::expr::{constrain_def_make_constraint, constrain_def_pattern, Env}; +use crate::pattern::{constrain_pattern, PatternState}; use roc_can::abilities::{PendingAbilitiesStore, PendingMemberType}; use roc_can::constraint::{Constraint, Constraints, Generalizable}; -use roc_can::expected::Expected; -use roc_can::expr::Declarations; +use roc_can::expected::{Expected, PExpected}; +use roc_can::expr::{AnnotatedMark, Declarations}; use roc_can::pattern::Pattern; +use roc_collections::MutMap; +use roc_error_macros::internal_error; use roc_module::symbol::{ModuleId, Symbol}; use roc_region::all::{Loc, Region}; +use roc_types::subs::Variable; use roc_types::types::{AnnotationSource, Category, Type, Types}; pub fn constrain_module( @@ -14,9 +18,18 @@ pub fn constrain_module( symbols_from_requires: Vec<(Loc, Loc)>, abilities_store: &PendingAbilitiesStore, declarations: &Declarations, + params_pattern: &Option<(Variable, AnnotatedMark, Loc)>, home: ModuleId, ) -> Constraint { let constraint = crate::expr::constrain_decls(types, constraints, home, declarations); + + let constraint = match params_pattern { + Some(params_pattern) => { + constrain_params(types, constraints, home, constraint, params_pattern) + } + None => constraint, + }; + let constraint = constrain_symbols_from_requires( types, constraints, @@ -33,6 +46,63 @@ pub fn constrain_module( constraint } +fn constrain_params( + types: &mut Types, + constraints: &mut Constraints, + home: ModuleId, + constraint: Constraint, + (pattern_var, _, loc_pattern): &(Variable, AnnotatedMark, Loc), +) -> Constraint { + let mut env = Env { + home, + rigids: MutMap::default(), + resolutions_to_make: vec![], + }; + + let index = constraints.push_variable(*pattern_var); + let expected_params = constraints.push_pat_expected_type(PExpected::NoExpectation(index)); + + let mut state = PatternState::default(); + + let closed_con = match loc_pattern.value { + Pattern::RecordDestructure { + whole_var: _, + ext_var, + destructs: _, + } => { + // Disallow record extension for module params + let empty_rec = constraints.push_type(types, Types::EMPTY_RECORD); + constraints.store(empty_rec, ext_var, file!(), line!()) + } + _ => internal_error!("Only record destructures are allowed in module params. This should've been caught earlier."), + }; + + state.constraints.push(closed_con); + + constrain_pattern( + types, + constraints, + &mut env, + &loc_pattern.value, + loc_pattern.region, + expected_params, + &mut state, + ); + + let pattern_constraints = constraints.and_constraint(state.constraints); + + let cons = constraints.let_constraint( + [], + state.vars, + state.headers, + pattern_constraints, + constraint, + Generalizable(true), + ); + + constraints.exists([*pattern_var], cons) +} + fn constrain_symbols_from_requires( types: &mut Types, constraints: &mut Constraints, diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index 25076b5940..b279a8fc9c 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -428,9 +428,9 @@ fn is_multiline_assigned_field_help(afield: &AssignedField<'_, T use self::AssignedField::*; match afield { - RequiredValue(_, spaces, ann) | OptionalValue(_, spaces, ann) => { - !spaces.is_empty() || ann.value.is_multiline() - } + RequiredValue(_, spaces, ann) + | OptionalValue(_, spaces, ann) + | IgnoredValue(_, spaces, ann) => !spaces.is_empty() || ann.value.is_multiline(), LabelOnly(_) => false, AssignedField::SpaceBefore(_, _) | AssignedField::SpaceAfter(_, _) => true, Malformed(text) => text.chars().any(|c| c == '\n'), @@ -483,6 +483,24 @@ fn format_assigned_field_help( buf.spaces(1); ann.value.format(buf, indent); } + IgnoredValue(name, spaces, ann) => { + if is_multiline { + buf.newline(); + } + + buf.indent(indent); + buf.push('_'); + buf.push_str(name.value); + + if !spaces.is_empty() { + fmt_spaces(buf, spaces.iter(), indent); + } + + buf.spaces(separator_spaces); + buf.push(':'); + buf.spaces(1); + ann.value.format(buf, indent); + } LabelOnly(name) => { if is_multiline { buf.newline(); diff --git a/crates/compiler/fmt/src/def.rs b/crates/compiler/fmt/src/def.rs index b3b2abd0c9..642dab3f54 100644 --- a/crates/compiler/fmt/src/def.rs +++ b/crates/compiler/fmt/src/def.rs @@ -252,14 +252,14 @@ impl<'a> Formattable for ModuleImportParams<'a> { fn is_multiline(&self) -> bool { let ModuleImportParams { before, params } = self; - !before.is_empty() || is_collection_multiline(params) + !before.is_empty() || is_collection_multiline(¶ms.value) } fn format_with_options(&self, buf: &mut Buf, _parens: Parens, newlines: Newlines, indent: u16) { let ModuleImportParams { before, params } = self; fmt_default_spaces(buf, before, indent); - fmt_collection(buf, indent, Braces::Curly, *params, newlines); + fmt_collection(buf, indent, Braces::Curly, params.value, newlines); } } diff --git a/crates/compiler/fmt/src/expr.rs b/crates/compiler/fmt/src/expr.rs index 7793bd125d..04544ea2c6 100644 --- a/crates/compiler/fmt/src/expr.rs +++ b/crates/compiler/fmt/src/expr.rs @@ -1529,6 +1529,23 @@ fn format_assigned_field_multiline( ann.value.format(buf, indent); buf.push(','); } + IgnoredValue(name, spaces, ann) => { + buf.newline(); + buf.indent(indent); + buf.push('_'); + buf.push_str(name.value); + + if !spaces.is_empty() { + fmt_spaces(buf, spaces.iter(), indent); + buf.indent(indent); + } + + buf.push_str(separator_prefix); + buf.push_str(":"); + buf.spaces(1); + ann.value.format(buf, indent); + buf.push(','); + } LabelOnly(name) => { buf.newline(); buf.indent(indent); diff --git a/crates/compiler/fmt/src/module.rs b/crates/compiler/fmt/src/header.rs similarity index 96% rename from crates/compiler/fmt/src/module.rs rename to crates/compiler/fmt/src/header.rs index 76568f85af..e76018956b 100644 --- a/crates/compiler/fmt/src/module.rs +++ b/crates/compiler/fmt/src/header.rs @@ -5,7 +5,7 @@ use crate::collection::{fmt_collection, Braces}; use crate::expr::fmt_str_literal; use crate::spaces::{fmt_comments_only, fmt_default_spaces, fmt_spaces, NewlineAt, INDENT}; use crate::Buf; -use roc_parse::ast::{Collection, CommentOrNewline, Header, Module, Spaced, Spaces}; +use roc_parse::ast::{Collection, CommentOrNewline, Header, Spaced, Spaces, SpacesBefore}; use roc_parse::header::{ AppHeader, ExposedName, ExposesKeyword, GeneratesKeyword, HostedHeader, ImportsEntry, ImportsKeyword, Keyword, KeywordItem, ModuleHeader, ModuleName, PackageEntry, PackageHeader, @@ -16,9 +16,9 @@ use roc_parse::header::{ use roc_parse::ident::UppercaseIdent; use roc_region::all::Loc; -pub fn fmt_module<'a>(buf: &mut Buf<'_>, module: &'a Module<'a>) { - fmt_comments_only(buf, module.comments.iter(), NewlineAt::Bottom, 0); - match &module.header { +pub fn fmt_header<'a>(buf: &mut Buf<'_>, header: &'a SpacesBefore<'a, Header<'a>>) { + fmt_comments_only(buf, header.before.iter(), NewlineAt::Bottom, 0); + match &header.item { Header::Module(header) => { fmt_module_header(buf, header); } @@ -174,11 +174,17 @@ pub fn fmt_module_header<'a>(buf: &mut Buf, header: &'a ModuleHeader<'a>) { let mut indent = fmt_spaces_with_outdent(buf, header.after_keyword, 0); if let Some(params) = &header.params { - if is_collection_multiline(¶ms.params) { + if is_collection_multiline(¶ms.pattern.value) { indent = INDENT; } - fmt_collection(buf, indent, Braces::Curly, params.params, Newlines::Yes); + fmt_collection( + buf, + indent, + Braces::Curly, + params.pattern.value, + Newlines::Yes, + ); indent = fmt_spaces_with_outdent(buf, params.before_arrow, indent); buf.push_str("->"); diff --git a/crates/compiler/fmt/src/lib.rs b/crates/compiler/fmt/src/lib.rs index 88a4974bf0..d92b0152ad 100644 --- a/crates/compiler/fmt/src/lib.rs +++ b/crates/compiler/fmt/src/lib.rs @@ -6,18 +6,11 @@ pub mod annotation; pub mod collection; pub mod def; pub mod expr; -pub mod module; +pub mod header; pub mod pattern; pub mod spaces; use bumpalo::{collections::String, Bump}; -use roc_parse::ast::Module; - -#[derive(Debug)] -pub struct Ast<'a> { - pub module: Module<'a>, - pub defs: roc_parse::ast::Defs<'a>, -} #[derive(Debug)] pub struct Buf<'a> { diff --git a/crates/compiler/fmt/src/spaces.rs b/crates/compiler/fmt/src/spaces.rs index e794a3c67a..7f56ab7176 100644 --- a/crates/compiler/fmt/src/spaces.rs +++ b/crates/compiler/fmt/src/spaces.rs @@ -1,7 +1,6 @@ -use bumpalo::Bump; -use roc_parse::{ast::CommentOrNewline, remove_spaces::RemoveSpaces}; +use roc_parse::ast::CommentOrNewline; -use crate::{Ast, Buf}; +use crate::Buf; /// The number of spaces to indent. pub const INDENT: u16 = 4; @@ -192,12 +191,3 @@ fn fmt_docs(buf: &mut Buf, docs: &str) { } buf.push_str(docs.trim_end()); } - -impl<'a> RemoveSpaces<'a> for Ast<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { - Ast { - module: self.module.remove_spaces(arena), - defs: self.defs.remove_spaces(arena), - } - } -} diff --git a/crates/compiler/load/tests/helpers/mod.rs b/crates/compiler/load/tests/helpers/mod.rs index e8110e4d63..63679c9820 100644 --- a/crates/compiler/load/tests/helpers/mod.rs +++ b/crates/compiler/load/tests/helpers/mod.rs @@ -51,6 +51,8 @@ pub fn infer_expr( exposed_by_module: &Default::default(), derived_module, function_kind: FunctionKind::LambdaSet, + params_pattern: None, + module_params_vars: Default::default(), #[cfg(debug_assertions)] checkmate: None, }; diff --git a/crates/compiler/load/tests/test_reporting.rs b/crates/compiler/load/tests/test_reporting.rs index 54963a2c06..96fd1aa33c 100644 --- a/crates/compiler/load/tests/test_reporting.rs +++ b/crates/compiler/load/tests/test_reporting.rs @@ -16,7 +16,7 @@ mod test_reporting { use roc_load::{self, ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading}; use roc_module::symbol::{Interns, ModuleId}; use roc_packaging::cache::RocCacheDir; - use roc_parse::module::parse_header; + use roc_parse::header::parse_header; use roc_parse::state::State; use roc_parse::test_helpers::parse_expr_with; use roc_problem::Severity; @@ -359,7 +359,7 @@ mod test_reporting { let src_lines: Vec<&str> = src.split('\n').collect(); let lines = LineInfo::new(src); - match roc_parse::module::parse_header(arena, state) { + match roc_parse::header::parse_header(arena, state) { Err(fail) => { let interns = Interns::default(); let home = crate::helpers::test_home(); @@ -10875,12 +10875,12 @@ All branches in an `if` must have the same type! ), @r#" ── EMPTY RECORD BUILDER in /code/proj/Main.roc ───────────────────────────────── - + This record builder has no fields: - + 4│ { a <- } ^^^^^^^^ - + I need at least two fields to combine their values into a record. "# ); @@ -10898,11 +10898,11 @@ All branches in an `if` must have the same type! ── NOT ENOUGH FIELDS IN RECORD BUILDER in /code/proj/Main.roc ────────────────── This record builder only has one field: - + 4│> { a <- 5│> b: 123 6│> } - + I need at least two fields to combine their values into a record. "# ); @@ -10919,14 +10919,14 @@ All branches in an `if` must have the same type! ), @r#" ── OPTIONAL FIELD IN RECORD BUILDER in /code/proj/Main.roc ───────────────────── - + Optional fields are not allowed to be used in record builders. - + 4│ { a <- 5│ b: 123, 6│> c? 456 7│ } - + Record builders can only have required values for their fields. "# ); diff --git a/crates/compiler/load_internal/src/docs.rs b/crates/compiler/load_internal/src/docs.rs index a8aa4505d8..3b4e3c8362 100644 --- a/crates/compiler/load_internal/src/docs.rs +++ b/crates/compiler/load_internal/src/docs.rs @@ -465,7 +465,8 @@ fn contains_unexposed_type( while let Some(field) = fields_to_process.pop() { match field { AssignedField::RequiredValue(_field, _spaces, loc_val) - | AssignedField::OptionalValue(_field, _spaces, loc_val) => { + | AssignedField::OptionalValue(_field, _spaces, loc_val) + | AssignedField::IgnoredValue(_field, _spaces, loc_val) => { if contains_unexposed_type(&loc_val.value, exposed_module_ids, module_ids) { return true; } @@ -721,7 +722,7 @@ fn record_field_to_doc( AssignedField::LabelOnly(label) => Some(RecordField::LabelOnly { name: label.value.to_string(), }), - AssignedField::Malformed(_) => None, + AssignedField::Malformed(_) | AssignedField::IgnoredValue(_, _, _) => None, } } diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index 2e6238c910..8a4af784e9 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -48,11 +48,11 @@ use roc_mono::reset_reuse; use roc_mono::{drop_specialization, inc_dec}; use roc_packaging::cache::RocCacheDir; use roc_parse::ast::{self, CommentOrNewline, ExtractSpaces, Spaced, ValueDef}; +use roc_parse::header::parse_module_defs; use roc_parse::header::{ self, AppHeader, ExposedName, HeaderType, ImportsKeywordItem, PackageEntry, PackageHeader, PlatformHeader, To, TypedIdent, }; -use roc_parse::module::parse_module_defs; use roc_parse::parser::{FileError, SourceError, SyntaxError}; use roc_problem::Severity; use roc_region::all::{LineInfo, Loc, Region}; @@ -1327,8 +1327,8 @@ fn load_packages_from_main<'a>( let parse_state = roc_parse::state::State::new(arena.alloc(src_bytes)); - let (parsed_module, _) = - roc_parse::module::parse_header(arena, parse_state.clone()).map_err(|fail| { + let (parsed_header, _) = + roc_parse::header::parse_header(arena, parse_state.clone()).map_err(|fail| { LoadingProblem::ParsingFailed( fail.map_problem(SyntaxError::Header) .into_file_error(filename.clone()), @@ -1337,7 +1337,7 @@ fn load_packages_from_main<'a>( use ast::Header::*; - let packages = match parsed_module.header { + let packages = match parsed_header.item { App(AppHeader { packages, .. }) | Package(PackageHeader { packages, .. }) => { unspace(arena, packages.value.items) } @@ -2395,6 +2395,13 @@ fn update<'a>( .pending_abilities .insert(module_id, constrained_module.module.abilities_store.clone()); + if let Some(params_pattern) = constrained_module.module.params_pattern.clone() { + state + .module_cache + .param_patterns + .insert(module_id, params_pattern); + } + state .module_cache .constrained @@ -3349,7 +3356,7 @@ fn load_package_from_disk<'a>( let parse_start = Instant::now(); let bytes = arena.alloc(bytes_vec); let parse_state = roc_parse::state::State::new(bytes); - let parsed = roc_parse::module::parse_header(arena, parse_state.clone()); + let parsed = roc_parse::header::parse_header(arena, parse_state.clone()); let parse_header_duration = parse_start.elapsed(); // Insert the first entries for this module's timings @@ -3360,8 +3367,8 @@ fn load_package_from_disk<'a>( match parsed { Ok(( - ast::Module { - header: ast::Header::Module(header), + ast::SpacesBefore { + item: ast::Header::Module(header), .. }, _parse_state, @@ -3369,8 +3376,8 @@ fn load_package_from_disk<'a>( "expected platform/package module, got Module with header\n{header:?}" ))), Ok(( - ast::Module { - header: ast::Header::Hosted(header), + ast::SpacesBefore { + item: ast::Header::Hosted(header), .. }, _parse_state, @@ -3378,8 +3385,8 @@ fn load_package_from_disk<'a>( "expected platform/package module, got Hosted module with header\n{header:?}" ))), Ok(( - ast::Module { - header: ast::Header::App(header), + ast::SpacesBefore { + item: ast::Header::App(header), .. }, _parse_state, @@ -3387,9 +3394,9 @@ fn load_package_from_disk<'a>( "expected platform/package module, got App with header\n{header:?}" ))), Ok(( - ast::Module { - header: ast::Header::Package(header), - comments, + ast::SpacesBefore { + item: ast::Header::Package(header), + before: comments, }, parser_state, )) => { @@ -3430,9 +3437,9 @@ fn load_package_from_disk<'a>( Ok(Msg::Many(messages)) } Ok(( - ast::Module { - header: ast::Header::Platform(header), - comments, + ast::SpacesBefore { + item: ast::Header::Platform(header), + before: comments, }, parser_state, )) => { @@ -3530,13 +3537,13 @@ fn load_builtin_module_help<'a>( let opt_shorthand = None; let filename = PathBuf::from(filename); let parse_state = roc_parse::state::State::new(src_bytes.as_bytes()); - let parsed = roc_parse::module::parse_header(arena, parse_state.clone()); + let parsed = roc_parse::header::parse_header(arena, parse_state.clone()); match parsed { Ok(( - ast::Module { - header: ast::Header::Module(header), - comments, + ast::SpacesBefore { + item: ast::Header::Module(header), + before: comments, }, parse_state, )) => { @@ -3551,6 +3558,7 @@ fn load_builtin_module_help<'a>( name: header::ModuleName::new(name_stem), exposes: unspace(arena, header.exposes.items), generates_with: &[], + opt_params: header.params, }, module_comments: comments, header_imports: header.interface_imports, @@ -3786,7 +3794,7 @@ fn parse_header<'a>( ) -> Result, LoadingProblem<'a>> { let parse_start = Instant::now(); let parse_state = roc_parse::state::State::new(src_bytes); - let parsed = roc_parse::module::parse_header(arena, parse_state.clone()); + let parsed = roc_parse::header::parse_header(arena, parse_state.clone()); let parse_header_duration = parse_start.elapsed(); if let Err(problem) = ensure_roc_file(&filename, src_bytes) { @@ -3815,9 +3823,9 @@ fn parse_header<'a>( match parsed { Ok(( - ast::Module { - header: ast::Header::Module(header), - comments, + ast::SpacesBefore { + item: ast::Header::Module(header), + before: comments, }, parse_state, )) => { @@ -3837,6 +3845,7 @@ fn parse_header<'a>( header_type: HeaderType::Module { name: roc_parse::header::ModuleName::new(module_name), exposes: unspace(arena, header.exposes.items), + opt_params: header.params, }, module_comments: comments, header_imports: header.interface_imports, @@ -3852,9 +3861,9 @@ fn parse_header<'a>( }) } Ok(( - ast::Module { - header: ast::Header::Hosted(header), - comments, + ast::SpacesBefore { + item: ast::Header::Hosted(header), + before: comments, }, parse_state, )) => { @@ -3883,9 +3892,9 @@ fn parse_header<'a>( }) } Ok(( - ast::Module { - header: ast::Header::App(header), - comments, + ast::SpacesBefore { + item: ast::Header::App(header), + before: comments, }, parse_state, )) => { @@ -3988,9 +3997,9 @@ fn parse_header<'a>( }) } Ok(( - ast::Module { - header: ast::Header::Package(header), - comments, + ast::SpacesBefore { + item: ast::Header::Package(header), + before: comments, }, parse_state, )) => { @@ -4015,9 +4024,9 @@ fn parse_header<'a>( } Ok(( - ast::Module { - header: ast::Header::Platform(header), - comments, + ast::SpacesBefore { + item: ast::Header::Platform(header), + before: comments, }, parse_state, )) => { @@ -4380,7 +4389,7 @@ pub fn add_imports( def_types: &mut Vec<(Symbol, Loc)>, imported_rigid_vars: &mut Vec, imported_flex_vars: &mut Vec, -) -> (Vec, AbilitiesStore) { +) -> (Vec, VecMap, AbilitiesStore) { let mut import_variables = Vec::new(); let mut cached_symbol_vars = VecMap::default(); @@ -4487,7 +4496,31 @@ pub fn add_imports( }, ); - (import_variables, abilities_store) + let mut imported_param_vars = VecMap::default(); + + for (module_id, _) in exposed_for_module.exposed_by_module.iter_all() { + let ExposedModuleTypes { + exposed_types_storage_subs: exposed_types, + .. + } = exposed_for_module.exposed_by_module.get(module_id).unwrap(); + + if let Some(stored_aprams_var) = exposed_types.stored_params_var { + let copied_import = exposed_types + .storage_subs + .export_variable_to(subs, stored_aprams_var); + + let copied_import_var = extend_imports_data_with_copied_import( + copied_import, + &mut import_variables, + imported_rigid_vars, + imported_flex_vars, + ); + + imported_param_vars.insert(*module_id, copied_import_var); + } + } + + (import_variables, imported_param_vars, abilities_store) } enum OnSymbolNotFound { @@ -4609,6 +4642,7 @@ fn run_solve_solve( aliases, rigid_variables, abilities_store: pending_abilities, + params_pattern, .. } = module; @@ -4618,7 +4652,7 @@ fn run_solve_solve( let mut subs = Subs::new_from_varstore(var_store); - let (import_variables, abilities_store) = add_imports( + let (import_variables, imported_param_vars, abilities_store) = add_imports( module.module_id, &mut constraints, &mut subs, @@ -4656,6 +4690,8 @@ fn run_solve_solve( derived_module, #[cfg(debug_assertions)] checkmate, + params_pattern: params_pattern.map(|(_, _, pattern)| pattern.value), + module_params_vars: imported_param_vars, }; let solve_output = roc_solve::module::run_solve( @@ -4740,6 +4776,11 @@ fn run_solve<'a>( // TODO remove when we write builtins in roc let aliases = module.aliases.clone(); + let opt_params_var = module + .params_pattern + .as_ref() + .map(|(params_var, _, _)| *params_var); + let mut module = module; let loc_expects = std::mem::take(&mut module.loc_expects); let loc_dbgs = std::mem::take(&mut module.loc_dbgs); @@ -4811,6 +4852,7 @@ fn run_solve<'a>( module_id, &mut solved_subs, &exposed_vars_by_symbol, + opt_params_var, &solved_implementations, &abilities_store, ); @@ -4922,6 +4964,7 @@ fn build_platform_header<'a>( .zip(requires.iter().copied()), arena, ); + let packages = unspace(arena, header.packages.item.items); let exposes = bumpalo::collections::Vec::from_iter_in( unspace(arena, header.exposes.item.items).iter().copied(), arena, @@ -4943,7 +4986,7 @@ fn build_platform_header<'a>( filename, is_root_module, opt_shorthand, - packages: &[], + packages, header_type, module_comments: comments, header_imports: Some(header.imports), @@ -5059,6 +5102,7 @@ fn canonicalize_and_constrain<'a>( module_output.symbols_from_requires, &module_output.scope.abilities_store, &module_output.declarations, + &module_output.params_pattern, module_id, ) }; @@ -5115,6 +5159,7 @@ fn canonicalize_and_constrain<'a>( abilities_store: module_output.scope.abilities_store, loc_expects: module_output.loc_expects, loc_dbgs: module_output.loc_dbgs, + params_pattern: module_output.params_pattern, }; let constrained_module = ConstrainedModule { @@ -5152,7 +5197,7 @@ fn parse<'a>( let parse_state = header.parse_state; let header_import_defs = - roc_parse::ast::Module::header_imports_to_defs(arena, header.header_imports); + roc_parse::ast::Header::header_imports_to_defs(arena, header.header_imports); let parsed_defs = match parse_module_defs(arena, parse_state.clone(), header_import_defs) { Ok(success) => success, @@ -5458,6 +5503,7 @@ fn make_specializations<'a>( ) -> Msg<'a> { let make_specializations_start = Instant::now(); let mut update_mode_ids = UpdateModeIds::new(); + // do the thing let mut mono_env = roc_mono::ir::Env { arena, diff --git a/crates/compiler/load_internal/src/module_cache.rs b/crates/compiler/load_internal/src/module_cache.rs index 0c202d93d1..ed62692a26 100644 --- a/crates/compiler/load_internal/src/module_cache.rs +++ b/crates/compiler/load_internal/src/module_cache.rs @@ -4,12 +4,13 @@ use crate::module::{ ModuleHeader, ParsedModule, TypeCheckedModule, }; use roc_can::abilities::PendingAbilitiesStore; +use roc_can::expr::AnnotatedMark; use roc_collections::{MutMap, MutSet, VecMap}; use roc_module::ident::ModuleName; use roc_module::symbol::{ModuleId, PQModuleName, Symbol}; use roc_mono::ir::ExternalSpecializations; use roc_problem::Severity; -use roc_region::all::Region; +use roc_region::all::{Loc, Region}; use roc_solve_problem::TypeError; use roc_types::subs::Variable; use roc_types::types::Alias; @@ -26,6 +27,8 @@ pub(crate) struct ModuleCache<'a> { pub(crate) aliases: MutMap>, pub(crate) pending_abilities: MutMap, pub(crate) constrained: MutMap, + pub(crate) param_patterns: + MutMap)>, pub(crate) typechecked: MutMap>, pub(crate) checked: MutMap, pub(crate) found_specializations: MutMap>, @@ -100,6 +103,7 @@ impl Default for ModuleCache<'_> { aliases: Default::default(), pending_abilities: Default::default(), constrained: Default::default(), + param_patterns: Default::default(), typechecked: Default::default(), checked: Default::default(), found_specializations: Default::default(), diff --git a/crates/compiler/load_internal/tests/test_load.rs b/crates/compiler/load_internal/tests/test_load.rs index ddb664568a..ca4363b840 100644 --- a/crates/compiler/load_internal/tests/test_load.rs +++ b/crates/compiler/load_internal/tests/test_load.rs @@ -27,10 +27,11 @@ use roc_module::symbol::{Interns, ModuleId}; use roc_packaging::cache::RocCacheDir; use roc_problem::can::Problem; use roc_region::all::LineInfo; -use roc_reporting::report::RocDocAllocator; use roc_reporting::report::{can_problem, DEFAULT_PALETTE}; use roc_reporting::report::{strip_colors, RenderTarget}; +use roc_reporting::report::{type_problem, RocDocAllocator}; use roc_solve::FunctionKind; +use roc_solve_problem::TypeError; use roc_target::Target; use roc_test_utils_dir::TmpDir; use roc_types::pretty_print::name_and_print_var; @@ -107,6 +108,33 @@ fn format_can_problems( buf } +fn format_type_problems( + problems: Vec, + home: ModuleId, + interns: &Interns, + filename: PathBuf, + src: &str, +) -> String { + use ven_pretty::DocAllocator; + + let src_lines: Vec<&str> = src.split('\n').collect(); + let lines = LineInfo::new(src); + let alloc = RocDocAllocator::new(&src_lines, home, interns); + let reports = problems + .into_iter() + .flat_map(|problem| type_problem(&alloc, &lines, filename.clone(), problem)) + .map(|report| report.pretty(&alloc)); + + let mut buf = String::new(); + alloc + .stack(reports) + .append(alloc.line()) + .1 + .render_raw(70, &mut roc_reporting::report::CiWrite::new(&mut buf)) + .unwrap(); + buf +} + fn multiple_modules(subdir: &str, files: Vec<(&str, &str)>) -> Result { let arena = Bump::new(); let arena = &arena; @@ -130,11 +158,19 @@ fn multiple_modules(subdir: &str, files: Vec<(&str, &str)>) -> Result { + let body = declarations.expressions[index].clone(); + + if let roc_can::expr::Expr::ImportParams(_, _, None) = body.value { + // Skip import defs without params + continue; + } + let symbol = declarations.symbols[index].value; let expr_var = declarations.variables[index]; @@ -407,7 +450,13 @@ fn module_with_deps() { match declarations.declarations[index] { Value | Function(_) | Recursive(_) | TailRecursive(_) => { - def_count += 1; + let body = declarations.expressions[index].clone(); + + if let roc_can::expr::Expr::ImportParams(_, _, None) = body.value { + // Skip import defs without params + } else { + def_count += 1; + } } Destructure(_) => { def_count += 1; @@ -1563,6 +1612,325 @@ fn cannot_use_original_name_if_imported_with_alias() { multiple_modules("cannot_use_original_name_if_imported_with_alias", modules).unwrap_err(); } +#[test] +fn module_params_checks() { + let modules = vec![ + ( + "Api.roc", + indoc!( + r#" + module { key } -> [url] + + url = "example.com/$(key)" + "# + ), + ), + ( + "Main.roc", + indoc!( + r#" + module [example] + + import Api { key: "abcdef" } + + example = Api.url + "# + ), + ), + ]; + + let result = multiple_modules("module_params_checks", modules); + assert!(result.is_ok()); +} + +#[test] +fn module_params_optional() { + let modules = vec![ + ( + "Api.roc", + indoc!( + r#" + module { key, exp ? "default" } -> [url] + + url = "example.com/$(key)?exp=$(exp)" + "# + ), + ), + ( + "Main.roc", + indoc!( + r#" + module [example] + + import Api { key: "abcdef" } + + example = Api.url + "# + ), + ), + ]; + + let result = multiple_modules("module_params_optional", modules); + assert!(result.is_ok()) +} + +#[test] +fn module_params_typecheck_fail() { + let modules = vec![ + ( + "Api.roc", + indoc!( + r#" + module { key } -> [url] + + url = "example.com/$(key)" + "# + ), + ), + ( + "Main.roc", + indoc!( + r#" + module [example] + + import Api { key: 123 } + + example = Api.url + "# + ), + ), + ]; + + let result = multiple_modules("module_params_typecheck_fail", modules).unwrap_err(); + assert_eq!( + result, + indoc!( + r#" + ── MODULE PARAMS MISMATCH in tmp/module_params_typecheck_fail/Main.roc ───────── + + Something is off with the params provided by this import: + + 3│ import Api { key: 123 } + ^^^^^^^^^^^^ + + This is the type I inferred: + + { key : Num * } + + However, Api expects: + + { key : Str } + "# + ) + ); +} + +#[test] +fn module_params_missing_fields() { + let modules = vec![ + ( + "Api.roc", + indoc!( + r#" + module { key } -> [url] + + url = "example.com/$(key)" + "# + ), + ), + ( + "Main.roc", + indoc!( + r#" + module [example] + + import Api {} + + example = Api.url + "# + ), + ), + ]; + + let result = multiple_modules("module_params_missing_fields", modules).unwrap_err(); + assert_eq!( + result, + indoc!( + r#" + ── MODULE PARAMS MISMATCH in tmp/module_params_missing_fields/Main.roc ───────── + + Something is off with the params provided by this import: + + 3│ import Api {} + ^^ + + This is the type I inferred: + + {} + + However, Api expects: + + { key : Str } + + Tip: Looks like the key field is missing. + "# + ) + ); +} + +#[test] +fn module_params_extra_fields() { + let modules = vec![ + ( + "Api.roc", + indoc!( + r#" + module { key } -> [url] + + url = "example.com/$(key)" + "# + ), + ), + ( + "Main.roc", + indoc!( + r#" + module [example] + + import Api { key: "123", doesNotExist: Bool.true } + + example = Api.url + "# + ), + ), + ]; + + let result = multiple_modules("module_params_extra_fields", modules).unwrap_err(); + assert_eq!( + result, + indoc!( + r#" + ── MODULE PARAMS MISMATCH in tmp/module_params_extra_fields/Main.roc ─────────── + + Something is off with the params provided by this import: + + 3│ import Api { key: "123", doesNotExist: Bool.true } + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + This is the type I inferred: + + { doesNotExist : Bool, … } + + However, Api expects: + + { … } + + + "# + ) + ); +} + +#[test] +fn module_params_unexpected() { + let modules = vec![ + ( + "Api.roc", + indoc!( + r#" + module [url] + + url = "example.com" + "# + ), + ), + ( + "Main.roc", + indoc!( + r#" + module [example] + + import Api { key: 123 } + + example = Api.url + "# + ), + ), + ]; + + let err = multiple_modules("module_params_unexpected", modules).unwrap_err(); + assert_eq!( + err, + indoc!( + r#" + ── UNEXPECTED MODULE PARAMS in tmp/module_params_unexpected/Main.roc ─────────── + + This import specifies module params: + + 3│ import Api { key: 123 } + ^^^^^^^^^^^^ + + However, Api does not expect any. Did you intend to import a different + module? + "# + ) + ) +} + +#[test] +fn module_params_missing() { + let modules = vec![ + ( + "Api.roc", + indoc!( + r#" + module { key, exp } -> [url] + + url = "example.com/$(key)?exp=$(Num.toStr exp)" + "# + ), + ), + ( + "Main.roc", + indoc!( + r#" + module [example] + + import Api + + example = Api.url + "# + ), + ), + ]; + + let err = multiple_modules("module_params_missing", modules).unwrap_err(); + assert_eq!( + err, + indoc!( + r#" + ── MISSING MODULE PARAMS in tmp/module_params_missing/Main.roc ───────────────── + + This import specifies no module params: + + 3│ import Api + ^^^^^^^^^^ + + However, Api expects the following to be provided: + + { + exp : Num *, + key : Str, + } + + You can provide params after the module name, like: + + import Menu { echo, read } + "# + ) + ) +} + #[test] fn issue_2863_module_type_does_not_exist() { let modules = vec![ diff --git a/crates/compiler/module/src/symbol.rs b/crates/compiler/module/src/symbol.rs index 2713be16ae..385a98b5d0 100644 --- a/crates/compiler/module/src/symbol.rs +++ b/crates/compiler/module/src/symbol.rs @@ -627,67 +627,12 @@ impl ModuleIds { pub fn available_modules(&self) -> impl Iterator { self.by_id.iter() } -} -#[derive(Debug, Clone)] -pub struct ScopeModules { - modules: VecMap, - sources: VecMap, -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum ScopeModuleSource { - Builtin, - Current, - Import(Region), -} - -impl ScopeModules { - pub fn get_id(&self, module_name: &ModuleName) -> Option { - self.modules.get(module_name).copied() - } - - pub fn has_id(&self, module_id: ModuleId) -> bool { - self.sources.contains_key(&module_id) - } - - pub fn available_names(&self) -> impl Iterator { - self.modules.keys() - } - - pub fn insert( - &mut self, - module_name: ModuleName, - module_id: ModuleId, - region: Region, - ) -> Result<(), ScopeModuleSource> { - if let Some(existing_module_id) = self.modules.get(&module_name) { - if *existing_module_id == module_id { - return Ok(()); - } - - return Err(*self.sources.get(existing_module_id).unwrap()); - } - - self.modules.insert(module_name, module_id); - self.sources - .insert(module_id, ScopeModuleSource::Import(region)); - Ok(()) - } - - pub fn len(&self) -> usize { - debug_assert_eq!(self.modules.len(), self.sources.len()); - self.modules.len() - } - - pub fn is_empty(&self) -> bool { - debug_assert_eq!(self.modules.is_empty(), self.sources.is_empty()); - self.modules.is_empty() - } - - pub fn truncate(&mut self, len: usize) { - self.modules.truncate(len); - self.sources.truncate(len); + pub fn iter(&self) -> impl ExactSizeIterator { + self.by_id + .iter() + .enumerate() + .map(|(index, name)| (ModuleId::from_zero_indexed(index), name)) } } @@ -1031,32 +976,6 @@ macro_rules! define_builtins { } } - impl ScopeModules { - pub fn new(home_id: ModuleId, home_name: ModuleName) -> Self { - // +1 because the user will be compiling at least 1 non-builtin module! - let capacity = $total + 1; - - let mut modules = VecMap::with_capacity(capacity); - let mut sources = VecMap::with_capacity(capacity); - - modules.insert(home_name, home_id); - sources.insert(home_id, ScopeModuleSource::Current); - - let mut insert_both = |id: ModuleId, name_str: &'static str| { - let name: ModuleName = name_str.into(); - - modules.insert(name, id); - sources.insert(id, ScopeModuleSource::Builtin); - }; - - $( - insert_both(ModuleId::$module_const, $module_name); - )+ - - ScopeModules { modules, sources } - } - } - impl<'a> Default for PackageModuleIds<'a> { fn default() -> Self { // +1 because the user will be compiling at least 1 non-builtin module! @@ -1556,6 +1475,8 @@ define_builtins! { 5 RESULT_WITH_DEFAULT: "withDefault" 6 RESULT_TRY: "try" 7 RESULT_IS_OK: "isOk" + 8 RESULT_MAP_BOTH: "mapBoth" + 9 RESULT_MAP_TWO: "map2" } 8 DICT: "Dict" => { 0 DICT_DICT: "Dict" exposed_type=true // the Dict.Dict type alias diff --git a/crates/compiler/mono/src/ir.rs b/crates/compiler/mono/src/ir.rs index 6fbe5ad96f..d4956cc154 100644 --- a/crates/compiler/mono/src/ir.rs +++ b/crates/compiler/mono/src/ir.rs @@ -4443,6 +4443,15 @@ pub fn with_hole<'a>( specialize_naked_symbol(env, variable, procs, layout_cache, assigned, hole, symbol) } + ParamsVar { .. } => { + unimplemented!("module params code generation") + } + ImportParams(_, _, Some((_, value))) => { + with_hole(env, *value, variable, procs, layout_cache, assigned, hole) + } + ImportParams(_, _, None) => { + internal_error!("Missing module params should've been dropped by now"); + } AbilityMember(member, specialization_id, specialization_var) => { let specialization_symbol = late_resolve_ability_specialization( env, diff --git a/crates/compiler/parse/benches/bench_parse.rs b/crates/compiler/parse/benches/bench_parse.rs index ecdf751deb..d3b4b1eee4 100644 --- a/crates/compiler/parse/benches/bench_parse.rs +++ b/crates/compiler/parse/benches/bench_parse.rs @@ -2,7 +2,7 @@ use bumpalo::Bump; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use roc_parse::{ ast::Defs, - module::{self, parse_module_defs}, + header::{self, parse_module_defs}, state::State, }; use std::path::PathBuf; @@ -20,7 +20,7 @@ pub fn parse_benchmark(c: &mut Criterion) { let arena = Bump::new(); let (_actual, state) = - module::parse_header(&arena, State::new(src.as_bytes())).unwrap(); + header::parse_header(&arena, State::new(src.as_bytes())).unwrap(); let res = parse_module_defs(&arena, state, Defs::default()).unwrap(); @@ -41,7 +41,7 @@ pub fn parse_benchmark(c: &mut Criterion) { let arena = Bump::new(); let (_actual, state) = - module::parse_header(&arena, State::new(src.as_bytes())).unwrap(); + header::parse_header(&arena, State::new(src.as_bytes())).unwrap(); let res = parse_module_defs(&arena, state, Defs::default()).unwrap(); diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index 36899d0d8d..445b7c5254 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -14,6 +14,12 @@ use roc_module::called_via::{BinOp, CalledVia, UnaryOp}; use roc_module::ident::QualifiedModuleName; use roc_region::all::{Loc, Position, Region}; +#[derive(Debug, Clone)] +pub struct FullAst<'a> { + pub header: SpacesBefore<'a, Header<'a>>, + pub defs: Defs<'a>, +} + #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct Spaces<'a, T> { pub before: &'a [CommentOrNewline<'a>], @@ -111,15 +117,9 @@ impl<'a, T: ExtractSpaces<'a>> ExtractSpaces<'a> for Loc { } } -#[derive(Clone, Debug, PartialEq)] -pub struct Module<'a> { - pub comments: &'a [CommentOrNewline<'a>], - pub header: Header<'a>, -} - -impl<'a> Module<'a> { +impl<'a> Header<'a> { pub fn upgrade_header_imports(self, arena: &'a Bump) -> (Self, Defs<'a>) { - let (header, defs) = match self.header { + let (header, defs) = match self { Header::Module(header) => ( Header::Module(ModuleHeader { interface_imports: None, @@ -134,12 +134,10 @@ impl<'a> Module<'a> { }), Self::header_imports_to_defs(arena, header.old_imports), ), - Header::Package(_) | Header::Platform(_) | Header::Hosted(_) => { - (self.header, Defs::default()) - } + Header::Package(_) | Header::Platform(_) | Header::Hosted(_) => (self, Defs::default()), }; - (Module { header, ..self }, defs) + (header, defs) } pub fn header_imports_to_defs( @@ -681,9 +679,9 @@ fn is_when_branch_suffixed(branch: &WhenBranch<'_>) -> bool { fn is_assigned_value_suffixed<'a>(value: &AssignedField<'a, Expr<'a>>) -> bool { match value { - AssignedField::RequiredValue(_, _, a) | AssignedField::OptionalValue(_, _, a) => { - is_expr_suffixed(&a.value) - } + AssignedField::RequiredValue(_, _, a) + | AssignedField::OptionalValue(_, _, a) + | AssignedField::IgnoredValue(_, _, a) => is_expr_suffixed(&a.value), AssignedField::LabelOnly(_) => false, AssignedField::SpaceBefore(a, _) | AssignedField::SpaceAfter(a, _) => { is_assigned_value_suffixed(a) @@ -869,9 +867,9 @@ impl<'a, 'b> RecursiveValueDefIter<'a, 'b> { use AssignedField::*; match current { - RequiredValue(_, _, loc_val) | OptionalValue(_, _, loc_val) => { - break expr_stack.push(&loc_val.value) - } + RequiredValue(_, _, loc_val) + | OptionalValue(_, _, loc_val) + | IgnoredValue(_, _, loc_val) => break expr_stack.push(&loc_val.value), SpaceBefore(next, _) | SpaceAfter(next, _) => current = *next, LabelOnly(_) | Malformed(_) => break, } @@ -1070,7 +1068,7 @@ impl<'a, 'b> Iterator for RecursiveValueDefIter<'a, 'b> { params, }) => { if let Some(ModuleImportParams { before: _, params }) = params { - for loc_assigned_field in params.items { + for loc_assigned_field in params.value.items { if let Some(expr) = loc_assigned_field.value.value() { self.push_pending_from_expr(&expr.value); } @@ -1118,7 +1116,7 @@ pub struct ModuleImport<'a> { #[derive(Debug, Clone, Copy, PartialEq)] pub struct ModuleImportParams<'a> { pub before: &'a [CommentOrNewline<'a>], - pub params: Collection<'a, Loc>>>, + pub params: Loc>>>>, } #[derive(Debug, Clone, Copy, PartialEq)] @@ -1598,6 +1596,9 @@ pub enum AssignedField<'a, Val> { // and in destructuring patterns (e.g. `{ name ? "blah" }`) OptionalValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc), + // An ignored field, e.g. `{ _name: "blah" }` or `{ _ : Str }` + IgnoredValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc), + // A label with no value, e.g. `{ name }` (this is sugar for { name: name }) LabelOnly(Loc<&'a str>), @@ -1615,7 +1616,9 @@ impl<'a, Val> AssignedField<'a, Val> { loop { match current { - Self::RequiredValue(_, _, val) | Self::OptionalValue(_, _, val) => break Some(val), + Self::RequiredValue(_, _, val) + | Self::OptionalValue(_, _, val) + | Self::IgnoredValue(_, _, val) => break Some(val), Self::LabelOnly(_) | Self::Malformed(_) => break None, Self::SpaceBefore(next, _) | Self::SpaceAfter(next, _) => current = *next, } @@ -2433,9 +2436,9 @@ pub trait Malformed { fn is_malformed(&self) -> bool; } -impl<'a> Malformed for Module<'a> { +impl<'a> Malformed for FullAst<'a> { fn is_malformed(&self) -> bool { - self.header.is_malformed() + self.header.item.is_malformed() || self.defs.is_malformed() } } @@ -2457,6 +2460,12 @@ impl<'a, T: Malformed> Malformed for Spaces<'a, T> { } } +impl<'a, T: Malformed> Malformed for SpacesBefore<'a, T> { + fn is_malformed(&self) -> bool { + self.item.is_malformed() + } +} + impl<'a> Malformed for Expr<'a> { fn is_malformed(&self) -> bool { use Expr::*; @@ -2577,9 +2586,9 @@ impl Malformed for Option { impl<'a, T: Malformed> Malformed for AssignedField<'a, T> { fn is_malformed(&self) -> bool { match self { - AssignedField::RequiredValue(_, _, val) | AssignedField::OptionalValue(_, _, val) => { - val.is_malformed() - } + AssignedField::RequiredValue(_, _, val) + | AssignedField::OptionalValue(_, _, val) + | AssignedField::IgnoredValue(_, _, val) => val.is_malformed(), AssignedField::LabelOnly(_) => false, AssignedField::SpaceBefore(field, _) | AssignedField::SpaceAfter(field, _) => { field.is_malformed() diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 03a4534cb3..d19fc740ec 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -9,10 +9,10 @@ use crate::blankspace::{ loc_space0_e, require_newline_or_eof, space0_after_e, space0_around_ee, space0_before_e, space0_before_optional_after, space0_e, spaces, spaces_around, spaces_before, }; +use crate::header::module_name_help; use crate::ident::{ integer_ident, lowercase_ident, parse_ident, unqualified_ident, Accessor, Ident, Suffix, }; -use crate::module::module_name_help; use crate::parser::{ self, and, backtrackable, between, byte, byte_indent, collection_inner, collection_trailing_sep_e, either, increment_min_indent, indented_seq_skip_first, loc, map, @@ -24,8 +24,8 @@ use crate::parser::{ use crate::pattern::closure_param; use crate::state::State; use crate::string_literal::{self, StrLikeLiteral}; +use crate::type_annotation; use crate::{header, keyword}; -use crate::{module, type_annotation}; use bumpalo::collections::Vec; use bumpalo::Bump; use roc_collections::soa::Slice; @@ -892,10 +892,10 @@ fn import_params<'a>() -> impl Parser<'a, ModuleImportParams<'a>, EImportParams< then( and( backtrackable(space0_e(EImportParams::Indent)), - specialize_err(EImportParams::Record, record_help()), + specialize_err(EImportParams::Record, loc(record_help())), ), - |arena, state, _, (before, record): (_, RecordHelp<'a>)| { - if let Some(prefix) = record.prefix { + |arena, state, _, (before, loc_record): (_, Loc>)| { + if let Some(prefix) = loc_record.value.prefix { match prefix { (update, RecordHelpPrefix::Update) => { return Err(( @@ -912,17 +912,27 @@ fn import_params<'a>() -> impl Parser<'a, ModuleImportParams<'a>, EImportParams< } } - let params = record.fields.map_items_result(arena, |loc_field| { - match loc_field.value.to_assigned_field(arena) { - Ok(field) => Ok(Loc::at(loc_field.region, field)), - Err(FoundApplyValue) => Err(( - MadeProgress, - EImportParams::RecordApplyFound(loc_field.region), - )), - } - })?; + let params = loc_record + .value + .fields + .map_items_result(arena, |loc_field| { + match loc_field.value.to_assigned_field(arena) { + Ok(AssignedField::IgnoredValue(_, _, _)) => Err(( + MadeProgress, + EImportParams::RecordIgnoredFieldFound(loc_field.region), + )), + Ok(field) => Ok(Loc::at(loc_field.region, field)), + Err(FoundApplyValue) => Err(( + MadeProgress, + EImportParams::RecordApplyFound(loc_field.region), + )), + } + })?; - let import_params = ModuleImportParams { before, params }; + let import_params = ModuleImportParams { + before, + params: Loc::at(loc_record.region, params), + }; Ok((MadeProgress, import_params, state)) }, @@ -944,7 +954,7 @@ fn imported_module_name<'a>() -> impl Parser<'a, ImportedModuleName<'a>, EImport fn import_as<'a>( ) -> impl Parser<'a, header::KeywordItem<'a, ImportAsKeyword, Loc>>, EImport<'a>> { record!(header::KeywordItem { - keyword: module::spaces_around_keyword( + keyword: header::spaces_around_keyword( ImportAsKeyword, EImport::As, EImport::IndentAs, @@ -978,7 +988,7 @@ fn import_exposing<'a>() -> impl Parser< EImport<'a>, > { record!(header::KeywordItem { - keyword: module::spaces_around_keyword( + keyword: header::spaces_around_keyword( ImportExposingKeyword, EImport::Exposing, EImport::IndentExposing, @@ -1023,7 +1033,7 @@ fn import_ingested_file_body<'a>() -> impl Parser<'a, ValueDef<'a>, EImport<'a>> fn import_ingested_file_as<'a>( ) -> impl Parser<'a, header::KeywordItem<'a, ImportAsKeyword, Loc<&'a str>>, EImport<'a>> { record!(header::KeywordItem { - keyword: module::spaces_around_keyword( + keyword: header::spaces_around_keyword( ImportAsKeyword, EImport::As, EImport::IndentAs, @@ -2234,6 +2244,7 @@ fn assigned_expr_field_to_pattern_help<'a>( spaces, ), AssignedField::Malformed(string) => Pattern::Malformed(string), + AssignedField::IgnoredValue(_, _, _) => return Err(()), }) } @@ -3322,6 +3333,7 @@ fn list_literal_help<'a>() -> impl Parser<'a, Expr<'a>, EList<'a>> { pub enum RecordField<'a> { RequiredValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc>), OptionalValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc>), + IgnoredValue(Loc<&'a str>, &'a [CommentOrNewline<'a>], &'a Loc>), LabelOnly(Loc<&'a str>), SpaceBefore(&'a RecordField<'a>, &'a [CommentOrNewline<'a>]), SpaceAfter(&'a RecordField<'a>, &'a [CommentOrNewline<'a>]), @@ -3337,7 +3349,10 @@ pub enum RecordField<'a> { pub struct FoundApplyValue; #[derive(Debug)] -struct FoundOptionalValue; +pub enum NotOldBuilderFieldValue { + FoundOptionalValue, + FoundIgnoredValue, +} impl<'a> RecordField<'a> { fn is_apply_value(&self) -> bool { @@ -3354,6 +3369,20 @@ impl<'a> RecordField<'a> { } } + fn is_ignored_value(&self) -> bool { + let mut current = self; + + loop { + match current { + RecordField::IgnoredValue(_, _, _) => break true, + RecordField::SpaceBefore(field, _) | RecordField::SpaceAfter(field, _) => { + current = *field; + } + _ => break false, + } + } + } + pub fn to_assigned_field( self, arena: &'a Bump, @@ -3369,6 +3398,10 @@ impl<'a> RecordField<'a> { Ok(OptionalValue(loc_label, spaces, loc_expr)) } + RecordField::IgnoredValue(loc_label, spaces, loc_expr) => { + Ok(IgnoredValue(loc_label, spaces, loc_expr)) + } + RecordField::LabelOnly(loc_label) => Ok(LabelOnly(loc_label)), RecordField::ApplyValue(_, _, _, _) => Err(FoundApplyValue), @@ -3390,7 +3423,7 @@ impl<'a> RecordField<'a> { fn to_builder_field( self, arena: &'a Bump, - ) -> Result, FoundOptionalValue> { + ) -> Result, NotOldBuilderFieldValue> { use OldRecordBuilderField::*; match self { @@ -3398,7 +3431,9 @@ impl<'a> RecordField<'a> { Ok(Value(loc_label, spaces, loc_expr)) } - RecordField::OptionalValue(_, _, _) => Err(FoundOptionalValue), + RecordField::OptionalValue(_, _, _) => Err(NotOldBuilderFieldValue::FoundOptionalValue), + + RecordField::IgnoredValue(_, _, _) => Err(NotOldBuilderFieldValue::FoundIgnoredValue), RecordField::LabelOnly(loc_label) => Ok(LabelOnly(loc_label)), @@ -3434,42 +3469,70 @@ pub fn record_field<'a>() -> impl Parser<'a, RecordField<'a>, ERecord<'a>> { use RecordField::*; map_with_arena( - and( - specialize_err(|_, pos| ERecord::Field(pos), loc(lowercase_ident())), + either( and( - spaces(), - optional(either( - and(byte(b':', ERecord::Colon), record_field_expr()), - and( - byte(b'?', ERecord::QuestionMark), + specialize_err(|_, pos| ERecord::Field(pos), loc(lowercase_ident())), + and( + spaces(), + optional(either( + and(byte(b':', ERecord::Colon), record_field_expr()), + and( + byte(b'?', ERecord::QuestionMark), + spaces_before(specialize_err_ref(ERecord::Expr, loc_expr(false))), + ), + )), + ), + ), + and( + loc(skip_first( + byte(b'_', ERecord::UnderscoreField), + optional(specialize_err( + |_, pos| ERecord::Field(pos), + lowercase_ident(), + )), + )), + and( + spaces(), + skip_first( + byte(b':', ERecord::Colon), spaces_before(specialize_err_ref(ERecord::Expr, loc_expr(false))), ), - )), + ), ), ), - |arena: &'a bumpalo::Bump, (loc_label, (spaces, opt_loc_val))| { - match opt_loc_val { - Some(Either::First((_, RecordFieldExpr::Value(loc_val)))) => { - RequiredValue(loc_label, spaces, arena.alloc(loc_val)) - } + |arena: &'a bumpalo::Bump, field_data| { + match field_data { + Either::First((loc_label, (spaces, opt_loc_val))) => { + match opt_loc_val { + Some(Either::First((_, RecordFieldExpr::Value(loc_val)))) => { + RequiredValue(loc_label, spaces, arena.alloc(loc_val)) + } - Some(Either::First((_, RecordFieldExpr::Apply(arrow_spaces, loc_val)))) => { - ApplyValue(loc_label, spaces, arrow_spaces, arena.alloc(loc_val)) - } + Some(Either::First((_, RecordFieldExpr::Apply(arrow_spaces, loc_val)))) => { + ApplyValue(loc_label, spaces, arrow_spaces, arena.alloc(loc_val)) + } - Some(Either::Second((_, loc_val))) => { - OptionalValue(loc_label, spaces, arena.alloc(loc_val)) - } + Some(Either::Second((_, loc_val))) => { + OptionalValue(loc_label, spaces, arena.alloc(loc_val)) + } - // If no value was provided, record it as a Var. - // Canonicalize will know what to do with a Var later. - None => { - if !spaces.is_empty() { - SpaceAfter(arena.alloc(LabelOnly(loc_label)), spaces) - } else { - LabelOnly(loc_label) + // If no value was provided, record it as a Var. + // Canonicalize will know what to do with a Var later. + None => { + if !spaces.is_empty() { + SpaceAfter(arena.alloc(LabelOnly(loc_label)), spaces) + } else { + LabelOnly(loc_label) + } + } } } + Either::Second((loc_opt_label, (spaces, loc_val))) => { + let loc_label = loc_opt_label + .map(|opt_label| opt_label.unwrap_or_else(|| arena.alloc_str(""))); + + IgnoredValue(loc_label, spaces, arena.alloc(loc_val)) + } } }, ) @@ -3573,20 +3636,23 @@ fn record_literal_help<'a>() -> impl Parser<'a, Expr<'a>, EExpr<'a>> { new_record_builder_help(arena, mapper, record.fields) } None => { - let is_old_record_builder = record - .fields - .iter() - .any(|field| field.value.is_apply_value()); + let special_field_found = record.fields.iter().find_map(|field| { + if field.value.is_apply_value() { + Some(old_record_builder_help(arena, record.fields)) + } else if field.value.is_ignored_value() { + Some(Err(EExpr::RecordUpdateIgnoredField(field.region))) + } else { + None + } + }); - if is_old_record_builder { - old_record_builder_help(arena, record.fields) - } else { + special_field_found.unwrap_or_else(|| { let fields = record.fields.map_items(arena, |loc_field| { loc_field.map(|field| field.to_assigned_field(arena).unwrap()) }); Ok(Expr::Record(fields)) - } + }) } }; @@ -3609,11 +3675,14 @@ fn record_update_help<'a>( ) -> Result, EExpr<'a>> { let result = fields.map_items_result(arena, |loc_field| { match loc_field.value.to_assigned_field(arena) { + Ok(AssignedField::IgnoredValue(_, _, _)) => { + Err(EExpr::RecordUpdateIgnoredField(loc_field.region)) + } Ok(builder_field) => Ok(Loc { region: loc_field.region, value: builder_field, }), - Err(FoundApplyValue) => Err(EExpr::RecordUpdateAccumulator(loc_field.region)), + Err(FoundApplyValue) => Err(EExpr::RecordUpdateOldBuilderField(loc_field.region)), } }); @@ -3634,7 +3703,7 @@ fn new_record_builder_help<'a>( region: loc_field.region, value: builder_field, }), - Err(FoundApplyValue) => Err(EExpr::RecordBuilderAccumulator(loc_field.region)), + Err(FoundApplyValue) => Err(EExpr::RecordBuilderOldBuilderField(loc_field.region)), } }); @@ -3654,7 +3723,12 @@ fn old_record_builder_help<'a>( region: loc_field.region, value: builder_field, }), - Err(FoundOptionalValue) => Err(EExpr::OptionalValueInRecordBuilder(loc_field.region)), + Err(NotOldBuilderFieldValue::FoundOptionalValue) => { + Err(EExpr::OptionalValueInOldRecordBuilder(loc_field.region)) + } + Err(NotOldBuilderFieldValue::FoundIgnoredValue) => { + Err(EExpr::IgnoredValueInOldRecordBuilder(loc_field.region)) + } } }); diff --git a/crates/compiler/parse/src/header.rs b/crates/compiler/parse/src/header.rs index 6bbda2cea7..ae1d916631 100644 --- a/crates/compiler/parse/src/header.rs +++ b/crates/compiler/parse/src/header.rs @@ -1,19 +1,949 @@ -use crate::ast::{ - Collection, CommentOrNewline, Malformed, Pattern, Spaced, Spaces, StrLiteral, TypeAnnotation, -}; -use crate::blankspace::space0_e; -use crate::expr::merge_spaces; -use crate::ident::{lowercase_ident, UppercaseIdent}; -use crate::parser::{ - and, byte, loc, map_with_arena, skip_first, skip_second, specialize_err, EPackageEntry, - EPackageName, Parser, -}; -use crate::parser::{optional, then}; -use crate::string_literal; -use roc_module::symbol::{ModuleId, Symbol}; -use roc_region::all::Loc; use std::fmt::Debug; +use crate::ast::{ + Collection, CommentOrNewline, Defs, Header, Malformed, Pattern, Spaced, Spaces, SpacesBefore, + StrLiteral, TypeAnnotation, +}; +use crate::blankspace::{space0_around_ee, space0_before_e, space0_e}; +use crate::expr::merge_spaces; +use crate::ident::{self, lowercase_ident, unqualified_ident, uppercase, UppercaseIdent}; +use crate::parser::Progress::{self, *}; +use crate::parser::{ + and, backtrackable, byte, collection_trailing_sep_e, increment_min_indent, loc, map, + map_with_arena, optional, reset_min_indent, skip_first, skip_second, specialize_err, succeed, + then, two_bytes, zero_or_more, EExposes, EGenerates, EGeneratesWith, EHeader, EImports, + EPackageEntry, EPackageName, EPackages, EParams, EProvides, ERequires, ETypedIdent, Parser, + SourceError, SpaceProblem, SyntaxError, +}; +use crate::pattern::record_pattern_fields; +use crate::state::State; +use crate::string_literal::{self, parse_str_literal}; +use crate::type_annotation; +use roc_module::symbol::{ModuleId, Symbol}; +use roc_region::all::{Loc, Position, Region}; + +fn end_of_file<'a>() -> impl Parser<'a, (), SyntaxError<'a>> { + |_arena, state: State<'a>, _min_indent: u32| { + if state.has_reached_end() { + Ok((NoProgress, (), state)) + } else { + Err((NoProgress, SyntaxError::NotEndOfFile(state.pos()))) + } + } +} + +pub fn parse_module_defs<'a>( + arena: &'a bumpalo::Bump, + state: State<'a>, + defs: Defs<'a>, +) -> Result, SyntaxError<'a>> { + let min_indent = 0; + match crate::expr::parse_top_level_defs(arena, state.clone(), defs) { + Ok((_, defs, state)) => match end_of_file().parse(arena, state, min_indent) { + Ok(_) => Ok(defs), + Err((_, fail)) => Err(fail), + }, + Err((_, fail)) => Err(SyntaxError::Expr(fail, state.pos())), + } +} + +pub fn parse_header<'a>( + arena: &'a bumpalo::Bump, + state: State<'a>, +) -> Result<(SpacesBefore<'a, Header<'a>>, State<'a>), SourceError<'a, EHeader<'a>>> { + let min_indent = 0; + match header().parse(arena, state.clone(), min_indent) { + Ok((_, module, state)) => Ok((module, state)), + Err((_, fail)) => Err(SourceError::new(fail, &state)), + } +} + +pub fn header<'a>() -> impl Parser<'a, SpacesBefore<'a, Header<'a>>, EHeader<'a>> { + use crate::parser::keyword; + + record!(SpacesBefore { + before: space0_e(EHeader::IndentStart), + item: one_of![ + map( + skip_first( + keyword("module", EHeader::Start), + increment_min_indent(module_header()) + ), + Header::Module + ), + map( + skip_first( + keyword("interface", EHeader::Start), + increment_min_indent(interface_header()) + ), + Header::Module + ), + map( + skip_first( + keyword("app", EHeader::Start), + increment_min_indent(one_of![app_header(), old_app_header()]) + ), + Header::App + ), + map( + skip_first( + keyword("package", EHeader::Start), + increment_min_indent(one_of![package_header(), old_package_header()]) + ), + Header::Package + ), + map( + skip_first( + keyword("platform", EHeader::Start), + increment_min_indent(platform_header()) + ), + Header::Platform + ), + map( + skip_first( + keyword("hosted", EHeader::Start), + increment_min_indent(hosted_header()) + ), + Header::Hosted + ), + ] + }) +} + +#[inline(always)] +fn module_header<'a>() -> impl Parser<'a, ModuleHeader<'a>, EHeader<'a>> { + record!(ModuleHeader { + after_keyword: space0_e(EHeader::IndentStart), + params: optional(specialize_err(EHeader::Params, module_params())), + exposes: specialize_err(EHeader::Exposes, exposes_list()), + interface_imports: succeed(None) + }) + .trace("module_header") +} + +fn module_params<'a>() -> impl Parser<'a, ModuleParams<'a>, EParams<'a>> { + record!(ModuleParams { + pattern: specialize_err(EParams::Pattern, loc(record_pattern_fields())), + before_arrow: skip_second( + space0_e(EParams::BeforeArrow), + loc(two_bytes(b'-', b'>', EParams::Arrow)) + ), + after_arrow: space0_e(EParams::AfterArrow), + }) +} + +// TODO does this need to be a macro? +macro_rules! merge_n_spaces { + ($arena:expr, $($slice:expr),*) => { + { + let mut merged = bumpalo::collections::Vec::with_capacity_in(0 $(+ $slice.len())*, $arena); + $(merged.extend_from_slice($slice);)* + merged.into_bump_slice() + } + }; +} + +/// Parse old interface headers so we can format them into module headers +#[inline(always)] +fn interface_header<'a>() -> impl Parser<'a, ModuleHeader<'a>, EHeader<'a>> { + let after_keyword = map_with_arena( + and( + skip_second( + space0_e(EHeader::IndentStart), + loc(module_name_help(EHeader::ModuleName)), + ), + specialize_err(EHeader::Exposes, exposes_kw()), + ), + |arena: &'a bumpalo::Bump, + (before_name, kw): (&'a [CommentOrNewline<'a>], Spaces<'a, ExposesKeyword>)| { + merge_n_spaces!(arena, before_name, kw.before, kw.after) + }, + ); + + record!(ModuleHeader { + after_keyword: after_keyword, + params: succeed(None), + exposes: specialize_err(EHeader::Exposes, exposes_list()).trace("exposes_list"), + interface_imports: map( + specialize_err(EHeader::Imports, imports()), + imports_none_if_empty + ) + .trace("imports"), + }) + .trace("interface_header") +} + +fn imports_none_if_empty(value: ImportsKeywordItem<'_>) -> Option> { + if value.item.is_empty() { + None + } else { + Some(value) + } +} + +#[inline(always)] +fn hosted_header<'a>() -> impl Parser<'a, HostedHeader<'a>, EHeader<'a>> { + record!(HostedHeader { + before_name: space0_e(EHeader::IndentStart), + name: loc(module_name_help(EHeader::ModuleName)), + exposes: specialize_err(EHeader::Exposes, exposes_values_kw()), + imports: specialize_err(EHeader::Imports, imports()), + generates: specialize_err(EHeader::Generates, generates()), + generates_with: specialize_err(EHeader::GeneratesWith, generates_with()), + }) + .trace("hosted_header") +} + +fn chomp_module_name(buffer: &[u8]) -> Result<&str, Progress> { + use encode_unicode::CharExt; + + let mut chomped = 0; + + if let Ok((first_letter, width)) = char::from_utf8_slice_start(&buffer[chomped..]) { + if first_letter.is_uppercase() { + chomped += width; + } else { + return Err(Progress::NoProgress); + } + } + + while let Ok((ch, width)) = char::from_utf8_slice_start(&buffer[chomped..]) { + // After the first character, only these are allowed: + // + // * Unicode alphabetic chars - you might include `鹏` if that's clear to your readers + // * ASCII digits - e.g. `1` but not `¾`, both of which pass .is_numeric() + // * A '.' separating module parts + if ch.is_alphabetic() || ch.is_ascii_digit() { + chomped += width; + } else if ch == '.' { + chomped += width; + + if let Ok((first_letter, width)) = char::from_utf8_slice_start(&buffer[chomped..]) { + if first_letter.is_uppercase() { + chomped += width; + } else if first_letter == '{' { + // the .{ starting a `Foo.{ bar, baz }` importing clauses + chomped -= width; + break; + } else { + return Err(Progress::MadeProgress); + } + } + } else { + // we're done + break; + } + } + + let name = unsafe { std::str::from_utf8_unchecked(&buffer[..chomped]) }; + + Ok(name) +} + +#[inline(always)] +fn module_name<'a>() -> impl Parser<'a, ModuleName<'a>, ()> { + |_, mut state: State<'a>, _min_indent: u32| match chomp_module_name(state.bytes()) { + Ok(name) => { + let width = name.len(); + state = state.advance(width); + + Ok((MadeProgress, ModuleName::new(name), state)) + } + Err(progress) => Err((progress, ())), + } +} + +#[inline(always)] +fn app_header<'a>() -> impl Parser<'a, AppHeader<'a>, EHeader<'a>> { + record!(AppHeader { + before_provides: space0_e(EHeader::IndentStart), + provides: specialize_err(EHeader::Exposes, exposes_list()), + before_packages: space0_e(EHeader::IndentStart), + packages: specialize_err(EHeader::Packages, loc(packages_collection())), + old_imports: succeed(None), + old_provides_to_new_package: succeed(None), + }) + .trace("app_header") +} + +struct OldAppHeader<'a> { + pub before_name: &'a [CommentOrNewline<'a>], + pub packages: Option>>, + pub imports: Option>>, + pub provides: ProvidesTo<'a>, +} + +type OldAppPackages<'a> = + KeywordItem<'a, PackagesKeyword, Collection<'a, Loc>>>>; + +#[inline(always)] +fn old_app_header<'a>() -> impl Parser<'a, AppHeader<'a>, EHeader<'a>> { + let old = record!(OldAppHeader { + before_name: skip_second( + space0_e(EHeader::IndentStart), + loc(crate::parser::specialize_err( + EHeader::AppName, + string_literal::parse_str_literal() + )) + ), + packages: optional(specialize_err(EHeader::Packages, loc(packages()))), + imports: optional(specialize_err(EHeader::Imports, imports())), + provides: specialize_err(EHeader::Provides, provides_to()), + }); + + map_with_arena(old, |arena: &'a bumpalo::Bump, old: OldAppHeader<'a>| { + let mut before_packages: &'a [CommentOrNewline] = &[]; + + let packages = match old.packages { + Some(packages) => { + before_packages = merge_spaces( + arena, + packages.value.keyword.before, + packages.value.keyword.after, + ); + + if let To::ExistingPackage(platform_shorthand) = old.provides.to.value { + packages.map(|coll| { + coll.item.map_items(arena, |loc_spaced_pkg| { + if loc_spaced_pkg.value.item().shorthand == platform_shorthand { + loc_spaced_pkg.map(|spaced_pkg| { + spaced_pkg.map(arena, |pkg| { + let mut new_pkg = *pkg; + new_pkg.platform_marker = Some(merge_spaces( + arena, + old.provides.to_keyword.before, + old.provides.to_keyword.after, + )); + new_pkg + }) + }) + } else { + *loc_spaced_pkg + } + }) + }) + } else { + packages.map(|kw| kw.item) + } + } + None => Loc { + region: Region::zero(), + value: Collection::empty(), + }, + }; + + let provides = match old.provides.types { + Some(types) => { + let mut combined_items = bumpalo::collections::Vec::with_capacity_in( + old.provides.entries.items.len() + types.items.len(), + arena, + ); + + combined_items.extend_from_slice(old.provides.entries.items); + + for loc_spaced_type_ident in types.items { + combined_items.push(loc_spaced_type_ident.map(|spaced_type_ident| { + spaced_type_ident.map(arena, |type_ident| { + ExposedName::new(From::from(*type_ident)) + }) + })); + } + + let value_comments = old.provides.entries.final_comments(); + let type_comments = types.final_comments(); + + let mut combined_comments = bumpalo::collections::Vec::with_capacity_in( + value_comments.len() + type_comments.len(), + arena, + ); + combined_comments.extend_from_slice(value_comments); + combined_comments.extend_from_slice(type_comments); + + Collection::with_items_and_comments( + arena, + combined_items.into_bump_slice(), + combined_comments.into_bump_slice(), + ) + } + None => old.provides.entries, + }; + + AppHeader { + before_provides: merge_spaces( + arena, + old.before_name, + old.provides.provides_keyword.before, + ), + provides, + before_packages: merge_spaces( + arena, + before_packages, + old.provides.provides_keyword.after, + ), + packages, + old_imports: old.imports.and_then(imports_none_if_empty), + old_provides_to_new_package: match old.provides.to.value { + To::NewPackage(new_pkg) => Some(new_pkg), + To::ExistingPackage(_) => None, + }, + } + }) +} + +#[inline(always)] +fn package_header<'a>() -> impl Parser<'a, PackageHeader<'a>, EHeader<'a>> { + record!(PackageHeader { + before_exposes: space0_e(EHeader::IndentStart), + exposes: specialize_err(EHeader::Exposes, exposes_module_collection()), + before_packages: space0_e(EHeader::IndentStart), + packages: specialize_err(EHeader::Packages, loc(packages_collection())), + }) + .trace("package_header") +} + +#[derive(Debug, Clone, PartialEq)] +struct OldPackageHeader<'a> { + before_name: &'a [CommentOrNewline<'a>], + exposes: KeywordItem<'a, ExposesKeyword, Collection<'a, Loc>>>>, + packages: + Loc>>>>>, +} + +#[inline(always)] +fn old_package_header<'a>() -> impl Parser<'a, PackageHeader<'a>, EHeader<'a>> { + map_with_arena( + record!(OldPackageHeader { + before_name: skip_second( + space0_e(EHeader::IndentStart), + specialize_err(EHeader::PackageName, package_name()) + ), + exposes: specialize_err(EHeader::Exposes, exposes_modules()), + packages: specialize_err(EHeader::Packages, loc(packages())), + }), + |arena: &'a bumpalo::Bump, old: OldPackageHeader<'a>| { + let before_exposes = merge_n_spaces!( + arena, + old.before_name, + old.exposes.keyword.before, + old.exposes.keyword.after + ); + let before_packages = merge_spaces( + arena, + old.packages.value.keyword.before, + old.packages.value.keyword.after, + ); + + PackageHeader { + before_exposes, + exposes: old.exposes.item, + before_packages, + packages: old.packages.map(|kw| kw.item), + } + }, + ) + .trace("old_package_header") +} + +#[inline(always)] +fn platform_header<'a>() -> impl Parser<'a, PlatformHeader<'a>, EHeader<'a>> { + record!(PlatformHeader { + before_name: space0_e(EHeader::IndentStart), + name: loc(specialize_err(EHeader::PlatformName, package_name())), + requires: specialize_err(EHeader::Requires, requires()), + exposes: specialize_err(EHeader::Exposes, exposes_modules()), + packages: specialize_err(EHeader::Packages, packages()), + imports: specialize_err(EHeader::Imports, imports()), + provides: specialize_err(EHeader::Provides, provides_exposed()), + }) + .trace("platform_header") +} + +fn provides_to_package<'a>() -> impl Parser<'a, To<'a>, EProvides<'a>> { + one_of![ + specialize_err( + |_, pos| EProvides::Identifier(pos), + map(lowercase_ident(), To::ExistingPackage) + ), + specialize_err(EProvides::Package, map(package_name(), To::NewPackage)) + ] +} + +#[inline(always)] +fn provides_to<'a>() -> impl Parser<'a, ProvidesTo<'a>, EProvides<'a>> { + record!(ProvidesTo { + provides_keyword: spaces_around_keyword( + ProvidesKeyword, + EProvides::Provides, + EProvides::IndentProvides, + EProvides::IndentListStart + ), + entries: collection_trailing_sep_e( + byte(b'[', EProvides::ListStart), + exposes_entry(EProvides::Identifier), + byte(b',', EProvides::ListEnd), + byte(b']', EProvides::ListEnd), + Spaced::SpaceBefore + ), + types: optional(backtrackable(provides_types())), + to_keyword: spaces_around_keyword( + ToKeyword, + EProvides::To, + EProvides::IndentTo, + EProvides::IndentListStart + ), + to: loc(provides_to_package()), + }) + .trace("provides_to") +} + +fn provides_exposed<'a>() -> impl Parser< + 'a, + KeywordItem<'a, ProvidesKeyword, Collection<'a, Loc>>>>, + EProvides<'a>, +> { + record!(KeywordItem { + keyword: spaces_around_keyword( + ProvidesKeyword, + EProvides::Provides, + EProvides::IndentProvides, + EProvides::IndentListStart + ), + item: collection_trailing_sep_e( + byte(b'[', EProvides::ListStart), + exposes_entry(EProvides::Identifier), + byte(b',', EProvides::ListEnd), + byte(b']', EProvides::ListEnd), + Spaced::SpaceBefore + ), + }) +} + +#[inline(always)] +fn provides_types<'a>( +) -> impl Parser<'a, Collection<'a, Loc>>>, EProvides<'a>> { + skip_first( + // We only support spaces here, not newlines, because this is not intended + // to be the design forever. Someday it will hopefully work like Elm, + // where platform authors can provide functions like Browser.sandbox which + // present an API based on ordinary-looking type variables. + zero_or_more(byte( + b' ', + // HACK: If this errors, EProvides::Provides is not an accurate reflection + // of what went wrong. However, this is both skipped and zero_or_more, + // so this error should never be visible to anyone in practice! + EProvides::Provides, + )), + collection_trailing_sep_e( + byte(b'{', EProvides::ListStart), + provides_type_entry(EProvides::Identifier), + byte(b',', EProvides::ListEnd), + byte(b'}', EProvides::ListEnd), + Spaced::SpaceBefore, + ), + ) +} + +fn provides_type_entry<'a, F, E>( + to_expectation: F, +) -> impl Parser<'a, Loc>>, E> +where + F: Fn(Position) -> E, + F: Copy, + E: 'a, +{ + loc(map( + specialize_err(move |_, pos| to_expectation(pos), ident::uppercase()), + Spaced::Item, + )) +} + +fn exposes_entry<'a, F, E>( + to_expectation: F, +) -> impl Parser<'a, Loc>>, E> +where + F: Fn(Position) -> E, + F: Copy, + E: 'a, +{ + loc(map( + specialize_err(move |_, pos| to_expectation(pos), unqualified_ident()), + |n| Spaced::Item(ExposedName::new(n)), + )) +} + +#[inline(always)] +fn requires<'a>( +) -> impl Parser<'a, KeywordItem<'a, RequiresKeyword, PlatformRequires<'a>>, ERequires<'a>> { + record!(KeywordItem { + keyword: spaces_around_keyword( + RequiresKeyword, + ERequires::Requires, + ERequires::IndentRequires, + ERequires::IndentListStart + ), + item: platform_requires(), + }) +} + +#[inline(always)] +fn platform_requires<'a>() -> impl Parser<'a, PlatformRequires<'a>, ERequires<'a>> { + record!(PlatformRequires { + rigids: skip_second(requires_rigids(), space0_e(ERequires::ListStart)), + signature: requires_typed_ident() + }) +} + +#[inline(always)] +fn requires_rigids<'a>( +) -> impl Parser<'a, Collection<'a, Loc>>>, ERequires<'a>> { + collection_trailing_sep_e( + byte(b'{', ERequires::ListStart), + specialize_err( + |_, pos| ERequires::Rigid(pos), + loc(map(ident::uppercase(), Spaced::Item)), + ), + byte(b',', ERequires::ListEnd), + byte(b'}', ERequires::ListEnd), + Spaced::SpaceBefore, + ) +} + +#[inline(always)] +fn requires_typed_ident<'a>() -> impl Parser<'a, Loc>>, ERequires<'a>> { + skip_first( + byte(b'{', ERequires::ListStart), + skip_second( + reset_min_indent(space0_around_ee( + specialize_err(ERequires::TypedIdent, loc(typed_ident())), + ERequires::ListStart, + ERequires::ListEnd, + )), + byte(b'}', ERequires::ListStart), + ), + ) +} + +#[inline(always)] +fn exposes_values_kw<'a>() -> impl Parser< + 'a, + KeywordItem<'a, ExposesKeyword, Collection<'a, Loc>>>>, + EExposes, +> { + record!(KeywordItem { + keyword: exposes_kw(), + item: exposes_list() + }) +} + +#[inline(always)] +fn exposes_kw<'a>() -> impl Parser<'a, Spaces<'a, ExposesKeyword>, EExposes> { + spaces_around_keyword( + ExposesKeyword, + EExposes::Exposes, + EExposes::IndentExposes, + EExposes::IndentListStart, + ) +} + +#[inline(always)] +fn exposes_list<'a>() -> impl Parser<'a, Collection<'a, Loc>>>, EExposes> +{ + collection_trailing_sep_e( + byte(b'[', EExposes::ListStart), + exposes_entry(EExposes::Identifier), + byte(b',', EExposes::ListEnd), + byte(b']', EExposes::ListEnd), + Spaced::SpaceBefore, + ) +} + +pub fn spaces_around_keyword<'a, K: Keyword, E>( + keyword_item: K, + expectation: fn(Position) -> E, + indent_problem1: fn(Position) -> E, + indent_problem2: fn(Position) -> E, +) -> impl Parser<'a, Spaces<'a, K>, E> +where + E: 'a + SpaceProblem, +{ + map( + and( + skip_second( + // parse any leading space before the keyword + backtrackable(space0_e(indent_problem1)), + // parse the keyword + crate::parser::keyword(K::KEYWORD, expectation), + ), + // parse the trailing space + space0_e(indent_problem2), + ), + move |(before, after)| Spaces { + before, + item: keyword_item, + after, + }, + ) +} + +#[inline(always)] +fn exposes_modules<'a>() -> impl Parser< + 'a, + KeywordItem<'a, ExposesKeyword, Collection<'a, Loc>>>>, + EExposes, +> { + record!(KeywordItem { + keyword: spaces_around_keyword( + ExposesKeyword, + EExposes::Exposes, + EExposes::IndentExposes, + EExposes::IndentListStart + ), + item: exposes_module_collection(), + }) +} + +fn exposes_module_collection<'a>( +) -> impl Parser<'a, Collection<'a, Loc>>>, EExposes> { + collection_trailing_sep_e( + byte(b'[', EExposes::ListStart), + exposes_module(EExposes::Identifier), + byte(b',', EExposes::ListEnd), + byte(b']', EExposes::ListEnd), + Spaced::SpaceBefore, + ) +} + +fn exposes_module<'a, F, E>( + to_expectation: F, +) -> impl Parser<'a, Loc>>, E> +where + F: Fn(Position) -> E, + F: Copy, + E: 'a, +{ + loc(map( + specialize_err(move |_, pos| to_expectation(pos), module_name()), + Spaced::Item, + )) +} + +#[inline(always)] +fn packages<'a>() -> impl Parser< + 'a, + KeywordItem<'a, PackagesKeyword, Collection<'a, Loc>>>>, + EPackages<'a>, +> { + record!(KeywordItem { + keyword: packages_kw(), + item: packages_collection() + }) +} + +#[inline(always)] +fn packages_kw<'a>() -> impl Parser<'a, Spaces<'a, PackagesKeyword>, EPackages<'a>> { + spaces_around_keyword( + PackagesKeyword, + EPackages::Packages, + EPackages::IndentPackages, + EPackages::IndentListStart, + ) +} + +#[inline(always)] +fn packages_collection<'a>( +) -> impl Parser<'a, Collection<'a, Loc>>>, EPackages<'a>> { + collection_trailing_sep_e( + byte(b'{', EPackages::ListStart), + specialize_err(EPackages::PackageEntry, loc(package_entry())), + byte(b',', EPackages::ListEnd), + byte(b'}', EPackages::ListEnd), + Spaced::SpaceBefore, + ) +} + +#[inline(always)] +fn generates<'a>( +) -> impl Parser<'a, KeywordItem<'a, GeneratesKeyword, UppercaseIdent<'a>>, EGenerates> { + record!(KeywordItem { + keyword: spaces_around_keyword( + GeneratesKeyword, + EGenerates::Generates, + EGenerates::IndentGenerates, + EGenerates::IndentTypeStart + ), + item: specialize_err(|(), pos| EGenerates::Identifier(pos), uppercase()) + }) +} + +#[inline(always)] +fn generates_with<'a>() -> impl Parser< + 'a, + KeywordItem<'a, WithKeyword, Collection<'a, Loc>>>>, + EGeneratesWith, +> { + record!(KeywordItem { + keyword: spaces_around_keyword( + WithKeyword, + EGeneratesWith::With, + EGeneratesWith::IndentWith, + EGeneratesWith::IndentListStart + ), + item: collection_trailing_sep_e( + byte(b'[', EGeneratesWith::ListStart), + exposes_entry(EGeneratesWith::Identifier), + byte(b',', EGeneratesWith::ListEnd), + byte(b']', EGeneratesWith::ListEnd), + Spaced::SpaceBefore + ) + }) +} + +#[inline(always)] +fn imports<'a>() -> impl Parser< + 'a, + KeywordItem<'a, ImportsKeyword, Collection<'a, Loc>>>>, + EImports, +> { + record!(KeywordItem { + keyword: spaces_around_keyword( + ImportsKeyword, + EImports::Imports, + EImports::IndentImports, + EImports::IndentListStart + ), + item: collection_trailing_sep_e( + byte(b'[', EImports::ListStart), + loc(imports_entry()), + byte(b',', EImports::ListEnd), + byte(b']', EImports::ListEnd), + Spaced::SpaceBefore + ) + }) + .trace("imports") +} + +#[inline(always)] +pub fn typed_ident<'a>() -> impl Parser<'a, Spaced<'a, TypedIdent<'a>>, ETypedIdent<'a>> { + // e.g. + // + // printLine : Str -> Effect {} + map( + and( + and( + loc(specialize_err( + |_, pos| ETypedIdent::Identifier(pos), + lowercase_ident(), + )), + space0_e(ETypedIdent::IndentHasType), + ), + skip_first( + byte(b':', ETypedIdent::HasType), + space0_before_e( + specialize_err( + ETypedIdent::Type, + reset_min_indent(type_annotation::located(true)), + ), + ETypedIdent::IndentType, + ), + ), + ), + |((ident, spaces_before_colon), ann)| { + Spaced::Item(TypedIdent { + ident, + spaces_before_colon, + ann, + }) + }, + ) +} + +fn shortname<'a>() -> impl Parser<'a, &'a str, EImports> { + specialize_err(|_, pos| EImports::Shorthand(pos), lowercase_ident()) +} + +pub fn module_name_help<'a, F, E>(to_expectation: F) -> impl Parser<'a, ModuleName<'a>, E> +where + F: Fn(Position) -> E, + E: 'a, + F: 'a, +{ + specialize_err(move |_, pos| to_expectation(pos), module_name()) +} + +#[inline(always)] +fn imports_entry<'a>() -> impl Parser<'a, Spaced<'a, ImportsEntry<'a>>, EImports> { + type Temp<'a> = ( + (Option<&'a str>, ModuleName<'a>), + Option>>>>, + ); + + let spaced_import = |((opt_shortname, module_name), opt_values): Temp<'a>| { + let exposed_values = opt_values.unwrap_or_else(Collection::empty); + + let entry = match opt_shortname { + Some(shortname) => ImportsEntry::Package(shortname, module_name, exposed_values), + + None => ImportsEntry::Module(module_name, exposed_values), + }; + + Spaced::Item(entry) + }; + + one_of!( + map( + and( + and( + // e.g. `pf.` + optional(backtrackable(skip_second( + shortname(), + byte(b'.', EImports::ShorthandDot) + ))), + // e.g. `Task` + module_name_help(EImports::ModuleName) + ), + // e.g. `.{ Task, after}` + optional(skip_first( + byte(b'.', EImports::ExposingDot), + collection_trailing_sep_e( + byte(b'{', EImports::SetStart), + exposes_entry(EImports::Identifier), + byte(b',', EImports::SetEnd), + byte(b'}', EImports::SetEnd), + Spaced::SpaceBefore + ) + )) + ), + spaced_import + ) + .trace("normal_import"), + map( + and( + and( + // e.g. "filename" + // TODO: str literal allows for multiline strings. We probably don't want that for file names. + specialize_err(|_, pos| EImports::StrLiteral(pos), parse_str_literal()), + // e.g. as + and( + and( + space0_e(EImports::AsKeyword), + two_bytes(b'a', b's', EImports::AsKeyword) + ), + space0_e(EImports::AsKeyword) + ) + ), + // e.g. file : Str + specialize_err(|_, pos| EImports::TypedIdent(pos), typed_ident()) + ), + |((file_name, _), typed_ident)| { + // TODO: look at blacking block strings during parsing. + Spaced::Item(ImportsEntry::IngestedFile(file_name, typed_ident)) + } + ) + .trace("ingest_file_import") + ) + .trace("imports_entry") +} + impl<'a> HeaderType<'a> { pub fn exposed_or_provided_values(&'a self) -> &'a [Loc>] { match self { @@ -55,6 +985,7 @@ pub enum HeaderType<'a> { name: ModuleName<'a>, exposes: &'a [Loc>], generates_with: &'a [Symbol], + opt_params: Option>, }, Package { /// usually something other than `pf` @@ -78,6 +1009,7 @@ pub enum HeaderType<'a> { Module { name: ModuleName<'a>, exposes: &'a [Loc>], + opt_params: Option>, }, } @@ -102,12 +1034,57 @@ impl<'a> HeaderType<'a> { } } + pub fn get_params(&self) -> &Option> { + match self { + Self::Module { + opt_params, + name: _, + exposes: _, + } + | Self::Builtin { + opt_params, + name: _, + exposes: _, + generates_with: _, + } => opt_params, + Self::App { + provides: _, + to_platform: _, + } + | Self::Package { + config_shorthand: _, + exposes: _, + exposes_ids: _, + } + | Self::Hosted { + name: _, + exposes: _, + generates: _, + generates_with: _, + } + | Self::Platform { + opt_app_module_id: _, + provides: _, + requires: _, + requires_types: _, + exposes: _, + exposes_ids: _, + config_shorthand: _, + } => &None, + } + } + pub fn to_maybe_builtin(self, module_id: ModuleId) -> Self { match self { - HeaderType::Module { name, exposes } if module_id.is_builtin() => HeaderType::Builtin { + HeaderType::Module { + name, + exposes, + opt_params, + } if module_id.is_builtin() => HeaderType::Builtin { name, exposes, generates_with: &[], + opt_params, }, _ => self, } @@ -178,7 +1155,7 @@ impl<'a> ModuleName<'a> { ModuleName(name) } - pub const fn as_str(&'a self) -> &'a str { + pub const fn as_str(&self) -> &'a str { self.0 } @@ -255,7 +1232,7 @@ pub struct ModuleHeader<'a> { #[derive(Clone, Debug, PartialEq)] pub struct ModuleParams<'a> { - pub params: Collection<'a, Loc>>, + pub pattern: Loc>>>, pub before_arrow: &'a [CommentOrNewline<'a>], pub after_arrow: &'a [CommentOrNewline<'a>], } diff --git a/crates/compiler/parse/src/highlight.rs b/crates/compiler/parse/src/highlight.rs index c94df15259..b5b5c5fff4 100644 --- a/crates/compiler/parse/src/highlight.rs +++ b/crates/compiler/parse/src/highlight.rs @@ -74,7 +74,7 @@ pub fn highlight(text: &str) -> Vec> { let header_keywords = HEADER_KEYWORDS.iter().copied().collect::>(); let body_keywords = KEYWORDS.iter().copied().collect::>(); - if let Ok((_prog, _, new_state)) = crate::module::header().parse(&arena, state.clone(), 0) { + if let Ok((_prog, _, new_state)) = crate::header::header().parse(&arena, state.clone(), 0) { let inner_state = State::new(text[..state.bytes().len() - new_state.bytes().len()].as_bytes()); highlight_inner(&arena, inner_state, &mut tokens, &header_keywords); diff --git a/crates/compiler/parse/src/lib.rs b/crates/compiler/parse/src/lib.rs index dc8a9a3aaa..f92899aa89 100644 --- a/crates/compiler/parse/src/lib.rs +++ b/crates/compiler/parse/src/lib.rs @@ -13,11 +13,10 @@ pub mod header; pub mod highlight; pub mod ident; pub mod keyword; -pub mod module; +pub mod normalize; pub mod number_literal; pub mod pattern; pub mod problems; -pub mod remove_spaces; pub mod src64; pub mod state; pub mod string_literal; diff --git a/crates/compiler/parse/src/module.rs b/crates/compiler/parse/src/module.rs deleted file mode 100644 index 3a895cdd2a..0000000000 --- a/crates/compiler/parse/src/module.rs +++ /dev/null @@ -1,945 +0,0 @@ -use crate::ast::{Collection, CommentOrNewline, Defs, Header, Module, Spaced, Spaces}; -use crate::blankspace::{space0_around_ee, space0_before_e, space0_e}; -use crate::expr::merge_spaces; -use crate::header::{ - package_entry, package_name, AppHeader, ExposedName, ExposesKeyword, GeneratesKeyword, - HostedHeader, ImportsCollection, ImportsEntry, ImportsKeyword, ImportsKeywordItem, Keyword, - KeywordItem, ModuleHeader, ModuleName, ModuleParams, PackageEntry, PackageHeader, - PackagesKeyword, PlatformHeader, PlatformRequires, ProvidesKeyword, ProvidesTo, - RequiresKeyword, To, ToKeyword, TypedIdent, WithKeyword, -}; -use crate::ident::{self, lowercase_ident, unqualified_ident, uppercase, UppercaseIdent}; -use crate::parser::Progress::{self, *}; -use crate::parser::{ - and, backtrackable, byte, collection_trailing_sep_e, increment_min_indent, loc, map, - map_with_arena, optional, reset_min_indent, skip_first, skip_second, specialize_err, succeed, - two_bytes, zero_or_more, EExposes, EGenerates, EGeneratesWith, EHeader, EImports, EPackages, - EParams, EProvides, ERequires, ETypedIdent, Parser, SourceError, SpaceProblem, SyntaxError, -}; -use crate::pattern::record_pattern_fields; -use crate::state::State; -use crate::string_literal::{self, parse_str_literal}; -use crate::type_annotation; -use roc_region::all::{Loc, Position, Region}; - -fn end_of_file<'a>() -> impl Parser<'a, (), SyntaxError<'a>> { - |_arena, state: State<'a>, _min_indent: u32| { - if state.has_reached_end() { - Ok((NoProgress, (), state)) - } else { - Err((NoProgress, SyntaxError::NotEndOfFile(state.pos()))) - } - } -} - -pub fn parse_module_defs<'a>( - arena: &'a bumpalo::Bump, - state: State<'a>, - defs: Defs<'a>, -) -> Result, SyntaxError<'a>> { - let min_indent = 0; - match crate::expr::parse_top_level_defs(arena, state.clone(), defs) { - Ok((_, defs, state)) => match end_of_file().parse(arena, state, min_indent) { - Ok(_) => Ok(defs), - Err((_, fail)) => Err(fail), - }, - Err((_, fail)) => Err(SyntaxError::Expr(fail, state.pos())), - } -} - -pub fn parse_header<'a>( - arena: &'a bumpalo::Bump, - state: State<'a>, -) -> Result<(Module<'a>, State<'a>), SourceError<'a, EHeader<'a>>> { - let min_indent = 0; - match header().parse(arena, state.clone(), min_indent) { - Ok((_, module, state)) => Ok((module, state)), - Err((_, fail)) => Err(SourceError::new(fail, &state)), - } -} - -pub fn header<'a>() -> impl Parser<'a, Module<'a>, EHeader<'a>> { - use crate::parser::keyword; - - record!(Module { - comments: space0_e(EHeader::IndentStart), - header: one_of![ - map( - skip_first( - keyword("module", EHeader::Start), - increment_min_indent(module_header()) - ), - Header::Module - ), - map( - skip_first( - keyword("interface", EHeader::Start), - increment_min_indent(interface_header()) - ), - Header::Module - ), - map( - skip_first( - keyword("app", EHeader::Start), - increment_min_indent(one_of![app_header(), old_app_header()]) - ), - Header::App - ), - map( - skip_first( - keyword("package", EHeader::Start), - increment_min_indent(one_of![package_header(), old_package_header()]) - ), - Header::Package - ), - map( - skip_first( - keyword("platform", EHeader::Start), - increment_min_indent(platform_header()) - ), - Header::Platform - ), - map( - skip_first( - keyword("hosted", EHeader::Start), - increment_min_indent(hosted_header()) - ), - Header::Hosted - ), - ] - }) -} - -#[inline(always)] -fn module_header<'a>() -> impl Parser<'a, ModuleHeader<'a>, EHeader<'a>> { - record!(ModuleHeader { - after_keyword: space0_e(EHeader::IndentStart), - params: optional(specialize_err(EHeader::Params, module_params())), - exposes: specialize_err(EHeader::Exposes, exposes_list()), - interface_imports: succeed(None) - }) - .trace("module_header") -} - -fn module_params<'a>() -> impl Parser<'a, ModuleParams<'a>, EParams<'a>> { - record!(ModuleParams { - params: specialize_err(EParams::Pattern, record_pattern_fields()), - before_arrow: skip_second( - space0_e(EParams::BeforeArrow), - loc(two_bytes(b'-', b'>', EParams::Arrow)) - ), - after_arrow: space0_e(EParams::AfterArrow), - }) -} - -// TODO does this need to be a macro? -macro_rules! merge_n_spaces { - ($arena:expr, $($slice:expr),*) => { - { - let mut merged = bumpalo::collections::Vec::with_capacity_in(0 $(+ $slice.len())*, $arena); - $(merged.extend_from_slice($slice);)* - merged.into_bump_slice() - } - }; -} - -/// Parse old interface headers so we can format them into module headers -#[inline(always)] -fn interface_header<'a>() -> impl Parser<'a, ModuleHeader<'a>, EHeader<'a>> { - let after_keyword = map_with_arena( - and( - skip_second( - space0_e(EHeader::IndentStart), - loc(module_name_help(EHeader::ModuleName)), - ), - specialize_err(EHeader::Exposes, exposes_kw()), - ), - |arena: &'a bumpalo::Bump, - (before_name, kw): (&'a [CommentOrNewline<'a>], Spaces<'a, ExposesKeyword>)| { - merge_n_spaces!(arena, before_name, kw.before, kw.after) - }, - ); - - record!(ModuleHeader { - after_keyword: after_keyword, - params: succeed(None), - exposes: specialize_err(EHeader::Exposes, exposes_list()).trace("exposes_list"), - interface_imports: map( - specialize_err(EHeader::Imports, imports()), - imports_none_if_empty - ) - .trace("imports"), - }) - .trace("interface_header") -} - -fn imports_none_if_empty(value: ImportsKeywordItem<'_>) -> Option> { - if value.item.is_empty() { - None - } else { - Some(value) - } -} - -#[inline(always)] -fn hosted_header<'a>() -> impl Parser<'a, HostedHeader<'a>, EHeader<'a>> { - record!(HostedHeader { - before_name: space0_e(EHeader::IndentStart), - name: loc(module_name_help(EHeader::ModuleName)), - exposes: specialize_err(EHeader::Exposes, exposes_values_kw()), - imports: specialize_err(EHeader::Imports, imports()), - generates: specialize_err(EHeader::Generates, generates()), - generates_with: specialize_err(EHeader::GeneratesWith, generates_with()), - }) - .trace("hosted_header") -} - -fn chomp_module_name(buffer: &[u8]) -> Result<&str, Progress> { - use encode_unicode::CharExt; - - let mut chomped = 0; - - if let Ok((first_letter, width)) = char::from_utf8_slice_start(&buffer[chomped..]) { - if first_letter.is_uppercase() { - chomped += width; - } else { - return Err(Progress::NoProgress); - } - } - - while let Ok((ch, width)) = char::from_utf8_slice_start(&buffer[chomped..]) { - // After the first character, only these are allowed: - // - // * Unicode alphabetic chars - you might include `鹏` if that's clear to your readers - // * ASCII digits - e.g. `1` but not `¾`, both of which pass .is_numeric() - // * A '.' separating module parts - if ch.is_alphabetic() || ch.is_ascii_digit() { - chomped += width; - } else if ch == '.' { - chomped += width; - - if let Ok((first_letter, width)) = char::from_utf8_slice_start(&buffer[chomped..]) { - if first_letter.is_uppercase() { - chomped += width; - } else if first_letter == '{' { - // the .{ starting a `Foo.{ bar, baz }` importing clauses - chomped -= width; - break; - } else { - return Err(Progress::MadeProgress); - } - } - } else { - // we're done - break; - } - } - - let name = unsafe { std::str::from_utf8_unchecked(&buffer[..chomped]) }; - - Ok(name) -} - -#[inline(always)] -fn module_name<'a>() -> impl Parser<'a, ModuleName<'a>, ()> { - |_, mut state: State<'a>, _min_indent: u32| match chomp_module_name(state.bytes()) { - Ok(name) => { - let width = name.len(); - state = state.advance(width); - - Ok((MadeProgress, ModuleName::new(name), state)) - } - Err(progress) => Err((progress, ())), - } -} - -#[inline(always)] -fn app_header<'a>() -> impl Parser<'a, AppHeader<'a>, EHeader<'a>> { - record!(AppHeader { - before_provides: space0_e(EHeader::IndentStart), - provides: specialize_err(EHeader::Exposes, exposes_list()), - before_packages: space0_e(EHeader::IndentStart), - packages: specialize_err(EHeader::Packages, loc(packages_collection())), - old_imports: succeed(None), - old_provides_to_new_package: succeed(None), - }) - .trace("app_header") -} - -struct OldAppHeader<'a> { - pub before_name: &'a [CommentOrNewline<'a>], - pub packages: Option>>, - pub imports: Option>>, - pub provides: ProvidesTo<'a>, -} - -type OldAppPackages<'a> = - KeywordItem<'a, PackagesKeyword, Collection<'a, Loc>>>>; - -#[inline(always)] -fn old_app_header<'a>() -> impl Parser<'a, AppHeader<'a>, EHeader<'a>> { - let old = record!(OldAppHeader { - before_name: skip_second( - space0_e(EHeader::IndentStart), - loc(crate::parser::specialize_err( - EHeader::AppName, - string_literal::parse_str_literal() - )) - ), - packages: optional(specialize_err(EHeader::Packages, loc(packages()))), - imports: optional(specialize_err(EHeader::Imports, imports())), - provides: specialize_err(EHeader::Provides, provides_to()), - }); - - map_with_arena(old, |arena: &'a bumpalo::Bump, old: OldAppHeader<'a>| { - let mut before_packages: &'a [CommentOrNewline] = &[]; - - let packages = match old.packages { - Some(packages) => { - before_packages = merge_spaces( - arena, - packages.value.keyword.before, - packages.value.keyword.after, - ); - - if let To::ExistingPackage(platform_shorthand) = old.provides.to.value { - packages.map(|coll| { - coll.item.map_items(arena, |loc_spaced_pkg| { - if loc_spaced_pkg.value.item().shorthand == platform_shorthand { - loc_spaced_pkg.map(|spaced_pkg| { - spaced_pkg.map(arena, |pkg| { - let mut new_pkg = *pkg; - new_pkg.platform_marker = Some(merge_spaces( - arena, - old.provides.to_keyword.before, - old.provides.to_keyword.after, - )); - new_pkg - }) - }) - } else { - *loc_spaced_pkg - } - }) - }) - } else { - packages.map(|kw| kw.item) - } - } - None => Loc { - region: Region::zero(), - value: Collection::empty(), - }, - }; - - let provides = match old.provides.types { - Some(types) => { - let mut combined_items = bumpalo::collections::Vec::with_capacity_in( - old.provides.entries.items.len() + types.items.len(), - arena, - ); - - combined_items.extend_from_slice(old.provides.entries.items); - - for loc_spaced_type_ident in types.items { - combined_items.push(loc_spaced_type_ident.map(|spaced_type_ident| { - spaced_type_ident.map(arena, |type_ident| { - ExposedName::new(From::from(*type_ident)) - }) - })); - } - - let value_comments = old.provides.entries.final_comments(); - let type_comments = types.final_comments(); - - let mut combined_comments = bumpalo::collections::Vec::with_capacity_in( - value_comments.len() + type_comments.len(), - arena, - ); - combined_comments.extend_from_slice(value_comments); - combined_comments.extend_from_slice(type_comments); - - Collection::with_items_and_comments( - arena, - combined_items.into_bump_slice(), - combined_comments.into_bump_slice(), - ) - } - None => old.provides.entries, - }; - - AppHeader { - before_provides: merge_spaces( - arena, - old.before_name, - old.provides.provides_keyword.before, - ), - provides, - before_packages: merge_spaces( - arena, - before_packages, - old.provides.provides_keyword.after, - ), - packages, - old_imports: old.imports.and_then(imports_none_if_empty), - old_provides_to_new_package: match old.provides.to.value { - To::NewPackage(new_pkg) => Some(new_pkg), - To::ExistingPackage(_) => None, - }, - } - }) -} - -#[inline(always)] -fn package_header<'a>() -> impl Parser<'a, PackageHeader<'a>, EHeader<'a>> { - record!(PackageHeader { - before_exposes: space0_e(EHeader::IndentStart), - exposes: specialize_err(EHeader::Exposes, exposes_module_collection()), - before_packages: space0_e(EHeader::IndentStart), - packages: specialize_err(EHeader::Packages, loc(packages_collection())), - }) - .trace("package_header") -} - -#[derive(Debug, Clone, PartialEq)] -struct OldPackageHeader<'a> { - before_name: &'a [CommentOrNewline<'a>], - exposes: KeywordItem<'a, ExposesKeyword, Collection<'a, Loc>>>>, - packages: - Loc>>>>>, -} - -#[inline(always)] -fn old_package_header<'a>() -> impl Parser<'a, PackageHeader<'a>, EHeader<'a>> { - map_with_arena( - record!(OldPackageHeader { - before_name: skip_second( - space0_e(EHeader::IndentStart), - specialize_err(EHeader::PackageName, package_name()) - ), - exposes: specialize_err(EHeader::Exposes, exposes_modules()), - packages: specialize_err(EHeader::Packages, loc(packages())), - }), - |arena: &'a bumpalo::Bump, old: OldPackageHeader<'a>| { - let before_exposes = merge_n_spaces!( - arena, - old.before_name, - old.exposes.keyword.before, - old.exposes.keyword.after - ); - let before_packages = merge_spaces( - arena, - old.packages.value.keyword.before, - old.packages.value.keyword.after, - ); - - PackageHeader { - before_exposes, - exposes: old.exposes.item, - before_packages, - packages: old.packages.map(|kw| kw.item), - } - }, - ) - .trace("old_package_header") -} - -#[inline(always)] -fn platform_header<'a>() -> impl Parser<'a, PlatformHeader<'a>, EHeader<'a>> { - record!(PlatformHeader { - before_name: space0_e(EHeader::IndentStart), - name: loc(specialize_err(EHeader::PlatformName, package_name())), - requires: specialize_err(EHeader::Requires, requires()), - exposes: specialize_err(EHeader::Exposes, exposes_modules()), - packages: specialize_err(EHeader::Packages, packages()), - imports: specialize_err(EHeader::Imports, imports()), - provides: specialize_err(EHeader::Provides, provides_exposed()), - }) - .trace("platform_header") -} - -fn provides_to_package<'a>() -> impl Parser<'a, To<'a>, EProvides<'a>> { - one_of![ - specialize_err( - |_, pos| EProvides::Identifier(pos), - map(lowercase_ident(), To::ExistingPackage) - ), - specialize_err(EProvides::Package, map(package_name(), To::NewPackage)) - ] -} - -#[inline(always)] -fn provides_to<'a>() -> impl Parser<'a, ProvidesTo<'a>, EProvides<'a>> { - record!(ProvidesTo { - provides_keyword: spaces_around_keyword( - ProvidesKeyword, - EProvides::Provides, - EProvides::IndentProvides, - EProvides::IndentListStart - ), - entries: collection_trailing_sep_e( - byte(b'[', EProvides::ListStart), - exposes_entry(EProvides::Identifier), - byte(b',', EProvides::ListEnd), - byte(b']', EProvides::ListEnd), - Spaced::SpaceBefore - ), - types: optional(backtrackable(provides_types())), - to_keyword: spaces_around_keyword( - ToKeyword, - EProvides::To, - EProvides::IndentTo, - EProvides::IndentListStart - ), - to: loc(provides_to_package()), - }) - .trace("provides_to") -} - -fn provides_exposed<'a>() -> impl Parser< - 'a, - KeywordItem<'a, ProvidesKeyword, Collection<'a, Loc>>>>, - EProvides<'a>, -> { - record!(KeywordItem { - keyword: spaces_around_keyword( - ProvidesKeyword, - EProvides::Provides, - EProvides::IndentProvides, - EProvides::IndentListStart - ), - item: collection_trailing_sep_e( - byte(b'[', EProvides::ListStart), - exposes_entry(EProvides::Identifier), - byte(b',', EProvides::ListEnd), - byte(b']', EProvides::ListEnd), - Spaced::SpaceBefore - ), - }) -} - -#[inline(always)] -fn provides_types<'a>( -) -> impl Parser<'a, Collection<'a, Loc>>>, EProvides<'a>> { - skip_first( - // We only support spaces here, not newlines, because this is not intended - // to be the design forever. Someday it will hopefully work like Elm, - // where platform authors can provide functions like Browser.sandbox which - // present an API based on ordinary-looking type variables. - zero_or_more(byte( - b' ', - // HACK: If this errors, EProvides::Provides is not an accurate reflection - // of what went wrong. However, this is both skipped and zero_or_more, - // so this error should never be visible to anyone in practice! - EProvides::Provides, - )), - collection_trailing_sep_e( - byte(b'{', EProvides::ListStart), - provides_type_entry(EProvides::Identifier), - byte(b',', EProvides::ListEnd), - byte(b'}', EProvides::ListEnd), - Spaced::SpaceBefore, - ), - ) -} - -fn provides_type_entry<'a, F, E>( - to_expectation: F, -) -> impl Parser<'a, Loc>>, E> -where - F: Fn(Position) -> E, - F: Copy, - E: 'a, -{ - loc(map( - specialize_err(move |_, pos| to_expectation(pos), ident::uppercase()), - Spaced::Item, - )) -} - -fn exposes_entry<'a, F, E>( - to_expectation: F, -) -> impl Parser<'a, Loc>>, E> -where - F: Fn(Position) -> E, - F: Copy, - E: 'a, -{ - loc(map( - specialize_err(move |_, pos| to_expectation(pos), unqualified_ident()), - |n| Spaced::Item(ExposedName::new(n)), - )) -} - -#[inline(always)] -fn requires<'a>( -) -> impl Parser<'a, KeywordItem<'a, RequiresKeyword, PlatformRequires<'a>>, ERequires<'a>> { - record!(KeywordItem { - keyword: spaces_around_keyword( - RequiresKeyword, - ERequires::Requires, - ERequires::IndentRequires, - ERequires::IndentListStart - ), - item: platform_requires(), - }) -} - -#[inline(always)] -fn platform_requires<'a>() -> impl Parser<'a, PlatformRequires<'a>, ERequires<'a>> { - record!(PlatformRequires { - rigids: skip_second(requires_rigids(), space0_e(ERequires::ListStart)), - signature: requires_typed_ident() - }) -} - -#[inline(always)] -fn requires_rigids<'a>( -) -> impl Parser<'a, Collection<'a, Loc>>>, ERequires<'a>> { - collection_trailing_sep_e( - byte(b'{', ERequires::ListStart), - specialize_err( - |_, pos| ERequires::Rigid(pos), - loc(map(ident::uppercase(), Spaced::Item)), - ), - byte(b',', ERequires::ListEnd), - byte(b'}', ERequires::ListEnd), - Spaced::SpaceBefore, - ) -} - -#[inline(always)] -fn requires_typed_ident<'a>() -> impl Parser<'a, Loc>>, ERequires<'a>> { - skip_first( - byte(b'{', ERequires::ListStart), - skip_second( - reset_min_indent(space0_around_ee( - specialize_err(ERequires::TypedIdent, loc(typed_ident())), - ERequires::ListStart, - ERequires::ListEnd, - )), - byte(b'}', ERequires::ListStart), - ), - ) -} - -#[inline(always)] -fn exposes_values_kw<'a>() -> impl Parser< - 'a, - KeywordItem<'a, ExposesKeyword, Collection<'a, Loc>>>>, - EExposes, -> { - record!(KeywordItem { - keyword: exposes_kw(), - item: exposes_list() - }) -} - -#[inline(always)] -fn exposes_kw<'a>() -> impl Parser<'a, Spaces<'a, ExposesKeyword>, EExposes> { - spaces_around_keyword( - ExposesKeyword, - EExposes::Exposes, - EExposes::IndentExposes, - EExposes::IndentListStart, - ) -} - -#[inline(always)] -fn exposes_list<'a>() -> impl Parser<'a, Collection<'a, Loc>>>, EExposes> -{ - collection_trailing_sep_e( - byte(b'[', EExposes::ListStart), - exposes_entry(EExposes::Identifier), - byte(b',', EExposes::ListEnd), - byte(b']', EExposes::ListEnd), - Spaced::SpaceBefore, - ) -} - -pub fn spaces_around_keyword<'a, K: Keyword, E>( - keyword_item: K, - expectation: fn(Position) -> E, - indent_problem1: fn(Position) -> E, - indent_problem2: fn(Position) -> E, -) -> impl Parser<'a, Spaces<'a, K>, E> -where - E: 'a + SpaceProblem, -{ - map( - and( - skip_second( - // parse any leading space before the keyword - backtrackable(space0_e(indent_problem1)), - // parse the keyword - crate::parser::keyword(K::KEYWORD, expectation), - ), - // parse the trailing space - space0_e(indent_problem2), - ), - move |(before, after)| Spaces { - before, - item: keyword_item, - after, - }, - ) -} - -#[inline(always)] -fn exposes_modules<'a>() -> impl Parser< - 'a, - KeywordItem<'a, ExposesKeyword, Collection<'a, Loc>>>>, - EExposes, -> { - record!(KeywordItem { - keyword: spaces_around_keyword( - ExposesKeyword, - EExposes::Exposes, - EExposes::IndentExposes, - EExposes::IndentListStart - ), - item: exposes_module_collection(), - }) -} - -fn exposes_module_collection<'a>( -) -> impl Parser<'a, Collection<'a, Loc>>>, EExposes> { - collection_trailing_sep_e( - byte(b'[', EExposes::ListStart), - exposes_module(EExposes::Identifier), - byte(b',', EExposes::ListEnd), - byte(b']', EExposes::ListEnd), - Spaced::SpaceBefore, - ) -} - -fn exposes_module<'a, F, E>( - to_expectation: F, -) -> impl Parser<'a, Loc>>, E> -where - F: Fn(Position) -> E, - F: Copy, - E: 'a, -{ - loc(map( - specialize_err(move |_, pos| to_expectation(pos), module_name()), - Spaced::Item, - )) -} - -#[inline(always)] -fn packages<'a>() -> impl Parser< - 'a, - KeywordItem<'a, PackagesKeyword, Collection<'a, Loc>>>>, - EPackages<'a>, -> { - record!(KeywordItem { - keyword: packages_kw(), - item: packages_collection() - }) -} - -#[inline(always)] -fn packages_kw<'a>() -> impl Parser<'a, Spaces<'a, PackagesKeyword>, EPackages<'a>> { - spaces_around_keyword( - PackagesKeyword, - EPackages::Packages, - EPackages::IndentPackages, - EPackages::IndentListStart, - ) -} - -#[inline(always)] -fn packages_collection<'a>( -) -> impl Parser<'a, Collection<'a, Loc>>>, EPackages<'a>> { - collection_trailing_sep_e( - byte(b'{', EPackages::ListStart), - specialize_err(EPackages::PackageEntry, loc(package_entry())), - byte(b',', EPackages::ListEnd), - byte(b'}', EPackages::ListEnd), - Spaced::SpaceBefore, - ) -} - -#[inline(always)] -fn generates<'a>( -) -> impl Parser<'a, KeywordItem<'a, GeneratesKeyword, UppercaseIdent<'a>>, EGenerates> { - record!(KeywordItem { - keyword: spaces_around_keyword( - GeneratesKeyword, - EGenerates::Generates, - EGenerates::IndentGenerates, - EGenerates::IndentTypeStart - ), - item: specialize_err(|(), pos| EGenerates::Identifier(pos), uppercase()) - }) -} - -#[inline(always)] -fn generates_with<'a>() -> impl Parser< - 'a, - KeywordItem<'a, WithKeyword, Collection<'a, Loc>>>>, - EGeneratesWith, -> { - record!(KeywordItem { - keyword: spaces_around_keyword( - WithKeyword, - EGeneratesWith::With, - EGeneratesWith::IndentWith, - EGeneratesWith::IndentListStart - ), - item: collection_trailing_sep_e( - byte(b'[', EGeneratesWith::ListStart), - exposes_entry(EGeneratesWith::Identifier), - byte(b',', EGeneratesWith::ListEnd), - byte(b']', EGeneratesWith::ListEnd), - Spaced::SpaceBefore - ) - }) -} - -#[inline(always)] -fn imports<'a>() -> impl Parser< - 'a, - KeywordItem<'a, ImportsKeyword, Collection<'a, Loc>>>>, - EImports, -> { - record!(KeywordItem { - keyword: spaces_around_keyword( - ImportsKeyword, - EImports::Imports, - EImports::IndentImports, - EImports::IndentListStart - ), - item: collection_trailing_sep_e( - byte(b'[', EImports::ListStart), - loc(imports_entry()), - byte(b',', EImports::ListEnd), - byte(b']', EImports::ListEnd), - Spaced::SpaceBefore - ) - }) - .trace("imports") -} - -#[inline(always)] -pub fn typed_ident<'a>() -> impl Parser<'a, Spaced<'a, TypedIdent<'a>>, ETypedIdent<'a>> { - // e.g. - // - // printLine : Str -> Effect {} - map( - and( - and( - loc(specialize_err( - |_, pos| ETypedIdent::Identifier(pos), - lowercase_ident(), - )), - space0_e(ETypedIdent::IndentHasType), - ), - skip_first( - byte(b':', ETypedIdent::HasType), - space0_before_e( - specialize_err( - ETypedIdent::Type, - reset_min_indent(type_annotation::located(true)), - ), - ETypedIdent::IndentType, - ), - ), - ), - |((ident, spaces_before_colon), ann)| { - Spaced::Item(TypedIdent { - ident, - spaces_before_colon, - ann, - }) - }, - ) -} - -fn shortname<'a>() -> impl Parser<'a, &'a str, EImports> { - specialize_err(|_, pos| EImports::Shorthand(pos), lowercase_ident()) -} - -pub fn module_name_help<'a, F, E>(to_expectation: F) -> impl Parser<'a, ModuleName<'a>, E> -where - F: Fn(Position) -> E, - E: 'a, - F: 'a, -{ - specialize_err(move |_, pos| to_expectation(pos), module_name()) -} - -#[inline(always)] -fn imports_entry<'a>() -> impl Parser<'a, Spaced<'a, ImportsEntry<'a>>, EImports> { - type Temp<'a> = ( - (Option<&'a str>, ModuleName<'a>), - Option>>>>, - ); - - let spaced_import = |((opt_shortname, module_name), opt_values): Temp<'a>| { - let exposed_values = opt_values.unwrap_or_else(Collection::empty); - - let entry = match opt_shortname { - Some(shortname) => ImportsEntry::Package(shortname, module_name, exposed_values), - - None => ImportsEntry::Module(module_name, exposed_values), - }; - - Spaced::Item(entry) - }; - - one_of!( - map( - and( - and( - // e.g. `pf.` - optional(backtrackable(skip_second( - shortname(), - byte(b'.', EImports::ShorthandDot) - ))), - // e.g. `Task` - module_name_help(EImports::ModuleName) - ), - // e.g. `.{ Task, after}` - optional(skip_first( - byte(b'.', EImports::ExposingDot), - collection_trailing_sep_e( - byte(b'{', EImports::SetStart), - exposes_entry(EImports::Identifier), - byte(b',', EImports::SetEnd), - byte(b'}', EImports::SetEnd), - Spaced::SpaceBefore - ) - )) - ), - spaced_import - ) - .trace("normal_import"), - map( - and( - and( - // e.g. "filename" - // TODO: str literal allows for multiline strings. We probably don't want that for file names. - specialize_err(|_, pos| EImports::StrLiteral(pos), parse_str_literal()), - // e.g. as - and( - and( - space0_e(EImports::AsKeyword), - two_bytes(b'a', b's', EImports::AsKeyword) - ), - space0_e(EImports::AsKeyword) - ) - ), - // e.g. file : Str - specialize_err(|_, pos| EImports::TypedIdent(pos), typed_ident()) - ), - |((file_name, _), typed_ident)| { - // TODO: look at blacking block strings during parsing. - Spaced::Item(ImportsEntry::IngestedFile(file_name, typed_ident)) - } - ) - .trace("ingest_file_import") - ) - .trace("imports_entry") -} diff --git a/crates/compiler/parse/src/remove_spaces.rs b/crates/compiler/parse/src/normalize.rs similarity index 59% rename from crates/compiler/parse/src/remove_spaces.rs rename to crates/compiler/parse/src/normalize.rs index 1de484706e..3d69dc3657 100644 --- a/crates/compiler/parse/src/remove_spaces.rs +++ b/crates/compiler/parse/src/normalize.rs @@ -1,16 +1,16 @@ -use bumpalo::collections::Vec; +use bumpalo::collections::{String, Vec}; use bumpalo::Bump; use roc_module::called_via::{BinOp, UnaryOp}; use roc_region::all::{Loc, Position, Region}; use crate::{ ast::{ - AbilityImpls, AbilityMember, AssignedField, Collection, Defs, Expr, Header, Implements, - ImplementsAbilities, ImplementsAbility, ImplementsClause, ImportAlias, ImportAsKeyword, - ImportExposingKeyword, ImportedModuleName, IngestedFileAnnotation, IngestedFileImport, - Module, ModuleImport, ModuleImportParams, OldRecordBuilderField, Pattern, PatternAs, - Spaced, Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation, TypeDef, TypeHeader, ValueDef, - WhenBranch, + AbilityImpls, AbilityMember, AssignedField, Collection, Defs, Expr, FullAst, Header, + Implements, ImplementsAbilities, ImplementsAbility, ImplementsClause, ImportAlias, + ImportAsKeyword, ImportExposingKeyword, ImportedModuleName, IngestedFileAnnotation, + IngestedFileImport, ModuleImport, ModuleImportParams, OldRecordBuilderField, Pattern, + PatternAs, Spaced, Spaces, SpacesBefore, StrLiteral, StrSegment, Tag, TypeAnnotation, + TypeDef, TypeHeader, ValueDef, WhenBranch, }, header::{ AppHeader, ExposedName, ExposesKeyword, GeneratesKeyword, HostedHeader, ImportsEntry, @@ -29,25 +29,26 @@ use crate::{ }, }; -/// RemoveSpaces normalizes the ast to something that we _expect_ to be invariant under formatting. +/// Normalizes the ast to something that we _expect_ to be invariant under formatting. /// /// Currently this consists of: /// * Removing newlines /// * Removing comments /// * Removing parens in Exprs +/// * Normalizing string encoding /// /// Long term, we actually want this transform to preserve comments (so we can assert they're maintained by formatting) /// - but there are currently several bugs where they're _not_ preserved. /// TODO: ensure formatting retains comments -pub trait RemoveSpaces<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self; +pub trait Normalize<'a> { + fn normalize(&self, arena: &'a Bump) -> Self; } macro_rules! keywords { ($($name:ident),* $(,)?) => { $( - impl<'a> RemoveSpaces<'a> for $name { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { + impl<'a> Normalize<'a> for $name { + fn normalize(&self, _arena: &'a Bump) -> Self { *self } } @@ -68,8 +69,8 @@ keywords! { PlatformKeyword, } -impl<'a> RemoveSpaces<'a> for Defs<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for Defs<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { let mut defs = self.clone(); defs.spaces.clear(); @@ -77,188 +78,200 @@ impl<'a> RemoveSpaces<'a> for Defs<'a> { defs.space_after.clear(); for type_def in defs.type_defs.iter_mut() { - *type_def = type_def.remove_spaces(arena); + *type_def = type_def.normalize(arena); } for value_def in defs.value_defs.iter_mut() { - *value_def = value_def.remove_spaces(arena); + *value_def = value_def.normalize(arena); } for region_def in defs.regions.iter_mut() { - *region_def = region_def.remove_spaces(arena); + *region_def = region_def.normalize(arena); } defs } } -impl<'a, V: RemoveSpaces<'a>> RemoveSpaces<'a> for Spaces<'a, V> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a, V: Normalize<'a>> Normalize<'a> for Spaces<'a, V> { + fn normalize(&self, arena: &'a Bump) -> Self { Spaces { before: &[], - item: self.item.remove_spaces(arena), + item: self.item.normalize(arena), after: &[], } } } -impl<'a, K: RemoveSpaces<'a>, V: RemoveSpaces<'a>> RemoveSpaces<'a> for KeywordItem<'a, K, V> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a, V: Normalize<'a>> Normalize<'a> for SpacesBefore<'a, V> { + fn normalize(&self, arena: &'a Bump) -> Self { + SpacesBefore { + before: &[], + item: self.item.normalize(arena), + } + } +} + +impl<'a> Normalize<'a> for FullAst<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { + FullAst { + header: self.header.normalize(arena), + defs: self.defs.normalize(arena), + } + } +} + +impl<'a, K: Normalize<'a>, V: Normalize<'a>> Normalize<'a> for KeywordItem<'a, K, V> { + fn normalize(&self, arena: &'a Bump) -> Self { KeywordItem { - keyword: self.keyword.remove_spaces(arena), - item: self.item.remove_spaces(arena), + keyword: self.keyword.normalize(arena), + item: self.item.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for ProvidesTo<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ProvidesTo<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { ProvidesTo { - provides_keyword: self.provides_keyword.remove_spaces(arena), - entries: self.entries.remove_spaces(arena), - types: self.types.remove_spaces(arena), - to_keyword: self.to_keyword.remove_spaces(arena), - to: self.to.remove_spaces(arena), + provides_keyword: self.provides_keyword.normalize(arena), + entries: self.entries.normalize(arena), + types: self.types.normalize(arena), + to_keyword: self.to_keyword.normalize(arena), + to: self.to.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for Module<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { - let header = match &self.header { +impl<'a> Normalize<'a> for Header<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { + match self { Header::Module(header) => Header::Module(ModuleHeader { after_keyword: &[], - params: header.params.remove_spaces(arena), - exposes: header.exposes.remove_spaces(arena), - interface_imports: header.interface_imports.remove_spaces(arena), + params: header.params.normalize(arena), + exposes: header.exposes.normalize(arena), + interface_imports: header.interface_imports.normalize(arena), }), Header::App(header) => Header::App(AppHeader { before_provides: &[], - provides: header.provides.remove_spaces(arena), + provides: header.provides.normalize(arena), before_packages: &[], - packages: header.packages.remove_spaces(arena), - old_imports: header.old_imports.remove_spaces(arena), - old_provides_to_new_package: header - .old_provides_to_new_package - .remove_spaces(arena), + packages: header.packages.normalize(arena), + old_imports: header.old_imports.normalize(arena), + old_provides_to_new_package: header.old_provides_to_new_package.normalize(arena), }), Header::Package(header) => Header::Package(PackageHeader { before_exposes: &[], - exposes: header.exposes.remove_spaces(arena), + exposes: header.exposes.normalize(arena), before_packages: &[], - packages: header.packages.remove_spaces(arena), + packages: header.packages.normalize(arena), }), Header::Platform(header) => Header::Platform(PlatformHeader { before_name: &[], - name: header.name.remove_spaces(arena), - requires: header.requires.remove_spaces(arena), - exposes: header.exposes.remove_spaces(arena), - packages: header.packages.remove_spaces(arena), - imports: header.imports.remove_spaces(arena), - provides: header.provides.remove_spaces(arena), + name: header.name.normalize(arena), + requires: header.requires.normalize(arena), + exposes: header.exposes.normalize(arena), + packages: header.packages.normalize(arena), + imports: header.imports.normalize(arena), + provides: header.provides.normalize(arena), }), Header::Hosted(header) => Header::Hosted(HostedHeader { before_name: &[], - name: header.name.remove_spaces(arena), - exposes: header.exposes.remove_spaces(arena), - imports: header.imports.remove_spaces(arena), - generates: header.generates.remove_spaces(arena), - generates_with: header.generates_with.remove_spaces(arena), + name: header.name.normalize(arena), + exposes: header.exposes.normalize(arena), + imports: header.imports.normalize(arena), + generates: header.generates.normalize(arena), + generates_with: header.generates_with.normalize(arena), }), - }; - Module { - comments: &[], - header, } } } -impl<'a> RemoveSpaces<'a> for ModuleParams<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ModuleParams<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { ModuleParams { - params: self.params.remove_spaces(arena), + pattern: self.pattern.normalize(arena), before_arrow: &[], after_arrow: &[], } } } -impl<'a> RemoveSpaces<'a> for Region { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for Region { + fn normalize(&self, _arena: &'a Bump) -> Self { Region::zero() } } -impl<'a> RemoveSpaces<'a> for &'a str { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for &'a str { + fn normalize(&self, _arena: &'a Bump) -> Self { self } } -impl<'a, T: RemoveSpaces<'a> + Copy> RemoveSpaces<'a> for Spaced<'a, T> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a, T: Normalize<'a> + Copy> Normalize<'a> for Spaced<'a, T> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { - Spaced::Item(a) => Spaced::Item(a.remove_spaces(arena)), - Spaced::SpaceBefore(a, _) => a.remove_spaces(arena), - Spaced::SpaceAfter(a, _) => a.remove_spaces(arena), + Spaced::Item(a) => Spaced::Item(a.normalize(arena)), + Spaced::SpaceBefore(a, _) => a.normalize(arena), + Spaced::SpaceAfter(a, _) => a.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for ExposedName<'a> { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ExposedName<'a> { + fn normalize(&self, _arena: &'a Bump) -> Self { *self } } -impl<'a> RemoveSpaces<'a> for ModuleName<'a> { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ModuleName<'a> { + fn normalize(&self, _arena: &'a Bump) -> Self { *self } } -impl<'a> RemoveSpaces<'a> for PackageName<'a> { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for PackageName<'a> { + fn normalize(&self, _arena: &'a Bump) -> Self { *self } } -impl<'a> RemoveSpaces<'a> for To<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for To<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { To::ExistingPackage(a) => To::ExistingPackage(a), - To::NewPackage(a) => To::NewPackage(a.remove_spaces(arena)), + To::NewPackage(a) => To::NewPackage(a.normalize(arena)), } } } -impl<'a> RemoveSpaces<'a> for TypedIdent<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for TypedIdent<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { TypedIdent { - ident: self.ident.remove_spaces(arena), + ident: self.ident.normalize(arena), spaces_before_colon: &[], - ann: self.ann.remove_spaces(arena), + ann: self.ann.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for PlatformRequires<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for PlatformRequires<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { PlatformRequires { - rigids: self.rigids.remove_spaces(arena), - signature: self.signature.remove_spaces(arena), + rigids: self.rigids.normalize(arena), + signature: self.signature.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for UppercaseIdent<'a> { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for UppercaseIdent<'a> { + fn normalize(&self, _arena: &'a Bump) -> Self { *self } } -impl<'a> RemoveSpaces<'a> for PackageEntry<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for PackageEntry<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { PackageEntry { shorthand: self.shorthand, spaces_after_shorthand: &[], @@ -266,83 +279,81 @@ impl<'a> RemoveSpaces<'a> for PackageEntry<'a> { Some(_) => Some(&[]), None => None, }, - package_name: self.package_name.remove_spaces(arena), + package_name: self.package_name.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for ImportsEntry<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ImportsEntry<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { - ImportsEntry::Module(a, b) => ImportsEntry::Module(a, b.remove_spaces(arena)), - ImportsEntry::Package(a, b, c) => ImportsEntry::Package(a, b, c.remove_spaces(arena)), - ImportsEntry::IngestedFile(a, b) => { - ImportsEntry::IngestedFile(a, b.remove_spaces(arena)) - } + ImportsEntry::Module(a, b) => ImportsEntry::Module(a, b.normalize(arena)), + ImportsEntry::Package(a, b, c) => ImportsEntry::Package(a, b, c.normalize(arena)), + ImportsEntry::IngestedFile(a, b) => ImportsEntry::IngestedFile(a, b.normalize(arena)), } } } -impl<'a, T: RemoveSpaces<'a>> RemoveSpaces<'a> for Option { - fn remove_spaces(&self, arena: &'a Bump) -> Self { - self.as_ref().map(|a| a.remove_spaces(arena)) +impl<'a, T: Normalize<'a>> Normalize<'a> for Option { + fn normalize(&self, arena: &'a Bump) -> Self { + self.as_ref().map(|a| a.normalize(arena)) } } -impl<'a, T: RemoveSpaces<'a> + std::fmt::Debug> RemoveSpaces<'a> for Loc { - fn remove_spaces(&self, arena: &'a Bump) -> Self { - let res = self.value.remove_spaces(arena); +impl<'a, T: Normalize<'a> + std::fmt::Debug> Normalize<'a> for Loc { + fn normalize(&self, arena: &'a Bump) -> Self { + let res = self.value.normalize(arena); Loc::at(Region::zero(), res) } } -impl<'a, A: RemoveSpaces<'a>, B: RemoveSpaces<'a>> RemoveSpaces<'a> for (A, B) { - fn remove_spaces(&self, arena: &'a Bump) -> Self { - (self.0.remove_spaces(arena), self.1.remove_spaces(arena)) +impl<'a, A: Normalize<'a>, B: Normalize<'a>> Normalize<'a> for (A, B) { + fn normalize(&self, arena: &'a Bump) -> Self { + (self.0.normalize(arena), self.1.normalize(arena)) } } -impl<'a, T: RemoveSpaces<'a>> RemoveSpaces<'a> for Collection<'a, T> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a, T: Normalize<'a>> Normalize<'a> for Collection<'a, T> { + fn normalize(&self, arena: &'a Bump) -> Self { let mut items = Vec::with_capacity_in(self.items.len(), arena); for item in self.items { - items.push(item.remove_spaces(arena)); + items.push(item.normalize(arena)); } Collection::with_items(items.into_bump_slice()) } } -impl<'a, T: RemoveSpaces<'a> + std::fmt::Debug> RemoveSpaces<'a> for &'a [T] { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a, T: Normalize<'a> + std::fmt::Debug> Normalize<'a> for &'a [T] { + fn normalize(&self, arena: &'a Bump) -> Self { let mut items = Vec::with_capacity_in(self.len(), arena); for item in *self { - let res = item.remove_spaces(arena); + let res = item.normalize(arena); items.push(res); } items.into_bump_slice() } } -impl<'a> RemoveSpaces<'a> for UnaryOp { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for UnaryOp { + fn normalize(&self, _arena: &'a Bump) -> Self { *self } } -impl<'a> RemoveSpaces<'a> for BinOp { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for BinOp { + fn normalize(&self, _arena: &'a Bump) -> Self { *self } } -impl<'a, T: RemoveSpaces<'a>> RemoveSpaces<'a> for &'a T { - fn remove_spaces(&self, arena: &'a Bump) -> Self { - arena.alloc((*self).remove_spaces(arena)) +impl<'a, T: Normalize<'a>> Normalize<'a> for &'a T { + fn normalize(&self, arena: &'a Bump) -> Self { + arena.alloc((*self).normalize(arena)) } } -impl<'a> RemoveSpaces<'a> for TypeDef<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for TypeDef<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { use TypeDef::*; match *self { @@ -351,10 +362,10 @@ impl<'a> RemoveSpaces<'a> for TypeDef<'a> { ann, } => Alias { header: TypeHeader { - name: name.remove_spaces(arena), - vars: vars.remove_spaces(arena), + name: name.normalize(arena), + vars: vars.normalize(arena), }, - ann: ann.remove_spaces(arena), + ann: ann.normalize(arena), }, Opaque { header: TypeHeader { name, vars }, @@ -362,11 +373,11 @@ impl<'a> RemoveSpaces<'a> for TypeDef<'a> { derived, } => Opaque { header: TypeHeader { - name: name.remove_spaces(arena), - vars: vars.remove_spaces(arena), + name: name.normalize(arena), + vars: vars.normalize(arena), }, - typ: typ.remove_spaces(arena), - derived: derived.remove_spaces(arena), + typ: typ.normalize(arena), + derived: derived.normalize(arena), }, Ability { header: TypeHeader { name, vars }, @@ -374,25 +385,25 @@ impl<'a> RemoveSpaces<'a> for TypeDef<'a> { members, } => Ability { header: TypeHeader { - name: name.remove_spaces(arena), - vars: vars.remove_spaces(arena), + name: name.normalize(arena), + vars: vars.normalize(arena), }, - loc_implements: loc_has.remove_spaces(arena), - members: members.remove_spaces(arena), + loc_implements: loc_has.normalize(arena), + members: members.normalize(arena), }, } } } -impl<'a> RemoveSpaces<'a> for ValueDef<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ValueDef<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { use ValueDef::*; match *self { - Annotation(a, b) => Annotation(a.remove_spaces(arena), b.remove_spaces(arena)), + Annotation(a, b) => Annotation(a.normalize(arena), b.normalize(arena)), Body(a, b) => Body( - arena.alloc(a.remove_spaces(arena)), - arena.alloc(b.remove_spaces(arena)), + arena.alloc(a.normalize(arena)), + arena.alloc(b.normalize(arena)), ), AnnotatedBody { ann_pattern, @@ -401,206 +412,300 @@ impl<'a> RemoveSpaces<'a> for ValueDef<'a> { body_pattern, body_expr, } => AnnotatedBody { - ann_pattern: arena.alloc(ann_pattern.remove_spaces(arena)), - ann_type: arena.alloc(ann_type.remove_spaces(arena)), + ann_pattern: arena.alloc(ann_pattern.normalize(arena)), + ann_type: arena.alloc(ann_type.normalize(arena)), lines_between: &[], - body_pattern: arena.alloc(body_pattern.remove_spaces(arena)), - body_expr: arena.alloc(body_expr.remove_spaces(arena)), + body_pattern: arena.alloc(body_pattern.normalize(arena)), + body_expr: arena.alloc(body_expr.normalize(arena)), }, Dbg { condition, preceding_comment: _, } => Dbg { - condition: arena.alloc(condition.remove_spaces(arena)), + condition: arena.alloc(condition.normalize(arena)), preceding_comment: Region::zero(), }, Expect { condition, preceding_comment: _, } => Expect { - condition: arena.alloc(condition.remove_spaces(arena)), + condition: arena.alloc(condition.normalize(arena)), preceding_comment: Region::zero(), }, ExpectFx { condition, preceding_comment: _, } => ExpectFx { - condition: arena.alloc(condition.remove_spaces(arena)), + condition: arena.alloc(condition.normalize(arena)), preceding_comment: Region::zero(), }, - ModuleImport(module_import) => ModuleImport(module_import.remove_spaces(arena)), + ModuleImport(module_import) => ModuleImport(module_import.normalize(arena)), IngestedFileImport(ingested_file_import) => { - IngestedFileImport(ingested_file_import.remove_spaces(arena)) + IngestedFileImport(ingested_file_import.normalize(arena)) } - Stmt(loc_expr) => Stmt(arena.alloc(loc_expr.remove_spaces(arena))), + Stmt(loc_expr) => Stmt(arena.alloc(loc_expr.normalize(arena))), } } } -impl<'a> RemoveSpaces<'a> for ModuleImport<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ModuleImport<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { ModuleImport { before_name: &[], - name: self.name.remove_spaces(arena), - params: self.params.remove_spaces(arena), - alias: self.alias.remove_spaces(arena), - exposed: self.exposed.remove_spaces(arena), + name: self.name.normalize(arena), + params: self.params.normalize(arena), + alias: self.alias.normalize(arena), + exposed: self.exposed.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for ModuleImportParams<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ModuleImportParams<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { ModuleImportParams { before: &[], - params: self.params.remove_spaces(arena), + params: self.params.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for IngestedFileImport<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for IngestedFileImport<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { IngestedFileImport { before_path: &[], - path: self.path.remove_spaces(arena), - name: self.name.remove_spaces(arena), - annotation: self.annotation.remove_spaces(arena), + path: self.path.normalize(arena), + name: self.name.normalize(arena), + annotation: self.annotation.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for ImportedModuleName<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ImportedModuleName<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { ImportedModuleName { - package: self.package.remove_spaces(arena), - name: self.name.remove_spaces(arena), + package: self.package.normalize(arena), + name: self.name.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for ImportAlias<'a> { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ImportAlias<'a> { + fn normalize(&self, _arena: &'a Bump) -> Self { *self } } -impl<'a> RemoveSpaces<'a> for ImportAsKeyword { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ImportAsKeyword { + fn normalize(&self, _arena: &'a Bump) -> Self { *self } } -impl<'a> RemoveSpaces<'a> for ImportExposingKeyword { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ImportExposingKeyword { + fn normalize(&self, _arena: &'a Bump) -> Self { *self } } -impl<'a> RemoveSpaces<'a> for IngestedFileAnnotation<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for IngestedFileAnnotation<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { IngestedFileAnnotation { before_colon: &[], - annotation: self.annotation.remove_spaces(arena), + annotation: self.annotation.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for Implements<'a> { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for Implements<'a> { + fn normalize(&self, _arena: &'a Bump) -> Self { Implements::Implements } } -impl<'a> RemoveSpaces<'a> for AbilityMember<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for AbilityMember<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { AbilityMember { - name: self.name.remove_spaces(arena), - typ: self.typ.remove_spaces(arena), + name: self.name.normalize(arena), + typ: self.typ.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for WhenBranch<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for WhenBranch<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { WhenBranch { - patterns: self.patterns.remove_spaces(arena), - value: self.value.remove_spaces(arena), - guard: self.guard.remove_spaces(arena), + patterns: self.patterns.normalize(arena), + value: self.value.normalize(arena), + guard: self.guard.normalize(arena), } } } -impl<'a, T: RemoveSpaces<'a> + Copy + std::fmt::Debug> RemoveSpaces<'a> for AssignedField<'a, T> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a, T: Normalize<'a> + Copy + std::fmt::Debug> Normalize<'a> for AssignedField<'a, T> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { AssignedField::RequiredValue(a, _, c) => AssignedField::RequiredValue( - a.remove_spaces(arena), + a.normalize(arena), arena.alloc([]), - arena.alloc(c.remove_spaces(arena)), + arena.alloc(c.normalize(arena)), ), AssignedField::OptionalValue(a, _, c) => AssignedField::OptionalValue( - a.remove_spaces(arena), + a.normalize(arena), arena.alloc([]), - arena.alloc(c.remove_spaces(arena)), + arena.alloc(c.normalize(arena)), ), - AssignedField::LabelOnly(a) => AssignedField::LabelOnly(a.remove_spaces(arena)), + AssignedField::IgnoredValue(a, _, c) => AssignedField::IgnoredValue( + a.normalize(arena), + arena.alloc([]), + arena.alloc(c.normalize(arena)), + ), + AssignedField::LabelOnly(a) => AssignedField::LabelOnly(a.normalize(arena)), AssignedField::Malformed(a) => AssignedField::Malformed(a), - AssignedField::SpaceBefore(a, _) => a.remove_spaces(arena), - AssignedField::SpaceAfter(a, _) => a.remove_spaces(arena), + AssignedField::SpaceBefore(a, _) => a.normalize(arena), + AssignedField::SpaceAfter(a, _) => a.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for OldRecordBuilderField<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for OldRecordBuilderField<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { OldRecordBuilderField::Value(a, _, c) => OldRecordBuilderField::Value( - a.remove_spaces(arena), + a.normalize(arena), &[], - arena.alloc(c.remove_spaces(arena)), + arena.alloc(c.normalize(arena)), ), OldRecordBuilderField::ApplyValue(a, _, _, c) => OldRecordBuilderField::ApplyValue( - a.remove_spaces(arena), + a.normalize(arena), &[], &[], - arena.alloc(c.remove_spaces(arena)), + arena.alloc(c.normalize(arena)), ), OldRecordBuilderField::LabelOnly(a) => { - OldRecordBuilderField::LabelOnly(a.remove_spaces(arena)) + OldRecordBuilderField::LabelOnly(a.normalize(arena)) } OldRecordBuilderField::Malformed(a) => OldRecordBuilderField::Malformed(a), - OldRecordBuilderField::SpaceBefore(a, _) => a.remove_spaces(arena), - OldRecordBuilderField::SpaceAfter(a, _) => a.remove_spaces(arena), + OldRecordBuilderField::SpaceBefore(a, _) => a.normalize(arena), + OldRecordBuilderField::SpaceAfter(a, _) => a.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for StrLiteral<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for StrLiteral<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { StrLiteral::PlainLine(t) => StrLiteral::PlainLine(t), - StrLiteral::Line(t) => StrLiteral::Line(t.remove_spaces(arena)), - StrLiteral::Block(t) => StrLiteral::Block(t.remove_spaces(arena)), - } - } -} + StrLiteral::Line(t) => { + let mut needs_merge = false; + let mut last_was_mergable = false; + for segment in t.iter() { + let mergable = matches!( + segment, + StrSegment::Plaintext(_) + | StrSegment::Unicode(_) + | StrSegment::EscapedChar(_) + ); + if mergable && last_was_mergable { + needs_merge = true; + break; + } + last_was_mergable = mergable; + } -impl<'a> RemoveSpaces<'a> for StrSegment<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { - match *self { - StrSegment::Plaintext(t) => StrSegment::Plaintext(t), - StrSegment::Unicode(t) => StrSegment::Unicode(t.remove_spaces(arena)), - StrSegment::EscapedChar(c) => StrSegment::EscapedChar(c), - StrSegment::Interpolated(t) => StrSegment::Interpolated(t.remove_spaces(arena)), - StrSegment::DeprecatedInterpolated(t) => { - StrSegment::Interpolated(t.remove_spaces(arena)) + if !needs_merge { + return StrLiteral::Line(t.normalize(arena)); + } + + let mut new_segments = Vec::new_in(arena); + let mut last_text = String::new_in(arena); + + normalize_str_segments(arena, t, &mut last_text, &mut new_segments); + if !last_text.is_empty() { + new_segments.push(StrSegment::Plaintext(last_text.into_bump_str())); + } + + StrLiteral::Line(new_segments.into_bump_slice()) + } + StrLiteral::Block(t) => { + let mut new_segments = Vec::new_in(arena); + let mut last_text = String::new_in(arena); + for line in t { + normalize_str_segments(arena, line, &mut last_text, &mut new_segments); + } + if !last_text.is_empty() { + new_segments.push(StrSegment::Plaintext(last_text.into_bump_str())); + } + + StrLiteral::Line(new_segments.into_bump_slice()) } } } } -impl<'a> RemoveSpaces<'a> for Expr<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +fn normalize_str_segments<'a>( + arena: &'a Bump, + segments: &[StrSegment<'a>], + last_text: &mut String<'a>, + new_segments: &mut Vec<'a, StrSegment<'a>>, +) { + for segment in segments.iter() { + match segment { + StrSegment::Plaintext(t) => { + last_text.push_str(t); + } + StrSegment::Unicode(t) => { + let hex_code: &str = t.value; + let c = char::from_u32(u32::from_str_radix(hex_code, 16).unwrap()).unwrap(); + last_text.push(c); + } + StrSegment::EscapedChar(c) => { + last_text.push(c.unescape()); + } + StrSegment::Interpolated(e) => { + if !last_text.is_empty() { + let text = std::mem::replace(last_text, String::new_in(arena)); + new_segments.push(StrSegment::Plaintext(text.into_bump_str())); + } + new_segments.push(StrSegment::Interpolated(e.normalize(arena))); + } + StrSegment::DeprecatedInterpolated(e) => { + if !last_text.is_empty() { + let text = std::mem::replace(last_text, String::new_in(arena)); + new_segments.push(StrSegment::Plaintext(text.into_bump_str())); + } + new_segments.push(StrSegment::Interpolated(e.normalize(arena))); + } + } + } +} + +#[test] +fn test_str_normalize() { + use crate::test_helpers::parse_expr_with; + let arena = Bump::new(); + let a = parse_expr_with(&arena, r#""a\nb""#).unwrap(); + let b = parse_expr_with(&arena, "\"\"\"\na\nb\"\"\"").unwrap(); + + let ar = a.normalize(&arena); + let br = b.normalize(&arena); + + assert_eq!(ar, br); +} + +impl<'a> Normalize<'a> for StrSegment<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { + match *self { + StrSegment::Plaintext(t) => StrSegment::Plaintext(t), + StrSegment::Unicode(t) => StrSegment::Unicode(t.normalize(arena)), + StrSegment::EscapedChar(c) => StrSegment::EscapedChar(c), + StrSegment::Interpolated(t) => StrSegment::Interpolated(t.normalize(arena)), + StrSegment::DeprecatedInterpolated(t) => StrSegment::Interpolated(t.normalize(arena)), + } + } +} + +impl<'a> Normalize<'a> for Expr<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { Expr::Float(a) => Expr::Float(a), Expr::Num(a) => Expr::Num(a), @@ -613,30 +718,30 @@ impl<'a> RemoveSpaces<'a> for Expr<'a> { base, is_negative, }, - Expr::Str(a) => Expr::Str(a.remove_spaces(arena)), - Expr::RecordAccess(a, b) => Expr::RecordAccess(arena.alloc(a.remove_spaces(arena)), b), + Expr::Str(a) => Expr::Str(a.normalize(arena)), + Expr::RecordAccess(a, b) => Expr::RecordAccess(arena.alloc(a.normalize(arena)), b), Expr::AccessorFunction(a) => Expr::AccessorFunction(a), - Expr::TupleAccess(a, b) => Expr::TupleAccess(arena.alloc(a.remove_spaces(arena)), b), - Expr::TaskAwaitBang(a) => Expr::TaskAwaitBang(arena.alloc(a.remove_spaces(arena))), - Expr::List(a) => Expr::List(a.remove_spaces(arena)), + Expr::TupleAccess(a, b) => Expr::TupleAccess(arena.alloc(a.normalize(arena)), b), + Expr::TaskAwaitBang(a) => Expr::TaskAwaitBang(arena.alloc(a.normalize(arena))), + Expr::List(a) => Expr::List(a.normalize(arena)), Expr::RecordUpdate { update, fields } => Expr::RecordUpdate { - update: arena.alloc(update.remove_spaces(arena)), - fields: fields.remove_spaces(arena), + update: arena.alloc(update.normalize(arena)), + fields: fields.normalize(arena), }, - Expr::Record(a) => Expr::Record(a.remove_spaces(arena)), - Expr::OldRecordBuilder(a) => Expr::OldRecordBuilder(a.remove_spaces(arena)), + Expr::Record(a) => Expr::Record(a.normalize(arena)), + Expr::OldRecordBuilder(a) => Expr::OldRecordBuilder(a.normalize(arena)), Expr::RecordBuilder { mapper, fields } => Expr::RecordBuilder { - mapper: arena.alloc(mapper.remove_spaces(arena)), - fields: fields.remove_spaces(arena), + mapper: arena.alloc(mapper.normalize(arena)), + fields: fields.normalize(arena), }, - Expr::Tuple(a) => Expr::Tuple(a.remove_spaces(arena)), + Expr::Tuple(a) => Expr::Tuple(a.normalize(arena)), Expr::Var { module_name, ident } => Expr::Var { module_name, ident }, Expr::Underscore(a) => Expr::Underscore(a), Expr::Tag(a) => Expr::Tag(a), Expr::OpaqueRef(a) => Expr::OpaqueRef(a), Expr::Closure(a, b) => Expr::Closure( - arena.alloc(a.remove_spaces(arena)), - arena.alloc(b.remove_spaces(arena)), + arena.alloc(a.normalize(arena)), + arena.alloc(b.normalize(arena)), ), Expr::Crash => Expr::Crash, Expr::Defs(a, b) => { @@ -647,74 +752,68 @@ impl<'a> RemoveSpaces<'a> for Expr<'a> { defs.spaces.clear(); for type_def in defs.type_defs.iter_mut() { - *type_def = type_def.remove_spaces(arena); + *type_def = type_def.normalize(arena); } for value_def in defs.value_defs.iter_mut() { - *value_def = value_def.remove_spaces(arena); + *value_def = value_def.normalize(arena); } - Expr::Defs(arena.alloc(defs), arena.alloc(b.remove_spaces(arena))) + Expr::Defs(arena.alloc(defs), arena.alloc(b.normalize(arena))) } Expr::Backpassing(a, b, c) => Expr::Backpassing( - arena.alloc(a.remove_spaces(arena)), - arena.alloc(b.remove_spaces(arena)), - arena.alloc(c.remove_spaces(arena)), + arena.alloc(a.normalize(arena)), + arena.alloc(b.normalize(arena)), + arena.alloc(c.normalize(arena)), ), Expr::Expect(a, b) => Expr::Expect( - arena.alloc(a.remove_spaces(arena)), - arena.alloc(b.remove_spaces(arena)), + arena.alloc(a.normalize(arena)), + arena.alloc(b.normalize(arena)), ), Expr::Dbg(a, b) => Expr::Dbg( - arena.alloc(a.remove_spaces(arena)), - arena.alloc(b.remove_spaces(arena)), + arena.alloc(a.normalize(arena)), + arena.alloc(b.normalize(arena)), ), Expr::LowLevelDbg(x, a, b) => Expr::LowLevelDbg( x, - arena.alloc(a.remove_spaces(arena)), - arena.alloc(b.remove_spaces(arena)), + arena.alloc(a.normalize(arena)), + arena.alloc(b.normalize(arena)), ), - Expr::Apply(a, b, c) => Expr::Apply( - arena.alloc(a.remove_spaces(arena)), - b.remove_spaces(arena), - c, - ), - Expr::BinOps(a, b) => { - Expr::BinOps(a.remove_spaces(arena), arena.alloc(b.remove_spaces(arena))) + Expr::Apply(a, b, c) => { + Expr::Apply(arena.alloc(a.normalize(arena)), b.normalize(arena), c) } + Expr::BinOps(a, b) => Expr::BinOps(a.normalize(arena), arena.alloc(b.normalize(arena))), Expr::UnaryOp(a, b) => { - Expr::UnaryOp(arena.alloc(a.remove_spaces(arena)), b.remove_spaces(arena)) - } - Expr::If(a, b) => Expr::If(a.remove_spaces(arena), arena.alloc(b.remove_spaces(arena))), - Expr::When(a, b) => { - Expr::When(arena.alloc(a.remove_spaces(arena)), b.remove_spaces(arena)) + Expr::UnaryOp(arena.alloc(a.normalize(arena)), b.normalize(arena)) } + Expr::If(a, b) => Expr::If(a.normalize(arena), arena.alloc(b.normalize(arena))), + Expr::When(a, b) => Expr::When(arena.alloc(a.normalize(arena)), b.normalize(arena)), Expr::ParensAround(a) => { // The formatter can remove redundant parentheses, so also remove these when normalizing for comparison. - a.remove_spaces(arena) + a.normalize(arena) } Expr::MalformedIdent(a, b) => Expr::MalformedIdent(a, remove_spaces_bad_ident(b)), Expr::MalformedClosure => Expr::MalformedClosure, Expr::MalformedSuffixed(a) => Expr::MalformedSuffixed(a), Expr::PrecedenceConflict(a) => Expr::PrecedenceConflict(a), - Expr::SpaceBefore(a, _) => a.remove_spaces(arena), - Expr::SpaceAfter(a, _) => a.remove_spaces(arena), + Expr::SpaceBefore(a, _) => a.normalize(arena), + Expr::SpaceAfter(a, _) => a.normalize(arena), Expr::SingleQuote(a) => Expr::Num(a), Expr::MultipleOldRecordBuilders(a) => { - Expr::MultipleOldRecordBuilders(arena.alloc(a.remove_spaces(arena))) + Expr::MultipleOldRecordBuilders(arena.alloc(a.normalize(arena))) } Expr::UnappliedOldRecordBuilder(a) => { - Expr::UnappliedOldRecordBuilder(arena.alloc(a.remove_spaces(arena))) + Expr::UnappliedOldRecordBuilder(arena.alloc(a.normalize(arena))) } Expr::EmptyRecordBuilder(a) => { - Expr::EmptyRecordBuilder(arena.alloc(a.remove_spaces(arena))) + Expr::EmptyRecordBuilder(arena.alloc(a.normalize(arena))) } Expr::SingleFieldRecordBuilder(a) => { - Expr::SingleFieldRecordBuilder(arena.alloc(a.remove_spaces(arena))) + Expr::SingleFieldRecordBuilder(arena.alloc(a.normalize(arena))) } Expr::OptionalFieldInRecordBuilder(a, b) => Expr::OptionalFieldInRecordBuilder( - arena.alloc(a.remove_spaces(arena)), - arena.alloc(b.remove_spaces(arena)), + arena.alloc(a.normalize(arena)), + arena.alloc(b.normalize(arena)), ), } } @@ -743,26 +842,26 @@ fn remove_spaces_bad_ident(ident: BadIdent) -> BadIdent { } } -impl<'a> RemoveSpaces<'a> for Pattern<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for Pattern<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { Pattern::Identifier { ident } => Pattern::Identifier { ident }, Pattern::Tag(a) => Pattern::Tag(a), Pattern::OpaqueRef(a) => Pattern::OpaqueRef(a), Pattern::Apply(a, b) => Pattern::Apply( - arena.alloc(a.remove_spaces(arena)), - arena.alloc(b.remove_spaces(arena)), + arena.alloc(a.normalize(arena)), + arena.alloc(b.normalize(arena)), ), - Pattern::RecordDestructure(a) => Pattern::RecordDestructure(a.remove_spaces(arena)), + Pattern::RecordDestructure(a) => Pattern::RecordDestructure(a.normalize(arena)), Pattern::RequiredField(a, b) => { - Pattern::RequiredField(a, arena.alloc(b.remove_spaces(arena))) + Pattern::RequiredField(a, arena.alloc(b.normalize(arena))) } Pattern::OptionalField(a, b) => { - Pattern::OptionalField(a, arena.alloc(b.remove_spaces(arena))) + Pattern::OptionalField(a, arena.alloc(b.normalize(arena))) } Pattern::As(pattern, pattern_as) => Pattern::As( - arena.alloc(pattern.remove_spaces(arena)), - pattern_as.remove_spaces(arena), + arena.alloc(pattern.normalize(arena)), + pattern_as.normalize(arena), ), Pattern::NumLiteral(a) => Pattern::NumLiteral(a), Pattern::NonBase10Literal { @@ -782,136 +881,133 @@ impl<'a> RemoveSpaces<'a> for Pattern<'a> { Pattern::QualifiedIdentifier { module_name, ident } => { Pattern::QualifiedIdentifier { module_name, ident } } - Pattern::SpaceBefore(a, _) => a.remove_spaces(arena), - Pattern::SpaceAfter(a, _) => a.remove_spaces(arena), + Pattern::SpaceBefore(a, _) => a.normalize(arena), + Pattern::SpaceAfter(a, _) => a.normalize(arena), Pattern::SingleQuote(a) => Pattern::SingleQuote(a), - Pattern::List(pats) => Pattern::List(pats.remove_spaces(arena)), - Pattern::Tuple(pats) => Pattern::Tuple(pats.remove_spaces(arena)), + Pattern::List(pats) => Pattern::List(pats.normalize(arena)), + Pattern::Tuple(pats) => Pattern::Tuple(pats.normalize(arena)), Pattern::ListRest(opt_pattern_as) => Pattern::ListRest( - opt_pattern_as - .map(|(_, pattern_as)| ([].as_ref(), pattern_as.remove_spaces(arena))), + opt_pattern_as.map(|(_, pattern_as)| ([].as_ref(), pattern_as.normalize(arena))), ), } } } -impl<'a> RemoveSpaces<'a> for TypeAnnotation<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for TypeAnnotation<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { TypeAnnotation::Function(a, b) => TypeAnnotation::Function( - arena.alloc(a.remove_spaces(arena)), - arena.alloc(b.remove_spaces(arena)), + arena.alloc(a.normalize(arena)), + arena.alloc(b.normalize(arena)), ), - TypeAnnotation::Apply(a, b, c) => TypeAnnotation::Apply(a, b, c.remove_spaces(arena)), + TypeAnnotation::Apply(a, b, c) => TypeAnnotation::Apply(a, b, c.normalize(arena)), TypeAnnotation::BoundVariable(a) => TypeAnnotation::BoundVariable(a), TypeAnnotation::As(a, _, TypeHeader { name, vars }) => TypeAnnotation::As( - arena.alloc(a.remove_spaces(arena)), + arena.alloc(a.normalize(arena)), &[], TypeHeader { - name: name.remove_spaces(arena), - vars: vars.remove_spaces(arena), + name: name.normalize(arena), + vars: vars.normalize(arena), }, ), TypeAnnotation::Tuple { elems: fields, ext } => TypeAnnotation::Tuple { - elems: fields.remove_spaces(arena), - ext: ext.remove_spaces(arena), + elems: fields.normalize(arena), + ext: ext.normalize(arena), }, TypeAnnotation::Record { fields, ext } => TypeAnnotation::Record { - fields: fields.remove_spaces(arena), - ext: ext.remove_spaces(arena), + fields: fields.normalize(arena), + ext: ext.normalize(arena), }, TypeAnnotation::TagUnion { ext, tags } => TypeAnnotation::TagUnion { - ext: ext.remove_spaces(arena), - tags: tags.remove_spaces(arena), + ext: ext.normalize(arena), + tags: tags.normalize(arena), }, TypeAnnotation::Inferred => TypeAnnotation::Inferred, TypeAnnotation::Wildcard => TypeAnnotation::Wildcard, TypeAnnotation::Where(annot, has_clauses) => TypeAnnotation::Where( - arena.alloc(annot.remove_spaces(arena)), - arena.alloc(has_clauses.remove_spaces(arena)), + arena.alloc(annot.normalize(arena)), + arena.alloc(has_clauses.normalize(arena)), ), - TypeAnnotation::SpaceBefore(a, _) => a.remove_spaces(arena), - TypeAnnotation::SpaceAfter(a, _) => a.remove_spaces(arena), + TypeAnnotation::SpaceBefore(a, _) => a.normalize(arena), + TypeAnnotation::SpaceAfter(a, _) => a.normalize(arena), TypeAnnotation::Malformed(a) => TypeAnnotation::Malformed(a), } } } -impl<'a> RemoveSpaces<'a> for ImplementsClause<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ImplementsClause<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { ImplementsClause { - var: self.var.remove_spaces(arena), - abilities: self.abilities.remove_spaces(arena), + var: self.var.normalize(arena), + abilities: self.abilities.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for Tag<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for Tag<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { Tag::Apply { name, args } => Tag::Apply { - name: name.remove_spaces(arena), - args: args.remove_spaces(arena), + name: name.normalize(arena), + args: args.normalize(arena), }, Tag::Malformed(a) => Tag::Malformed(a), - Tag::SpaceBefore(a, _) => a.remove_spaces(arena), - Tag::SpaceAfter(a, _) => a.remove_spaces(arena), + Tag::SpaceBefore(a, _) => a.normalize(arena), + Tag::SpaceAfter(a, _) => a.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for AbilityImpls<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for AbilityImpls<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { - AbilityImpls::AbilityImpls(impls) => { - AbilityImpls::AbilityImpls(impls.remove_spaces(arena)) - } + AbilityImpls::AbilityImpls(impls) => AbilityImpls::AbilityImpls(impls.normalize(arena)), AbilityImpls::SpaceBefore(has, _) | AbilityImpls::SpaceAfter(has, _) => { - has.remove_spaces(arena) + has.normalize(arena) } } } } -impl<'a> RemoveSpaces<'a> for ImplementsAbility<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ImplementsAbility<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { ImplementsAbility::ImplementsAbility { ability, impls } => { ImplementsAbility::ImplementsAbility { - ability: ability.remove_spaces(arena), - impls: impls.remove_spaces(arena), + ability: ability.normalize(arena), + impls: impls.normalize(arena), } } ImplementsAbility::SpaceBefore(has, _) | ImplementsAbility::SpaceAfter(has, _) => { - has.remove_spaces(arena) + has.normalize(arena) } } } } -impl<'a> RemoveSpaces<'a> for ImplementsAbilities<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ImplementsAbilities<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match *self { ImplementsAbilities::Implements(derived) => { - ImplementsAbilities::Implements(derived.remove_spaces(arena)) + ImplementsAbilities::Implements(derived.normalize(arena)) } ImplementsAbilities::SpaceBefore(derived, _) - | ImplementsAbilities::SpaceAfter(derived, _) => derived.remove_spaces(arena), + | ImplementsAbilities::SpaceAfter(derived, _) => derived.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for PatternAs<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for PatternAs<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { PatternAs { spaces_before: &[], - identifier: self.identifier.remove_spaces(arena), + identifier: self.identifier.normalize(arena), } } } -impl<'a> RemoveSpaces<'a> for EExpr<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EExpr<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EExpr::TrailingOperator(_pos) => EExpr::TrailingOperator(Position::zero()), EExpr::Start(_pos) => EExpr::Start(Position::zero()), @@ -922,24 +1018,22 @@ impl<'a> RemoveSpaces<'a> for EExpr<'a> { EExpr::Access(_pos) => EExpr::Access(Position::zero()), EExpr::UnaryNot(_pos) => EExpr::UnaryNot(Position::zero()), EExpr::UnaryNegate(_pos) => EExpr::UnaryNegate(Position::zero()), - EExpr::BadOperator(inner_err, _pos) => EExpr::BadOperator( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + EExpr::BadOperator(inner_err, _pos) => { + EExpr::BadOperator(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } EExpr::DefMissingFinalExpr(_pos) => EExpr::DefMissingFinalExpr(Position::zero()), EExpr::DefMissingFinalExpr2(inner_err, _pos) => EExpr::DefMissingFinalExpr2( - arena.alloc(inner_err.remove_spaces(arena)), + arena.alloc(inner_err.normalize(arena)), Position::zero(), ), EExpr::Type(inner_err, _pos) => { - EExpr::Type(inner_err.remove_spaces(arena), Position::zero()) + EExpr::Type(inner_err.normalize(arena), Position::zero()) + } + EExpr::Pattern(inner_err, _pos) => { + EExpr::Pattern(arena.alloc(inner_err.normalize(arena)), Position::zero()) } - EExpr::Pattern(inner_err, _pos) => EExpr::Pattern( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), EExpr::Ability(inner_err, _pos) => { - EExpr::Ability(inner_err.remove_spaces(arena), Position::zero()) + EExpr::Ability(inner_err.normalize(arena), Position::zero()) } EExpr::IndentDefBody(_pos) => EExpr::IndentDefBody(Position::zero()), EExpr::IndentEquals(_pos) => EExpr::IndentEquals(Position::zero()), @@ -958,68 +1052,71 @@ impl<'a> RemoveSpaces<'a> for EExpr<'a> { EExpr::BackpassContinue(_pos) => EExpr::BackpassContinue(Position::zero()), EExpr::DbgContinue(_pos) => EExpr::DbgContinue(Position::zero()), EExpr::When(inner_err, _pos) => { - EExpr::When(inner_err.remove_spaces(arena), Position::zero()) - } - EExpr::If(inner_err, _pos) => { - EExpr::If(inner_err.remove_spaces(arena), Position::zero()) + EExpr::When(inner_err.normalize(arena), Position::zero()) } + EExpr::If(inner_err, _pos) => EExpr::If(inner_err.normalize(arena), Position::zero()), EExpr::Expect(inner_err, _pos) => { - EExpr::Expect(inner_err.remove_spaces(arena), Position::zero()) - } - EExpr::Dbg(inner_err, _pos) => { - EExpr::Dbg(inner_err.remove_spaces(arena), Position::zero()) + EExpr::Expect(inner_err.normalize(arena), Position::zero()) } + EExpr::Dbg(inner_err, _pos) => EExpr::Dbg(inner_err.normalize(arena), Position::zero()), EExpr::Import(inner_err, _pos) => { - EExpr::Import(inner_err.remove_spaces(arena), Position::zero()) + EExpr::Import(inner_err.normalize(arena), Position::zero()) } EExpr::Closure(inner_err, _pos) => { - EExpr::Closure(inner_err.remove_spaces(arena), Position::zero()) + EExpr::Closure(inner_err.normalize(arena), Position::zero()) } EExpr::Underscore(_pos) => EExpr::Underscore(Position::zero()), EExpr::Crash(_pos) => EExpr::Crash(Position::zero()), EExpr::InParens(inner_err, _pos) => { - EExpr::InParens(inner_err.remove_spaces(arena), Position::zero()) + EExpr::InParens(inner_err.normalize(arena), Position::zero()) } EExpr::Record(inner_err, _pos) => { - EExpr::Record(inner_err.remove_spaces(arena), Position::zero()) + EExpr::Record(inner_err.normalize(arena), Position::zero()) } - EExpr::OptionalValueInRecordBuilder(_pos) => { - EExpr::OptionalValueInRecordBuilder(Region::zero()) + EExpr::OptionalValueInOldRecordBuilder(_pos) => { + EExpr::OptionalValueInOldRecordBuilder(Region::zero()) } - EExpr::Str(inner_err, _pos) => { - EExpr::Str(inner_err.remove_spaces(arena), Position::zero()) + EExpr::IgnoredValueInOldRecordBuilder(_pos) => { + EExpr::OptionalValueInOldRecordBuilder(Region::zero()) } + EExpr::Str(inner_err, _pos) => EExpr::Str(inner_err.normalize(arena), Position::zero()), EExpr::Number(inner_err, _pos) => EExpr::Number(inner_err.clone(), Position::zero()), EExpr::List(inner_err, _pos) => { - EExpr::List(inner_err.remove_spaces(arena), Position::zero()) + EExpr::List(inner_err.normalize(arena), Position::zero()) } EExpr::IndentStart(_pos) => EExpr::IndentStart(Position::zero()), EExpr::IndentEnd(_pos) => EExpr::IndentEnd(Position::zero()), EExpr::UnexpectedComma(_pos) => EExpr::UnexpectedComma(Position::zero()), EExpr::UnexpectedTopLevelExpr(_pos) => EExpr::UnexpectedTopLevelExpr(Position::zero()), EExpr::StmtAfterExpr(_pos) => EExpr::StmtAfterExpr(Position::zero()), - EExpr::RecordUpdateAccumulator(_) => EExpr::RecordUpdateAccumulator(Region::zero()), - EExpr::RecordBuilderAccumulator(_) => EExpr::RecordBuilderAccumulator(Region::zero()), + EExpr::RecordUpdateOldBuilderField(_pos) => { + EExpr::RecordUpdateOldBuilderField(Region::zero()) + } + EExpr::RecordUpdateIgnoredField(_pos) => { + EExpr::RecordUpdateIgnoredField(Region::zero()) + } + EExpr::RecordBuilderOldBuilderField(_pos) => { + EExpr::RecordBuilderOldBuilderField(Region::zero()) + } } } } -impl<'a> RemoveSpaces<'a> for EList<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EList<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EList::Open(_pos) => EList::Open(Position::zero()), EList::End(_pos) => EList::End(Position::zero()), EList::Space(inner_err, _pos) => EList::Space(*inner_err, Position::zero()), - EList::Expr(inner_err, _pos) => EList::Expr( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + EList::Expr(inner_err, _pos) => { + EList::Expr(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } } } } -impl<'a> RemoveSpaces<'a> for EString<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EString<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EString::Open(_) => EString::Open(Position::zero()), EString::CodePtOpen(_) => EString::CodePtOpen(Position::zero()), @@ -1033,7 +1130,7 @@ impl<'a> RemoveSpaces<'a> for EString<'a> { EString::EndlessSingleQuote(_) => EString::EndlessSingleQuote(Position::zero()), EString::UnknownEscape(_) => EString::UnknownEscape(Position::zero()), EString::Format(inner, _) => { - EString::Format(arena.alloc(inner.remove_spaces(arena)), Position::zero()) + EString::Format(arena.alloc(inner.normalize(arena)), Position::zero()) } EString::FormatEnd(_) => EString::FormatEnd(Position::zero()), EString::MultilineInsufficientIndent(_) => { @@ -1046,8 +1143,8 @@ impl<'a> RemoveSpaces<'a> for EString<'a> { } } -impl<'a> RemoveSpaces<'a> for EClosure<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EClosure<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EClosure::Space(inner_err, _) => EClosure::Space(*inner_err, Position::zero()), EClosure::Start(_) => EClosure::Start(Position::zero()), @@ -1055,12 +1152,11 @@ impl<'a> RemoveSpaces<'a> for EClosure<'a> { EClosure::Comma(_) => EClosure::Comma(Position::zero()), EClosure::Arg(_) => EClosure::Arg(Position::zero()), EClosure::Pattern(inner_err, _) => { - EClosure::Pattern(inner_err.remove_spaces(arena), Position::zero()) + EClosure::Pattern(inner_err.normalize(arena), Position::zero()) + } + EClosure::Body(inner_err, _) => { + EClosure::Body(arena.alloc(inner_err.normalize(arena)), Position::zero()) } - EClosure::Body(inner_err, _) => EClosure::Body( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), EClosure::IndentArrow(_) => EClosure::IndentArrow(Position::zero()), EClosure::IndentBody(_) => EClosure::IndentBody(Position::zero()), EClosure::IndentArg(_) => EClosure::IndentArg(Position::zero()), @@ -1068,49 +1164,48 @@ impl<'a> RemoveSpaces<'a> for EClosure<'a> { } } -impl<'a> RemoveSpaces<'a> for EInParens<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EInParens<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EInParens::End(_) => EInParens::End(Position::zero()), EInParens::Open(_) => EInParens::Open(Position::zero()), EInParens::Empty(_) => EInParens::Empty(Position::zero()), - EInParens::Expr(inner_err, _) => EInParens::Expr( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + EInParens::Expr(inner_err, _) => { + EInParens::Expr(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } EInParens::Space(inner_err, _) => EInParens::Space(*inner_err, Position::zero()), } } } -impl<'a> RemoveSpaces<'a> for ERecord<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ERecord<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { ERecord::End(_) => ERecord::End(Position::zero()), ERecord::Open(_) => ERecord::Open(Position::zero()), ERecord::Field(_pos) => ERecord::Field(Position::zero()), + ERecord::UnderscoreField(_pos) => ERecord::Field(Position::zero()), ERecord::Colon(_) => ERecord::Colon(Position::zero()), ERecord::QuestionMark(_) => ERecord::QuestionMark(Position::zero()), ERecord::Arrow(_) => ERecord::Arrow(Position::zero()), ERecord::Ampersand(_) => ERecord::Ampersand(Position::zero()), - ERecord::Expr(inner_err, _) => ERecord::Expr( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + ERecord::Expr(inner_err, _) => { + ERecord::Expr(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } ERecord::Space(inner_err, _) => ERecord::Space(*inner_err, Position::zero()), ERecord::Prefix(_) => ERecord::Prefix(Position::zero()), } } } -impl<'a> RemoveSpaces<'a> for EPattern<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EPattern<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EPattern::Record(inner_err, _) => { - EPattern::Record(inner_err.remove_spaces(arena), Position::zero()) + EPattern::Record(inner_err.normalize(arena), Position::zero()) } EPattern::List(inner_err, _) => { - EPattern::List(inner_err.remove_spaces(arena), Position::zero()) + EPattern::List(inner_err.normalize(arena), Position::zero()) } EPattern::AsKeyword(_) => EPattern::AsKeyword(Position::zero()), EPattern::AsIdentifier(_) => EPattern::AsIdentifier(Position::zero()), @@ -1120,7 +1215,7 @@ impl<'a> RemoveSpaces<'a> for EPattern<'a> { EPattern::End(_) => EPattern::End(Position::zero()), EPattern::Space(inner_err, _) => EPattern::Space(*inner_err, Position::zero()), EPattern::PInParens(inner_err, _) => { - EPattern::PInParens(inner_err.remove_spaces(arena), Position::zero()) + EPattern::PInParens(inner_err.normalize(arena), Position::zero()) } EPattern::NumLiteral(inner_err, _) => { EPattern::NumLiteral(inner_err.clone(), Position::zero()) @@ -1133,8 +1228,8 @@ impl<'a> RemoveSpaces<'a> for EPattern<'a> { } } -impl<'a> RemoveSpaces<'a> for EImport<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EImport<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EImport::Import(_) => EImport::Import(Position::zero()), EImport::IndentStart(_) => EImport::IndentStart(Position::zero()), @@ -1142,7 +1237,7 @@ impl<'a> RemoveSpaces<'a> for EImport<'a> { EImport::PackageShorthandDot(_) => EImport::PackageShorthandDot(Position::zero()), EImport::ModuleName(_) => EImport::ModuleName(Position::zero()), EImport::Params(inner_err, _) => { - EImport::Params(inner_err.remove_spaces(arena), Position::zero()) + EImport::Params(inner_err.normalize(arena), Position::zero()) } EImport::IndentAs(_) => EImport::IndentAs(Position::zero()), EImport::As(_) => EImport::As(Position::zero()), @@ -1162,7 +1257,7 @@ impl<'a> RemoveSpaces<'a> for EImport<'a> { EImport::Colon(_) => EImport::Colon(Position::zero()), EImport::IndentAnnotation(_) => EImport::IndentAnnotation(Position::zero()), EImport::Annotation(inner_err, _) => { - EImport::Annotation(inner_err.remove_spaces(arena), Position::zero()) + EImport::Annotation(inner_err.normalize(arena), Position::zero()) } EImport::Space(inner_err, _) => EImport::Space(*inner_err, Position::zero()), EImport::EndNewline(_) => EImport::EndNewline(Position::zero()), @@ -1170,25 +1265,25 @@ impl<'a> RemoveSpaces<'a> for EImport<'a> { } } -impl<'a> RemoveSpaces<'a> for EType<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EType<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EType::Space(inner_err, _) => EType::Space(*inner_err, Position::zero()), EType::UnderscoreSpacing(_) => EType::UnderscoreSpacing(Position::zero()), EType::TRecord(inner_err, _) => { - EType::TRecord(inner_err.remove_spaces(arena), Position::zero()) + EType::TRecord(inner_err.normalize(arena), Position::zero()) } EType::TTagUnion(inner_err, _) => { - EType::TTagUnion(inner_err.remove_spaces(arena), Position::zero()) + EType::TTagUnion(inner_err.normalize(arena), Position::zero()) } EType::TInParens(inner_err, _) => { - EType::TInParens(inner_err.remove_spaces(arena), Position::zero()) + EType::TInParens(inner_err.normalize(arena), Position::zero()) } EType::TApply(inner_err, _) => { - EType::TApply(inner_err.remove_spaces(arena), Position::zero()) + EType::TApply(inner_err.normalize(arena), Position::zero()) } EType::TInlineAlias(inner_err, _) => { - EType::TInlineAlias(inner_err.remove_spaces(arena), Position::zero()) + EType::TInlineAlias(inner_err.normalize(arena), Position::zero()) } EType::TBadTypeVariable(_) => EType::TBadTypeVariable(Position::zero()), EType::TWildcard(_) => EType::TWildcard(Position::zero()), @@ -1199,7 +1294,7 @@ impl<'a> RemoveSpaces<'a> for EType<'a> { EType::TWhereBar(_) => EType::TWhereBar(Position::zero()), EType::TImplementsClause(_) => EType::TImplementsClause(Position::zero()), EType::TAbilityImpl(inner_err, _) => { - EType::TAbilityImpl(inner_err.remove_spaces(arena), Position::zero()) + EType::TAbilityImpl(inner_err.normalize(arena), Position::zero()) } EType::TIndentStart(_) => EType::TIndentStart(Position::zero()), EType::TIndentEnd(_) => EType::TIndentEnd(Position::zero()), @@ -1208,15 +1303,18 @@ impl<'a> RemoveSpaces<'a> for EType<'a> { } } -impl<'a> RemoveSpaces<'a> for EImportParams<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EImportParams<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EImportParams::Indent(_) => EImportParams::Indent(Position::zero()), EImportParams::Record(inner_err, _) => { - EImportParams::Record(inner_err.remove_spaces(arena), Position::zero()) + EImportParams::Record(inner_err.normalize(arena), Position::zero()) } EImportParams::RecordUpdateFound(_) => EImportParams::RecordUpdateFound(Region::zero()), EImportParams::RecordApplyFound(_) => EImportParams::RecordApplyFound(Region::zero()), + EImportParams::RecordIgnoredFieldFound(_) => { + EImportParams::RecordIgnoredFieldFound(Region::zero()) + } EImportParams::Space(inner_err, _) => { EImportParams::Space(*inner_err, Position::zero()) } @@ -1227,43 +1325,43 @@ impl<'a> RemoveSpaces<'a> for EImportParams<'a> { } } -impl<'a> RemoveSpaces<'a> for PInParens<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for PInParens<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { PInParens::Empty(_) => PInParens::Empty(Position::zero()), PInParens::End(_) => PInParens::End(Position::zero()), PInParens::Open(_) => PInParens::Open(Position::zero()), - PInParens::Pattern(inner_err, _) => PInParens::Pattern( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + PInParens::Pattern(inner_err, _) => { + PInParens::Pattern(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } PInParens::Space(inner_err, _) => PInParens::Space(*inner_err, Position::zero()), } } } -impl<'a> RemoveSpaces<'a> for ETypeAbilityImpl<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ETypeAbilityImpl<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { ETypeAbilityImpl::End(_) => ETypeAbilityImpl::End(Position::zero()), ETypeAbilityImpl::Open(_) => ETypeAbilityImpl::Open(Position::zero()), ETypeAbilityImpl::Field(_) => ETypeAbilityImpl::Field(Position::zero()), + ETypeAbilityImpl::UnderscoreField(_) => { + ETypeAbilityImpl::UnderscoreField(Position::zero()) + } ETypeAbilityImpl::Colon(_) => ETypeAbilityImpl::Colon(Position::zero()), ETypeAbilityImpl::Arrow(_) => ETypeAbilityImpl::Arrow(Position::zero()), ETypeAbilityImpl::Optional(_) => ETypeAbilityImpl::Optional(Position::zero()), - ETypeAbilityImpl::Type(inner_err, _) => ETypeAbilityImpl::Type( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + ETypeAbilityImpl::Type(inner_err, _) => { + ETypeAbilityImpl::Type(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } ETypeAbilityImpl::Space(inner_err, _) => { ETypeAbilityImpl::Space(*inner_err, Position::zero()) } ETypeAbilityImpl::QuestionMark(_) => ETypeAbilityImpl::QuestionMark(Position::zero()), ETypeAbilityImpl::Ampersand(_) => ETypeAbilityImpl::Ampersand(Position::zero()), - ETypeAbilityImpl::Expr(inner_err, _) => ETypeAbilityImpl::Expr( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + ETypeAbilityImpl::Expr(inner_err, _) => { + ETypeAbilityImpl::Expr(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } ETypeAbilityImpl::IndentBar(_) => ETypeAbilityImpl::IndentBar(Position::zero()), ETypeAbilityImpl::IndentAmpersand(_) => { ETypeAbilityImpl::IndentAmpersand(Position::zero()) @@ -1273,8 +1371,8 @@ impl<'a> RemoveSpaces<'a> for ETypeAbilityImpl<'a> { } } -impl<'a> RemoveSpaces<'a> for ETypeInlineAlias { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ETypeInlineAlias { + fn normalize(&self, _arena: &'a Bump) -> Self { match self { ETypeInlineAlias::NotAnAlias(_pos) => ETypeInlineAlias::NotAnAlias(Position::zero()), ETypeInlineAlias::Qualified(_pos) => ETypeInlineAlias::Qualified(Position::zero()), @@ -1285,8 +1383,8 @@ impl<'a> RemoveSpaces<'a> for ETypeInlineAlias { } } -impl<'a> RemoveSpaces<'a> for ETypeApply { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ETypeApply { + fn normalize(&self, _arena: &'a Bump) -> Self { match self { ETypeApply::StartNotUppercase(_) => ETypeApply::StartNotUppercase(Position::zero()), ETypeApply::End(_) => ETypeApply::End(Position::zero()), @@ -1298,16 +1396,15 @@ impl<'a> RemoveSpaces<'a> for ETypeApply { } } -impl<'a> RemoveSpaces<'a> for ETypeInParens<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ETypeInParens<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { ETypeInParens::Empty(_) => ETypeInParens::Empty(Position::zero()), ETypeInParens::End(_) => ETypeInParens::End(Position::zero()), ETypeInParens::Open(_) => ETypeInParens::Open(Position::zero()), - ETypeInParens::Type(inner_err, _) => ETypeInParens::Type( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + ETypeInParens::Type(inner_err, _) => { + ETypeInParens::Type(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } ETypeInParens::Space(inner_err, _) => { ETypeInParens::Space(*inner_err, Position::zero()) } @@ -1317,15 +1414,14 @@ impl<'a> RemoveSpaces<'a> for ETypeInParens<'a> { } } -impl<'a> RemoveSpaces<'a> for ETypeTagUnion<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ETypeTagUnion<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { ETypeTagUnion::End(_) => ETypeTagUnion::End(Position::zero()), ETypeTagUnion::Open(_) => ETypeTagUnion::Open(Position::zero()), - ETypeTagUnion::Type(inner_err, _) => ETypeTagUnion::Type( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + ETypeTagUnion::Type(inner_err, _) => { + ETypeTagUnion::Type(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } ETypeTagUnion::Space(inner_err, _) => { ETypeTagUnion::Space(*inner_err, Position::zero()) } @@ -1333,18 +1429,17 @@ impl<'a> RemoveSpaces<'a> for ETypeTagUnion<'a> { } } -impl<'a> RemoveSpaces<'a> for ETypeRecord<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ETypeRecord<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { ETypeRecord::End(_) => ETypeRecord::End(Position::zero()), ETypeRecord::Open(_) => ETypeRecord::Open(Position::zero()), ETypeRecord::Field(_) => ETypeRecord::Field(Position::zero()), ETypeRecord::Colon(_) => ETypeRecord::Colon(Position::zero()), ETypeRecord::Optional(_) => ETypeRecord::Optional(Position::zero()), - ETypeRecord::Type(inner_err, _) => ETypeRecord::Type( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + ETypeRecord::Type(inner_err, _) => { + ETypeRecord::Type(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } ETypeRecord::Space(inner_err, _) => ETypeRecord::Space(*inner_err, Position::zero()), ETypeRecord::IndentOpen(_) => ETypeRecord::IndentOpen(Position::zero()), ETypeRecord::IndentColon(_) => ETypeRecord::IndentColon(Position::zero()), @@ -1354,79 +1449,71 @@ impl<'a> RemoveSpaces<'a> for ETypeRecord<'a> { } } -impl<'a> RemoveSpaces<'a> for PRecord<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for PRecord<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { PRecord::End(_) => PRecord::End(Position::zero()), PRecord::Open(_) => PRecord::Open(Position::zero()), PRecord::Field(_) => PRecord::Field(Position::zero()), PRecord::Colon(_) => PRecord::Colon(Position::zero()), PRecord::Optional(_) => PRecord::Optional(Position::zero()), - PRecord::Pattern(inner_err, _) => PRecord::Pattern( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), - PRecord::Expr(inner_err, _) => PRecord::Expr( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + PRecord::Pattern(inner_err, _) => { + PRecord::Pattern(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } + PRecord::Expr(inner_err, _) => { + PRecord::Expr(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } PRecord::Space(inner_err, _) => PRecord::Space(*inner_err, Position::zero()), } } } -impl<'a> RemoveSpaces<'a> for PList<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for PList<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { PList::End(_) => PList::End(Position::zero()), PList::Open(_) => PList::Open(Position::zero()), PList::Rest(_) => PList::Rest(Position::zero()), - PList::Pattern(inner_err, _) => PList::Pattern( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + PList::Pattern(inner_err, _) => { + PList::Pattern(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } PList::Space(inner_err, _) => PList::Space(*inner_err, Position::zero()), } } } -impl<'a> RemoveSpaces<'a> for EExpect<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EExpect<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EExpect::Space(inner_err, _) => EExpect::Space(*inner_err, Position::zero()), EExpect::Dbg(_) => EExpect::Dbg(Position::zero()), EExpect::Expect(_) => EExpect::Expect(Position::zero()), - EExpect::Condition(inner_err, _) => EExpect::Condition( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), - EExpect::Continuation(inner_err, _) => EExpect::Continuation( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + EExpect::Condition(inner_err, _) => { + EExpect::Condition(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } + EExpect::Continuation(inner_err, _) => { + EExpect::Continuation(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } EExpect::IndentCondition(_) => EExpect::IndentCondition(Position::zero()), } } } -impl<'a> RemoveSpaces<'a> for EIf<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EIf<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EIf::Space(inner_err, _) => EIf::Space(*inner_err, Position::zero()), EIf::If(_) => EIf::If(Position::zero()), EIf::Then(_) => EIf::Then(Position::zero()), EIf::Else(_) => EIf::Else(Position::zero()), - EIf::Condition(inner_err, _) => EIf::Condition( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), - EIf::ThenBranch(inner_err, _) => EIf::ThenBranch( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), - EIf::ElseBranch(inner_err, _) => EIf::ElseBranch( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + EIf::Condition(inner_err, _) => { + EIf::Condition(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } + EIf::ThenBranch(inner_err, _) => { + EIf::ThenBranch(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } + EIf::ElseBranch(inner_err, _) => { + EIf::ElseBranch(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } EIf::IndentCondition(_) => EIf::IndentCondition(Position::zero()), EIf::IndentIf(_) => EIf::IndentIf(Position::zero()), EIf::IndentThenToken(_) => EIf::IndentThenToken(Position::zero()), @@ -1437,30 +1524,27 @@ impl<'a> RemoveSpaces<'a> for EIf<'a> { } } -impl<'a> RemoveSpaces<'a> for EWhen<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EWhen<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EWhen::Space(inner_err, _) => EWhen::Space(*inner_err, Position::zero()), EWhen::When(_) => EWhen::When(Position::zero()), EWhen::Is(_) => EWhen::Is(Position::zero()), EWhen::Pattern(inner_err, _) => { - EWhen::Pattern(inner_err.remove_spaces(arena), Position::zero()) + EWhen::Pattern(inner_err.normalize(arena), Position::zero()) } EWhen::Arrow(_) => EWhen::Arrow(Position::zero()), EWhen::Bar(_) => EWhen::Bar(Position::zero()), EWhen::IfToken(_) => EWhen::IfToken(Position::zero()), - EWhen::IfGuard(inner_err, _) => EWhen::IfGuard( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), - EWhen::Condition(inner_err, _) => EWhen::Condition( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), - EWhen::Branch(inner_err, _) => EWhen::Branch( - arena.alloc(inner_err.remove_spaces(arena)), - Position::zero(), - ), + EWhen::IfGuard(inner_err, _) => { + EWhen::IfGuard(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } + EWhen::Condition(inner_err, _) => { + EWhen::Condition(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } + EWhen::Branch(inner_err, _) => { + EWhen::Branch(arena.alloc(inner_err.normalize(arena)), Position::zero()) + } EWhen::IndentCondition(_) => EWhen::IndentCondition(Position::zero()), EWhen::IndentPattern(_) => EWhen::IndentPattern(Position::zero()), EWhen::IndentArrow(_) => EWhen::IndentArrow(Position::zero()), @@ -1471,12 +1555,12 @@ impl<'a> RemoveSpaces<'a> for EWhen<'a> { } } -impl<'a> RemoveSpaces<'a> for EAbility<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EAbility<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EAbility::Space(inner_err, _) => EAbility::Space(*inner_err, Position::zero()), EAbility::Type(inner_err, _) => { - EAbility::Type(inner_err.remove_spaces(arena), Position::zero()) + EAbility::Type(inner_err.normalize(arena), Position::zero()) } EAbility::DemandAlignment(_alignment, _) => { EAbility::DemandAlignment(0, Position::zero()) @@ -1487,8 +1571,8 @@ impl<'a> RemoveSpaces<'a> for EAbility<'a> { } } -impl<'a> RemoveSpaces<'a> for EGeneratesWith { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EGeneratesWith { + fn normalize(&self, _arena: &'a Bump) -> Self { match self { EGeneratesWith::Open(_) => EGeneratesWith::Open(Position::zero()), EGeneratesWith::With(_) => EGeneratesWith::With(Position::zero()), @@ -1505,8 +1589,8 @@ impl<'a> RemoveSpaces<'a> for EGeneratesWith { } } -impl<'a> RemoveSpaces<'a> for EGenerates { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EGenerates { + fn normalize(&self, _arena: &'a Bump) -> Self { match self { EGenerates::Open(_) => EGenerates::Open(Position::zero()), EGenerates::Generates(_) => EGenerates::Generates(Position::zero()), @@ -1519,8 +1603,8 @@ impl<'a> RemoveSpaces<'a> for EGenerates { } } -impl<'a> RemoveSpaces<'a> for EPackages<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EPackages<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EPackages::Open(_) => EPackages::Open(Position::zero()), EPackages::Space(inner_err, _) => EPackages::Space(*inner_err, Position::zero()), @@ -1531,50 +1615,50 @@ impl<'a> RemoveSpaces<'a> for EPackages<'a> { EPackages::IndentListStart(_) => EPackages::IndentListStart(Position::zero()), EPackages::IndentListEnd(_) => EPackages::IndentListEnd(Position::zero()), EPackages::PackageEntry(inner_err, _) => { - EPackages::PackageEntry(inner_err.remove_spaces(arena), Position::zero()) + EPackages::PackageEntry(inner_err.normalize(arena), Position::zero()) } } } } -impl<'a> RemoveSpaces<'a> for EHeader<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EHeader<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EHeader::Provides(inner_err, _) => { - EHeader::Provides(inner_err.remove_spaces(arena), Position::zero()) + EHeader::Provides(inner_err.normalize(arena), Position::zero()) } EHeader::Params(inner_err, _) => { - EHeader::Params(inner_err.remove_spaces(arena), Position::zero()) + EHeader::Params(inner_err.normalize(arena), Position::zero()) } EHeader::Exposes(inner_err, _) => { - EHeader::Exposes(inner_err.remove_spaces(arena), Position::zero()) + EHeader::Exposes(inner_err.normalize(arena), Position::zero()) } EHeader::Imports(inner_err, _) => { - EHeader::Imports(inner_err.remove_spaces(arena), Position::zero()) + EHeader::Imports(inner_err.normalize(arena), Position::zero()) } EHeader::Requires(inner_err, _) => { - EHeader::Requires(inner_err.remove_spaces(arena), Position::zero()) + EHeader::Requires(inner_err.normalize(arena), Position::zero()) } EHeader::Packages(inner_err, _) => { - EHeader::Packages(inner_err.remove_spaces(arena), Position::zero()) + EHeader::Packages(inner_err.normalize(arena), Position::zero()) } EHeader::Generates(inner_err, _) => { - EHeader::Generates(inner_err.remove_spaces(arena), Position::zero()) + EHeader::Generates(inner_err.normalize(arena), Position::zero()) } EHeader::GeneratesWith(inner_err, _) => { - EHeader::GeneratesWith(inner_err.remove_spaces(arena), Position::zero()) + EHeader::GeneratesWith(inner_err.normalize(arena), Position::zero()) } EHeader::Space(inner_err, _) => EHeader::Space(*inner_err, Position::zero()), EHeader::Start(_) => EHeader::Start(Position::zero()), EHeader::ModuleName(_) => EHeader::ModuleName(Position::zero()), EHeader::AppName(inner_err, _) => { - EHeader::AppName(inner_err.remove_spaces(arena), Position::zero()) + EHeader::AppName(inner_err.normalize(arena), Position::zero()) } EHeader::PackageName(inner_err, _) => { - EHeader::PackageName(inner_err.remove_spaces(arena), Position::zero()) + EHeader::PackageName(inner_err.normalize(arena), Position::zero()) } EHeader::PlatformName(inner_err, _) => { - EHeader::PlatformName(inner_err.remove_spaces(arena), Position::zero()) + EHeader::PlatformName(inner_err.normalize(arena), Position::zero()) } EHeader::IndentStart(_) => EHeader::IndentStart(Position::zero()), EHeader::InconsistentModuleName(_) => EHeader::InconsistentModuleName(Region::zero()), @@ -1582,11 +1666,11 @@ impl<'a> RemoveSpaces<'a> for EHeader<'a> { } } -impl<'a> RemoveSpaces<'a> for EPackageName<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EPackageName<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EPackageName::BadPath(inner_err, _) => { - EPackageName::BadPath(inner_err.remove_spaces(arena), Position::zero()) + EPackageName::BadPath(inner_err.normalize(arena), Position::zero()) } EPackageName::Escapes(_) => EPackageName::Escapes(Position::zero()), EPackageName::Multiline(_) => EPackageName::Multiline(Position::zero()), @@ -1594,8 +1678,8 @@ impl<'a> RemoveSpaces<'a> for EPackageName<'a> { } } -impl<'a> RemoveSpaces<'a> for SyntaxError<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for SyntaxError<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { SyntaxError::Unexpected(_) => SyntaxError::Unexpected(Region::zero()), SyntaxError::OutdentedTooFar => SyntaxError::OutdentedTooFar, @@ -1608,23 +1692,21 @@ impl<'a> RemoveSpaces<'a> for SyntaxError<'a> { } SyntaxError::NotYetImplemented(text) => SyntaxError::NotYetImplemented(text.clone()), SyntaxError::Todo => SyntaxError::Todo, - SyntaxError::Type(err) => SyntaxError::Type(err.remove_spaces(arena)), - SyntaxError::Pattern(err) => SyntaxError::Pattern(err.remove_spaces(arena)), - SyntaxError::Expr(err, _) => { - SyntaxError::Expr(err.remove_spaces(arena), Position::zero()) - } - SyntaxError::Header(err) => SyntaxError::Header(err.remove_spaces(arena)), + SyntaxError::Type(err) => SyntaxError::Type(err.normalize(arena)), + SyntaxError::Pattern(err) => SyntaxError::Pattern(err.normalize(arena)), + SyntaxError::Expr(err, _) => SyntaxError::Expr(err.normalize(arena), Position::zero()), + SyntaxError::Header(err) => SyntaxError::Header(err.normalize(arena)), SyntaxError::Space(inner_err) => SyntaxError::Space(*inner_err), SyntaxError::NotEndOfFile(_) => SyntaxError::NotEndOfFile(Position::zero()), } } } -impl<'a> RemoveSpaces<'a> for EPackageEntry<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EPackageEntry<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EPackageEntry::BadPackage(inner_err, _) => { - EPackageEntry::BadPackage(inner_err.remove_spaces(arena), Position::zero()) + EPackageEntry::BadPackage(inner_err.normalize(arena), Position::zero()) } EPackageEntry::Shorthand(_) => EPackageEntry::Shorthand(Position::zero()), EPackageEntry::Colon(_) => EPackageEntry::Colon(Position::zero()), @@ -1638,8 +1720,8 @@ impl<'a> RemoveSpaces<'a> for EPackageEntry<'a> { } } -impl<'a> RemoveSpaces<'a> for EProvides<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EProvides<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EProvides::Provides(_) => EProvides::Provides(Position::zero()), EProvides::Open(_) => EProvides::Open(Position::zero()), @@ -1652,18 +1734,18 @@ impl<'a> RemoveSpaces<'a> for EProvides<'a> { EProvides::ListEnd(_) => EProvides::ListEnd(Position::zero()), EProvides::Identifier(_) => EProvides::Identifier(Position::zero()), EProvides::Package(inner_err, _) => { - EProvides::Package(inner_err.remove_spaces(arena), Position::zero()) + EProvides::Package(inner_err.normalize(arena), Position::zero()) } EProvides::Space(inner_err, _) => EProvides::Space(*inner_err, Position::zero()), } } } -impl<'a> RemoveSpaces<'a> for EParams<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EParams<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { EParams::Pattern(inner_err, _) => { - EParams::Pattern(inner_err.remove_spaces(arena), Position::zero()) + EParams::Pattern(inner_err.normalize(arena), Position::zero()) } EParams::BeforeArrow(_) => EParams::BeforeArrow(Position::zero()), EParams::Arrow(_) => EParams::Arrow(Position::zero()), @@ -1673,8 +1755,8 @@ impl<'a> RemoveSpaces<'a> for EParams<'a> { } } -impl<'a> RemoveSpaces<'a> for EExposes { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EExposes { + fn normalize(&self, _arena: &'a Bump) -> Self { match self { EExposes::Exposes(_) => EExposes::Exposes(Position::zero()), EExposes::Open(_) => EExposes::Open(Position::zero()), @@ -1688,8 +1770,8 @@ impl<'a> RemoveSpaces<'a> for EExposes { } } -impl<'a> RemoveSpaces<'a> for EImports { - fn remove_spaces(&self, _arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for EImports { + fn normalize(&self, _arena: &'a Bump) -> Self { match self { EImports::Open(_) => EImports::Open(Position::zero()), EImports::Imports(_) => EImports::Imports(Position::zero()), @@ -1714,8 +1796,8 @@ impl<'a> RemoveSpaces<'a> for EImports { } } -impl<'a> RemoveSpaces<'a> for ERequires<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ERequires<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { ERequires::Requires(_) => ERequires::Requires(Position::zero()), ERequires::Open(_) => ERequires::Open(Position::zero()), @@ -1724,7 +1806,7 @@ impl<'a> RemoveSpaces<'a> for ERequires<'a> { ERequires::ListStart(_) => ERequires::ListStart(Position::zero()), ERequires::ListEnd(_) => ERequires::ListEnd(Position::zero()), ERequires::TypedIdent(inner_err, _) => { - ERequires::TypedIdent(inner_err.remove_spaces(arena), Position::zero()) + ERequires::TypedIdent(inner_err.normalize(arena), Position::zero()) } ERequires::Rigid(_) => ERequires::Rigid(Position::zero()), ERequires::Space(inner_err, _) => ERequires::Space(*inner_err, Position::zero()), @@ -1732,15 +1814,15 @@ impl<'a> RemoveSpaces<'a> for ERequires<'a> { } } -impl<'a> RemoveSpaces<'a> for ETypedIdent<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for ETypedIdent<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { ETypedIdent::Space(inner_err, _) => ETypedIdent::Space(*inner_err, Position::zero()), ETypedIdent::HasType(_) => ETypedIdent::HasType(Position::zero()), ETypedIdent::IndentHasType(_) => ETypedIdent::IndentHasType(Position::zero()), ETypedIdent::Name(_) => ETypedIdent::Name(Position::zero()), ETypedIdent::Type(inner_err, _) => { - ETypedIdent::Type(inner_err.remove_spaces(arena), Position::zero()) + ETypedIdent::Type(inner_err.normalize(arena), Position::zero()) } ETypedIdent::IndentType(_) => ETypedIdent::IndentType(Position::zero()), ETypedIdent::Identifier(_) => ETypedIdent::Identifier(Position::zero()), diff --git a/crates/compiler/parse/src/parser.rs b/crates/compiler/parse/src/parser.rs index 7eec1b83e9..c773acab73 100644 --- a/crates/compiler/parse/src/parser.rs +++ b/crates/compiler/parse/src/parser.rs @@ -372,9 +372,11 @@ pub enum EExpr<'a> { InParens(EInParens<'a>, Position), Record(ERecord<'a>, Position), - OptionalValueInRecordBuilder(Region), - RecordUpdateAccumulator(Region), - RecordBuilderAccumulator(Region), + OptionalValueInOldRecordBuilder(Region), + IgnoredValueInOldRecordBuilder(Region), + RecordUpdateOldBuilderField(Region), + RecordUpdateIgnoredField(Region), + RecordBuilderOldBuilderField(Region), // SingleQuote errors are folded into the EString Str(EString<'a>, Position), @@ -428,6 +430,7 @@ pub enum ERecord<'a> { Prefix(Position), Field(Position), + UnderscoreField(Position), Colon(Position), QuestionMark(Position), Arrow(Position), @@ -577,6 +580,7 @@ pub enum EImportParams<'a> { RecordUpdateFound(Region), RecordBuilderFound(Region), RecordApplyFound(Region), + RecordIgnoredFieldFound(Region), Space(BadInputError, Position), } @@ -735,6 +739,7 @@ pub enum ETypeAbilityImpl<'a> { Open(Position), Field(Position), + UnderscoreField(Position), Colon(Position), Arrow(Position), Optional(Position), @@ -756,6 +761,7 @@ impl<'a> From> for ETypeAbilityImpl<'a> { ERecord::End(p) => ETypeAbilityImpl::End(p), ERecord::Open(p) => ETypeAbilityImpl::Open(p), ERecord::Field(p) => ETypeAbilityImpl::Field(p), + ERecord::UnderscoreField(p) => ETypeAbilityImpl::UnderscoreField(p), ERecord::Colon(p) => ETypeAbilityImpl::Colon(p), ERecord::Arrow(p) => ETypeAbilityImpl::Arrow(p), ERecord::Space(s, p) => ETypeAbilityImpl::Space(s, p), diff --git a/crates/compiler/parse/src/pattern.rs b/crates/compiler/parse/src/pattern.rs index 739649cd32..623dc2e872 100644 --- a/crates/compiler/parse/src/pattern.rs +++ b/crates/compiler/parse/src/pattern.rs @@ -25,6 +25,7 @@ pub enum PatternType { DefExpr, FunctionArg, WhenBranch, + ModuleParams, } pub fn closure_param<'a>() -> impl Parser<'a, Loc>, EPattern<'a>> { diff --git a/crates/compiler/parse/src/test_helpers.rs b/crates/compiler/parse/src/test_helpers.rs index 91d1f24b19..194bab9c59 100644 --- a/crates/compiler/parse/src/test_helpers.rs +++ b/crates/compiler/parse/src/test_helpers.rs @@ -1,6 +1,8 @@ use crate::ast; use crate::ast::Defs; -use crate::module::parse_module_defs; +use crate::ast::Header; +use crate::ast::SpacesBefore; +use crate::header::parse_module_defs; use crate::parser::SourceError; use crate::parser::SyntaxError; use crate::state::State; @@ -39,10 +41,10 @@ pub fn parse_defs_with<'a>(arena: &'a Bump, input: &'a str) -> Result, pub fn parse_header_with<'a>( arena: &'a Bump, input: &'a str, -) -> Result, SyntaxError<'a>> { +) -> Result>, SyntaxError<'a>> { let state = State::new(input.as_bytes()); - match crate::module::parse_header(arena, state.clone()) { + match crate::header::parse_header(arena, state.clone()) { Ok((header, _)) => Ok(header), Err(fail) => Err(SyntaxError::Header(fail.problem)), } diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index 5bbc28903c..2802a902e2 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -565,6 +565,9 @@ fn parse_implements_ability<'a>() -> impl Parser<'a, ImplementsAbility<'a>, ETyp fn ability_impl_field<'a>() -> impl Parser<'a, AssignedField<'a, Expr<'a>>, ERecord<'a>> { then(record_field(), move |arena, state, _, field| { match field.to_assigned_field(arena) { + Ok(AssignedField::IgnoredValue(_, _, _)) => { + Err((MadeProgress, ERecord::Field(state.pos()))) + } Ok(assigned_field) => Ok((MadeProgress, assigned_field, state)), Err(FoundApplyValue) => Err((MadeProgress, ERecord::Field(state.pos()))), } diff --git a/crates/compiler/parse/tests/test_parse.rs b/crates/compiler/parse/tests/test_parse.rs index ec0c1efe63..2e4e0deadb 100644 --- a/crates/compiler/parse/tests/test_parse.rs +++ b/crates/compiler/parse/tests/test_parse.rs @@ -22,7 +22,7 @@ mod test_parse { use roc_parse::ast::StrSegment::*; use roc_parse::ast::{self, EscapedChar}; use roc_parse::ast::{CommentOrNewline, StrLiteral::*}; - use roc_parse::module::parse_module_defs; + use roc_parse::header::parse_module_defs; use roc_parse::parser::SyntaxError; use roc_parse::state::State; use roc_parse::test_helpers::parse_expr_with; diff --git a/crates/compiler/problem/src/can.rs b/crates/compiler/problem/src/can.rs index 7666e9fcde..b253dcab3d 100644 --- a/crates/compiler/problem/src/can.rs +++ b/crates/compiler/problem/src/can.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use roc_collections::all::MutSet; use roc_module::called_via::BinOp; use roc_module::ident::{Ident, Lowercase, ModuleName, TagName}; -use roc_module::symbol::{ModuleId, ScopeModuleSource, Symbol}; +use roc_module::symbol::{ModuleId, Symbol}; use roc_parse::ast::Base; use roc_parse::pattern::PatternType; use roc_region::all::{Loc, Region}; @@ -238,6 +238,13 @@ pub enum Problem { }, } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ScopeModuleSource { + Builtin, + Current, + Import(Region), +} + impl Problem { pub fn severity(&self) -> Severity { use Severity::{Fatal, RuntimeError, Warning}; diff --git a/crates/compiler/solve/src/module.rs b/crates/compiler/solve/src/module.rs index 77b4bf2aa6..de76e494b6 100644 --- a/crates/compiler/solve/src/module.rs +++ b/crates/compiler/solve/src/module.rs @@ -80,6 +80,10 @@ pub struct SolveConfig<'a> { #[cfg(debug_assertions)] /// The checkmate collector for this module. pub checkmate: Option, + + /// Module params + pub params_pattern: Option, + pub module_params_vars: VecMap, } pub struct SolveOutput { @@ -144,6 +148,7 @@ pub fn exposed_types_storage_subs( home: ModuleId, solved_subs: &mut Solved, exposed_vars_by_symbol: &[(Symbol, Variable)], + params_var: Option, solved_implementations: &ResolvedImplementations, abilities_store: &AbilitiesStore, ) -> ExposedTypesStorageSubs { @@ -156,6 +161,9 @@ pub fn exposed_types_storage_subs( stored_vars_by_symbol.insert(*symbol, new_var); } + let stored_params_var = + params_var.map(|params_var| storage_subs.import_variable_from(subs, params_var).variable); + let mut stored_specialization_lambda_set_vars = VecMap::with_capacity(solved_implementations.len()); @@ -213,6 +221,7 @@ pub fn exposed_types_storage_subs( stored_vars_by_symbol, stored_specialization_lambda_set_vars, stored_ability_member_vars, + stored_params_var, } } diff --git a/crates/compiler/solve/src/solve.rs b/crates/compiler/solve/src/solve.rs index 95dafa4851..17bfb4c637 100644 --- a/crates/compiler/solve/src/solve.rs +++ b/crates/compiler/solve/src/solve.rs @@ -16,11 +16,12 @@ use roc_can::abilities::{AbilitiesStore, MemberSpecializationInfo}; use roc_can::constraint::Constraint::{self, *}; use roc_can::constraint::{Cycle, LetConstraint, OpportunisticResolve}; use roc_can::expected::{Expected, PExpected}; +use roc_collections::VecMap; use roc_debug_flags::dbg_do; #[cfg(debug_assertions)] use roc_debug_flags::ROC_VERIFY_RIGID_LET_GENERALIZED; use roc_error_macros::internal_error; -use roc_module::symbol::Symbol; +use roc_module::symbol::{ModuleId, Symbol}; use roc_problem::can::CycleEntry; use roc_region::all::Loc; use roc_solve_problem::TypeError; @@ -129,15 +130,13 @@ fn run_help( exposed_by_module, derived_module, function_kind, + params_pattern, + module_params_vars, .. } = config; let mut pools = Pools::default(); - let state = State { - scope: Scope::default(), - mark: Mark::NONE.next(), - }; let rank = Rank::toplevel(); let arena = Bump::new(); @@ -178,7 +177,6 @@ fn run_help( let state = solve( &mut env, types, - state, rank, problems, aliases, @@ -186,6 +184,8 @@ fn run_help( abilities_store, &mut obligation_cache, &mut awaiting_specializations, + params_pattern, + module_params_vars, ); RunSolveOutput { @@ -236,7 +236,6 @@ enum Work<'a> { fn solve( env: &mut InferenceEnv, mut can_types: Types, - mut state: State, rank: Rank, problems: &mut Vec, aliases: &mut Aliases, @@ -244,15 +243,24 @@ fn solve( abilities_store: &mut AbilitiesStore, obligation_cache: &mut ObligationCache, awaiting_specializations: &mut AwaitingSpecializations, + params_pattern: Option, + module_params_vars: VecMap, ) -> State { + let scope = Scope::new(params_pattern); + let initial = Work::Constraint { - scope: &Scope::default(), + scope: &scope.clone(), rank, constraint, }; let mut stack = vec![initial]; + let mut state = State { + scope, + mark: Mark::NONE.next(), + }; + while let Some(work_item) = stack.pop() { let (scope, rank, constraint) = match work_item { Work::Constraint { @@ -1392,6 +1400,86 @@ fn solve( } } } + ImportParams(opt_provided, module_id, region) => { + match (module_params_vars.get(module_id), opt_provided) { + (Some(expected), Some(provided)) => { + let actual = either_type_index_to_var( + env, + rank, + problems, + abilities_store, + obligation_cache, + &mut can_types, + aliases, + *provided, + ); + + match unify( + &mut env.uenv(), + actual, + *expected, + UnificationMode::EQ, + Polarity::OF_VALUE, + ) { + Success { + vars, + must_implement_ability, + lambda_sets_to_specialize, + extra_metadata: _, + } => { + env.introduce(rank, &vars); + + problems.extend(obligation_cache.check_obligations( + env.subs, + abilities_store, + must_implement_ability, + AbilityImplError::DoesNotImplement, + )); + compact_lambdas_and_check_obligations( + env, + problems, + abilities_store, + obligation_cache, + awaiting_specializations, + lambda_sets_to_specialize, + ); + + state + } + + Failure(vars, actual_type, expected_type, _) => { + env.introduce(rank, &vars); + + problems.push(TypeError::ModuleParamsMismatch( + *region, + *module_id, + actual_type, + expected_type, + )); + + state + } + } + } + (Some(expected), None) => { + let expected_type = env.uenv().var_to_error_type(*expected, Polarity::Neg); + + problems.push(TypeError::MissingModuleParams( + *region, + *module_id, + expected_type, + )); + + state + } + (None, Some(_)) => { + problems.push(TypeError::UnexpectedModuleParams(*region, *module_id)); + + state + } + (None, None) => state, + } + } }; } diff --git a/crates/compiler/solve/src/solve/scope.rs b/crates/compiler/solve/src/solve/scope.rs index 5acd041c96..9214a9d6b2 100644 --- a/crates/compiler/solve/src/solve/scope.rs +++ b/crates/compiler/solve/src/solve/scope.rs @@ -2,13 +2,43 @@ use roc_module::symbol::Symbol; use roc_types::subs::Variable; /// The scope of the solver, as symbols are introduced. -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct Scope { symbols: Vec, variables: Vec, } impl Scope { + pub fn new(params_pattern: Option) -> Self { + match params_pattern { + Some(params_pattern) => match params_pattern { + roc_can::pattern::Pattern::RecordDestructure { + whole_var: _, + ext_var: _, + destructs, + } => { + let mut symbols = Vec::with_capacity(destructs.len()); + let mut variables = Vec::with_capacity(destructs.len()); + + for destruct in destructs { + symbols.push(destruct.value.symbol); + variables.push(destruct.value.var); + } + + Self { symbols, variables } + } + _ => unreachable!( + "other pattern types should have parsed: {:?}", + params_pattern + ), + }, + None => Self { + symbols: Vec::default(), + variables: Vec::default(), + }, + } + } + pub fn vars_by_symbol(&self) -> impl Iterator + '_ { let it1 = self.symbols.iter().copied(); let it2 = self.variables.iter().copied(); diff --git a/crates/compiler/solve_problem/src/lib.rs b/crates/compiler/solve_problem/src/lib.rs index 43de9204c4..9eabe601ba 100644 --- a/crates/compiler/solve_problem/src/lib.rs +++ b/crates/compiler/solve_problem/src/lib.rs @@ -2,7 +2,10 @@ use std::{path::PathBuf, str::Utf8Error}; use roc_can::expected::{Expected, PExpected}; -use roc_module::{ident::Lowercase, symbol::Symbol}; +use roc_module::{ + ident::Lowercase, + symbol::{ModuleId, Symbol}, +}; use roc_problem::{can::CycleEntry, Severity}; use roc_region::all::Region; @@ -33,6 +36,9 @@ pub enum TypeError { }, IngestedFileBadUtf8(Box, Utf8Error), IngestedFileUnsupportedType(Box, ErrorType), + UnexpectedModuleParams(Region, ModuleId), + MissingModuleParams(Region, ModuleId, ErrorType), + ModuleParamsMismatch(Region, ModuleId, ErrorType, ErrorType), } impl TypeError { @@ -52,6 +58,9 @@ impl TypeError { TypeError::Exhaustive(exhtv) => exhtv.severity(), TypeError::StructuralSpecialization { .. } => RuntimeError, TypeError::WrongSpecialization { .. } => RuntimeError, + TypeError::UnexpectedModuleParams(..) => Warning, + TypeError::MissingModuleParams(..) => RuntimeError, + TypeError::ModuleParamsMismatch(..) => RuntimeError, TypeError::IngestedFileBadUtf8(..) => Fatal, TypeError::IngestedFileUnsupportedType(..) => Fatal, } @@ -66,7 +75,10 @@ impl TypeError { | TypeError::BadExprMissingAbility(region, ..) | TypeError::StructuralSpecialization { region, .. } | TypeError::WrongSpecialization { region, .. } - | TypeError::BadPatternMissingAbility(region, ..) => Some(*region), + | TypeError::BadPatternMissingAbility(region, ..) + | TypeError::UnexpectedModuleParams(region, ..) + | TypeError::MissingModuleParams(region, ..) + | TypeError::ModuleParamsMismatch(region, ..) => Some(*region), TypeError::UnfulfilledAbility(ab, ..) => ab.region(), TypeError::Exhaustive(e) => Some(e.region()), TypeError::CircularDef(c) => c.first().map(|ce| ce.symbol_region), diff --git a/crates/compiler/test_derive/src/util.rs b/crates/compiler/test_derive/src/util.rs index 0fbb02e9be..a4d78169ed 100644 --- a/crates/compiler/test_derive/src/util.rs +++ b/crates/compiler/test_derive/src/util.rs @@ -405,7 +405,7 @@ fn check_derived_typechecks_and_golden( let mut def_types = Default::default(); let mut rigid_vars = Default::default(); let mut flex_vars = Default::default(); - let (import_variables, abilities_store) = add_imports( + let (import_variables, imported_param_vars, abilities_store) = add_imports( test_module, &mut constraints, &mut test_subs, @@ -438,6 +438,8 @@ fn check_derived_typechecks_and_golden( pending_derives: Default::default(), exposed_by_module: &exposed_for_module.exposed_by_module, derived_module: Default::default(), + params_pattern: None, + module_params_vars: imported_param_vars, #[cfg(debug_assertions)] checkmate: None, diff --git a/crates/compiler/test_gen/src/gen_result.rs b/crates/compiler/test_gen/src/gen_result.rs index 703d9fcd18..f9160a73a0 100644 --- a/crates/compiler/test_gen/src/gen_result.rs +++ b/crates/compiler/test_gen/src/gen_result.rs @@ -354,3 +354,85 @@ fn roc_result_after_err() { RocResult ); } + +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))] +fn roc_result_map_both() { + assert_evals_to!( + indoc!( + r#" + result : Result I64 I64 + result = Ok 42 + + result |> Result.mapBoth Num.toStr Num.toStr + "# + ), + RocResult::ok(RocStr::from("42")), + RocResult + ); + + assert_evals_to!( + indoc!( + r#" + result : Result I64 I64 + result = Err 24 + + result |> Result.mapBoth Num.toStr Num.toStr + "# + ), + RocResult::err(RocStr::from("24")), + RocResult + ); +} + +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))] +fn roc_result_map_two() { + assert_evals_to!( + indoc!( + r#" + first : Result I64 Str + first = Ok 24 + + second : Result I64 Str + second = Ok -10 + + Result.map2 first second \a, b -> a + b + "# + ), + RocResult::ok(14i64), + RocResult + ); + + assert_evals_to!( + indoc!( + r#" + first : Result I64 Str + first = Err "foo" + + second : Result I64 Str + second = Err "bar" + + Result.map2 first second \a, b -> a + b + "# + ), + RocResult::err(RocStr::from("foo")), + RocResult + ); + + assert_evals_to!( + indoc!( + r#" + first : Result I64 Str + first = Ok 42 + + second : Result I64 Str + second = Err "bar" + + Result.map2 first second \a, b -> a + b + "# + ), + RocResult::err(RocStr::from("bar")), + RocResult + ); +} diff --git a/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt b/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt index 85de690930..ea1183671e 100644 --- a/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt +++ b/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt @@ -2,93 +2,93 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.23; -procedure List.107 (List.536, List.537, List.538): - let List.640 : U64 = 0i64; - let List.641 : U64 = CallByName List.6 List.536; - let List.639 : [C U64, C U64] = CallByName List.80 List.536 List.537 List.538 List.640 List.641; - ret List.639; +procedure List.110 (List.539, List.540, List.541): + let List.643 : U64 = 0i64; + let List.644 : U64 = CallByName List.6 List.539; + let List.642 : [C U64, C U64] = CallByName List.80 List.539 List.540 List.541 List.643 List.644; + ret List.642; -procedure List.26 (List.204, List.205, List.206): - let List.633 : [C U64, C U64] = CallByName List.107 List.204 List.205 List.206; - let List.636 : U8 = 1i64; - let List.637 : U8 = GetTagId List.633; - let List.638 : Int1 = lowlevel Eq List.636 List.637; - if List.638 then - let List.207 : U64 = UnionAtIndex (Id 1) (Index 0) List.633; - ret List.207; +procedure List.26 (List.207, List.208, List.209): + let List.636 : [C U64, C U64] = CallByName List.110 List.207 List.208 List.209; + let List.639 : U8 = 1i64; + let List.640 : U8 = GetTagId List.636; + let List.641 : Int1 = lowlevel Eq List.639 List.640; + if List.641 then + let List.210 : U64 = UnionAtIndex (Id 1) (Index 0) List.636; + ret List.210; else - let List.208 : U64 = UnionAtIndex (Id 0) (Index 0) List.633; - ret List.208; + let List.211 : U64 = UnionAtIndex (Id 0) (Index 0) List.636; + ret List.211; -procedure List.38 (List.392, List.393): - let List.632 : U64 = CallByName List.6 List.392; - let List.394 : U64 = CallByName Num.77 List.632 List.393; - let List.622 : List U8 = CallByName List.43 List.392 List.394; - ret List.622; - -procedure List.43 (List.390, List.391): - let List.630 : U64 = CallByName List.6 List.390; - let List.629 : U64 = CallByName Num.77 List.630 List.391; - let List.624 : {U64, U64} = Struct {List.391, List.629}; - let List.623 : List U8 = CallByName List.49 List.390 List.624; - ret List.623; - -procedure List.49 (List.468, List.469): - let List.626 : U64 = StructAtIndex 1 List.469; - let List.627 : U64 = StructAtIndex 0 List.469; - let List.625 : List U8 = CallByName List.72 List.468 List.626 List.627; +procedure List.38 (List.395, List.396): + let List.635 : U64 = CallByName List.6 List.395; + let List.397 : U64 = CallByName Num.77 List.635 List.396; + let List.625 : List U8 = CallByName List.43 List.395 List.397; ret List.625; -procedure List.6 (#Attr.2): - let List.631 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.631; +procedure List.43 (List.393, List.394): + let List.633 : U64 = CallByName List.6 List.393; + let List.632 : U64 = CallByName Num.77 List.633 List.394; + let List.627 : {U64, U64} = Struct {List.394, List.632}; + let List.626 : List U8 = CallByName List.49 List.393 List.627; + ret List.626; -procedure List.66 (#Attr.2, #Attr.3): - let List.654 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.654; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.628 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; +procedure List.49 (List.471, List.472): + let List.629 : U64 = StructAtIndex 1 List.472; + let List.630 : U64 = StructAtIndex 0 List.472; + let List.628 : List U8 = CallByName List.72 List.471 List.629 List.630; ret List.628; +procedure List.6 (#Attr.2): + let List.634 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.634; + +procedure List.66 (#Attr.2, #Attr.3): + let List.657 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.657; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.631 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.631; + procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.642 List.539 List.540 List.541 List.542 List.543: - let List.644 : Int1 = CallByName Num.22 List.542 List.543; - if List.644 then - let List.653 : U8 = CallByName List.66 List.539 List.542; - let List.645 : [C U64, C U64] = CallByName Test.4 List.540 List.653; - let List.650 : U8 = 1i64; - let List.651 : U8 = GetTagId List.645; - let List.652 : Int1 = lowlevel Eq List.650 List.651; - if List.652 then - let List.544 : U64 = UnionAtIndex (Id 1) (Index 0) List.645; - let List.648 : U64 = 1i64; - let List.647 : U64 = CallByName Num.51 List.542 List.648; - jump List.642 List.539 List.544 List.541 List.647 List.543; + joinpoint List.645 List.542 List.543 List.544 List.545 List.546: + let List.647 : Int1 = CallByName Num.22 List.545 List.546; + if List.647 then + let List.656 : U8 = CallByName List.66 List.542 List.545; + let List.648 : [C U64, C U64] = CallByName Test.4 List.543 List.656; + let List.653 : U8 = 1i64; + let List.654 : U8 = GetTagId List.648; + let List.655 : Int1 = lowlevel Eq List.653 List.654; + if List.655 then + let List.547 : U64 = UnionAtIndex (Id 1) (Index 0) List.648; + let List.651 : U64 = 1i64; + let List.650 : U64 = CallByName Num.51 List.545 List.651; + jump List.645 List.542 List.547 List.544 List.650 List.546; else - dec List.539; - let List.545 : U64 = UnionAtIndex (Id 0) (Index 0) List.645; - let List.649 : [C U64, C U64] = TagId(0) List.545; - ret List.649; + dec List.542; + let List.548 : U64 = UnionAtIndex (Id 0) (Index 0) List.648; + let List.652 : [C U64, C U64] = TagId(0) List.548; + ret List.652; else - dec List.539; - let List.643 : [C U64, C U64] = TagId(1) List.540; - ret List.643; + dec List.542; + let List.646 : [C U64, C U64] = TagId(1) List.543; + ret List.646; in inc #Derived_gen.0; - jump List.642 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.645 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.22 (#Attr.2, #Attr.3): - let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.282; + let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.284; procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; procedure Num.77 (#Attr.2, #Attr.3): - let Num.280 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3; + ret Num.282; procedure Test.1 (Test.2): let Test.13 : U64 = 0i64; diff --git a/crates/compiler/test_mono/generated/binary_tree_fbip.txt b/crates/compiler/test_mono/generated/binary_tree_fbip.txt index 537c559e58..28940afe84 100644 --- a/crates/compiler/test_mono/generated/binary_tree_fbip.txt +++ b/crates/compiler/test_mono/generated/binary_tree_fbip.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.4 (Test.27): let Test.39 : [C [, C *self *self] *self, ] = TagId(0) ; diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt index 3f9c3f00ee..a5c284002a 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt @@ -1,59 +1,59 @@ -procedure List.18 (List.163, List.164, List.165): - let List.626 : U64 = 0i64; - let List.627 : U64 = CallByName List.6 List.163; - let List.625 : List {} = CallByName List.92 List.163 List.164 List.165 List.626 List.627; - ret List.625; +procedure List.18 (List.166, List.167, List.168): + let List.629 : U64 = 0i64; + let List.630 : U64 = CallByName List.6 List.166; + let List.628 : List {} = CallByName List.95 List.166 List.167 List.168 List.629 List.630; + ret List.628; -procedure List.275 (List.276, List.277, List.273): - let List.639 : {} = CallByName Test.2 List.277; - let List.638 : List {} = CallByName List.71 List.276 List.639; - ret List.638; - -procedure List.5 (List.272, List.273): - let List.274 : U64 = CallByName List.6 List.272; - let List.623 : List {} = CallByName List.68 List.274; - let List.622 : List {} = CallByName List.18 List.272 List.623 List.273; - ret List.622; - -procedure List.6 (#Attr.2): - let List.636 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.636; - -procedure List.66 (#Attr.2, #Attr.3): - let List.635 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.635; - -procedure List.68 (#Attr.2): - let List.641 : List {} = lowlevel ListWithCapacity #Attr.2; +procedure List.278 (List.279, List.280, List.276): + let List.642 : {} = CallByName Test.2 List.280; + let List.641 : List {} = CallByName List.71 List.279 List.642; ret List.641; -procedure List.71 (#Attr.2, #Attr.3): - let List.640 : List {} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.640; +procedure List.5 (List.275, List.276): + let List.277 : U64 = CallByName List.6 List.275; + let List.626 : List {} = CallByName List.68 List.277; + let List.625 : List {} = CallByName List.18 List.275 List.626 List.276; + ret List.625; -procedure List.92 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.628 List.166 List.167 List.168 List.169 List.170: - let List.630 : Int1 = CallByName Num.22 List.169 List.170; - if List.630 then - let List.634 : [] = CallByName List.66 List.166 List.169; - let List.171 : List {} = CallByName List.275 List.167 List.634 List.168; - let List.633 : U64 = 1i64; - let List.632 : U64 = CallByName Num.51 List.169 List.633; - jump List.628 List.166 List.171 List.168 List.632 List.170; +procedure List.6 (#Attr.2): + let List.639 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.639; + +procedure List.66 (#Attr.2, #Attr.3): + let List.638 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.638; + +procedure List.68 (#Attr.2): + let List.644 : List {} = lowlevel ListWithCapacity #Attr.2; + ret List.644; + +procedure List.71 (#Attr.2, #Attr.3): + let List.643 : List {} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.643; + +procedure List.95 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.631 List.169 List.170 List.171 List.172 List.173: + let List.633 : Int1 = CallByName Num.22 List.172 List.173; + if List.633 then + let List.637 : [] = CallByName List.66 List.169 List.172; + let List.174 : List {} = CallByName List.278 List.170 List.637 List.171; + let List.636 : U64 = 1i64; + let List.635 : U64 = CallByName Num.51 List.172 List.636; + jump List.631 List.169 List.174 List.171 List.635 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.3; - jump List.628 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + inc #Derived_gen.0; + jump List.631 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; procedure Test.2 (Test.3): let Test.7 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt index 010431ffda..a174241d8c 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt @@ -1,59 +1,59 @@ -procedure List.18 (List.163, List.164, List.165): - let List.626 : U64 = 0i64; - let List.627 : U64 = CallByName List.6 List.163; - let List.625 : List [] = CallByName List.92 List.163 List.164 List.165 List.626 List.627; - ret List.625; +procedure List.18 (List.166, List.167, List.168): + let List.629 : U64 = 0i64; + let List.630 : U64 = CallByName List.6 List.166; + let List.628 : List [] = CallByName List.95 List.166 List.167 List.168 List.629 List.630; + ret List.628; -procedure List.275 (List.276, List.277, List.273): - let List.639 : [] = CallByName Test.2 List.277; - let List.638 : List [] = CallByName List.71 List.276 List.639; - ret List.638; - -procedure List.5 (List.272, List.273): - let List.274 : U64 = CallByName List.6 List.272; - let List.623 : List [] = CallByName List.68 List.274; - let List.622 : List [] = CallByName List.18 List.272 List.623 List.273; - ret List.622; - -procedure List.6 (#Attr.2): - let List.636 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.636; - -procedure List.66 (#Attr.2, #Attr.3): - let List.635 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.635; - -procedure List.68 (#Attr.2): - let List.641 : List [] = lowlevel ListWithCapacity #Attr.2; +procedure List.278 (List.279, List.280, List.276): + let List.642 : [] = CallByName Test.2 List.280; + let List.641 : List [] = CallByName List.71 List.279 List.642; ret List.641; -procedure List.71 (#Attr.2, #Attr.3): - let List.640 : List [] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.640; +procedure List.5 (List.275, List.276): + let List.277 : U64 = CallByName List.6 List.275; + let List.626 : List [] = CallByName List.68 List.277; + let List.625 : List [] = CallByName List.18 List.275 List.626 List.276; + ret List.625; -procedure List.92 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.628 List.166 List.167 List.168 List.169 List.170: - let List.630 : Int1 = CallByName Num.22 List.169 List.170; - if List.630 then - let List.634 : [] = CallByName List.66 List.166 List.169; - let List.171 : List [] = CallByName List.275 List.167 List.634 List.168; - let List.633 : U64 = 1i64; - let List.632 : U64 = CallByName Num.51 List.169 List.633; - jump List.628 List.166 List.171 List.168 List.632 List.170; +procedure List.6 (#Attr.2): + let List.639 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.639; + +procedure List.66 (#Attr.2, #Attr.3): + let List.638 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.638; + +procedure List.68 (#Attr.2): + let List.644 : List [] = lowlevel ListWithCapacity #Attr.2; + ret List.644; + +procedure List.71 (#Attr.2, #Attr.3): + let List.643 : List [] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.643; + +procedure List.95 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.631 List.169 List.170 List.171 List.172 List.173: + let List.633 : Int1 = CallByName Num.22 List.172 List.173; + if List.633 then + let List.637 : [] = CallByName List.66 List.169 List.172; + let List.174 : List [] = CallByName List.278 List.170 List.637 List.171; + let List.636 : U64 = 1i64; + let List.635 : U64 = CallByName Num.51 List.172 List.636; + jump List.631 List.169 List.174 List.171 List.635 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.3; - jump List.628 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + inc #Derived_gen.0; + jump List.631 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; procedure Test.2 (Test.3): let Test.7 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/capture_void_layout_task.txt b/crates/compiler/test_mono/generated/capture_void_layout_task.txt index 8186f9f09c..611c5663b3 100644 --- a/crates/compiler/test_mono/generated/capture_void_layout_task.txt +++ b/crates/compiler/test_mono/generated/capture_void_layout_task.txt @@ -1,40 +1,40 @@ -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : [C {}, C *self {{}, []}] = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : [C {}, C *self {{}, []}] = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; procedure List.6 (#Attr.2): - let List.633 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.633; + let List.636 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.636; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; -procedure List.92 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : [] = CallByName List.66 List.166 List.169; - let List.171 : [C {}, C *self {{}, []}] = CallByName Test.29 List.167 List.631 List.168; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : [] = CallByName List.66 List.169 List.172; + let List.174 : [C {}, C *self {{}, []}] = CallByName Test.29 List.170 List.634 List.171; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.11; - jump List.625 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; + inc #Derived_gen.13; + jump List.628 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; procedure Test.10 (Test.69, #Attr.12): let Test.72 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12; diff --git a/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt b/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt index 9767918687..6f4be4a2c5 100644 --- a/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt +++ b/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt @@ -2,112 +2,112 @@ procedure Bool.1 (): let Bool.24 : Int1 = false; ret Bool.24; -procedure List.18 (List.163, List.164, List.165): - let List.642 : U64 = 0i64; - let List.643 : U64 = CallByName List.6 List.163; - let List.641 : List Str = CallByName List.92 List.163 List.164 List.165 List.642 List.643; - ret List.641; +procedure List.18 (List.166, List.167, List.168): + let List.645 : U64 = 0i64; + let List.646 : U64 = CallByName List.6 List.166; + let List.644 : List Str = CallByName List.95 List.166 List.167 List.168 List.645 List.646; + ret List.644; -procedure List.2 (List.111, List.112): - let List.636 : U64 = CallByName List.6 List.111; - let List.632 : Int1 = CallByName Num.22 List.112 List.636; - if List.632 then - let List.634 : Str = CallByName List.66 List.111 List.112; - inc List.634; - let List.633 : [C {}, C Str] = TagId(1) List.634; - ret List.633; +procedure List.2 (List.114, List.115): + let List.639 : U64 = CallByName List.6 List.114; + let List.635 : Int1 = CallByName Num.22 List.115 List.639; + if List.635 then + let List.637 : Str = CallByName List.66 List.114 List.115; + inc List.637; + let List.636 : [C {}, C Str] = TagId(1) List.637; + ret List.636; else - let List.631 : {} = Struct {}; - let List.630 : [C {}, C Str] = TagId(0) List.631; - ret List.630; + let List.634 : {} = Struct {}; + let List.633 : [C {}, C Str] = TagId(0) List.634; + ret List.633; -procedure List.275 (List.276, List.277, List.273): - let List.655 : Str = CallByName Test.10 List.277; - let List.654 : List Str = CallByName List.71 List.276 List.655; - ret List.654; - -procedure List.5 (List.272, List.273): - let List.274 : U64 = CallByName List.6 List.272; - let List.639 : List Str = CallByName List.68 List.274; - let List.638 : List Str = CallByName List.18 List.272 List.639 List.273; - ret List.638; - -procedure List.6 (#Attr.2): - let List.637 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.637; - -procedure List.6 (#Attr.2): - let List.652 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.652; - -procedure List.66 (#Attr.2, #Attr.3): - let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.635; - -procedure List.66 (#Attr.2, #Attr.3): - let List.651 : [C List [C List *self, C *self], C [C List *self, C *self]] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.651; - -procedure List.68 (#Attr.2): - let List.657 : List Str = lowlevel ListWithCapacity #Attr.2; +procedure List.278 (List.279, List.280, List.276): + let List.658 : Str = CallByName Test.10 List.280; + let List.657 : List Str = CallByName List.71 List.279 List.658; ret List.657; +procedure List.5 (List.275, List.276): + let List.277 : U64 = CallByName List.6 List.275; + let List.642 : List Str = CallByName List.68 List.277; + let List.641 : List Str = CallByName List.18 List.275 List.642 List.276; + ret List.641; + +procedure List.6 (#Attr.2): + let List.640 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.640; + +procedure List.6 (#Attr.2): + let List.655 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.655; + +procedure List.66 (#Attr.2, #Attr.3): + let List.638 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.638; + +procedure List.66 (#Attr.2, #Attr.3): + let List.654 : [C List [C List *self, C *self], C [C List *self, C *self]] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.654; + +procedure List.68 (#Attr.2): + let List.660 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.660; + procedure List.71 (#Attr.2, #Attr.3): - let List.656 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.656; + let List.659 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.659; -procedure List.9 (List.383): - let List.629 : U64 = 0i64; - let List.622 : [C {}, C Str] = CallByName List.2 List.383 List.629; - let List.626 : U8 = 1i64; - let List.627 : U8 = GetTagId List.622; - let List.628 : Int1 = lowlevel Eq List.626 List.627; - if List.628 then - let List.384 : Str = UnionAtIndex (Id 1) (Index 0) List.622; - let List.623 : [C {}, C Str] = TagId(1) List.384; - ret List.623; +procedure List.9 (List.386): + let List.632 : U64 = 0i64; + let List.625 : [C {}, C Str] = CallByName List.2 List.386 List.632; + let List.629 : U8 = 1i64; + let List.630 : U8 = GetTagId List.625; + let List.631 : Int1 = lowlevel Eq List.629 List.630; + if List.631 then + let List.387 : Str = UnionAtIndex (Id 1) (Index 0) List.625; + let List.626 : [C {}, C Str] = TagId(1) List.387; + ret List.626; else - dec List.622; - let List.625 : {} = Struct {}; - let List.624 : [C {}, C Str] = TagId(0) List.625; - ret List.624; + dec List.625; + let List.628 : {} = Struct {}; + let List.627 : [C {}, C Str] = TagId(0) List.628; + ret List.627; -procedure List.92 (#Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8): - joinpoint List.644 List.166 List.167 List.168 List.169 List.170: - let List.646 : Int1 = CallByName Num.22 List.169 List.170; - if List.646 then - let List.650 : [C List [C List *self, C *self], C [C List *self, C *self]] = CallByName List.66 List.166 List.169; - inc List.650; - let List.171 : List Str = CallByName List.275 List.167 List.650 List.168; - let List.649 : U64 = 1i64; - let List.648 : U64 = CallByName Num.51 List.169 List.649; - jump List.644 List.166 List.171 List.168 List.648 List.170; +procedure List.95 (#Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8): + joinpoint List.647 List.169 List.170 List.171 List.172 List.173: + let List.649 : Int1 = CallByName Num.22 List.172 List.173; + if List.649 then + let List.653 : [C List [C List *self, C *self], C [C List *self, C *self]] = CallByName List.66 List.169 List.172; + inc List.653; + let List.174 : List Str = CallByName List.278 List.170 List.653 List.171; + let List.652 : U64 = 1i64; + let List.651 : U64 = CallByName Num.51 List.172 List.652; + jump List.647 List.169 List.174 List.171 List.651 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in inc #Derived_gen.4; - jump List.644 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8; + jump List.647 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; -procedure Result.5 (Result.10, Result.11): - let Result.37 : U8 = 1i64; - let Result.38 : U8 = GetTagId Result.10; - let Result.39 : Int1 = lowlevel Eq Result.37 Result.38; - if Result.39 then - dec Result.11; - let Result.12 : Str = UnionAtIndex (Id 1) (Index 0) Result.10; - ret Result.12; +procedure Result.5 (Result.13, Result.14): + let Result.57 : U8 = 1i64; + let Result.58 : U8 = GetTagId Result.13; + let Result.59 : Int1 = lowlevel Eq Result.57 Result.58; + if Result.59 then + dec Result.14; + let Result.15 : Str = UnionAtIndex (Id 1) (Index 0) Result.13; + ret Result.15; else - dec Result.10; - ret Result.11; + dec Result.13; + ret Result.14; procedure Test.10 (Test.11): let Test.12 : Str = CallByName Test.2 Test.11; diff --git a/crates/compiler/test_mono/generated/choose_i128_layout.txt b/crates/compiler/test_mono/generated/choose_i128_layout.txt index e6047f606b..1fb244b30f 100644 --- a/crates/compiler/test_mono/generated/choose_i128_layout.txt +++ b/crates/compiler/test_mono/generated/choose_i128_layout.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.280 : I128 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : I128 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.282; procedure Test.0 (): let Test.6 : I128 = 18446744073709551616i64; diff --git a/crates/compiler/test_mono/generated/choose_u128_layout.txt b/crates/compiler/test_mono/generated/choose_u128_layout.txt index 4a8c66ef99..d9d8b8b842 100644 --- a/crates/compiler/test_mono/generated/choose_u128_layout.txt +++ b/crates/compiler/test_mono/generated/choose_u128_layout.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : U128 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U128 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.2 : U128 = 170141183460469231731687303715884105728u128; diff --git a/crates/compiler/test_mono/generated/choose_u64_layout.txt b/crates/compiler/test_mono/generated/choose_u64_layout.txt index d532d66232..2c0493ca01 100644 --- a/crates/compiler/test_mono/generated/choose_u64_layout.txt +++ b/crates/compiler/test_mono/generated/choose_u64_layout.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.2 : U64 = 9999999999999999999i64; diff --git a/crates/compiler/test_mono/generated/closure_in_list.txt b/crates/compiler/test_mono/generated/closure_in_list.txt index 04ee9ad399..600b345fa3 100644 --- a/crates/compiler/test_mono/generated/closure_in_list.txt +++ b/crates/compiler/test_mono/generated/closure_in_list.txt @@ -1,6 +1,6 @@ procedure List.6 (#Attr.2): - let List.622 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.622; + let List.625 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.625; procedure Test.1 (Test.5): let Test.2 : I64 = 41i64; diff --git a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt index d8085bef89..f1596bff44 100644 --- a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt +++ b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt @@ -2,47 +2,47 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : [, C *self Int1, C *self Int1] = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : [, C *self Int1, C *self Int1] = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; procedure List.6 (#Attr.2): - let List.633 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.633; + let List.636 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.636; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; -procedure List.92 (#Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : Int1 = CallByName List.66 List.166 List.169; - let List.171 : [, C *self Int1, C *self Int1] = CallByName Test.6 List.167 List.631 List.168; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : Int1 = CallByName List.66 List.169 List.172; + let List.174 : [, C *self Int1, C *self Int1] = CallByName Test.6 List.170 List.634 List.171; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in inc #Derived_gen.5; - jump List.625 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9; + jump List.628 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; procedure Str.3 (#Attr.2, #Attr.3): - let Str.234 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.234; + let Str.238 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.238; procedure Test.1 (Test.5): ret Test.5; diff --git a/crates/compiler/test_mono/generated/dbg_in_expect.txt b/crates/compiler/test_mono/generated/dbg_in_expect.txt index a8faeb7c33..33e1b5189c 100644 --- a/crates/compiler/test_mono/generated/dbg_in_expect.txt +++ b/crates/compiler/test_mono/generated/dbg_in_expect.txt @@ -2,50 +2,50 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure Inspect.246 (Inspect.247, Inspect.245): +procedure Inspect.250 (Inspect.251, Inspect.249): + let Inspect.323 : Str = "\""; + let Inspect.322 : Str = CallByName Inspect.63 Inspect.251 Inspect.323; + dec Inspect.323; + let Inspect.318 : Str = CallByName Inspect.63 Inspect.322 Inspect.249; let Inspect.319 : Str = "\""; - let Inspect.318 : Str = CallByName Inspect.59 Inspect.247 Inspect.319; + let Inspect.317 : Str = CallByName Inspect.63 Inspect.318 Inspect.319; dec Inspect.319; - let Inspect.314 : Str = CallByName Inspect.59 Inspect.318 Inspect.245; - let Inspect.315 : Str = "\""; - let Inspect.313 : Str = CallByName Inspect.59 Inspect.314 Inspect.315; - dec Inspect.315; - ret Inspect.313; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; - -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; - ret Inspect.307; - -procedure Inspect.43 (Inspect.245): - let Inspect.309 : Str = CallByName Inspect.30 Inspect.245; - ret Inspect.309; - -procedure Inspect.5 (Inspect.146): - let Inspect.308 : Str = CallByName Inspect.43 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName Inspect.246 Inspect.304 Inspect.308; - dec Inspect.308; - ret Inspect.303; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.317 : Str = CallByName Str.3 Inspect.296 Inspect.292; ret Inspect.317; -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; + +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.47 (Inspect.249): + let Inspect.313 : Str = CallByName Inspect.30 Inspect.249; + ret Inspect.313; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : Str = CallByName Inspect.47 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName Inspect.250 Inspect.308 Inspect.312; + dec Inspect.312; + ret Inspect.307; + +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.321 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.321; + +procedure Inspect.64 (Inspect.302): + ret Inspect.302; procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.1 (): let Test.4 : Str = ""; diff --git a/crates/compiler/test_mono/generated/dbg_str_followed_by_number.txt b/crates/compiler/test_mono/generated/dbg_str_followed_by_number.txt index e07bb8179e..93657ac458 100644 --- a/crates/compiler/test_mono/generated/dbg_str_followed_by_number.txt +++ b/crates/compiler/test_mono/generated/dbg_str_followed_by_number.txt @@ -1,47 +1,47 @@ -procedure Inspect.246 (Inspect.247, Inspect.245): +procedure Inspect.250 (Inspect.251, Inspect.249): + let Inspect.323 : Str = "\""; + let Inspect.322 : Str = CallByName Inspect.63 Inspect.251 Inspect.323; + dec Inspect.323; + let Inspect.318 : Str = CallByName Inspect.63 Inspect.322 Inspect.249; let Inspect.319 : Str = "\""; - let Inspect.318 : Str = CallByName Inspect.59 Inspect.247 Inspect.319; + let Inspect.317 : Str = CallByName Inspect.63 Inspect.318 Inspect.319; dec Inspect.319; - let Inspect.314 : Str = CallByName Inspect.59 Inspect.318 Inspect.245; - let Inspect.315 : Str = "\""; - let Inspect.313 : Str = CallByName Inspect.59 Inspect.314 Inspect.315; - dec Inspect.315; - ret Inspect.313; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; - -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; - ret Inspect.307; - -procedure Inspect.43 (Inspect.245): - let Inspect.309 : Str = CallByName Inspect.30 Inspect.245; - ret Inspect.309; - -procedure Inspect.5 (Inspect.146): - let Inspect.308 : Str = CallByName Inspect.43 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName Inspect.246 Inspect.304 Inspect.308; - dec Inspect.308; - ret Inspect.303; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.317 : Str = CallByName Str.3 Inspect.296 Inspect.292; ret Inspect.317; -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; + +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.47 (Inspect.249): + let Inspect.313 : Str = CallByName Inspect.30 Inspect.249; + ret Inspect.313; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : Str = CallByName Inspect.47 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName Inspect.250 Inspect.308 Inspect.312; + dec Inspect.312; + ret Inspect.307; + +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.321 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.321; + +procedure Inspect.64 (Inspect.302): + ret Inspect.302; procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.0 (): let Test.3 : Str = ""; diff --git a/crates/compiler/test_mono/generated/dict.txt b/crates/compiler/test_mono/generated/dict.txt index eafc8f9356..4e06c0eeb5 100644 --- a/crates/compiler/test_mono/generated/dict.txt +++ b/crates/compiler/test_mono/generated/dict.txt @@ -1,37 +1,37 @@ -procedure Dict.1 (Dict.723): - let Dict.732 : List {U32, U32} = Array []; - let Dict.733 : List {[], []} = Array []; - let Dict.734 : U64 = 0i64; - let Dict.44 : Float32 = CallByName Dict.44; - let Dict.45 : U8 = CallByName Dict.45; - let Dict.731 : {List {U32, U32}, List {[], []}, U64, Float32, U8} = Struct {Dict.732, Dict.733, Dict.734, Dict.44, Dict.45}; - ret Dict.731; - -procedure Dict.4 (Dict.729): - let Dict.156 : List {[], []} = StructAtIndex 1 Dict.729; - let #Derived_gen.0 : List {U32, U32} = StructAtIndex 0 Dict.729; - dec #Derived_gen.0; - let Dict.730 : U64 = CallByName List.6 Dict.156; - dec Dict.156; - ret Dict.730; - -procedure Dict.44 (): - let Dict.738 : Float32 = 0.8f64; +procedure Dict.1 (Dict.730): + let Dict.739 : List {U32, U32} = Array []; + let Dict.740 : List {[], []} = Array []; + let Dict.741 : U64 = 0i64; + let Dict.51 : Float32 = CallByName Dict.51; + let Dict.52 : U8 = CallByName Dict.52; + let Dict.738 : {List {U32, U32}, List {[], []}, U64, Float32, U8} = Struct {Dict.739, Dict.740, Dict.741, Dict.51, Dict.52}; ret Dict.738; -procedure Dict.45 (): - let Dict.736 : U8 = 64i64; - let Dict.737 : U8 = 3i64; - let Dict.735 : U8 = CallByName Num.75 Dict.736 Dict.737; - ret Dict.735; +procedure Dict.4 (Dict.736): + let Dict.163 : List {[], []} = StructAtIndex 1 Dict.736; + let #Derived_gen.0 : List {U32, U32} = StructAtIndex 0 Dict.736; + dec #Derived_gen.0; + let Dict.737 : U64 = CallByName List.6 Dict.163; + dec Dict.163; + ret Dict.737; + +procedure Dict.51 (): + let Dict.745 : Float32 = 0.8f64; + ret Dict.745; + +procedure Dict.52 (): + let Dict.743 : U8 = 64i64; + let Dict.744 : U8 = 3i64; + let Dict.742 : U8 = CallByName Num.75 Dict.743 Dict.744; + ret Dict.742; procedure List.6 (#Attr.2): - let List.622 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.622; + let List.625 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.625; procedure Num.75 (#Attr.2, #Attr.3): - let Num.279 : U8 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U8 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.3 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt index dea287786d..a41d71ca8a 100644 --- a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt +++ b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt @@ -2,29 +2,29 @@ procedure Bool.1 (): let Bool.23 : Int1 = false; ret Bool.23; -procedure List.2 (List.111, List.112): - let List.628 : U64 = CallByName List.6 List.111; - let List.624 : Int1 = CallByName Num.22 List.112 List.628; - if List.624 then - let List.626 : {} = CallByName List.66 List.111 List.112; - let List.625 : [C {}, C {}] = TagId(1) List.626; - ret List.625; +procedure List.2 (List.114, List.115): + let List.631 : U64 = CallByName List.6 List.114; + let List.627 : Int1 = CallByName Num.22 List.115 List.631; + if List.627 then + let List.629 : {} = CallByName List.66 List.114 List.115; + let List.628 : [C {}, C {}] = TagId(1) List.629; + ret List.628; else - let List.623 : {} = Struct {}; - let List.622 : [C {}, C {}] = TagId(0) List.623; - ret List.622; + let List.626 : {} = Struct {}; + let List.625 : [C {}, C {}] = TagId(0) List.626; + ret List.625; procedure List.6 (#Attr.2): - let List.629 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.629; + let List.632 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.632; procedure List.66 (#Attr.2, #Attr.3): - let List.627 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.627; + let List.630 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.630; procedure Num.22 (#Attr.2, #Attr.3): - let Num.279 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.281; procedure Test.2 (Test.5): let Test.17 : Str = "bar"; diff --git a/crates/compiler/test_mono/generated/encode.txt b/crates/compiler/test_mono/generated/encode.txt index aaa6b91396..2d81463737 100644 --- a/crates/compiler/test_mono/generated/encode.txt +++ b/crates/compiler/test_mono/generated/encode.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.127, List.128): - let List.625 : U64 = 1i64; - let List.623 : List U8 = CallByName List.70 List.127 List.625; - let List.622 : List U8 = CallByName List.71 List.623 List.128; - ret List.622; +procedure List.4 (List.130, List.131): + let List.628 : U64 = 1i64; + let List.626 : List U8 = CallByName List.70 List.130 List.628; + let List.625 : List U8 = CallByName List.71 List.626 List.131; + ret List.625; procedure List.70 (#Attr.2, #Attr.3): - let List.626 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.626; + let List.629 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.629; procedure List.71 (#Attr.2, #Attr.3): - let List.624 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.624; + let List.627 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.627; procedure Test.23 (Test.24, Test.35, Test.22): let Test.37 : List U8 = CallByName List.4 Test.24 Test.22; diff --git a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt index 40113e725a..e2e8554b7e 100644 --- a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt @@ -7,7 +7,7 @@ procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1): let #Derived_gen.8 : Str = CallByName #Derived.5 #Derived.1; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8}; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6]; - let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5; + let #Derived_gen.4 : List {Str, Str} = CallByName Test.22 #Derived_gen.5; let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4; dec #Derived_gen.4; ret #Derived_gen.3; @@ -18,263 +18,263 @@ procedure #Derived.5 (#Derived.6): procedure #Derived.7 (#Derived.8, #Derived.9, #Derived.6): let #Derived_gen.17 : Str = "b"; - let #Derived_gen.18 : Str = CallByName Test.19 #Derived.6; + let #Derived_gen.18 : Str = CallByName Test.20 #Derived.6; let #Derived_gen.16 : {Str, Str} = Struct {#Derived_gen.17, #Derived_gen.18}; let #Derived_gen.15 : List {Str, Str} = Array [#Derived_gen.16]; - let #Derived_gen.14 : List {Str, Str} = CallByName Test.21 #Derived_gen.15; + let #Derived_gen.14 : List {Str, Str} = CallByName Test.22 #Derived_gen.15; let #Derived_gen.13 : List U8 = CallByName Encode.24 #Derived.8 #Derived_gen.14 #Derived.9; dec #Derived_gen.14; ret #Derived_gen.13; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.111 : List U8 = CallByName #Derived.2 Encode.99 Encode.101 Encode.107; - ret Encode.111; - -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.113 : List U8 = CallByName #Derived.2 Encode.101 Encode.103 Encode.109; ret Encode.113; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.116 : List U8 = CallByName #Derived.7 Encode.99 Encode.101 Encode.107; - ret Encode.116; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.115 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109; + ret Encode.115; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.119 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107; - ret Encode.119; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.118 : List U8 = CallByName #Derived.7 Encode.101 Encode.103 Encode.109; + ret Encode.118; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.124 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; - ret Encode.124; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.121 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109; + ret Encode.121; -procedure Encode.26 (Encode.105, Encode.106): - let Encode.109 : List U8 = Array []; - let Encode.110 : Str = CallByName #Derived.0 Encode.105; - let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; - ret Encode.108; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.126 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109; + ret Encode.126; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure Encode.26 (Encode.107, Encode.108): + let Encode.111 : List U8 = Array []; + let Encode.112 : Str = CallByName #Derived.0 Encode.107; + let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; + ret Encode.110; -procedure List.18 (List.163, List.164, List.165): - let List.649 : U64 = 0i64; - let List.650 : U64 = CallByName List.6 List.163; - let List.648 : List U8 = CallByName List.92 List.163 List.164 List.165 List.649 List.650; - ret List.648; +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; -procedure List.4 (List.127, List.128): - let List.670 : U64 = 1i64; - let List.669 : List U8 = CallByName List.70 List.127 List.670; - let List.668 : List U8 = CallByName List.71 List.669 List.128; - ret List.668; +procedure List.18 (List.166, List.167, List.168): + let List.652 : U64 = 0i64; + let List.653 : U64 = CallByName List.6 List.166; + let List.651 : List U8 = CallByName List.95 List.166 List.167 List.168 List.652 List.653; + ret List.651; + +procedure List.4 (List.130, List.131): + let List.673 : U64 = 1i64; + let List.672 : List U8 = CallByName List.70 List.130 List.673; + let List.671 : List U8 = CallByName List.71 List.672 List.131; + ret List.671; procedure List.6 (#Attr.2): - let List.647 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.647; + let List.650 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.650; procedure List.6 (#Attr.2): - let List.673 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.673; + let List.676 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.676; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; procedure List.66 (#Attr.2, #Attr.3): - let List.658 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.658; + let List.661 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.661; procedure List.70 (#Attr.2, #Attr.3): - let List.664 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.664; + let List.667 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.667; procedure List.71 (#Attr.2, #Attr.3): - let List.662 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.662; + let List.665 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.665; procedure List.8 (#Attr.2, #Attr.3): - let List.672 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.672; + let List.675 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.675; -procedure List.92 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): - joinpoint List.651 List.166 List.167 List.168 List.169 List.170: - let List.653 : Int1 = CallByName Num.22 List.169 List.170; - if List.653 then - let List.657 : {Str, Str} = CallByName List.66 List.166 List.169; - inc List.657; - let List.171 : List U8 = CallByName Test.70 List.167 List.657; - let List.656 : U64 = 1i64; - let List.655 : U64 = CallByName Num.51 List.169 List.656; - jump List.651 List.166 List.171 List.168 List.655 List.170; +procedure List.95 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : {Str, Str} = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : List U8 = CallByName Test.71 List.170 List.634; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.29; - jump List.651 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; + inc #Derived_gen.26; + jump List.628 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; -procedure List.92 (#Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40, #Derived_gen.41): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : List U8 = CallByName Test.70 List.167 List.631; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.40, #Derived_gen.41, #Derived_gen.42, #Derived_gen.43, #Derived_gen.44): + joinpoint List.654 List.169 List.170 List.171 List.172 List.173: + let List.656 : Int1 = CallByName Num.22 List.172 List.173; + if List.656 then + let List.660 : {Str, Str} = CallByName List.66 List.169 List.172; + inc List.660; + let List.174 : List U8 = CallByName Test.71 List.170 List.660; + let List.659 : U64 = 1i64; + let List.658 : U64 = CallByName Num.51 List.172 List.659; + jump List.654 List.169 List.174 List.171 List.658 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.37; - jump List.625 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41; + inc #Derived_gen.40; + jump List.654 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42 #Derived_gen.43 #Derived_gen.44; procedure Num.127 (#Attr.2): - let Num.284 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.284; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.286 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + let Num.286 : U8 = lowlevel NumIntCast #Attr.2; ret Num.286; +procedure Num.22 (#Attr.2, #Attr.3): + let Num.288 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.288; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.285 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.285; + let Num.287 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.287; procedure Num.96 (#Attr.2): - let Num.283 : Str = lowlevel NumToStr #Attr.2; - ret Num.283; + let Num.285 : Str = lowlevel NumToStr #Attr.2; + ret Num.285; procedure Str.12 (#Attr.2): - let Str.244 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.244; + let Str.248 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.248; procedure Str.36 (#Attr.2): - let Str.245 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; - ret Str.245; + let Str.249 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.249; procedure Str.43 (#Attr.2): - let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; - ret Str.239; + let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; + ret Str.243; -procedure Str.9 (Str.67): - let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; - let Str.236 : Int1 = StructAtIndex 2 Str.68; - if Str.236 then - let Str.238 : Str = StructAtIndex 1 Str.68; - let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; - ret Str.237; +procedure Str.9 (Str.71): + let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71; + let Str.240 : Int1 = StructAtIndex 2 Str.72; + if Str.240 then + let Str.242 : Str = StructAtIndex 1 Str.72; + let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242; + ret Str.241; else - let Str.234 : U8 = StructAtIndex 3 Str.68; - let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.45 : Str = StructAtIndex 1 Str.68; + let Str.238 : U8 = StructAtIndex 3 Str.72; + let Str.239 : U64 = StructAtIndex 0 Str.72; + let #Derived_gen.45 : Str = StructAtIndex 1 Str.72; dec #Derived_gen.45; - let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; - let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; - ret Str.232; + let Str.237 : {U64, U8} = Struct {Str.239, Str.238}; + let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237; + ret Str.236; -procedure Test.19 (Test.55): - let Test.324 : Str = CallByName Encode.23 Test.55; - ret Test.324; +procedure Test.20 (Test.56): + let Test.325 : Str = CallByName Encode.23 Test.56; + ret Test.325; -procedure Test.2 (): - let Test.257 : {} = Struct {}; - ret Test.257; +procedure Test.22 (Test.67): + let Test.261 : List {Str, Str} = CallByName Encode.23 Test.67; + ret Test.261; -procedure Test.21 (Test.66): - let Test.260 : List {Str, Str} = CallByName Encode.23 Test.66; - ret Test.260; +procedure Test.22 (Test.67): + let Test.293 : List {Str, Str} = CallByName Encode.23 Test.67; + ret Test.293; -procedure Test.21 (Test.66): - let Test.292 : List {Str, Str} = CallByName Encode.23 Test.66; - ret Test.292; +procedure Test.3 (): + let Test.258 : {} = Struct {}; + ret Test.258; -procedure Test.3 (Test.48, Test.49, Test.50): - let Test.321 : U8 = CallByName Num.127 Test.49; - let Test.318 : List U8 = CallByName List.4 Test.48 Test.321; - let Test.320 : Str = CallByName Num.96 Test.50; - let Test.319 : List U8 = CallByName Str.12 Test.320; - let Test.316 : List U8 = CallByName List.8 Test.318 Test.319; - let Test.317 : U8 = 32i64; - let Test.315 : List U8 = CallByName List.4 Test.316 Test.317; - ret Test.315; +procedure Test.4 (Test.49, Test.50, Test.51): + let Test.322 : U8 = CallByName Num.127 Test.50; + let Test.319 : List U8 = CallByName List.4 Test.49 Test.322; + let Test.321 : Str = CallByName Num.96 Test.51; + let Test.320 : List U8 = CallByName Str.12 Test.321; + let Test.317 : List U8 = CallByName List.8 Test.319 Test.320; + let Test.318 : U8 = 32i64; + let Test.316 : List U8 = CallByName List.4 Test.317 Test.318; + ret Test.316; -procedure Test.56 (Test.57, Test.274, Test.55): - let Test.313 : I64 = 115i64; - let Test.314 : U64 = CallByName Str.36 Test.55; - let Test.311 : List U8 = CallByName Test.3 Test.57 Test.313 Test.314; - let Test.312 : List U8 = CallByName Str.12 Test.55; - let Test.309 : List U8 = CallByName List.8 Test.311 Test.312; - let Test.310 : U8 = 32i64; - let Test.308 : List U8 = CallByName List.4 Test.309 Test.310; - ret Test.308; +procedure Test.57 (Test.58, Test.275, Test.56): + let Test.314 : I64 = 115i64; + let Test.315 : U64 = CallByName Str.36 Test.56; + let Test.312 : List U8 = CallByName Test.4 Test.58 Test.314 Test.315; + let Test.313 : List U8 = CallByName Str.12 Test.56; + let Test.310 : List U8 = CallByName List.8 Test.312 Test.313; + let Test.311 : U8 = 32i64; + let Test.309 : List U8 = CallByName List.4 Test.310 Test.311; + ret Test.309; -procedure Test.67 (Test.68, Test.262, Test.66): - let Test.290 : I64 = 114i64; - let Test.291 : U64 = CallByName List.6 Test.66; - let Test.69 : List U8 = CallByName Test.3 Test.68 Test.290 Test.291; - let Test.265 : {} = Struct {}; - let Test.264 : List U8 = CallByName List.18 Test.66 Test.69 Test.265; - ret Test.264; +procedure Test.68 (Test.69, Test.263, Test.67): + let Test.291 : I64 = 114i64; + let Test.292 : U64 = CallByName List.6 Test.67; + let Test.70 : List U8 = CallByName Test.4 Test.69 Test.291 Test.292; + let Test.266 : {} = Struct {}; + let Test.265 : List U8 = CallByName List.18 Test.67 Test.70 Test.266; + ret Test.265; -procedure Test.67 (Test.68, Test.262, Test.66): - let Test.322 : I64 = 114i64; - let Test.323 : U64 = CallByName List.6 Test.66; - let Test.69 : List U8 = CallByName Test.3 Test.68 Test.322 Test.323; - let Test.297 : {} = Struct {}; - let Test.296 : List U8 = CallByName List.18 Test.66 Test.69 Test.297; - ret Test.296; +procedure Test.68 (Test.69, Test.263, Test.67): + let Test.323 : I64 = 114i64; + let Test.324 : U64 = CallByName List.6 Test.67; + let Test.70 : List U8 = CallByName Test.4 Test.69 Test.323 Test.324; + let Test.298 : {} = Struct {}; + let Test.297 : List U8 = CallByName List.18 Test.67 Test.70 Test.298; + ret Test.297; -procedure Test.70 (Test.71, Test.266): - let Test.72 : Str = StructAtIndex 0 Test.266; - let Test.73 : Str = StructAtIndex 1 Test.266; - let Test.270 : Str = CallByName Test.19 Test.72; - let Test.271 : {} = Struct {}; - let Test.268 : List U8 = CallByName Encode.24 Test.71 Test.270 Test.271; - let Test.269 : {} = Struct {}; - let Test.267 : List U8 = CallByName Encode.24 Test.268 Test.73 Test.269; - ret Test.267; +procedure Test.71 (Test.72, Test.267): + let Test.73 : Str = StructAtIndex 0 Test.267; + let Test.74 : Str = StructAtIndex 1 Test.267; + let Test.271 : Str = CallByName Test.20 Test.73; + let Test.272 : {} = Struct {}; + let Test.269 : List U8 = CallByName Encode.24 Test.72 Test.271 Test.272; + let Test.270 : {} = Struct {}; + let Test.268 : List U8 = CallByName Encode.24 Test.269 Test.74 Test.270; + ret Test.268; -procedure Test.70 (Test.71, Test.266): - let Test.72 : Str = StructAtIndex 0 Test.266; - let Test.73 : Str = StructAtIndex 1 Test.266; - let Test.302 : Str = CallByName Test.19 Test.72; - let Test.303 : {} = Struct {}; - let Test.300 : List U8 = CallByName Encode.24 Test.71 Test.302 Test.303; - let Test.301 : {} = Struct {}; - let Test.299 : List U8 = CallByName Encode.24 Test.300 Test.73 Test.301; - ret Test.299; +procedure Test.71 (Test.72, Test.267): + let Test.73 : Str = StructAtIndex 0 Test.267; + let Test.74 : Str = StructAtIndex 1 Test.267; + let Test.303 : Str = CallByName Test.20 Test.73; + let Test.304 : {} = Struct {}; + let Test.301 : List U8 = CallByName Encode.24 Test.72 Test.303 Test.304; + let Test.302 : {} = Struct {}; + let Test.300 : List U8 = CallByName Encode.24 Test.301 Test.74 Test.302; + ret Test.300; procedure Test.0 (): - let Test.259 : Str = "bar"; - let Test.256 : {} = CallByName Test.2; - let Test.254 : List U8 = CallByName Encode.26 Test.259 Test.256; - let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; - let Test.251 : U8 = 1i64; - let Test.252 : U8 = GetTagId Test.209; - let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; - if Test.253 then - let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; - ret Test.210; + let Test.260 : Str = "bar"; + let Test.257 : {} = CallByName Test.3; + let Test.255 : List U8 = CallByName Encode.26 Test.260 Test.257; + let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255; + let Test.252 : U8 = 1i64; + let Test.253 : U8 = GetTagId Test.210; + let Test.254 : Int1 = lowlevel Eq Test.252 Test.253; + if Test.254 then + let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210; + ret Test.211; else - dec Test.209; - let Test.250 : Str = ""; - ret Test.250; + dec Test.210; + let Test.251 : Str = ""; + ret Test.251; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt index c11cadaf9e..ff7eae9106 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt @@ -4,196 +4,196 @@ procedure #Derived.0 (#Derived.1): procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1): let #Derived_gen.7 : Str = "a"; - let #Derived_gen.8 : Str = CallByName Test.19 #Derived.1; + let #Derived_gen.8 : Str = CallByName Test.20 #Derived.1; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8}; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6]; - let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5; + let #Derived_gen.4 : List {Str, Str} = CallByName Test.22 #Derived_gen.5; let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4; dec #Derived_gen.4; ret #Derived_gen.3; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.111 : List U8 = CallByName #Derived.2 Encode.99 Encode.101 Encode.107; - ret Encode.111; - -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.113 : List U8 = CallByName #Derived.2 Encode.101 Encode.103 Encode.109; ret Encode.113; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.118 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; - ret Encode.118; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.115 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109; + ret Encode.115; -procedure Encode.26 (Encode.105, Encode.106): - let Encode.109 : List U8 = Array []; - let Encode.110 : Str = CallByName #Derived.0 Encode.105; - let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; - ret Encode.108; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.120 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109; + ret Encode.120; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure Encode.26 (Encode.107, Encode.108): + let Encode.111 : List U8 = Array []; + let Encode.112 : Str = CallByName #Derived.0 Encode.107; + let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; + ret Encode.110; -procedure List.4 (List.127, List.128): - let List.644 : U64 = 1i64; - let List.643 : List U8 = CallByName List.70 List.127 List.644; - let List.642 : List U8 = CallByName List.71 List.643 List.128; - ret List.642; +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; + +procedure List.4 (List.130, List.131): + let List.647 : U64 = 1i64; + let List.646 : List U8 = CallByName List.70 List.130 List.647; + let List.645 : List U8 = CallByName List.71 List.646 List.131; + ret List.645; procedure List.6 (#Attr.2): - let List.647 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.647; + let List.650 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.650; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; procedure List.70 (#Attr.2, #Attr.3): - let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.638; + let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.641; procedure List.71 (#Attr.2, #Attr.3): - let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.636; + let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.639; procedure List.8 (#Attr.2, #Attr.3): - let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.646; + let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.649; -procedure List.92 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : List U8 = CallByName Test.70 List.167 List.631; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : {Str, Str} = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : List U8 = CallByName Test.71 List.170 List.634; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in inc #Derived_gen.13; - jump List.625 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; + jump List.628 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; procedure Num.127 (#Attr.2): - let Num.280 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.280; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + let Num.282 : U8 = lowlevel NumIntCast #Attr.2; ret Num.282; +procedure Num.22 (#Attr.2, #Attr.3): + let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.284; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; procedure Num.96 (#Attr.2): - let Num.279 : Str = lowlevel NumToStr #Attr.2; - ret Num.279; + let Num.281 : Str = lowlevel NumToStr #Attr.2; + ret Num.281; procedure Str.12 (#Attr.2): - let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.241; + let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.245; procedure Str.36 (#Attr.2): - let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; - ret Str.242; + let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.246; procedure Str.43 (#Attr.2): - let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; - ret Str.239; + let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; + ret Str.243; -procedure Str.9 (Str.67): - let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; - let Str.236 : Int1 = StructAtIndex 2 Str.68; - if Str.236 then - let Str.238 : Str = StructAtIndex 1 Str.68; - let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; - ret Str.237; +procedure Str.9 (Str.71): + let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71; + let Str.240 : Int1 = StructAtIndex 2 Str.72; + if Str.240 then + let Str.242 : Str = StructAtIndex 1 Str.72; + let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242; + ret Str.241; else - let Str.234 : U8 = StructAtIndex 3 Str.68; - let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.24 : Str = StructAtIndex 1 Str.68; + let Str.238 : U8 = StructAtIndex 3 Str.72; + let Str.239 : U64 = StructAtIndex 0 Str.72; + let #Derived_gen.24 : Str = StructAtIndex 1 Str.72; dec #Derived_gen.24; - let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; - let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; - ret Str.232; + let Str.237 : {U64, U8} = Struct {Str.239, Str.238}; + let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237; + ret Str.236; -procedure Test.19 (Test.55): - let Test.291 : Str = CallByName Encode.23 Test.55; - ret Test.291; +procedure Test.20 (Test.56): + let Test.292 : Str = CallByName Encode.23 Test.56; + ret Test.292; -procedure Test.2 (): - let Test.257 : {} = Struct {}; - ret Test.257; +procedure Test.22 (Test.67): + let Test.260 : List {Str, Str} = CallByName Encode.23 Test.67; + ret Test.260; -procedure Test.21 (Test.66): - let Test.259 : List {Str, Str} = CallByName Encode.23 Test.66; - ret Test.259; +procedure Test.3 (): + let Test.258 : {} = Struct {}; + ret Test.258; -procedure Test.3 (Test.48, Test.49, Test.50): - let Test.288 : U8 = CallByName Num.127 Test.49; - let Test.285 : List U8 = CallByName List.4 Test.48 Test.288; - let Test.287 : Str = CallByName Num.96 Test.50; - let Test.286 : List U8 = CallByName Str.12 Test.287; - let Test.283 : List U8 = CallByName List.8 Test.285 Test.286; - let Test.284 : U8 = 32i64; - let Test.282 : List U8 = CallByName List.4 Test.283 Test.284; - ret Test.282; +procedure Test.4 (Test.49, Test.50, Test.51): + let Test.289 : U8 = CallByName Num.127 Test.50; + let Test.286 : List U8 = CallByName List.4 Test.49 Test.289; + let Test.288 : Str = CallByName Num.96 Test.51; + let Test.287 : List U8 = CallByName Str.12 Test.288; + let Test.284 : List U8 = CallByName List.8 Test.286 Test.287; + let Test.285 : U8 = 32i64; + let Test.283 : List U8 = CallByName List.4 Test.284 Test.285; + ret Test.283; -procedure Test.56 (Test.57, Test.273, Test.55): - let Test.280 : I64 = 115i64; - let Test.281 : U64 = CallByName Str.36 Test.55; - let Test.278 : List U8 = CallByName Test.3 Test.57 Test.280 Test.281; - let Test.279 : List U8 = CallByName Str.12 Test.55; - let Test.276 : List U8 = CallByName List.8 Test.278 Test.279; - let Test.277 : U8 = 32i64; - let Test.275 : List U8 = CallByName List.4 Test.276 Test.277; - ret Test.275; +procedure Test.57 (Test.58, Test.274, Test.56): + let Test.281 : I64 = 115i64; + let Test.282 : U64 = CallByName Str.36 Test.56; + let Test.279 : List U8 = CallByName Test.4 Test.58 Test.281 Test.282; + let Test.280 : List U8 = CallByName Str.12 Test.56; + let Test.277 : List U8 = CallByName List.8 Test.279 Test.280; + let Test.278 : U8 = 32i64; + let Test.276 : List U8 = CallByName List.4 Test.277 Test.278; + ret Test.276; -procedure Test.67 (Test.68, Test.261, Test.66): - let Test.289 : I64 = 114i64; - let Test.290 : U64 = CallByName List.6 Test.66; - let Test.69 : List U8 = CallByName Test.3 Test.68 Test.289 Test.290; - let Test.264 : {} = Struct {}; - let Test.263 : List U8 = CallByName List.18 Test.66 Test.69 Test.264; - ret Test.263; +procedure Test.68 (Test.69, Test.262, Test.67): + let Test.290 : I64 = 114i64; + let Test.291 : U64 = CallByName List.6 Test.67; + let Test.70 : List U8 = CallByName Test.4 Test.69 Test.290 Test.291; + let Test.265 : {} = Struct {}; + let Test.264 : List U8 = CallByName List.18 Test.67 Test.70 Test.265; + ret Test.264; -procedure Test.70 (Test.71, Test.265): - let Test.72 : Str = StructAtIndex 0 Test.265; - let Test.73 : Str = StructAtIndex 1 Test.265; - let Test.269 : Str = CallByName Test.19 Test.72; - let Test.270 : {} = Struct {}; - let Test.267 : List U8 = CallByName Encode.24 Test.71 Test.269 Test.270; - let Test.268 : {} = Struct {}; - let Test.266 : List U8 = CallByName Encode.24 Test.267 Test.73 Test.268; - ret Test.266; +procedure Test.71 (Test.72, Test.266): + let Test.73 : Str = StructAtIndex 0 Test.266; + let Test.74 : Str = StructAtIndex 1 Test.266; + let Test.270 : Str = CallByName Test.20 Test.73; + let Test.271 : {} = Struct {}; + let Test.268 : List U8 = CallByName Encode.24 Test.72 Test.270 Test.271; + let Test.269 : {} = Struct {}; + let Test.267 : List U8 = CallByName Encode.24 Test.268 Test.74 Test.269; + ret Test.267; procedure Test.0 (): - let Test.258 : Str = "foo"; - let Test.256 : {} = CallByName Test.2; - let Test.254 : List U8 = CallByName Encode.26 Test.258 Test.256; - let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; - let Test.251 : U8 = 1i64; - let Test.252 : U8 = GetTagId Test.209; - let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; - if Test.253 then - let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; - ret Test.210; + let Test.259 : Str = "foo"; + let Test.257 : {} = CallByName Test.3; + let Test.255 : List U8 = CallByName Encode.26 Test.259 Test.257; + let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255; + let Test.252 : U8 = 1i64; + let Test.253 : U8 = GetTagId Test.210; + let Test.254 : Int1 = lowlevel Eq Test.252 Test.253; + if Test.254 then + let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210; + ret Test.211; else - dec Test.209; - let Test.250 : Str = ""; - ret Test.250; + dec Test.210; + let Test.251 : Str = ""; + ret Test.251; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt index 41c2423d4c..1f00b25925 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt @@ -6,203 +6,203 @@ procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1): let #Derived_gen.11 : Str = "a"; let #Derived_gen.13 : Str = StructAtIndex 0 #Derived.1; inc #Derived_gen.13; - let #Derived_gen.12 : Str = CallByName Test.19 #Derived_gen.13; + let #Derived_gen.12 : Str = CallByName Test.20 #Derived_gen.13; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.11, #Derived_gen.12}; let #Derived_gen.8 : Str = "b"; let #Derived_gen.10 : Str = StructAtIndex 1 #Derived.1; dec #Derived_gen.13; - let #Derived_gen.9 : Str = CallByName Test.19 #Derived_gen.10; + let #Derived_gen.9 : Str = CallByName Test.20 #Derived_gen.10; let #Derived_gen.7 : {Str, Str} = Struct {#Derived_gen.8, #Derived_gen.9}; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6, #Derived_gen.7]; - let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5; + let #Derived_gen.4 : List {Str, Str} = CallByName Test.22 #Derived_gen.5; let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4; dec #Derived_gen.4; ret #Derived_gen.3; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.111 : List U8 = CallByName #Derived.2 Encode.99 Encode.101 Encode.107; - ret Encode.111; - -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.113 : List U8 = CallByName #Derived.2 Encode.101 Encode.103 Encode.109; ret Encode.113; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.119 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; - ret Encode.119; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.115 : List U8 = CallByName Test.68 Encode.101 Encode.103 Encode.109; + ret Encode.115; -procedure Encode.26 (Encode.105, Encode.106): - let Encode.109 : List U8 = Array []; - let Encode.110 : {Str, Str} = CallByName #Derived.0 Encode.105; - let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; - ret Encode.108; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.121 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109; + ret Encode.121; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure Encode.26 (Encode.107, Encode.108): + let Encode.111 : List U8 = Array []; + let Encode.112 : {Str, Str} = CallByName #Derived.0 Encode.107; + let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; + ret Encode.110; -procedure List.4 (List.127, List.128): - let List.644 : U64 = 1i64; - let List.643 : List U8 = CallByName List.70 List.127 List.644; - let List.642 : List U8 = CallByName List.71 List.643 List.128; - ret List.642; +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; + +procedure List.4 (List.130, List.131): + let List.647 : U64 = 1i64; + let List.646 : List U8 = CallByName List.70 List.130 List.647; + let List.645 : List U8 = CallByName List.71 List.646 List.131; + ret List.645; procedure List.6 (#Attr.2): - let List.647 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.647; + let List.650 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.650; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; procedure List.70 (#Attr.2, #Attr.3): - let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.638; + let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.641; procedure List.71 (#Attr.2, #Attr.3): - let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.636; + let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.639; procedure List.8 (#Attr.2, #Attr.3): - let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.646; + let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.649; -procedure List.92 (#Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : List U8 = CallByName Test.70 List.167 List.631; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : {Str, Str} = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : List U8 = CallByName Test.71 List.170 List.634; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in inc #Derived_gen.17; - jump List.625 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21; + jump List.628 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21; procedure Num.127 (#Attr.2): - let Num.280 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.280; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + let Num.282 : U8 = lowlevel NumIntCast #Attr.2; ret Num.282; +procedure Num.22 (#Attr.2, #Attr.3): + let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.284; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; procedure Num.96 (#Attr.2): - let Num.279 : Str = lowlevel NumToStr #Attr.2; - ret Num.279; + let Num.281 : Str = lowlevel NumToStr #Attr.2; + ret Num.281; procedure Str.12 (#Attr.2): - let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.241; + let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.245; procedure Str.36 (#Attr.2): - let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; - ret Str.242; + let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.246; procedure Str.43 (#Attr.2): - let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; - ret Str.239; + let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; + ret Str.243; -procedure Str.9 (Str.67): - let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; - let Str.236 : Int1 = StructAtIndex 2 Str.68; - if Str.236 then - let Str.238 : Str = StructAtIndex 1 Str.68; - let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; - ret Str.237; +procedure Str.9 (Str.71): + let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71; + let Str.240 : Int1 = StructAtIndex 2 Str.72; + if Str.240 then + let Str.242 : Str = StructAtIndex 1 Str.72; + let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242; + ret Str.241; else - let Str.234 : U8 = StructAtIndex 3 Str.68; - let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.28 : Str = StructAtIndex 1 Str.68; + let Str.238 : U8 = StructAtIndex 3 Str.72; + let Str.239 : U64 = StructAtIndex 0 Str.72; + let #Derived_gen.28 : Str = StructAtIndex 1 Str.72; dec #Derived_gen.28; - let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; - let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; - ret Str.232; + let Str.237 : {U64, U8} = Struct {Str.239, Str.238}; + let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237; + ret Str.236; -procedure Test.19 (Test.55): - let Test.295 : Str = CallByName Encode.23 Test.55; - ret Test.295; +procedure Test.20 (Test.56): + let Test.296 : Str = CallByName Encode.23 Test.56; + ret Test.296; -procedure Test.2 (): - let Test.257 : {} = Struct {}; - ret Test.257; +procedure Test.22 (Test.67): + let Test.261 : List {Str, Str} = CallByName Encode.23 Test.67; + ret Test.261; -procedure Test.21 (Test.66): - let Test.260 : List {Str, Str} = CallByName Encode.23 Test.66; - ret Test.260; +procedure Test.3 (): + let Test.258 : {} = Struct {}; + ret Test.258; -procedure Test.3 (Test.48, Test.49, Test.50): - let Test.289 : U8 = CallByName Num.127 Test.49; - let Test.286 : List U8 = CallByName List.4 Test.48 Test.289; - let Test.288 : Str = CallByName Num.96 Test.50; - let Test.287 : List U8 = CallByName Str.12 Test.288; - let Test.284 : List U8 = CallByName List.8 Test.286 Test.287; - let Test.285 : U8 = 32i64; - let Test.283 : List U8 = CallByName List.4 Test.284 Test.285; - ret Test.283; +procedure Test.4 (Test.49, Test.50, Test.51): + let Test.290 : U8 = CallByName Num.127 Test.50; + let Test.287 : List U8 = CallByName List.4 Test.49 Test.290; + let Test.289 : Str = CallByName Num.96 Test.51; + let Test.288 : List U8 = CallByName Str.12 Test.289; + let Test.285 : List U8 = CallByName List.8 Test.287 Test.288; + let Test.286 : U8 = 32i64; + let Test.284 : List U8 = CallByName List.4 Test.285 Test.286; + ret Test.284; -procedure Test.56 (Test.57, Test.274, Test.55): - let Test.281 : I64 = 115i64; - let Test.282 : U64 = CallByName Str.36 Test.55; - let Test.279 : List U8 = CallByName Test.3 Test.57 Test.281 Test.282; - let Test.280 : List U8 = CallByName Str.12 Test.55; - let Test.277 : List U8 = CallByName List.8 Test.279 Test.280; - let Test.278 : U8 = 32i64; - let Test.276 : List U8 = CallByName List.4 Test.277 Test.278; - ret Test.276; +procedure Test.57 (Test.58, Test.275, Test.56): + let Test.282 : I64 = 115i64; + let Test.283 : U64 = CallByName Str.36 Test.56; + let Test.280 : List U8 = CallByName Test.4 Test.58 Test.282 Test.283; + let Test.281 : List U8 = CallByName Str.12 Test.56; + let Test.278 : List U8 = CallByName List.8 Test.280 Test.281; + let Test.279 : U8 = 32i64; + let Test.277 : List U8 = CallByName List.4 Test.278 Test.279; + ret Test.277; -procedure Test.67 (Test.68, Test.262, Test.66): - let Test.290 : I64 = 114i64; - let Test.291 : U64 = CallByName List.6 Test.66; - let Test.69 : List U8 = CallByName Test.3 Test.68 Test.290 Test.291; - let Test.265 : {} = Struct {}; - let Test.264 : List U8 = CallByName List.18 Test.66 Test.69 Test.265; - ret Test.264; +procedure Test.68 (Test.69, Test.263, Test.67): + let Test.291 : I64 = 114i64; + let Test.292 : U64 = CallByName List.6 Test.67; + let Test.70 : List U8 = CallByName Test.4 Test.69 Test.291 Test.292; + let Test.266 : {} = Struct {}; + let Test.265 : List U8 = CallByName List.18 Test.67 Test.70 Test.266; + ret Test.265; -procedure Test.70 (Test.71, Test.266): - let Test.72 : Str = StructAtIndex 0 Test.266; - let Test.73 : Str = StructAtIndex 1 Test.266; - let Test.270 : Str = CallByName Test.19 Test.72; - let Test.271 : {} = Struct {}; - let Test.268 : List U8 = CallByName Encode.24 Test.71 Test.270 Test.271; - let Test.269 : {} = Struct {}; - let Test.267 : List U8 = CallByName Encode.24 Test.268 Test.73 Test.269; - ret Test.267; +procedure Test.71 (Test.72, Test.267): + let Test.73 : Str = StructAtIndex 0 Test.267; + let Test.74 : Str = StructAtIndex 1 Test.267; + let Test.271 : Str = CallByName Test.20 Test.73; + let Test.272 : {} = Struct {}; + let Test.269 : List U8 = CallByName Encode.24 Test.72 Test.271 Test.272; + let Test.270 : {} = Struct {}; + let Test.268 : List U8 = CallByName Encode.24 Test.269 Test.74 Test.270; + ret Test.268; procedure Test.0 (): - let Test.258 : Str = "foo"; - let Test.259 : Str = "bar"; - let Test.255 : {Str, Str} = Struct {Test.258, Test.259}; - let Test.256 : {} = CallByName Test.2; - let Test.254 : List U8 = CallByName Encode.26 Test.255 Test.256; - let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; - let Test.251 : U8 = 1i64; - let Test.252 : U8 = GetTagId Test.209; - let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; - if Test.253 then - let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; - ret Test.210; + let Test.259 : Str = "foo"; + let Test.260 : Str = "bar"; + let Test.256 : {Str, Str} = Struct {Test.259, Test.260}; + let Test.257 : {} = CallByName Test.3; + let Test.255 : List U8 = CallByName Encode.26 Test.256 Test.257; + let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255; + let Test.252 : U8 = 1i64; + let Test.253 : U8 = GetTagId Test.210; + let Test.254 : Int1 = lowlevel Eq Test.252 Test.253; + if Test.254 then + let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210; + ret Test.211; else - dec Test.209; - let Test.250 : Str = ""; - ret Test.250; + dec Test.210; + let Test.251 : Str = ""; + ret Test.251; diff --git a/crates/compiler/test_mono/generated/encode_derived_string.txt b/crates/compiler/test_mono/generated/encode_derived_string.txt index d89f5bea05..af88cb6488 100644 --- a/crates/compiler/test_mono/generated/encode_derived_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_string.txt @@ -1,110 +1,110 @@ -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.111 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; - ret Encode.111; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.113 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109; + ret Encode.113; -procedure Encode.26 (Encode.105, Encode.106): - let Encode.109 : List U8 = Array []; - let Encode.110 : Str = CallByName Test.19 Encode.105; - let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; - ret Encode.108; +procedure Encode.26 (Encode.107, Encode.108): + let Encode.111 : List U8 = Array []; + let Encode.112 : Str = CallByName Test.20 Encode.107; + let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; + ret Encode.110; -procedure List.4 (List.127, List.128): - let List.632 : U64 = 1i64; - let List.631 : List U8 = CallByName List.70 List.127 List.632; - let List.630 : List U8 = CallByName List.71 List.631 List.128; - ret List.630; +procedure List.4 (List.130, List.131): + let List.635 : U64 = 1i64; + let List.634 : List U8 = CallByName List.70 List.130 List.635; + let List.633 : List U8 = CallByName List.71 List.634 List.131; + ret List.633; procedure List.70 (#Attr.2, #Attr.3): - let List.626 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.626; + let List.629 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.629; procedure List.71 (#Attr.2, #Attr.3): - let List.624 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.624; + let List.627 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.627; procedure List.8 (#Attr.2, #Attr.3): - let List.634 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.634; + let List.637 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.637; procedure Num.127 (#Attr.2): - let Num.280 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.280; + let Num.282 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.282; procedure Num.96 (#Attr.2): - let Num.279 : Str = lowlevel NumToStr #Attr.2; - ret Num.279; + let Num.281 : Str = lowlevel NumToStr #Attr.2; + ret Num.281; procedure Str.12 (#Attr.2): - let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.241; + let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.245; procedure Str.36 (#Attr.2): - let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; - ret Str.242; + let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.246; procedure Str.43 (#Attr.2): - let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; - ret Str.239; + let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; + ret Str.243; -procedure Str.9 (Str.67): - let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; - let Str.236 : Int1 = StructAtIndex 2 Str.68; - if Str.236 then - let Str.238 : Str = StructAtIndex 1 Str.68; - let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; - ret Str.237; +procedure Str.9 (Str.71): + let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71; + let Str.240 : Int1 = StructAtIndex 2 Str.72; + if Str.240 then + let Str.242 : Str = StructAtIndex 1 Str.72; + let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242; + ret Str.241; else - let Str.234 : U8 = StructAtIndex 3 Str.68; - let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.3 : Str = StructAtIndex 1 Str.68; + let Str.238 : U8 = StructAtIndex 3 Str.72; + let Str.239 : U64 = StructAtIndex 0 Str.72; + let #Derived_gen.3 : Str = StructAtIndex 1 Str.72; dec #Derived_gen.3; - let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; - let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; - ret Str.232; + let Str.237 : {U64, U8} = Struct {Str.239, Str.238}; + let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237; + ret Str.236; -procedure Test.19 (Test.55): - let Test.258 : Str = CallByName Encode.23 Test.55; +procedure Test.20 (Test.56): + let Test.259 : Str = CallByName Encode.23 Test.56; + ret Test.259; + +procedure Test.3 (): + let Test.258 : {} = Struct {}; ret Test.258; -procedure Test.2 (): - let Test.257 : {} = Struct {}; - ret Test.257; +procedure Test.4 (Test.49, Test.50, Test.51): + let Test.276 : U8 = CallByName Num.127 Test.50; + let Test.273 : List U8 = CallByName List.4 Test.49 Test.276; + let Test.275 : Str = CallByName Num.96 Test.51; + let Test.274 : List U8 = CallByName Str.12 Test.275; + let Test.271 : List U8 = CallByName List.8 Test.273 Test.274; + let Test.272 : U8 = 32i64; + let Test.270 : List U8 = CallByName List.4 Test.271 Test.272; + ret Test.270; -procedure Test.3 (Test.48, Test.49, Test.50): - let Test.275 : U8 = CallByName Num.127 Test.49; - let Test.272 : List U8 = CallByName List.4 Test.48 Test.275; - let Test.274 : Str = CallByName Num.96 Test.50; - let Test.273 : List U8 = CallByName Str.12 Test.274; - let Test.270 : List U8 = CallByName List.8 Test.272 Test.273; - let Test.271 : U8 = 32i64; - let Test.269 : List U8 = CallByName List.4 Test.270 Test.271; - ret Test.269; - -procedure Test.56 (Test.57, Test.260, Test.55): - let Test.267 : I64 = 115i64; - let Test.268 : U64 = CallByName Str.36 Test.55; - let Test.265 : List U8 = CallByName Test.3 Test.57 Test.267 Test.268; - let Test.266 : List U8 = CallByName Str.12 Test.55; - let Test.263 : List U8 = CallByName List.8 Test.265 Test.266; - let Test.264 : U8 = 32i64; - let Test.262 : List U8 = CallByName List.4 Test.263 Test.264; - ret Test.262; +procedure Test.57 (Test.58, Test.261, Test.56): + let Test.268 : I64 = 115i64; + let Test.269 : U64 = CallByName Str.36 Test.56; + let Test.266 : List U8 = CallByName Test.4 Test.58 Test.268 Test.269; + let Test.267 : List U8 = CallByName Str.12 Test.56; + let Test.264 : List U8 = CallByName List.8 Test.266 Test.267; + let Test.265 : U8 = 32i64; + let Test.263 : List U8 = CallByName List.4 Test.264 Test.265; + ret Test.263; procedure Test.0 (): - let Test.255 : Str = "abc"; - let Test.256 : {} = CallByName Test.2; - let Test.254 : List U8 = CallByName Encode.26 Test.255 Test.256; - let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; - let Test.251 : U8 = 1i64; - let Test.252 : U8 = GetTagId Test.209; - let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; - if Test.253 then - let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; - ret Test.210; + let Test.256 : Str = "abc"; + let Test.257 : {} = CallByName Test.3; + let Test.255 : List U8 = CallByName Encode.26 Test.256 Test.257; + let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.255; + let Test.252 : U8 = 1i64; + let Test.253 : U8 = GetTagId Test.210; + let Test.254 : Int1 = lowlevel Eq Test.252 Test.253; + if Test.254 then + let Test.211 : Str = UnionAtIndex (Id 1) (Index 0) Test.210; + ret Test.211; else - dec Test.209; - let Test.250 : Str = ""; - ret Test.250; + dec Test.210; + let Test.251 : Str = ""; + ret Test.251; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt index ef38caf3fb..8a049df979 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt @@ -8,212 +8,212 @@ procedure #Derived.3 (#Derived.4, #Derived.5, #Derived.1): ret #Derived_gen.3; in let #Derived_gen.7 : Str = "A"; - let #Derived_gen.9 : Str = CallByName Test.19 #Derived.1; + let #Derived_gen.9 : Str = CallByName Test.20 #Derived.1; let #Derived_gen.8 : List Str = Array [#Derived_gen.9]; - let #Derived_gen.6 : {List Str, {}} = CallByName Test.23 #Derived_gen.7 #Derived_gen.8; + let #Derived_gen.6 : {List Str, {}} = CallByName Test.24 #Derived_gen.7 #Derived_gen.8; jump #Derived_gen.5 #Derived_gen.6; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.111 : List U8 = CallByName #Derived.3 Encode.99 Encode.101 Encode.107; - ret Encode.111; - -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName Test.60 Encode.99 Encode.101 Encode.107; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.113 : List U8 = CallByName #Derived.3 Encode.101 Encode.103 Encode.109; ret Encode.113; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.117 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; - ret Encode.117; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.115 : List U8 = CallByName Test.61 Encode.101 Encode.103 Encode.109; + ret Encode.115; -procedure Encode.26 (Encode.105, Encode.106): - let Encode.109 : List U8 = Array []; - let Encode.110 : Str = CallByName #Derived.0 Encode.105; - let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; - ret Encode.108; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.119 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109; + ret Encode.119; + +procedure Encode.26 (Encode.107, Encode.108): + let Encode.111 : List U8 = Array []; + let Encode.112 : Str = CallByName #Derived.0 Encode.107; + let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; + ret Encode.110; procedure List.13 (#Attr.2, #Attr.3): - let List.648 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.648; + let List.651 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.651; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; -procedure List.4 (List.127, List.128): - let List.644 : U64 = 1i64; - let List.643 : List U8 = CallByName List.70 List.127 List.644; - let List.642 : List U8 = CallByName List.71 List.643 List.128; - ret List.642; +procedure List.4 (List.130, List.131): + let List.647 : U64 = 1i64; + let List.646 : List U8 = CallByName List.70 List.130 List.647; + let List.645 : List U8 = CallByName List.71 List.646 List.131; + ret List.645; procedure List.6 (#Attr.2): - let List.647 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.647; + let List.650 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.650; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; procedure List.70 (#Attr.2, #Attr.3): - let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.638; + let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.641; procedure List.71 (#Attr.2, #Attr.3): - let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.636; + let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.639; procedure List.8 (#Attr.2, #Attr.3): - let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.646; + let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.649; -procedure List.92 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : Str = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : List U8 = CallByName Test.63 List.167 List.631 List.168; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : Str = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : List U8 = CallByName Test.64 List.170 List.634 List.171; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.13; - jump List.625 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; + inc #Derived_gen.10; + jump List.628 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; procedure Num.127 (#Attr.2): - let Num.280 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.280; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + let Num.282 : U8 = lowlevel NumIntCast #Attr.2; ret Num.282; +procedure Num.22 (#Attr.2, #Attr.3): + let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.284; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; procedure Num.96 (#Attr.2): - let Num.279 : Str = lowlevel NumToStr #Attr.2; - ret Num.279; + let Num.281 : Str = lowlevel NumToStr #Attr.2; + ret Num.281; procedure Str.12 (#Attr.2): - let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.241; + let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.245; procedure Str.36 (#Attr.2): - let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; - ret Str.242; + let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.246; procedure Str.43 (#Attr.2): - let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; - ret Str.239; + let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; + ret Str.243; -procedure Str.9 (Str.67): - let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; - let Str.236 : Int1 = StructAtIndex 2 Str.68; - if Str.236 then - let Str.238 : Str = StructAtIndex 1 Str.68; - let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; - ret Str.237; +procedure Str.9 (Str.71): + let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71; + let Str.240 : Int1 = StructAtIndex 2 Str.72; + if Str.240 then + let Str.242 : Str = StructAtIndex 1 Str.72; + let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242; + ret Str.241; else - let Str.234 : U8 = StructAtIndex 3 Str.68; - let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.27 : Str = StructAtIndex 1 Str.68; + let Str.238 : U8 = StructAtIndex 3 Str.72; + let Str.239 : U64 = StructAtIndex 0 Str.72; + let #Derived_gen.27 : Str = StructAtIndex 1 Str.72; dec #Derived_gen.27; - let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; - let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; - ret Str.232; + let Str.237 : {U64, U8} = Struct {Str.239, Str.238}; + let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237; + ret Str.236; -procedure Test.19 (Test.55): - let Test.296 : Str = CallByName Encode.23 Test.55; - ret Test.296; +procedure Test.20 (Test.56): + let Test.297 : Str = CallByName Encode.23 Test.56; + ret Test.297; -procedure Test.2 (): - let Test.258 : {} = Struct {}; - ret Test.258; +procedure Test.21 (Test.59, Test.60): + inc Test.59; + let Test.266 : {List Str, {}} = Struct {Test.59, Test.60}; + let Test.265 : {List Str, {}} = CallByName Encode.23 Test.266; + ret Test.265; -procedure Test.20 (Test.58, Test.59): - inc Test.58; - let Test.265 : {List Str, {}} = Struct {Test.58, Test.59}; - let Test.264 : {List Str, {}} = CallByName Encode.23 Test.265; - ret Test.264; +procedure Test.23 (Test.75): + let Test.264 : {} = Struct {}; + let Test.263 : {List Str, {}} = CallByName Test.21 Test.75 Test.264; + ret Test.263; -procedure Test.22 (Test.74): - let Test.263 : {} = Struct {}; - let Test.262 : {List Str, {}} = CallByName Test.20 Test.74 Test.263; - ret Test.262; +procedure Test.24 (Test.78, Test.79): + let Test.285 : Str = CallByName Test.20 Test.78; + let Test.262 : List Str = CallByName List.13 Test.79 Test.285; + let Test.261 : {List Str, {}} = CallByName Test.23 Test.262; + dec Test.262; + ret Test.261; -procedure Test.23 (Test.77, Test.78): - let Test.284 : Str = CallByName Test.19 Test.77; - let Test.261 : List Str = CallByName List.13 Test.78 Test.284; - let Test.260 : {List Str, {}} = CallByName Test.22 Test.261; - dec Test.261; - ret Test.260; +procedure Test.3 (): + let Test.259 : {} = Struct {}; + ret Test.259; -procedure Test.3 (Test.48, Test.49, Test.50): - let Test.282 : U8 = CallByName Num.127 Test.49; - let Test.279 : List U8 = CallByName List.4 Test.48 Test.282; - let Test.281 : Str = CallByName Num.96 Test.50; - let Test.280 : List U8 = CallByName Str.12 Test.281; - let Test.277 : List U8 = CallByName List.8 Test.279 Test.280; - let Test.278 : U8 = 32i64; - let Test.276 : List U8 = CallByName List.4 Test.277 Test.278; - ret Test.276; +procedure Test.4 (Test.49, Test.50, Test.51): + let Test.283 : U8 = CallByName Num.127 Test.50; + let Test.280 : List U8 = CallByName List.4 Test.49 Test.283; + let Test.282 : Str = CallByName Num.96 Test.51; + let Test.281 : List U8 = CallByName Str.12 Test.282; + let Test.278 : List U8 = CallByName List.8 Test.280 Test.281; + let Test.279 : U8 = 32i64; + let Test.277 : List U8 = CallByName List.4 Test.278 Test.279; + ret Test.277; -procedure Test.56 (Test.57, Test.287, Test.55): - let Test.294 : I64 = 115i64; - let Test.295 : U64 = CallByName Str.36 Test.55; - let Test.292 : List U8 = CallByName Test.3 Test.57 Test.294 Test.295; - let Test.293 : List U8 = CallByName Str.12 Test.55; - let Test.290 : List U8 = CallByName List.8 Test.292 Test.293; - let Test.291 : U8 = 32i64; - let Test.289 : List U8 = CallByName List.4 Test.290 Test.291; - ret Test.289; +procedure Test.57 (Test.58, Test.288, Test.56): + let Test.295 : I64 = 115i64; + let Test.296 : U64 = CallByName Str.36 Test.56; + let Test.293 : List U8 = CallByName Test.4 Test.58 Test.295 Test.296; + let Test.294 : List U8 = CallByName Str.12 Test.56; + let Test.291 : List U8 = CallByName List.8 Test.293 Test.294; + let Test.292 : U8 = 32i64; + let Test.290 : List U8 = CallByName List.4 Test.291 Test.292; + ret Test.290; -procedure Test.60 (Test.61, Test.266, #Attr.12): - let Test.59 : {} = StructAtIndex 1 #Attr.12; - let Test.58 : List Str = StructAtIndex 0 #Attr.12; - let Test.274 : I64 = 108i64; - let Test.275 : U64 = CallByName List.6 Test.58; - let Test.62 : List U8 = CallByName Test.3 Test.61 Test.274 Test.275; - let Test.268 : List U8 = CallByName List.18 Test.58 Test.62 Test.59; - dec Test.58; - ret Test.268; +procedure Test.61 (Test.62, Test.267, #Attr.12): + let Test.60 : {} = StructAtIndex 1 #Attr.12; + let Test.59 : List Str = StructAtIndex 0 #Attr.12; + let Test.275 : I64 = 108i64; + let Test.276 : U64 = CallByName List.6 Test.59; + let Test.63 : List U8 = CallByName Test.4 Test.62 Test.275 Test.276; + let Test.269 : List U8 = CallByName List.18 Test.59 Test.63 Test.60; + dec Test.59; + ret Test.269; -procedure Test.63 (Test.64, Test.65, Test.59): - let Test.272 : Str = CallByName Test.75 Test.65; - let Test.273 : {} = Struct {}; - let Test.271 : List U8 = CallByName Encode.24 Test.64 Test.272 Test.273; - ret Test.271; +procedure Test.64 (Test.65, Test.66, Test.60): + let Test.273 : Str = CallByName Test.76 Test.66; + let Test.274 : {} = Struct {}; + let Test.272 : List U8 = CallByName Encode.24 Test.65 Test.273 Test.274; + ret Test.272; -procedure Test.75 (Test.76): - ret Test.76; +procedure Test.76 (Test.77): + ret Test.77; procedure Test.0 (): - let Test.259 : Str = "foo"; - let Test.257 : {} = CallByName Test.2; - let Test.256 : List U8 = CallByName Encode.26 Test.259 Test.257; - let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.256; - let Test.253 : U8 = 1i64; - let Test.254 : U8 = GetTagId Test.210; - let Test.255 : Int1 = lowlevel Eq Test.253 Test.254; - if Test.255 then - let Test.212 : Str = UnionAtIndex (Id 1) (Index 0) Test.210; - ret Test.212; + let Test.260 : Str = "foo"; + let Test.258 : {} = CallByName Test.3; + let Test.257 : List U8 = CallByName Encode.26 Test.260 Test.258; + let Test.211 : [C {U64, U8}, C Str] = CallByName Str.9 Test.257; + let Test.254 : U8 = 1i64; + let Test.255 : U8 = GetTagId Test.211; + let Test.256 : Int1 = lowlevel Eq Test.254 Test.255; + if Test.256 then + let Test.213 : Str = UnionAtIndex (Id 1) (Index 0) Test.211; + ret Test.213; else - dec Test.210; - let Test.252 : Str = ""; - ret Test.252; + dec Test.211; + let Test.253 : Str = ""; + ret Test.253; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt index 97c5bc286c..d453fd30d9 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt @@ -10,215 +10,215 @@ procedure #Derived.4 (#Derived.5, #Derived.6, #Derived.1): let #Derived.2 : Str = StructAtIndex 0 #Derived.1; let #Derived.3 : Str = StructAtIndex 1 #Derived.1; let #Derived_gen.7 : Str = "A"; - let #Derived_gen.9 : Str = CallByName Test.19 #Derived.2; - let #Derived_gen.10 : Str = CallByName Test.19 #Derived.3; + let #Derived_gen.9 : Str = CallByName Test.20 #Derived.2; + let #Derived_gen.10 : Str = CallByName Test.20 #Derived.3; let #Derived_gen.8 : List Str = Array [#Derived_gen.9, #Derived_gen.10]; - let #Derived_gen.6 : {List Str, {}} = CallByName Test.23 #Derived_gen.7 #Derived_gen.8; + let #Derived_gen.6 : {List Str, {}} = CallByName Test.24 #Derived_gen.7 #Derived_gen.8; jump #Derived_gen.5 #Derived_gen.6; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.111 : List U8 = CallByName #Derived.4 Encode.99 Encode.101 Encode.107; - ret Encode.111; - -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName Test.60 Encode.99 Encode.101 Encode.107; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.113 : List U8 = CallByName #Derived.4 Encode.101 Encode.103 Encode.109; ret Encode.113; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.118 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; - ret Encode.118; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.115 : List U8 = CallByName Test.61 Encode.101 Encode.103 Encode.109; + ret Encode.115; -procedure Encode.26 (Encode.105, Encode.106): - let Encode.109 : List U8 = Array []; - let Encode.110 : {Str, Str} = CallByName #Derived.0 Encode.105; - let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; - ret Encode.108; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.120 : List U8 = CallByName Test.57 Encode.101 Encode.103 Encode.109; + ret Encode.120; + +procedure Encode.26 (Encode.107, Encode.108): + let Encode.111 : List U8 = Array []; + let Encode.112 : {Str, Str} = CallByName #Derived.0 Encode.107; + let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; + ret Encode.110; procedure List.13 (#Attr.2, #Attr.3): - let List.648 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.648; + let List.651 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.651; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; -procedure List.4 (List.127, List.128): - let List.644 : U64 = 1i64; - let List.643 : List U8 = CallByName List.70 List.127 List.644; - let List.642 : List U8 = CallByName List.71 List.643 List.128; - ret List.642; +procedure List.4 (List.130, List.131): + let List.647 : U64 = 1i64; + let List.646 : List U8 = CallByName List.70 List.130 List.647; + let List.645 : List U8 = CallByName List.71 List.646 List.131; + ret List.645; procedure List.6 (#Attr.2): - let List.647 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.647; + let List.650 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.650; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; procedure List.70 (#Attr.2, #Attr.3): - let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.638; + let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.641; procedure List.71 (#Attr.2, #Attr.3): - let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.636; + let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.639; procedure List.8 (#Attr.2, #Attr.3): - let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.646; + let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.649; -procedure List.92 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : Str = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : List U8 = CallByName Test.63 List.167 List.631 List.168; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : Str = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : List U8 = CallByName Test.64 List.170 List.634 List.171; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.14; - jump List.625 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; + inc #Derived_gen.11; + jump List.628 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; procedure Num.127 (#Attr.2): - let Num.280 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.280; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + let Num.282 : U8 = lowlevel NumIntCast #Attr.2; ret Num.282; +procedure Num.22 (#Attr.2, #Attr.3): + let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.284; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; procedure Num.96 (#Attr.2): - let Num.279 : Str = lowlevel NumToStr #Attr.2; - ret Num.279; + let Num.281 : Str = lowlevel NumToStr #Attr.2; + ret Num.281; procedure Str.12 (#Attr.2): - let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.241; + let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.245; procedure Str.36 (#Attr.2): - let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; - ret Str.242; + let Str.246 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.246; procedure Str.43 (#Attr.2): - let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; - ret Str.239; + let Str.243 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; + ret Str.243; -procedure Str.9 (Str.67): - let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; - let Str.236 : Int1 = StructAtIndex 2 Str.68; - if Str.236 then - let Str.238 : Str = StructAtIndex 1 Str.68; - let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; - ret Str.237; +procedure Str.9 (Str.71): + let Str.72 : {U64, Str, Int1, U8} = CallByName Str.43 Str.71; + let Str.240 : Int1 = StructAtIndex 2 Str.72; + if Str.240 then + let Str.242 : Str = StructAtIndex 1 Str.72; + let Str.241 : [C {U64, U8}, C Str] = TagId(1) Str.242; + ret Str.241; else - let Str.234 : U8 = StructAtIndex 3 Str.68; - let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.28 : Str = StructAtIndex 1 Str.68; + let Str.238 : U8 = StructAtIndex 3 Str.72; + let Str.239 : U64 = StructAtIndex 0 Str.72; + let #Derived_gen.28 : Str = StructAtIndex 1 Str.72; dec #Derived_gen.28; - let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; - let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; - ret Str.232; + let Str.237 : {U64, U8} = Struct {Str.239, Str.238}; + let Str.236 : [C {U64, U8}, C Str] = TagId(0) Str.237; + ret Str.236; -procedure Test.19 (Test.55): - let Test.300 : Str = CallByName Encode.23 Test.55; - ret Test.300; +procedure Test.20 (Test.56): + let Test.301 : Str = CallByName Encode.23 Test.56; + ret Test.301; -procedure Test.2 (): - let Test.258 : {} = Struct {}; - ret Test.258; +procedure Test.21 (Test.59, Test.60): + inc Test.59; + let Test.267 : {List Str, {}} = Struct {Test.59, Test.60}; + let Test.266 : {List Str, {}} = CallByName Encode.23 Test.267; + ret Test.266; -procedure Test.20 (Test.58, Test.59): - inc Test.58; - let Test.266 : {List Str, {}} = Struct {Test.58, Test.59}; - let Test.265 : {List Str, {}} = CallByName Encode.23 Test.266; - ret Test.265; +procedure Test.23 (Test.75): + let Test.265 : {} = Struct {}; + let Test.264 : {List Str, {}} = CallByName Test.21 Test.75 Test.265; + ret Test.264; -procedure Test.22 (Test.74): - let Test.264 : {} = Struct {}; - let Test.263 : {List Str, {}} = CallByName Test.20 Test.74 Test.264; - ret Test.263; +procedure Test.24 (Test.78, Test.79): + let Test.286 : Str = CallByName Test.20 Test.78; + let Test.263 : List Str = CallByName List.13 Test.79 Test.286; + let Test.262 : {List Str, {}} = CallByName Test.23 Test.263; + dec Test.263; + ret Test.262; -procedure Test.23 (Test.77, Test.78): - let Test.285 : Str = CallByName Test.19 Test.77; - let Test.262 : List Str = CallByName List.13 Test.78 Test.285; - let Test.261 : {List Str, {}} = CallByName Test.22 Test.262; - dec Test.262; - ret Test.261; +procedure Test.3 (): + let Test.259 : {} = Struct {}; + ret Test.259; -procedure Test.3 (Test.48, Test.49, Test.50): - let Test.283 : U8 = CallByName Num.127 Test.49; - let Test.280 : List U8 = CallByName List.4 Test.48 Test.283; - let Test.282 : Str = CallByName Num.96 Test.50; - let Test.281 : List U8 = CallByName Str.12 Test.282; - let Test.278 : List U8 = CallByName List.8 Test.280 Test.281; - let Test.279 : U8 = 32i64; - let Test.277 : List U8 = CallByName List.4 Test.278 Test.279; - ret Test.277; +procedure Test.4 (Test.49, Test.50, Test.51): + let Test.284 : U8 = CallByName Num.127 Test.50; + let Test.281 : List U8 = CallByName List.4 Test.49 Test.284; + let Test.283 : Str = CallByName Num.96 Test.51; + let Test.282 : List U8 = CallByName Str.12 Test.283; + let Test.279 : List U8 = CallByName List.8 Test.281 Test.282; + let Test.280 : U8 = 32i64; + let Test.278 : List U8 = CallByName List.4 Test.279 Test.280; + ret Test.278; -procedure Test.56 (Test.57, Test.288, Test.55): - let Test.295 : I64 = 115i64; - let Test.296 : U64 = CallByName Str.36 Test.55; - let Test.293 : List U8 = CallByName Test.3 Test.57 Test.295 Test.296; - let Test.294 : List U8 = CallByName Str.12 Test.55; - let Test.291 : List U8 = CallByName List.8 Test.293 Test.294; - let Test.292 : U8 = 32i64; - let Test.290 : List U8 = CallByName List.4 Test.291 Test.292; - ret Test.290; +procedure Test.57 (Test.58, Test.289, Test.56): + let Test.296 : I64 = 115i64; + let Test.297 : U64 = CallByName Str.36 Test.56; + let Test.294 : List U8 = CallByName Test.4 Test.58 Test.296 Test.297; + let Test.295 : List U8 = CallByName Str.12 Test.56; + let Test.292 : List U8 = CallByName List.8 Test.294 Test.295; + let Test.293 : U8 = 32i64; + let Test.291 : List U8 = CallByName List.4 Test.292 Test.293; + ret Test.291; -procedure Test.60 (Test.61, Test.267, #Attr.12): - let Test.59 : {} = StructAtIndex 1 #Attr.12; - let Test.58 : List Str = StructAtIndex 0 #Attr.12; - let Test.275 : I64 = 108i64; - let Test.276 : U64 = CallByName List.6 Test.58; - let Test.62 : List U8 = CallByName Test.3 Test.61 Test.275 Test.276; - let Test.269 : List U8 = CallByName List.18 Test.58 Test.62 Test.59; - dec Test.58; - ret Test.269; +procedure Test.61 (Test.62, Test.268, #Attr.12): + let Test.60 : {} = StructAtIndex 1 #Attr.12; + let Test.59 : List Str = StructAtIndex 0 #Attr.12; + let Test.276 : I64 = 108i64; + let Test.277 : U64 = CallByName List.6 Test.59; + let Test.63 : List U8 = CallByName Test.4 Test.62 Test.276 Test.277; + let Test.270 : List U8 = CallByName List.18 Test.59 Test.63 Test.60; + dec Test.59; + ret Test.270; -procedure Test.63 (Test.64, Test.65, Test.59): - let Test.273 : Str = CallByName Test.75 Test.65; - let Test.274 : {} = Struct {}; - let Test.272 : List U8 = CallByName Encode.24 Test.64 Test.273 Test.274; - ret Test.272; +procedure Test.64 (Test.65, Test.66, Test.60): + let Test.274 : Str = CallByName Test.76 Test.66; + let Test.275 : {} = Struct {}; + let Test.273 : List U8 = CallByName Encode.24 Test.65 Test.274 Test.275; + ret Test.273; -procedure Test.75 (Test.76): - ret Test.76; +procedure Test.76 (Test.77): + ret Test.77; procedure Test.0 (): + let Test.261 : Str = "foo"; let Test.260 : Str = "foo"; - let Test.259 : Str = "foo"; - let Test.209 : {Str, Str} = Struct {Test.259, Test.260}; - let Test.257 : {} = CallByName Test.2; - let Test.256 : List U8 = CallByName Encode.26 Test.209 Test.257; - let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.256; - let Test.253 : U8 = 1i64; - let Test.254 : U8 = GetTagId Test.210; - let Test.255 : Int1 = lowlevel Eq Test.253 Test.254; - if Test.255 then - let Test.212 : Str = UnionAtIndex (Id 1) (Index 0) Test.210; - ret Test.212; + let Test.210 : {Str, Str} = Struct {Test.260, Test.261}; + let Test.258 : {} = CallByName Test.3; + let Test.257 : List U8 = CallByName Encode.26 Test.210 Test.258; + let Test.211 : [C {U64, U8}, C Str] = CallByName Str.9 Test.257; + let Test.254 : U8 = 1i64; + let Test.255 : U8 = GetTagId Test.211; + let Test.256 : Int1 = lowlevel Eq Test.254 Test.255; + if Test.256 then + let Test.213 : Str = UnionAtIndex (Id 1) (Index 0) Test.211; + ret Test.213; else - dec Test.210; - let Test.252 : Str = ""; - ret Test.252; + dec Test.211; + let Test.253 : Str = ""; + ret Test.253; diff --git a/crates/compiler/test_mono/generated/factorial.txt b/crates/compiler/test_mono/generated/factorial.txt index 19d5d2862f..a9655ad62d 100644 --- a/crates/compiler/test_mono/generated/factorial.txt +++ b/crates/compiler/test_mono/generated/factorial.txt @@ -1,10 +1,10 @@ procedure Num.20 (#Attr.2, #Attr.3): - let Num.280 : I64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : I64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.282; procedure Num.21 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (#Derived_gen.0, #Derived_gen.1): joinpoint Test.7 Test.2 Test.3: diff --git a/crates/compiler/test_mono/generated/function_specialization_information_in_lambda_set_thunk.txt b/crates/compiler/test_mono/generated/function_specialization_information_in_lambda_set_thunk.txt index 59c8a2a93c..ec22d853c6 100644 --- a/crates/compiler/test_mono/generated/function_specialization_information_in_lambda_set_thunk.txt +++ b/crates/compiler/test_mono/generated/function_specialization_information_in_lambda_set_thunk.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (Test.8): let Test.3 : I64 = 10i64; diff --git a/crates/compiler/test_mono/generated/function_specialization_information_in_lambda_set_thunk_independent_defs.txt b/crates/compiler/test_mono/generated/function_specialization_information_in_lambda_set_thunk_independent_defs.txt index 4b360b65e6..96fa433e56 100644 --- a/crates/compiler/test_mono/generated/function_specialization_information_in_lambda_set_thunk_independent_defs.txt +++ b/crates/compiler/test_mono/generated/function_specialization_information_in_lambda_set_thunk_independent_defs.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.280 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.282; procedure Test.1 (Test.9): let Test.4 : U8 = 10i64; diff --git a/crates/compiler/test_mono/generated/inline_return_joinpoints_in_bool_lambda_set.txt b/crates/compiler/test_mono/generated/inline_return_joinpoints_in_bool_lambda_set.txt index 0e35e619a6..0e45e1077e 100644 --- a/crates/compiler/test_mono/generated/inline_return_joinpoints_in_bool_lambda_set.txt +++ b/crates/compiler/test_mono/generated/inline_return_joinpoints_in_bool_lambda_set.txt @@ -3,8 +3,8 @@ procedure Bool.1 (): ret Bool.23; procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.3 (Test.4): ret Test.4; diff --git a/crates/compiler/test_mono/generated/inline_return_joinpoints_in_enum_lambda_set.txt b/crates/compiler/test_mono/generated/inline_return_joinpoints_in_enum_lambda_set.txt index 4215c45805..8cd25bf390 100644 --- a/crates/compiler/test_mono/generated/inline_return_joinpoints_in_enum_lambda_set.txt +++ b/crates/compiler/test_mono/generated/inline_return_joinpoints_in_enum_lambda_set.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.283; procedure Test.2 (Test.3): switch Test.3: diff --git a/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt b/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt index 9451b2635d..575a74f1db 100644 --- a/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt +++ b/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.280 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.282; procedure Test.2 (Test.3, Test.1): let Test.18 : Int1 = false; diff --git a/crates/compiler/test_mono/generated/inspect_derived_dict.txt b/crates/compiler/test_mono/generated/inspect_derived_dict.txt index 6e34fadece..80360493fa 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_dict.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_dict.txt @@ -34,1162 +34,1162 @@ procedure Bool.7 (Bool.19, Bool.20): let Bool.27 : Int1 = CallByName Bool.12 Bool.19 Bool.20; ret Bool.27; -procedure Dict.1 (Dict.723): - let Dict.885 : List {U32, U32} = Array []; - let Dict.886 : List {Str, I64} = Array []; - let Dict.887 : U64 = 0i64; - let Dict.44 : Float32 = CallByName Dict.44; - let Dict.45 : U8 = CallByName Dict.45; - let Dict.884 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = Struct {Dict.885, Dict.886, Dict.887, Dict.44, Dict.45}; - ret Dict.884; - -procedure Dict.10 (Dict.724, Dict.179, Dict.180): - let Dict.178 : List {Str, I64} = StructAtIndex 1 Dict.724; - let #Derived_gen.68 : List {U32, U32} = StructAtIndex 0 Dict.724; - dec #Derived_gen.68; - let Dict.1101 : {Str, Int1} = CallByName List.18 Dict.178 Dict.179 Dict.180; - dec Dict.178; - ret Dict.1101; - -procedure Dict.12 (Dict.151): - let Dict.883 : {} = Struct {}; - let Dict.731 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.1 Dict.883; - let Dict.732 : {} = Struct {}; - let Dict.730 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName List.18 Dict.151 Dict.731 Dict.732; - ret Dict.730; - -procedure Dict.120 (Dict.121, Dict.119): - let Dict.1098 : {} = Struct {}; - let Dict.1099 : {} = Struct {}; - let Dict.1100 : {} = Struct {}; - let Dict.1097 : {{List {U32, U32}, List {Str, I64}, U64, Float32, U8}, {}, {}, {}} = CallByName Inspect.38 Dict.119 Dict.1098 Dict.1099 Dict.1100; - let Dict.1096 : Str = CallByName Inspect.31 Dict.1097 Dict.121; - ret Dict.1096; - -procedure Dict.152 (Dict.153, Dict.733): - let Dict.154 : Str = StructAtIndex 0 Dict.733; - let Dict.155 : I64 = StructAtIndex 1 Dict.733; - let Dict.734 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.8 Dict.153 Dict.154 Dict.155; - ret Dict.734; - -procedure Dict.181 (Dict.182, Dict.1103, Dict.180): - let Dict.183 : Str = StructAtIndex 0 Dict.1103; - let Dict.184 : I64 = StructAtIndex 1 Dict.1103; - let Dict.1105 : {Str, Int1} = CallByName Inspect.187 Dict.182 Dict.183 Dict.184 Dict.180; - ret Dict.1105; - -procedure Dict.20 (Dict.720): - let Dict.148 : U64 = StructAtIndex 2 Dict.720; - let #Derived_gen.70 : List {U32, U32} = StructAtIndex 0 Dict.720; - dec #Derived_gen.70; - let #Derived_gen.69 : List {Str, I64} = StructAtIndex 1 Dict.720; - dec #Derived_gen.69; - ret Dict.148; - -procedure Dict.22 (#Attr.2, #Attr.3): - let Dict.765 : {U32, U32} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret Dict.765; - -procedure Dict.22 (#Attr.2, #Attr.3): - let Dict.781 : {Str, I64} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret Dict.781; - -procedure Dict.22 (#Attr.2, #Attr.3): - let Dict.944 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret Dict.944; - -procedure Dict.23 (#Attr.2): - let Dict.817 : U64 = lowlevel DictPseudoSeed #Attr.2; - ret Dict.817; - -procedure Dict.36 (Dict.119): - let Dict.1093 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Inspect.30 Dict.119; - ret Dict.1093; - -procedure Dict.38 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8): - joinpoint Dict.736 Dict.221 Dict.222 Dict.223 Dict.224 Dict.225 Dict.226 Dict.227 Dict.228 Dict.229: - let Dict.230 : {U32, U32} = CallByName Dict.22 Dict.221 Dict.223; - let Dict.783 : U32 = StructAtIndex 1 Dict.230; - let Dict.771 : Int1 = CallByName Bool.11 Dict.224 Dict.783; - if Dict.771 then - let Dict.782 : U32 = StructAtIndex 0 Dict.230; - let Dict.780 : U64 = CallByName Num.133 Dict.782; - let Dict.779 : {Str, I64} = CallByName Dict.22 Dict.222 Dict.780; - let Dict.231 : Str = StructAtIndex 0 Dict.779; - let Dict.774 : Int1 = CallByName Bool.11 Dict.231 Dict.225; - if Dict.774 then - let Dict.778 : U32 = StructAtIndex 0 Dict.230; - let Dict.776 : U64 = CallByName Num.133 Dict.778; - let Dict.777 : {Str, I64} = Struct {Dict.225, Dict.226}; - let Dict.232 : List {Str, I64} = CallByName List.3 Dict.222 Dict.776 Dict.777; - let Dict.775 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = Struct {Dict.221, Dict.232, Dict.227, Dict.228, Dict.229}; - ret Dict.775; - else - let Dict.773 : U64 = CallByName List.6 Dict.221; - let Dict.233 : U64 = CallByName Dict.68 Dict.223 Dict.773; - let Dict.234 : U32 = CallByName Dict.48 Dict.224; - jump Dict.736 Dict.221 Dict.222 Dict.233 Dict.234 Dict.225 Dict.226 Dict.227 Dict.228 Dict.229; - else - let Dict.770 : U32 = StructAtIndex 1 Dict.230; - let Dict.750 : Int1 = CallByName Num.24 Dict.224 Dict.770; - if Dict.750 then - let Dict.769 : {Str, I64} = Struct {Dict.225, Dict.226}; - let Dict.235 : List {Str, I64} = CallByName List.4 Dict.222 Dict.769; - let Dict.767 : U64 = CallByName List.6 Dict.235; - let Dict.768 : U64 = 1i64; - let Dict.236 : U64 = CallByName Num.75 Dict.767 Dict.768; - let Dict.766 : U32 = CallByName Num.131 Dict.236; - let Dict.752 : {U32, U32} = Struct {Dict.766, Dict.224}; - let Dict.237 : List {U32, U32} = CallByName Dict.67 Dict.221 Dict.752 Dict.223; - let Dict.751 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = Struct {Dict.237, Dict.235, Dict.227, Dict.228, Dict.229}; - ret Dict.751; - else - let Dict.743 : U64 = CallByName List.6 Dict.221; - let Dict.238 : U64 = CallByName Dict.68 Dict.223 Dict.743; - let Dict.239 : U32 = CallByName Dict.48 Dict.224; - jump Dict.736 Dict.221 Dict.222 Dict.238 Dict.239 Dict.225 Dict.226 Dict.227 Dict.228 Dict.229; - in - inc #Derived_gen.4; - jump Dict.736 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8; - -procedure Dict.398 (Dict.399, Dict.840, Dict.401, Dict.397): - let Dict.400 : Str = StructAtIndex 0 Dict.840; - let Dict.845 : {U64, U32} = CallByName Dict.65 Dict.399 Dict.400 Dict.397; - let Dict.402 : U64 = StructAtIndex 0 Dict.845; - let Dict.403 : U32 = StructAtIndex 1 Dict.845; - let Dict.844 : U32 = CallByName Num.131 Dict.401; - let Dict.843 : {U32, U32} = Struct {Dict.844, Dict.403}; - let Dict.842 : List {U32, U32} = CallByName Dict.67 Dict.399 Dict.843 Dict.402; - ret Dict.842; - -procedure Dict.4 (Dict.729): - let Dict.156 : List {Str, I64} = StructAtIndex 1 Dict.729; - let #Derived_gen.66 : List {U32, U32} = StructAtIndex 0 Dict.729; - dec #Derived_gen.66; - let Dict.882 : U64 = CallByName List.6 Dict.156; - dec Dict.156; - ret Dict.882; - -procedure Dict.41 (): - let Dict.860 : U32 = 0i64; - let Dict.861 : U32 = 0i64; - let Dict.859 : {U32, U32} = Struct {Dict.860, Dict.861}; - ret Dict.859; - -procedure Dict.42 (): - let Dict.741 : U32 = 1i64; - let Dict.742 : U8 = 8i64; - let Dict.740 : U32 = CallByName Num.72 Dict.741 Dict.742; - ret Dict.740; - -procedure Dict.43 (): - let Dict.791 : U32 = CallByName Dict.42; - let Dict.792 : U32 = 1i64; - let Dict.790 : U32 = CallByName Num.75 Dict.791 Dict.792; - ret Dict.790; - -procedure Dict.44 (): - let Dict.891 : Float32 = 0.8f64; +procedure Dict.1 (Dict.730): + let Dict.892 : List {U32, U32} = Array []; + let Dict.893 : List {Str, I64} = Array []; + let Dict.894 : U64 = 0i64; + let Dict.51 : Float32 = CallByName Dict.51; + let Dict.52 : U8 = CallByName Dict.52; + let Dict.891 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = Struct {Dict.892, Dict.893, Dict.894, Dict.51, Dict.52}; ret Dict.891; -procedure Dict.45 (): - let Dict.889 : U8 = 64i64; - let Dict.890 : U8 = 3i64; - let Dict.888 : U8 = CallByName Num.75 Dict.889 Dict.890; - ret Dict.888; - -procedure Dict.46 (): - let Dict.834 : U64 = 1i64; - let Dict.835 : U8 = 32i64; - let Dict.833 : U64 = CallByName Num.72 Dict.834 Dict.835; - ret Dict.833; - -procedure Dict.47 (): - let Dict.832 : U64 = CallByName Dict.46; - ret Dict.832; - -procedure Dict.48 (Dict.306): - let Dict.739 : U32 = CallByName Dict.42; - let Dict.738 : U32 = CallByName Num.51 Dict.306 Dict.739; - ret Dict.738; - -procedure Dict.59 (Dict.719): - let Dict.376 : List {Str, I64} = StructAtIndex 1 Dict.719; - let Dict.377 : U64 = StructAtIndex 2 Dict.719; - let Dict.378 : Float32 = StructAtIndex 3 Dict.719; - let Dict.379 : U8 = StructAtIndex 4 Dict.719; - let #Derived_gen.67 : List {U32, U32} = StructAtIndex 0 Dict.719; +procedure Dict.10 (Dict.731, Dict.186, Dict.187): + let Dict.185 : List {Str, I64} = StructAtIndex 1 Dict.731; + let #Derived_gen.67 : List {U32, U32} = StructAtIndex 0 Dict.731; dec #Derived_gen.67; - let Dict.877 : U64 = CallByName Dict.47; - let Dict.836 : Int1 = CallByName Bool.7 Dict.377 Dict.877; - if Dict.836 then - let Dict.876 : U8 = 1i64; - let Dict.380 : U8 = CallByName Num.75 Dict.379 Dict.876; - let Dict.855 : {List {U32, U32}, U64} = CallByName Dict.60 Dict.380 Dict.378; - let Dict.381 : List {U32, U32} = StructAtIndex 0 Dict.855; - let Dict.382 : U64 = StructAtIndex 1 Dict.855; - let Dict.383 : List {U32, U32} = CallByName Dict.64 Dict.381 Dict.376 Dict.380; - let Dict.837 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = Struct {Dict.383, Dict.376, Dict.382, Dict.378, Dict.380}; - ret Dict.837; - else - dec Dict.376; - let Dict.827 : Str = "Dict hit limit of "; - let Dict.831 : U64 = CallByName Dict.47; - let Dict.829 : Str = CallByName Num.96 Dict.831; - let Dict.830 : Str = " elements. Unable to grow more."; - let Dict.828 : Str = CallByName Str.3 Dict.829 Dict.830; - dec Dict.830; - let Dict.826 : Str = CallByName Str.3 Dict.827 Dict.828; - dec Dict.828; - Crash Dict.826 + let Dict.1108 : {Str, Int1} = CallByName List.18 Dict.185 Dict.186 Dict.187; + dec Dict.185; + ret Dict.1108; -procedure Dict.60 (Dict.384, Dict.385): - let Dict.386 : U64 = CallByName Dict.63 Dict.384; - let Dict.869 : U64 = CallByName Dict.47; - let Dict.864 : Int1 = CallByName Bool.11 Dict.386 Dict.869; - if Dict.864 then - let Dict.867 : {U32, U32} = CallByName Dict.41; - let Dict.868 : U64 = CallByName Dict.47; - let Dict.866 : List {U32, U32} = CallByName List.11 Dict.867 Dict.868; - let Dict.47 : U64 = CallByName Dict.47; - let Dict.865 : {List {U32, U32}, U64} = Struct {Dict.866, Dict.47}; - ret Dict.865; - else - let Dict.863 : Float32 = CallByName Num.139 Dict.386; - let Dict.862 : Float32 = CallByName Num.21 Dict.863 Dict.385; - let Dict.387 : U64 = CallByName Num.50 Dict.862; - let Dict.858 : {U32, U32} = CallByName Dict.41; - let Dict.857 : List {U32, U32} = CallByName List.11 Dict.858 Dict.386; - let Dict.856 : {List {U32, U32}, U64} = Struct {Dict.857, Dict.387}; - ret Dict.856; +procedure Dict.100 (Dict.544, Dict.545, Dict.546): + let Dict.1061 : U8 = CallByName Dict.22 Dict.544 Dict.545; + let Dict.547 : U64 = CallByName Num.133 Dict.1061; + let Dict.1060 : U8 = 1i64; + let Dict.1059 : U64 = CallByName Num.74 Dict.546 Dict.1060; + let Dict.1058 : U64 = CallByName Num.51 Dict.1059 Dict.545; + let Dict.1057 : U8 = CallByName Dict.22 Dict.544 Dict.1058; + let Dict.548 : U64 = CallByName Num.133 Dict.1057; + let Dict.1056 : U64 = 1i64; + let Dict.1055 : U64 = CallByName Num.75 Dict.546 Dict.1056; + let Dict.1054 : U64 = CallByName Num.51 Dict.1055 Dict.545; + let Dict.1053 : U8 = CallByName Dict.22 Dict.544 Dict.1054; + let Dict.549 : U64 = CallByName Num.133 Dict.1053; + let Dict.1052 : U8 = 16i64; + let Dict.1049 : U64 = CallByName Num.72 Dict.547 Dict.1052; + let Dict.1051 : U8 = 8i64; + let Dict.1050 : U64 = CallByName Num.72 Dict.548 Dict.1051; + let Dict.550 : U64 = CallByName Num.71 Dict.1049 Dict.1050; + let Dict.1048 : U64 = CallByName Num.71 Dict.550 Dict.549; + ret Dict.1048; -procedure Dict.63 (Dict.394): - let Dict.873 : U64 = 1i64; - let Dict.875 : U8 = 64i64; - let Dict.874 : U8 = CallByName Num.75 Dict.875 Dict.394; - let Dict.871 : U64 = CallByName Num.72 Dict.873 Dict.874; - let Dict.872 : U64 = CallByName Dict.47; - let Dict.870 : U64 = CallByName Num.148 Dict.871 Dict.872; - ret Dict.870; +procedure Dict.12 (Dict.158): + let Dict.890 : {} = Struct {}; + let Dict.738 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.1 Dict.890; + let Dict.739 : {} = Struct {}; + let Dict.737 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName List.18 Dict.158 Dict.738 Dict.739; + ret Dict.737; -procedure Dict.64 (Dict.395, Dict.396, Dict.397): - let Dict.838 : List {U32, U32} = CallByName List.83 Dict.396 Dict.395 Dict.397; - ret Dict.838; +procedure Dict.127 (Dict.128, Dict.126): + let Dict.1105 : {} = Struct {}; + let Dict.1106 : {} = Struct {}; + let Dict.1107 : {} = Struct {}; + let Dict.1104 : {{List {U32, U32}, List {Str, I64}, U64, Float32, U8}, {}, {}, {}} = CallByName Inspect.42 Dict.126 Dict.1105 Dict.1106 Dict.1107; + let Dict.1103 : Str = CallByName Inspect.31 Dict.1104 Dict.128; + ret Dict.1103; -procedure Dict.65 (Dict.404, Dict.405, Dict.406): - let Dict.407 : U64 = CallByName Dict.69 Dict.405; - let Dict.408 : U32 = CallByName Dict.70 Dict.407; - let Dict.409 : U64 = CallByName Dict.71 Dict.407 Dict.406; - let Dict.846 : {U64, U32} = CallByName Dict.66 Dict.404 Dict.409 Dict.408; - ret Dict.846; +procedure Dict.159 (Dict.160, Dict.740): + let Dict.161 : Str = StructAtIndex 0 Dict.740; + let Dict.162 : I64 = StructAtIndex 1 Dict.740; + let Dict.741 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.8 Dict.160 Dict.161 Dict.162; + ret Dict.741; -procedure Dict.66 (#Derived_gen.40, #Derived_gen.41, #Derived_gen.42): - joinpoint Dict.847 Dict.410 Dict.411 Dict.412: - let Dict.413 : {U32, U32} = CallByName Dict.22 Dict.410 Dict.411; - let Dict.854 : U32 = StructAtIndex 1 Dict.413; - let Dict.849 : Int1 = CallByName Num.22 Dict.412 Dict.854; - if Dict.849 then - let Dict.853 : U64 = CallByName List.6 Dict.410; - let Dict.851 : U64 = CallByName Dict.68 Dict.411 Dict.853; - let Dict.852 : U32 = CallByName Dict.48 Dict.412; - jump Dict.847 Dict.410 Dict.851 Dict.852; +procedure Dict.188 (Dict.189, Dict.1110, Dict.187): + let Dict.190 : Str = StructAtIndex 0 Dict.1110; + let Dict.191 : I64 = StructAtIndex 1 Dict.1110; + let Dict.1112 : {Str, Int1} = CallByName Inspect.191 Dict.189 Dict.190 Dict.191 Dict.187; + ret Dict.1112; + +procedure Dict.20 (Dict.727): + let Dict.155 : U64 = StructAtIndex 2 Dict.727; + let #Derived_gen.70 : List {U32, U32} = StructAtIndex 0 Dict.727; + dec #Derived_gen.70; + let #Derived_gen.69 : List {Str, I64} = StructAtIndex 1 Dict.727; + dec #Derived_gen.69; + ret Dict.155; + +procedure Dict.22 (#Attr.2, #Attr.3): + let Dict.772 : {U32, U32} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret Dict.772; + +procedure Dict.22 (#Attr.2, #Attr.3): + let Dict.788 : {Str, I64} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret Dict.788; + +procedure Dict.22 (#Attr.2, #Attr.3): + let Dict.951 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret Dict.951; + +procedure Dict.23 (#Attr.2): + let Dict.824 : U64 = lowlevel DictPseudoSeed #Attr.2; + ret Dict.824; + +procedure Dict.4 (Dict.736): + let Dict.163 : List {Str, I64} = StructAtIndex 1 Dict.736; + let #Derived_gen.66 : List {U32, U32} = StructAtIndex 0 Dict.736; + dec #Derived_gen.66; + let Dict.889 : U64 = CallByName List.6 Dict.163; + dec Dict.163; + ret Dict.889; + +procedure Dict.405 (Dict.406, Dict.847, Dict.408, Dict.404): + let Dict.407 : Str = StructAtIndex 0 Dict.847; + let Dict.852 : {U64, U32} = CallByName Dict.72 Dict.406 Dict.407 Dict.404; + let Dict.409 : U64 = StructAtIndex 0 Dict.852; + let Dict.410 : U32 = StructAtIndex 1 Dict.852; + let Dict.851 : U32 = CallByName Num.131 Dict.408; + let Dict.850 : {U32, U32} = Struct {Dict.851, Dict.410}; + let Dict.849 : List {U32, U32} = CallByName Dict.74 Dict.406 Dict.850 Dict.409; + ret Dict.849; + +procedure Dict.43 (Dict.126): + let Dict.1100 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Inspect.30 Dict.126; + ret Dict.1100; + +procedure Dict.45 (#Derived_gen.42, #Derived_gen.43, #Derived_gen.44, #Derived_gen.45, #Derived_gen.46, #Derived_gen.47, #Derived_gen.48, #Derived_gen.49, #Derived_gen.50): + joinpoint Dict.743 Dict.228 Dict.229 Dict.230 Dict.231 Dict.232 Dict.233 Dict.234 Dict.235 Dict.236: + let Dict.237 : {U32, U32} = CallByName Dict.22 Dict.228 Dict.230; + let Dict.790 : U32 = StructAtIndex 1 Dict.237; + let Dict.778 : Int1 = CallByName Bool.11 Dict.231 Dict.790; + if Dict.778 then + let Dict.789 : U32 = StructAtIndex 0 Dict.237; + let Dict.787 : U64 = CallByName Num.133 Dict.789; + let Dict.786 : {Str, I64} = CallByName Dict.22 Dict.229 Dict.787; + let Dict.238 : Str = StructAtIndex 0 Dict.786; + let Dict.781 : Int1 = CallByName Bool.11 Dict.238 Dict.232; + if Dict.781 then + let Dict.785 : U32 = StructAtIndex 0 Dict.237; + let Dict.783 : U64 = CallByName Num.133 Dict.785; + let Dict.784 : {Str, I64} = Struct {Dict.232, Dict.233}; + let Dict.239 : List {Str, I64} = CallByName List.3 Dict.229 Dict.783 Dict.784; + let Dict.782 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = Struct {Dict.228, Dict.239, Dict.234, Dict.235, Dict.236}; + ret Dict.782; + else + let Dict.780 : U64 = CallByName List.6 Dict.228; + let Dict.240 : U64 = CallByName Dict.75 Dict.230 Dict.780; + let Dict.241 : U32 = CallByName Dict.55 Dict.231; + jump Dict.743 Dict.228 Dict.229 Dict.240 Dict.241 Dict.232 Dict.233 Dict.234 Dict.235 Dict.236; else - dec Dict.410; - let Dict.848 : {U64, U32} = Struct {Dict.411, Dict.412}; - ret Dict.848; + let Dict.777 : U32 = StructAtIndex 1 Dict.237; + let Dict.757 : Int1 = CallByName Num.24 Dict.231 Dict.777; + if Dict.757 then + let Dict.776 : {Str, I64} = Struct {Dict.232, Dict.233}; + let Dict.242 : List {Str, I64} = CallByName List.4 Dict.229 Dict.776; + let Dict.774 : U64 = CallByName List.6 Dict.242; + let Dict.775 : U64 = 1i64; + let Dict.243 : U64 = CallByName Num.75 Dict.774 Dict.775; + let Dict.773 : U32 = CallByName Num.131 Dict.243; + let Dict.759 : {U32, U32} = Struct {Dict.773, Dict.231}; + let Dict.244 : List {U32, U32} = CallByName Dict.74 Dict.228 Dict.759 Dict.230; + let Dict.758 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = Struct {Dict.244, Dict.242, Dict.234, Dict.235, Dict.236}; + ret Dict.758; + else + let Dict.750 : U64 = CallByName List.6 Dict.228; + let Dict.245 : U64 = CallByName Dict.75 Dict.230 Dict.750; + let Dict.246 : U32 = CallByName Dict.55 Dict.231; + jump Dict.743 Dict.228 Dict.229 Dict.245 Dict.246 Dict.232 Dict.233 Dict.234 Dict.235 Dict.236; in - inc #Derived_gen.40; - jump Dict.847 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42; + inc #Derived_gen.46; + jump Dict.743 #Derived_gen.42 #Derived_gen.43 #Derived_gen.44 #Derived_gen.45 #Derived_gen.46 #Derived_gen.47 #Derived_gen.48 #Derived_gen.49 #Derived_gen.50; -procedure Dict.67 (#Derived_gen.28, #Derived_gen.29, #Derived_gen.30): - joinpoint Dict.753 Dict.414 Dict.415 Dict.416: - let Dict.417 : {U32, U32} = CallByName Dict.22 Dict.414 Dict.416; - let Dict.763 : U32 = StructAtIndex 1 Dict.417; - let Dict.764 : U32 = 0i64; - let Dict.755 : Int1 = CallByName Bool.7 Dict.763 Dict.764; - if Dict.755 then - let Dict.418 : List {U32, U32} = CallByName List.3 Dict.414 Dict.416 Dict.415; - let Dict.760 : U32 = StructAtIndex 0 Dict.417; - let Dict.761 : U32 = StructAtIndex 1 Dict.417; - let Dict.762 : U32 = CallByName Dict.48 Dict.761; - let Dict.757 : {U32, U32} = Struct {Dict.760, Dict.762}; - let Dict.759 : U64 = CallByName List.6 Dict.418; - let Dict.758 : U64 = CallByName Dict.68 Dict.416 Dict.759; - jump Dict.753 Dict.418 Dict.757 Dict.758; - else - let Dict.754 : List {U32, U32} = CallByName List.3 Dict.414 Dict.416 Dict.415; - ret Dict.754; - in - jump Dict.753 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; +procedure Dict.48 (): + let Dict.867 : U32 = 0i64; + let Dict.868 : U32 = 0i64; + let Dict.866 : {U32, U32} = Struct {Dict.867, Dict.868}; + ret Dict.866; -procedure Dict.68 (Dict.419, Dict.420): - let Dict.749 : U64 = 1i64; - let Dict.748 : U64 = CallByName Num.51 Dict.419 Dict.749; - let Dict.745 : Int1 = CallByName Bool.7 Dict.748 Dict.420; - if Dict.745 then - let Dict.747 : U64 = 1i64; - let Dict.746 : U64 = CallByName Num.51 Dict.419 Dict.747; - ret Dict.746; - else - let Dict.744 : U64 = 0i64; - ret Dict.744; +procedure Dict.49 (): + let Dict.748 : U32 = 1i64; + let Dict.749 : U8 = 8i64; + let Dict.747 : U32 = CallByName Num.72 Dict.748 Dict.749; + ret Dict.747; -procedure Dict.69 (Dict.421): - let Dict.797 : [C , C U64] = TagId(0) ; - let Dict.796 : {U64, U64} = CallByName Dict.73 Dict.797; - let Dict.794 : {U64, U64} = CallByName Hash.19 Dict.796 Dict.421; - let Dict.793 : U64 = CallByName Dict.76 Dict.794; - ret Dict.793; +procedure Dict.50 (): + let Dict.798 : U32 = CallByName Dict.49; + let Dict.799 : U32 = 1i64; + let Dict.797 : U32 = CallByName Num.75 Dict.798 Dict.799; + ret Dict.797; -procedure Dict.70 (Dict.423): - let Dict.788 : U32 = CallByName Num.131 Dict.423; - let Dict.789 : U32 = CallByName Dict.43; - let Dict.786 : U32 = CallByName Num.69 Dict.788 Dict.789; - let Dict.787 : U32 = CallByName Dict.42; - let Dict.785 : U32 = CallByName Num.71 Dict.786 Dict.787; - ret Dict.785; +procedure Dict.51 (): + let Dict.898 : Float32 = 0.8f64; + ret Dict.898; -procedure Dict.71 (Dict.424, Dict.425): - let Dict.784 : U64 = CallByName Num.74 Dict.424 Dict.425; - ret Dict.784; - -procedure Dict.73 (Dict.427): - joinpoint Dict.814 Dict.428: - let Dict.799 : U64 = CallByName Dict.75 Dict.428; - let Dict.798 : {U64, U64} = Struct {Dict.799, Dict.428}; - ret Dict.798; - in - let Dict.819 : U8 = 0i64; - let Dict.820 : U8 = GetTagId Dict.427; - let Dict.821 : Int1 = lowlevel Eq Dict.819 Dict.820; - if Dict.821 then - let Dict.816 : {} = Struct {}; - let Dict.815 : U64 = CallByName Dict.23 Dict.816; - jump Dict.814 Dict.815; - else - let Dict.429 : U64 = UnionAtIndex (Id 1) (Index 0) Dict.427; - jump Dict.814 Dict.429; - -procedure Dict.74 (Dict.708, Dict.709): - let Dict.432 : U64 = StructAtIndex 0 Dict.709; - let Dict.433 : U64 = StructAtIndex 1 Dict.709; - let Dict.435 : U64 = StructAtIndex 2 Dict.709; - let Dict.434 : U64 = StructAtIndex 3 Dict.709; - let Dict.430 : U64 = StructAtIndex 0 Dict.708; - let Dict.431 : U64 = StructAtIndex 1 Dict.708; - let Dict.913 : U64 = CallByName Dict.86; - let Dict.911 : U64 = CallByName Num.70 Dict.432 Dict.913; - let Dict.912 : U64 = CallByName Num.70 Dict.433 Dict.434; - let Dict.436 : {U64, U64} = CallByName Dict.90 Dict.911 Dict.912; - let Dict.908 : U64 = StructAtIndex 0 Dict.436; - let Dict.909 : U64 = CallByName Dict.85; - let Dict.907 : U64 = CallByName Num.70 Dict.908 Dict.909; - let Dict.437 : U64 = CallByName Num.70 Dict.907 Dict.435; - let Dict.904 : U64 = StructAtIndex 1 Dict.436; - let Dict.905 : U64 = CallByName Dict.86; - let Dict.438 : U64 = CallByName Num.70 Dict.904 Dict.905; - let Dict.439 : U64 = CallByName Dict.89 Dict.437 Dict.438; - let Dict.896 : U64 = CallByName Dict.89 Dict.431 Dict.439; - let Dict.895 : {U64, U64} = Struct {Dict.430, Dict.896}; +procedure Dict.52 (): + let Dict.896 : U8 = 64i64; + let Dict.897 : U8 = 3i64; + let Dict.895 : U8 = CallByName Num.75 Dict.896 Dict.897; ret Dict.895; -procedure Dict.75 (Dict.440): - let Dict.812 : U64 = CallByName Dict.85; - let Dict.802 : U64 = CallByName Num.70 Dict.440 Dict.812; - let Dict.803 : U64 = CallByName Dict.86; - let Dict.801 : U64 = CallByName Dict.89 Dict.802 Dict.803; - let Dict.800 : U64 = CallByName Num.70 Dict.801 Dict.440; +procedure Dict.53 (): + let Dict.841 : U64 = 1i64; + let Dict.842 : U8 = 32i64; + let Dict.840 : U64 = CallByName Num.72 Dict.841 Dict.842; + ret Dict.840; + +procedure Dict.54 (): + let Dict.839 : U64 = CallByName Dict.53; + ret Dict.839; + +procedure Dict.55 (Dict.313): + let Dict.746 : U32 = CallByName Dict.49; + let Dict.745 : U32 = CallByName Num.51 Dict.313 Dict.746; + ret Dict.745; + +procedure Dict.66 (Dict.726): + let Dict.383 : List {Str, I64} = StructAtIndex 1 Dict.726; + let Dict.384 : U64 = StructAtIndex 2 Dict.726; + let Dict.385 : Float32 = StructAtIndex 3 Dict.726; + let Dict.386 : U8 = StructAtIndex 4 Dict.726; + let #Derived_gen.68 : List {U32, U32} = StructAtIndex 0 Dict.726; + dec #Derived_gen.68; + let Dict.884 : U64 = CallByName Dict.54; + let Dict.843 : Int1 = CallByName Bool.7 Dict.384 Dict.884; + if Dict.843 then + let Dict.883 : U8 = 1i64; + let Dict.387 : U8 = CallByName Num.75 Dict.386 Dict.883; + let Dict.862 : {List {U32, U32}, U64} = CallByName Dict.67 Dict.387 Dict.385; + let Dict.388 : List {U32, U32} = StructAtIndex 0 Dict.862; + let Dict.389 : U64 = StructAtIndex 1 Dict.862; + let Dict.390 : List {U32, U32} = CallByName Dict.71 Dict.388 Dict.383 Dict.387; + let Dict.844 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = Struct {Dict.390, Dict.383, Dict.389, Dict.385, Dict.387}; + ret Dict.844; + else + dec Dict.383; + let Dict.834 : Str = "Dict hit limit of "; + let Dict.838 : U64 = CallByName Dict.54; + let Dict.836 : Str = CallByName Num.96 Dict.838; + let Dict.837 : Str = " elements. Unable to grow more."; + let Dict.835 : Str = CallByName Str.3 Dict.836 Dict.837; + dec Dict.837; + let Dict.833 : Str = CallByName Str.3 Dict.834 Dict.835; + dec Dict.835; + Crash Dict.833 + +procedure Dict.67 (Dict.391, Dict.392): + let Dict.393 : U64 = CallByName Dict.70 Dict.391; + let Dict.876 : U64 = CallByName Dict.54; + let Dict.871 : Int1 = CallByName Bool.11 Dict.393 Dict.876; + if Dict.871 then + let Dict.874 : {U32, U32} = CallByName Dict.48; + let Dict.875 : U64 = CallByName Dict.54; + let Dict.873 : List {U32, U32} = CallByName List.11 Dict.874 Dict.875; + let Dict.54 : U64 = CallByName Dict.54; + let Dict.872 : {List {U32, U32}, U64} = Struct {Dict.873, Dict.54}; + ret Dict.872; + else + let Dict.870 : Float32 = CallByName Num.139 Dict.393; + let Dict.869 : Float32 = CallByName Num.21 Dict.870 Dict.392; + let Dict.394 : U64 = CallByName Num.50 Dict.869; + let Dict.865 : {U32, U32} = CallByName Dict.48; + let Dict.864 : List {U32, U32} = CallByName List.11 Dict.865 Dict.393; + let Dict.863 : {List {U32, U32}, U64} = Struct {Dict.864, Dict.394}; + ret Dict.863; + +procedure Dict.70 (Dict.401): + let Dict.880 : U64 = 1i64; + let Dict.882 : U8 = 64i64; + let Dict.881 : U8 = CallByName Num.75 Dict.882 Dict.401; + let Dict.878 : U64 = CallByName Num.72 Dict.880 Dict.881; + let Dict.879 : U64 = CallByName Dict.54; + let Dict.877 : U64 = CallByName Num.148 Dict.878 Dict.879; + ret Dict.877; + +procedure Dict.71 (Dict.402, Dict.403, Dict.404): + let Dict.845 : List {U32, U32} = CallByName List.83 Dict.403 Dict.402 Dict.404; + ret Dict.845; + +procedure Dict.72 (Dict.411, Dict.412, Dict.413): + let Dict.414 : U64 = CallByName Dict.76 Dict.412; + let Dict.415 : U32 = CallByName Dict.77 Dict.414; + let Dict.416 : U64 = CallByName Dict.78 Dict.414 Dict.413; + let Dict.853 : {U64, U32} = CallByName Dict.73 Dict.411 Dict.416 Dict.415; + ret Dict.853; + +procedure Dict.73 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18): + joinpoint Dict.854 Dict.417 Dict.418 Dict.419: + let Dict.420 : {U32, U32} = CallByName Dict.22 Dict.417 Dict.418; + let Dict.861 : U32 = StructAtIndex 1 Dict.420; + let Dict.856 : Int1 = CallByName Num.22 Dict.419 Dict.861; + if Dict.856 then + let Dict.860 : U64 = CallByName List.6 Dict.417; + let Dict.858 : U64 = CallByName Dict.75 Dict.418 Dict.860; + let Dict.859 : U32 = CallByName Dict.55 Dict.419; + jump Dict.854 Dict.417 Dict.858 Dict.859; + else + dec Dict.417; + let Dict.855 : {U64, U32} = Struct {Dict.418, Dict.419}; + ret Dict.855; + in + inc #Derived_gen.16; + jump Dict.854 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; + +procedure Dict.74 (#Derived_gen.51, #Derived_gen.52, #Derived_gen.53): + joinpoint Dict.760 Dict.421 Dict.422 Dict.423: + let Dict.424 : {U32, U32} = CallByName Dict.22 Dict.421 Dict.423; + let Dict.770 : U32 = StructAtIndex 1 Dict.424; + let Dict.771 : U32 = 0i64; + let Dict.762 : Int1 = CallByName Bool.7 Dict.770 Dict.771; + if Dict.762 then + let Dict.425 : List {U32, U32} = CallByName List.3 Dict.421 Dict.423 Dict.422; + let Dict.767 : U32 = StructAtIndex 0 Dict.424; + let Dict.768 : U32 = StructAtIndex 1 Dict.424; + let Dict.769 : U32 = CallByName Dict.55 Dict.768; + let Dict.764 : {U32, U32} = Struct {Dict.767, Dict.769}; + let Dict.766 : U64 = CallByName List.6 Dict.425; + let Dict.765 : U64 = CallByName Dict.75 Dict.423 Dict.766; + jump Dict.760 Dict.425 Dict.764 Dict.765; + else + let Dict.761 : List {U32, U32} = CallByName List.3 Dict.421 Dict.423 Dict.422; + ret Dict.761; + in + jump Dict.760 #Derived_gen.51 #Derived_gen.52 #Derived_gen.53; + +procedure Dict.75 (Dict.426, Dict.427): + let Dict.756 : U64 = 1i64; + let Dict.755 : U64 = CallByName Num.51 Dict.426 Dict.756; + let Dict.752 : Int1 = CallByName Bool.7 Dict.755 Dict.427; + if Dict.752 then + let Dict.754 : U64 = 1i64; + let Dict.753 : U64 = CallByName Num.51 Dict.426 Dict.754; + ret Dict.753; + else + let Dict.751 : U64 = 0i64; + ret Dict.751; + +procedure Dict.76 (Dict.428): + let Dict.804 : [C , C U64] = TagId(0) ; + let Dict.803 : {U64, U64} = CallByName Dict.80 Dict.804; + let Dict.801 : {U64, U64} = CallByName Hash.19 Dict.803 Dict.428; + let Dict.800 : U64 = CallByName Dict.83 Dict.801; ret Dict.800; -procedure Dict.76 (Dict.727): - let Dict.441 : U64 = StructAtIndex 1 Dict.727; - ret Dict.441; +procedure Dict.77 (Dict.430): + let Dict.795 : U32 = CallByName Num.131 Dict.430; + let Dict.796 : U32 = CallByName Dict.50; + let Dict.793 : U32 = CallByName Num.69 Dict.795 Dict.796; + let Dict.794 : U32 = CallByName Dict.49; + let Dict.792 : U32 = CallByName Num.71 Dict.793 Dict.794; + ret Dict.792; -procedure Dict.8 (Dict.210, Dict.211, Dict.212): - joinpoint Dict.824 Dict.822: - let Dict.213 : List {U32, U32} = StructAtIndex 0 Dict.822; - let Dict.214 : List {Str, I64} = StructAtIndex 1 Dict.822; - let Dict.215 : U64 = StructAtIndex 2 Dict.822; - let Dict.216 : Float32 = StructAtIndex 3 Dict.822; - let Dict.217 : U8 = StructAtIndex 4 Dict.822; - inc Dict.211; - let Dict.218 : U64 = CallByName Dict.69 Dict.211; - let Dict.219 : U32 = CallByName Dict.70 Dict.218; - let Dict.220 : U64 = CallByName Dict.71 Dict.218 Dict.217; - let Dict.735 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.38 Dict.213 Dict.214 Dict.220 Dict.219 Dict.211 Dict.212 Dict.215 Dict.216 Dict.217; - dec Dict.211; - ret Dict.735; +procedure Dict.78 (Dict.431, Dict.432): + let Dict.791 : U64 = CallByName Num.74 Dict.431 Dict.432; + ret Dict.791; + +procedure Dict.8 (Dict.217, Dict.218, Dict.219): + joinpoint Dict.831 Dict.829: + let Dict.220 : List {U32, U32} = StructAtIndex 0 Dict.829; + let Dict.221 : List {Str, I64} = StructAtIndex 1 Dict.829; + let Dict.222 : U64 = StructAtIndex 2 Dict.829; + let Dict.223 : Float32 = StructAtIndex 3 Dict.829; + let Dict.224 : U8 = StructAtIndex 4 Dict.829; + inc Dict.218; + let Dict.225 : U64 = CallByName Dict.76 Dict.218; + let Dict.226 : U32 = CallByName Dict.77 Dict.225; + let Dict.227 : U64 = CallByName Dict.78 Dict.225 Dict.224; + let Dict.742 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.45 Dict.220 Dict.221 Dict.227 Dict.226 Dict.218 Dict.219 Dict.222 Dict.223 Dict.224; + dec Dict.218; + ret Dict.742; in - inc 2 Dict.210; - let Dict.879 : U64 = CallByName Dict.4 Dict.210; - let Dict.880 : U64 = CallByName Dict.20 Dict.210; - let Dict.878 : Int1 = CallByName Num.22 Dict.879 Dict.880; - if Dict.878 then - jump Dict.824 Dict.210; + inc 2 Dict.217; + let Dict.886 : U64 = CallByName Dict.4 Dict.217; + let Dict.887 : U64 = CallByName Dict.20 Dict.217; + let Dict.885 : Int1 = CallByName Num.22 Dict.886 Dict.887; + if Dict.885 then + jump Dict.831 Dict.217; else - let Dict.823 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.59 Dict.210; - jump Dict.824 Dict.823; + let Dict.830 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.66 Dict.217; + jump Dict.831 Dict.830; -procedure Dict.82 (Dict.702, Dict.480): - let Dict.478 : U64 = StructAtIndex 0 Dict.702; - let Dict.479 : U64 = StructAtIndex 1 Dict.702; - let Dict.481 : U64 = CallByName List.6 Dict.480; - joinpoint Dict.918 Dict.482: - let Dict.893 : {U64, U64} = Struct {Dict.478, Dict.479}; - let Dict.914 : U64 = StructAtIndex 0 Dict.482; - let Dict.915 : U64 = StructAtIndex 1 Dict.482; - let Dict.916 : U64 = StructAtIndex 2 Dict.482; - let Dict.894 : {U64, U64, U64, U64} = Struct {Dict.914, Dict.915, Dict.481, Dict.916}; - let Dict.892 : {U64, U64} = CallByName Dict.74 Dict.893 Dict.894; - ret Dict.892; +procedure Dict.80 (Dict.434): + joinpoint Dict.821 Dict.435: + let Dict.806 : U64 = CallByName Dict.82 Dict.435; + let Dict.805 : {U64, U64} = Struct {Dict.806, Dict.435}; + ret Dict.805; in - let Dict.1092 : U64 = 16i64; - let Dict.1032 : Int1 = CallByName Num.23 Dict.481 Dict.1092; - if Dict.1032 then - joinpoint Dict.1034 Dict.917: - jump Dict.918 Dict.917; + let Dict.826 : U8 = 0i64; + let Dict.827 : U8 = GetTagId Dict.434; + let Dict.828 : Int1 = lowlevel Eq Dict.826 Dict.827; + if Dict.828 then + let Dict.823 : {} = Struct {}; + let Dict.822 : U64 = CallByName Dict.23 Dict.823; + jump Dict.821 Dict.822; + else + let Dict.436 : U64 = UnionAtIndex (Id 1) (Index 0) Dict.434; + jump Dict.821 Dict.436; + +procedure Dict.81 (Dict.715, Dict.716): + let Dict.439 : U64 = StructAtIndex 0 Dict.716; + let Dict.440 : U64 = StructAtIndex 1 Dict.716; + let Dict.442 : U64 = StructAtIndex 2 Dict.716; + let Dict.441 : U64 = StructAtIndex 3 Dict.716; + let Dict.437 : U64 = StructAtIndex 0 Dict.715; + let Dict.438 : U64 = StructAtIndex 1 Dict.715; + let Dict.920 : U64 = CallByName Dict.93; + let Dict.918 : U64 = CallByName Num.70 Dict.439 Dict.920; + let Dict.919 : U64 = CallByName Num.70 Dict.440 Dict.441; + let Dict.443 : {U64, U64} = CallByName Dict.97 Dict.918 Dict.919; + let Dict.915 : U64 = StructAtIndex 0 Dict.443; + let Dict.916 : U64 = CallByName Dict.92; + let Dict.914 : U64 = CallByName Num.70 Dict.915 Dict.916; + let Dict.444 : U64 = CallByName Num.70 Dict.914 Dict.442; + let Dict.911 : U64 = StructAtIndex 1 Dict.443; + let Dict.912 : U64 = CallByName Dict.93; + let Dict.445 : U64 = CallByName Num.70 Dict.911 Dict.912; + let Dict.446 : U64 = CallByName Dict.96 Dict.444 Dict.445; + let Dict.903 : U64 = CallByName Dict.96 Dict.438 Dict.446; + let Dict.902 : {U64, U64} = Struct {Dict.437, Dict.903}; + ret Dict.902; + +procedure Dict.82 (Dict.447): + let Dict.819 : U64 = CallByName Dict.92; + let Dict.809 : U64 = CallByName Num.70 Dict.447 Dict.819; + let Dict.810 : U64 = CallByName Dict.93; + let Dict.808 : U64 = CallByName Dict.96 Dict.809 Dict.810; + let Dict.807 : U64 = CallByName Num.70 Dict.808 Dict.447; + ret Dict.807; + +procedure Dict.83 (Dict.734): + let Dict.448 : U64 = StructAtIndex 1 Dict.734; + ret Dict.448; + +procedure Dict.89 (Dict.709, Dict.487): + let Dict.485 : U64 = StructAtIndex 0 Dict.709; + let Dict.486 : U64 = StructAtIndex 1 Dict.709; + let Dict.488 : U64 = CallByName List.6 Dict.487; + joinpoint Dict.925 Dict.489: + let Dict.900 : {U64, U64} = Struct {Dict.485, Dict.486}; + let Dict.921 : U64 = StructAtIndex 0 Dict.489; + let Dict.922 : U64 = StructAtIndex 1 Dict.489; + let Dict.923 : U64 = StructAtIndex 2 Dict.489; + let Dict.901 : {U64, U64, U64, U64} = Struct {Dict.921, Dict.922, Dict.488, Dict.923}; + let Dict.899 : {U64, U64} = CallByName Dict.81 Dict.900 Dict.901; + ret Dict.899; + in + let Dict.1099 : U64 = 16i64; + let Dict.1039 : Int1 = CallByName Num.23 Dict.488 Dict.1099; + if Dict.1039 then + joinpoint Dict.1041 Dict.924: + jump Dict.925 Dict.924; in - let Dict.1091 : U64 = 4i64; - let Dict.1056 : Int1 = CallByName Num.25 Dict.481 Dict.1091; - if Dict.1056 then - let Dict.1090 : U8 = 3i64; - let Dict.1088 : U64 = CallByName Num.74 Dict.481 Dict.1090; - let Dict.1089 : U8 = 2i64; - let Dict.483 : U64 = CallByName Num.72 Dict.1088 Dict.1089; - let Dict.1087 : U64 = 0i64; - let Dict.1085 : U64 = CallByName Dict.92 Dict.480 Dict.1087; - let Dict.1086 : U8 = 32i64; - let Dict.1083 : U64 = CallByName Num.72 Dict.1085 Dict.1086; - let Dict.1084 : U64 = CallByName Dict.92 Dict.480 Dict.483; - let Dict.484 : U64 = CallByName Num.71 Dict.1083 Dict.1084; - let Dict.1082 : U64 = 4i64; - let Dict.1081 : U64 = CallByName Num.75 Dict.481 Dict.1082; - let Dict.1079 : U64 = CallByName Dict.92 Dict.480 Dict.1081; - let Dict.1080 : U8 = 32i64; - let Dict.1057 : U64 = CallByName Num.72 Dict.1079 Dict.1080; - let Dict.1078 : U64 = 4i64; - let Dict.1077 : U64 = CallByName Num.75 Dict.481 Dict.1078; - let Dict.1059 : U64 = CallByName Num.75 Dict.1077 Dict.483; - let Dict.1058 : U64 = CallByName Dict.92 Dict.480 Dict.1059; - let Dict.485 : U64 = CallByName Num.71 Dict.1057 Dict.1058; - let Dict.1033 : {U64, U64, U64} = Struct {Dict.484, Dict.485, Dict.478}; - jump Dict.1034 Dict.1033; + let Dict.1098 : U64 = 4i64; + let Dict.1063 : Int1 = CallByName Num.25 Dict.488 Dict.1098; + if Dict.1063 then + let Dict.1097 : U8 = 3i64; + let Dict.1095 : U64 = CallByName Num.74 Dict.488 Dict.1097; + let Dict.1096 : U8 = 2i64; + let Dict.490 : U64 = CallByName Num.72 Dict.1095 Dict.1096; + let Dict.1094 : U64 = 0i64; + let Dict.1092 : U64 = CallByName Dict.99 Dict.487 Dict.1094; + let Dict.1093 : U8 = 32i64; + let Dict.1090 : U64 = CallByName Num.72 Dict.1092 Dict.1093; + let Dict.1091 : U64 = CallByName Dict.99 Dict.487 Dict.490; + let Dict.491 : U64 = CallByName Num.71 Dict.1090 Dict.1091; + let Dict.1089 : U64 = 4i64; + let Dict.1088 : U64 = CallByName Num.75 Dict.488 Dict.1089; + let Dict.1086 : U64 = CallByName Dict.99 Dict.487 Dict.1088; + let Dict.1087 : U8 = 32i64; + let Dict.1064 : U64 = CallByName Num.72 Dict.1086 Dict.1087; + let Dict.1085 : U64 = 4i64; + let Dict.1084 : U64 = CallByName Num.75 Dict.488 Dict.1085; + let Dict.1066 : U64 = CallByName Num.75 Dict.1084 Dict.490; + let Dict.1065 : U64 = CallByName Dict.99 Dict.487 Dict.1066; + let Dict.492 : U64 = CallByName Num.71 Dict.1064 Dict.1065; + let Dict.1040 : {U64, U64, U64} = Struct {Dict.491, Dict.492, Dict.485}; + jump Dict.1041 Dict.1040; else - let Dict.1055 : U64 = 0i64; - let Dict.1037 : Int1 = CallByName Num.24 Dict.481 Dict.1055; - if Dict.1037 then - let Dict.1040 : U64 = 0i64; - let Dict.1038 : U64 = CallByName Dict.93 Dict.480 Dict.1040 Dict.481; - let Dict.1039 : U64 = 0i64; - let Dict.1033 : {U64, U64, U64} = Struct {Dict.1038, Dict.1039, Dict.478}; - jump Dict.1034 Dict.1033; + let Dict.1062 : U64 = 0i64; + let Dict.1044 : Int1 = CallByName Num.24 Dict.488 Dict.1062; + if Dict.1044 then + let Dict.1047 : U64 = 0i64; + let Dict.1045 : U64 = CallByName Dict.100 Dict.487 Dict.1047 Dict.488; + let Dict.1046 : U64 = 0i64; + let Dict.1040 : {U64, U64, U64} = Struct {Dict.1045, Dict.1046, Dict.485}; + jump Dict.1041 Dict.1040; else - let Dict.1035 : U64 = 0i64; - let Dict.1036 : U64 = 0i64; - let Dict.1033 : {U64, U64, U64} = Struct {Dict.1035, Dict.1036, Dict.478}; - jump Dict.1034 Dict.1033; + let Dict.1042 : U64 = 0i64; + let Dict.1043 : U64 = 0i64; + let Dict.1040 : {U64, U64, U64} = Struct {Dict.1042, Dict.1043, Dict.485}; + jump Dict.1041 Dict.1040; else - let Dict.1031 : U64 = 48i64; - let Dict.1029 : Int1 = CallByName Num.23 Dict.481 Dict.1031; - if Dict.1029 then - let Dict.1030 : U64 = 0i64; - let Dict.917 : {U64, U64, U64} = CallByName Dict.84 Dict.478 Dict.480 Dict.1030 Dict.481; - jump Dict.918 Dict.917; + let Dict.1038 : U64 = 48i64; + let Dict.1036 : Int1 = CallByName Num.23 Dict.488 Dict.1038; + if Dict.1036 then + let Dict.1037 : U64 = 0i64; + let Dict.924 : {U64, U64, U64} = CallByName Dict.91 Dict.485 Dict.487 Dict.1037 Dict.488; + jump Dict.925 Dict.924; else - let Dict.919 : U64 = 0i64; - let Dict.917 : {U64, U64, U64} = CallByName Dict.83 Dict.478 Dict.478 Dict.478 Dict.480 Dict.919 Dict.481; - jump Dict.918 Dict.917; + let Dict.926 : U64 = 0i64; + let Dict.924 : {U64, U64, U64} = CallByName Dict.90 Dict.485 Dict.485 Dict.485 Dict.487 Dict.926 Dict.488; + jump Dict.925 Dict.924; -procedure Dict.83 (#Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): - joinpoint Dict.920 Dict.486 Dict.487 Dict.488 Dict.489 Dict.490 Dict.491: - let Dict.1027 : U64 = CallByName Dict.91 Dict.489 Dict.490; - let Dict.1028 : U64 = CallByName Dict.86; - let Dict.1022 : U64 = CallByName Num.70 Dict.1027 Dict.1028; - let Dict.1026 : U64 = 8i64; - let Dict.1025 : U64 = CallByName Num.51 Dict.490 Dict.1026; - let Dict.1024 : U64 = CallByName Dict.91 Dict.489 Dict.1025; - let Dict.1023 : U64 = CallByName Num.70 Dict.1024 Dict.486; - let Dict.492 : U64 = CallByName Dict.89 Dict.1022 Dict.1023; - let Dict.1021 : U64 = 16i64; - let Dict.1020 : U64 = CallByName Num.51 Dict.490 Dict.1021; - let Dict.1017 : U64 = CallByName Dict.91 Dict.489 Dict.1020; - let Dict.1018 : U64 = CallByName Dict.87; - let Dict.1012 : U64 = CallByName Num.70 Dict.1017 Dict.1018; - let Dict.1016 : U64 = 24i64; - let Dict.1015 : U64 = CallByName Num.51 Dict.490 Dict.1016; - let Dict.1014 : U64 = CallByName Dict.91 Dict.489 Dict.1015; - let Dict.1013 : U64 = CallByName Num.70 Dict.1014 Dict.487; - let Dict.493 : U64 = CallByName Dict.89 Dict.1012 Dict.1013; - let Dict.1011 : U64 = 32i64; - let Dict.1010 : U64 = CallByName Num.51 Dict.490 Dict.1011; - let Dict.1007 : U64 = CallByName Dict.91 Dict.489 Dict.1010; - let Dict.1008 : U64 = CallByName Dict.88; - let Dict.1002 : U64 = CallByName Num.70 Dict.1007 Dict.1008; - let Dict.1006 : U64 = 40i64; - let Dict.1005 : U64 = CallByName Num.51 Dict.490 Dict.1006; - let Dict.1004 : U64 = CallByName Dict.91 Dict.489 Dict.1005; - let Dict.1003 : U64 = CallByName Num.70 Dict.1004 Dict.488; - let Dict.494 : U64 = CallByName Dict.89 Dict.1002 Dict.1003; - let Dict.1001 : U64 = 48i64; - let Dict.495 : U64 = CallByName Num.75 Dict.491 Dict.1001; - let Dict.1000 : U64 = 48i64; - let Dict.496 : U64 = CallByName Num.51 Dict.490 Dict.1000; - let Dict.999 : U64 = 48i64; - let Dict.997 : Int1 = CallByName Num.24 Dict.495 Dict.999; - if Dict.997 then - jump Dict.920 Dict.492 Dict.493 Dict.494 Dict.489 Dict.496 Dict.495; +procedure Dict.90 (#Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11): + joinpoint Dict.927 Dict.493 Dict.494 Dict.495 Dict.496 Dict.497 Dict.498: + let Dict.1034 : U64 = CallByName Dict.98 Dict.496 Dict.497; + let Dict.1035 : U64 = CallByName Dict.93; + let Dict.1029 : U64 = CallByName Num.70 Dict.1034 Dict.1035; + let Dict.1033 : U64 = 8i64; + let Dict.1032 : U64 = CallByName Num.51 Dict.497 Dict.1033; + let Dict.1031 : U64 = CallByName Dict.98 Dict.496 Dict.1032; + let Dict.1030 : U64 = CallByName Num.70 Dict.1031 Dict.493; + let Dict.499 : U64 = CallByName Dict.96 Dict.1029 Dict.1030; + let Dict.1028 : U64 = 16i64; + let Dict.1027 : U64 = CallByName Num.51 Dict.497 Dict.1028; + let Dict.1024 : U64 = CallByName Dict.98 Dict.496 Dict.1027; + let Dict.1025 : U64 = CallByName Dict.94; + let Dict.1019 : U64 = CallByName Num.70 Dict.1024 Dict.1025; + let Dict.1023 : U64 = 24i64; + let Dict.1022 : U64 = CallByName Num.51 Dict.497 Dict.1023; + let Dict.1021 : U64 = CallByName Dict.98 Dict.496 Dict.1022; + let Dict.1020 : U64 = CallByName Num.70 Dict.1021 Dict.494; + let Dict.500 : U64 = CallByName Dict.96 Dict.1019 Dict.1020; + let Dict.1018 : U64 = 32i64; + let Dict.1017 : U64 = CallByName Num.51 Dict.497 Dict.1018; + let Dict.1014 : U64 = CallByName Dict.98 Dict.496 Dict.1017; + let Dict.1015 : U64 = CallByName Dict.95; + let Dict.1009 : U64 = CallByName Num.70 Dict.1014 Dict.1015; + let Dict.1013 : U64 = 40i64; + let Dict.1012 : U64 = CallByName Num.51 Dict.497 Dict.1013; + let Dict.1011 : U64 = CallByName Dict.98 Dict.496 Dict.1012; + let Dict.1010 : U64 = CallByName Num.70 Dict.1011 Dict.495; + let Dict.501 : U64 = CallByName Dict.96 Dict.1009 Dict.1010; + let Dict.1008 : U64 = 48i64; + let Dict.502 : U64 = CallByName Num.75 Dict.498 Dict.1008; + let Dict.1007 : U64 = 48i64; + let Dict.503 : U64 = CallByName Num.51 Dict.497 Dict.1007; + let Dict.1006 : U64 = 48i64; + let Dict.1004 : Int1 = CallByName Num.24 Dict.502 Dict.1006; + if Dict.1004 then + jump Dict.927 Dict.499 Dict.500 Dict.501 Dict.496 Dict.503 Dict.502; else - let Dict.996 : U64 = 16i64; - let Dict.971 : Int1 = CallByName Num.24 Dict.495 Dict.996; - if Dict.971 then - let Dict.995 : U64 = CallByName Num.70 Dict.493 Dict.492; - let Dict.497 : U64 = CallByName Num.70 Dict.494 Dict.995; - let Dict.972 : {U64, U64, U64} = CallByName Dict.84 Dict.497 Dict.489 Dict.496 Dict.495; - dec Dict.489; - ret Dict.972; + let Dict.1003 : U64 = 16i64; + let Dict.978 : Int1 = CallByName Num.24 Dict.502 Dict.1003; + if Dict.978 then + let Dict.1002 : U64 = CallByName Num.70 Dict.500 Dict.499; + let Dict.504 : U64 = CallByName Num.70 Dict.501 Dict.1002; + let Dict.979 : {U64, U64, U64} = CallByName Dict.91 Dict.504 Dict.496 Dict.503 Dict.502; + dec Dict.496; + ret Dict.979; else - let Dict.970 : U64 = CallByName Num.70 Dict.493 Dict.492; - let Dict.498 : U64 = CallByName Num.70 Dict.494 Dict.970; - let Dict.969 : U64 = 16i64; - let Dict.968 : U64 = CallByName Num.75 Dict.495 Dict.969; - let Dict.967 : U64 = CallByName Num.51 Dict.968 Dict.496; - let Dict.922 : U64 = CallByName Dict.91 Dict.489 Dict.967; - let Dict.966 : U64 = 8i64; - let Dict.965 : U64 = CallByName Num.75 Dict.495 Dict.966; - let Dict.924 : U64 = CallByName Num.51 Dict.965 Dict.496; - let Dict.923 : U64 = CallByName Dict.91 Dict.489 Dict.924; - dec Dict.489; - let Dict.921 : {U64, U64, U64} = Struct {Dict.922, Dict.923, Dict.498}; - ret Dict.921; + let Dict.977 : U64 = CallByName Num.70 Dict.500 Dict.499; + let Dict.505 : U64 = CallByName Num.70 Dict.501 Dict.977; + let Dict.976 : U64 = 16i64; + let Dict.975 : U64 = CallByName Num.75 Dict.502 Dict.976; + let Dict.974 : U64 = CallByName Num.51 Dict.975 Dict.503; + let Dict.929 : U64 = CallByName Dict.98 Dict.496 Dict.974; + let Dict.973 : U64 = 8i64; + let Dict.972 : U64 = CallByName Num.75 Dict.502 Dict.973; + let Dict.931 : U64 = CallByName Num.51 Dict.972 Dict.503; + let Dict.930 : U64 = CallByName Dict.98 Dict.496 Dict.931; + dec Dict.496; + let Dict.928 : {U64, U64, U64} = Struct {Dict.929, Dict.930, Dict.505}; + ret Dict.928; in - inc #Derived_gen.12; - jump Dict.920 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; + inc #Derived_gen.9; + jump Dict.927 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11; -procedure Dict.84 (#Derived_gen.43, #Derived_gen.44, #Derived_gen.45, #Derived_gen.46): - joinpoint Dict.973 Dict.499 Dict.500 Dict.501 Dict.502: - let Dict.993 : U64 = CallByName Dict.91 Dict.500 Dict.501; - let Dict.994 : U64 = CallByName Dict.86; - let Dict.988 : U64 = CallByName Num.70 Dict.993 Dict.994; - let Dict.992 : U64 = 8i64; - let Dict.991 : U64 = CallByName Num.51 Dict.501 Dict.992; - let Dict.990 : U64 = CallByName Dict.91 Dict.500 Dict.991; - let Dict.989 : U64 = CallByName Num.70 Dict.990 Dict.499; - let Dict.503 : U64 = CallByName Dict.89 Dict.988 Dict.989; - let Dict.987 : U64 = 16i64; - let Dict.504 : U64 = CallByName Num.75 Dict.502 Dict.987; - let Dict.986 : U64 = 16i64; - let Dict.505 : U64 = CallByName Num.51 Dict.501 Dict.986; - let Dict.985 : U64 = 16i64; - let Dict.975 : Int1 = CallByName Num.23 Dict.504 Dict.985; - if Dict.975 then - let Dict.984 : U64 = 16i64; - let Dict.983 : U64 = CallByName Num.75 Dict.504 Dict.984; - let Dict.982 : U64 = CallByName Num.51 Dict.983 Dict.505; - let Dict.977 : U64 = CallByName Dict.91 Dict.500 Dict.982; - let Dict.981 : U64 = 8i64; - let Dict.980 : U64 = CallByName Num.75 Dict.504 Dict.981; - let Dict.979 : U64 = CallByName Num.51 Dict.980 Dict.505; - let Dict.978 : U64 = CallByName Dict.91 Dict.500 Dict.979; - dec Dict.500; - let Dict.976 : {U64, U64, U64} = Struct {Dict.977, Dict.978, Dict.503}; - ret Dict.976; +procedure Dict.91 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3): + joinpoint Dict.980 Dict.506 Dict.507 Dict.508 Dict.509: + let Dict.1000 : U64 = CallByName Dict.98 Dict.507 Dict.508; + let Dict.1001 : U64 = CallByName Dict.93; + let Dict.995 : U64 = CallByName Num.70 Dict.1000 Dict.1001; + let Dict.999 : U64 = 8i64; + let Dict.998 : U64 = CallByName Num.51 Dict.508 Dict.999; + let Dict.997 : U64 = CallByName Dict.98 Dict.507 Dict.998; + let Dict.996 : U64 = CallByName Num.70 Dict.997 Dict.506; + let Dict.510 : U64 = CallByName Dict.96 Dict.995 Dict.996; + let Dict.994 : U64 = 16i64; + let Dict.511 : U64 = CallByName Num.75 Dict.509 Dict.994; + let Dict.993 : U64 = 16i64; + let Dict.512 : U64 = CallByName Num.51 Dict.508 Dict.993; + let Dict.992 : U64 = 16i64; + let Dict.982 : Int1 = CallByName Num.23 Dict.511 Dict.992; + if Dict.982 then + let Dict.991 : U64 = 16i64; + let Dict.990 : U64 = CallByName Num.75 Dict.511 Dict.991; + let Dict.989 : U64 = CallByName Num.51 Dict.990 Dict.512; + let Dict.984 : U64 = CallByName Dict.98 Dict.507 Dict.989; + let Dict.988 : U64 = 8i64; + let Dict.987 : U64 = CallByName Num.75 Dict.511 Dict.988; + let Dict.986 : U64 = CallByName Num.51 Dict.987 Dict.512; + let Dict.985 : U64 = CallByName Dict.98 Dict.507 Dict.986; + dec Dict.507; + let Dict.983 : {U64, U64, U64} = Struct {Dict.984, Dict.985, Dict.510}; + ret Dict.983; else - jump Dict.973 Dict.503 Dict.500 Dict.505 Dict.504; + jump Dict.980 Dict.510 Dict.507 Dict.512 Dict.511; in - inc #Derived_gen.44; - jump Dict.973 #Derived_gen.43 #Derived_gen.44 #Derived_gen.45 #Derived_gen.46; + inc #Derived_gen.1; + jump Dict.980 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3; -procedure Dict.85 (): - let Dict.910 : U64 = 11562461410679940143i64; - ret Dict.910; +procedure Dict.92 (): + let Dict.917 : U64 = 11562461410679940143i64; + ret Dict.917; -procedure Dict.86 (): - let Dict.906 : U64 = 16646288086500911323i64; +procedure Dict.93 (): + let Dict.913 : U64 = 16646288086500911323i64; + ret Dict.913; + +procedure Dict.94 (): + let Dict.1026 : U64 = 10285213230658275043i64; + ret Dict.1026; + +procedure Dict.95 (): + let Dict.1016 : U64 = 6384245875588680899i64; + ret Dict.1016; + +procedure Dict.96 (Dict.513, Dict.514): + let Dict.905 : {U64, U64} = CallByName Dict.97 Dict.513 Dict.514; + let Dict.515 : U64 = StructAtIndex 0 Dict.905; + let Dict.516 : U64 = StructAtIndex 1 Dict.905; + let Dict.904 : U64 = CallByName Num.70 Dict.515 Dict.516; + ret Dict.904; + +procedure Dict.97 (Dict.517, Dict.518): + let Dict.909 : U128 = CallByName Num.135 Dict.517; + let Dict.910 : U128 = CallByName Num.135 Dict.518; + let Dict.519 : U128 = CallByName Num.78 Dict.909 Dict.910; + let Dict.520 : U64 = CallByName Num.133 Dict.519; + let Dict.908 : U8 = 64i64; + let Dict.907 : U128 = CallByName Num.74 Dict.519 Dict.908; + let Dict.521 : U64 = CallByName Num.133 Dict.907; + let Dict.906 : {U64, U64} = Struct {Dict.520, Dict.521}; ret Dict.906; -procedure Dict.87 (): - let Dict.1019 : U64 = 10285213230658275043i64; - ret Dict.1019; +procedure Dict.98 (Dict.522, Dict.523): + let Dict.971 : U8 = CallByName Dict.22 Dict.522 Dict.523; + let Dict.524 : U64 = CallByName Num.133 Dict.971; + let Dict.970 : U64 = 1i64; + let Dict.969 : U64 = CallByName Num.51 Dict.523 Dict.970; + let Dict.968 : U8 = CallByName Dict.22 Dict.522 Dict.969; + let Dict.525 : U64 = CallByName Num.133 Dict.968; + let Dict.967 : U64 = 2i64; + let Dict.966 : U64 = CallByName Num.51 Dict.523 Dict.967; + let Dict.965 : U8 = CallByName Dict.22 Dict.522 Dict.966; + let Dict.526 : U64 = CallByName Num.133 Dict.965; + let Dict.964 : U64 = 3i64; + let Dict.963 : U64 = CallByName Num.51 Dict.523 Dict.964; + let Dict.962 : U8 = CallByName Dict.22 Dict.522 Dict.963; + let Dict.527 : U64 = CallByName Num.133 Dict.962; + let Dict.961 : U64 = 4i64; + let Dict.960 : U64 = CallByName Num.51 Dict.523 Dict.961; + let Dict.959 : U8 = CallByName Dict.22 Dict.522 Dict.960; + let Dict.528 : U64 = CallByName Num.133 Dict.959; + let Dict.958 : U64 = 5i64; + let Dict.957 : U64 = CallByName Num.51 Dict.523 Dict.958; + let Dict.956 : U8 = CallByName Dict.22 Dict.522 Dict.957; + let Dict.529 : U64 = CallByName Num.133 Dict.956; + let Dict.955 : U64 = 6i64; + let Dict.954 : U64 = CallByName Num.51 Dict.523 Dict.955; + let Dict.953 : U8 = CallByName Dict.22 Dict.522 Dict.954; + let Dict.530 : U64 = CallByName Num.133 Dict.953; + let Dict.952 : U64 = 7i64; + let Dict.950 : U64 = CallByName Num.51 Dict.523 Dict.952; + let Dict.949 : U8 = CallByName Dict.22 Dict.522 Dict.950; + let Dict.531 : U64 = CallByName Num.133 Dict.949; + let Dict.948 : U8 = 8i64; + let Dict.947 : U64 = CallByName Num.72 Dict.525 Dict.948; + let Dict.532 : U64 = CallByName Num.71 Dict.524 Dict.947; + let Dict.946 : U8 = 16i64; + let Dict.943 : U64 = CallByName Num.72 Dict.526 Dict.946; + let Dict.945 : U8 = 24i64; + let Dict.944 : U64 = CallByName Num.72 Dict.527 Dict.945; + let Dict.533 : U64 = CallByName Num.71 Dict.943 Dict.944; + let Dict.942 : U8 = 32i64; + let Dict.939 : U64 = CallByName Num.72 Dict.528 Dict.942; + let Dict.941 : U8 = 40i64; + let Dict.940 : U64 = CallByName Num.72 Dict.529 Dict.941; + let Dict.534 : U64 = CallByName Num.71 Dict.939 Dict.940; + let Dict.938 : U8 = 48i64; + let Dict.935 : U64 = CallByName Num.72 Dict.530 Dict.938; + let Dict.937 : U8 = 56i64; + let Dict.936 : U64 = CallByName Num.72 Dict.531 Dict.937; + let Dict.535 : U64 = CallByName Num.71 Dict.935 Dict.936; + let Dict.933 : U64 = CallByName Num.71 Dict.532 Dict.533; + let Dict.934 : U64 = CallByName Num.71 Dict.534 Dict.535; + let Dict.932 : U64 = CallByName Num.71 Dict.933 Dict.934; + ret Dict.932; -procedure Dict.88 (): - let Dict.1009 : U64 = 6384245875588680899i64; - ret Dict.1009; +procedure Dict.99 (Dict.536, Dict.537): + let Dict.1083 : U8 = CallByName Dict.22 Dict.536 Dict.537; + let Dict.538 : U64 = CallByName Num.133 Dict.1083; + let Dict.1082 : U64 = 1i64; + let Dict.1081 : U64 = CallByName Num.51 Dict.537 Dict.1082; + let Dict.1080 : U8 = CallByName Dict.22 Dict.536 Dict.1081; + let Dict.539 : U64 = CallByName Num.133 Dict.1080; + let Dict.1079 : U64 = 2i64; + let Dict.1078 : U64 = CallByName Num.51 Dict.537 Dict.1079; + let Dict.1077 : U8 = CallByName Dict.22 Dict.536 Dict.1078; + let Dict.540 : U64 = CallByName Num.133 Dict.1077; + let Dict.1076 : U64 = 3i64; + let Dict.1075 : U64 = CallByName Num.51 Dict.537 Dict.1076; + let Dict.1074 : U8 = CallByName Dict.22 Dict.536 Dict.1075; + let Dict.541 : U64 = CallByName Num.133 Dict.1074; + let Dict.1073 : U8 = 8i64; + let Dict.1072 : U64 = CallByName Num.72 Dict.539 Dict.1073; + let Dict.542 : U64 = CallByName Num.71 Dict.538 Dict.1072; + let Dict.1071 : U8 = 16i64; + let Dict.1068 : U64 = CallByName Num.72 Dict.540 Dict.1071; + let Dict.1070 : U8 = 24i64; + let Dict.1069 : U64 = CallByName Num.72 Dict.541 Dict.1070; + let Dict.543 : U64 = CallByName Num.71 Dict.1068 Dict.1069; + let Dict.1067 : U64 = CallByName Num.71 Dict.542 Dict.543; + ret Dict.1067; -procedure Dict.89 (Dict.506, Dict.507): - let Dict.898 : {U64, U64} = CallByName Dict.90 Dict.506 Dict.507; - let Dict.508 : U64 = StructAtIndex 0 Dict.898; - let Dict.509 : U64 = StructAtIndex 1 Dict.898; - let Dict.897 : U64 = CallByName Num.70 Dict.508 Dict.509; - ret Dict.897; +procedure Hash.19 (Hash.42, Hash.43): + let Hash.75 : List U8 = CallByName Str.12 Hash.43; + let Hash.74 : {U64, U64} = CallByName Dict.89 Hash.42 Hash.75; + dec Hash.75; + ret Hash.74; -procedure Dict.90 (Dict.510, Dict.511): - let Dict.902 : U128 = CallByName Num.135 Dict.510; - let Dict.903 : U128 = CallByName Num.135 Dict.511; - let Dict.512 : U128 = CallByName Num.78 Dict.902 Dict.903; - let Dict.513 : U64 = CallByName Num.133 Dict.512; - let Dict.901 : U8 = 64i64; - let Dict.900 : U128 = CallByName Num.74 Dict.512 Dict.901; - let Dict.514 : U64 = CallByName Num.133 Dict.900; - let Dict.899 : {U64, U64} = Struct {Dict.513, Dict.514}; - ret Dict.899; - -procedure Dict.91 (Dict.515, Dict.516): - let Dict.964 : U8 = CallByName Dict.22 Dict.515 Dict.516; - let Dict.517 : U64 = CallByName Num.133 Dict.964; - let Dict.963 : U64 = 1i64; - let Dict.962 : U64 = CallByName Num.51 Dict.516 Dict.963; - let Dict.961 : U8 = CallByName Dict.22 Dict.515 Dict.962; - let Dict.518 : U64 = CallByName Num.133 Dict.961; - let Dict.960 : U64 = 2i64; - let Dict.959 : U64 = CallByName Num.51 Dict.516 Dict.960; - let Dict.958 : U8 = CallByName Dict.22 Dict.515 Dict.959; - let Dict.519 : U64 = CallByName Num.133 Dict.958; - let Dict.957 : U64 = 3i64; - let Dict.956 : U64 = CallByName Num.51 Dict.516 Dict.957; - let Dict.955 : U8 = CallByName Dict.22 Dict.515 Dict.956; - let Dict.520 : U64 = CallByName Num.133 Dict.955; - let Dict.954 : U64 = 4i64; - let Dict.953 : U64 = CallByName Num.51 Dict.516 Dict.954; - let Dict.952 : U8 = CallByName Dict.22 Dict.515 Dict.953; - let Dict.521 : U64 = CallByName Num.133 Dict.952; - let Dict.951 : U64 = 5i64; - let Dict.950 : U64 = CallByName Num.51 Dict.516 Dict.951; - let Dict.949 : U8 = CallByName Dict.22 Dict.515 Dict.950; - let Dict.522 : U64 = CallByName Num.133 Dict.949; - let Dict.948 : U64 = 6i64; - let Dict.947 : U64 = CallByName Num.51 Dict.516 Dict.948; - let Dict.946 : U8 = CallByName Dict.22 Dict.515 Dict.947; - let Dict.523 : U64 = CallByName Num.133 Dict.946; - let Dict.945 : U64 = 7i64; - let Dict.943 : U64 = CallByName Num.51 Dict.516 Dict.945; - let Dict.942 : U8 = CallByName Dict.22 Dict.515 Dict.943; - let Dict.524 : U64 = CallByName Num.133 Dict.942; - let Dict.941 : U8 = 8i64; - let Dict.940 : U64 = CallByName Num.72 Dict.518 Dict.941; - let Dict.525 : U64 = CallByName Num.71 Dict.517 Dict.940; - let Dict.939 : U8 = 16i64; - let Dict.936 : U64 = CallByName Num.72 Dict.519 Dict.939; - let Dict.938 : U8 = 24i64; - let Dict.937 : U64 = CallByName Num.72 Dict.520 Dict.938; - let Dict.526 : U64 = CallByName Num.71 Dict.936 Dict.937; - let Dict.935 : U8 = 32i64; - let Dict.932 : U64 = CallByName Num.72 Dict.521 Dict.935; - let Dict.934 : U8 = 40i64; - let Dict.933 : U64 = CallByName Num.72 Dict.522 Dict.934; - let Dict.527 : U64 = CallByName Num.71 Dict.932 Dict.933; - let Dict.931 : U8 = 48i64; - let Dict.928 : U64 = CallByName Num.72 Dict.523 Dict.931; - let Dict.930 : U8 = 56i64; - let Dict.929 : U64 = CallByName Num.72 Dict.524 Dict.930; - let Dict.528 : U64 = CallByName Num.71 Dict.928 Dict.929; - let Dict.926 : U64 = CallByName Num.71 Dict.525 Dict.526; - let Dict.927 : U64 = CallByName Num.71 Dict.527 Dict.528; - let Dict.925 : U64 = CallByName Num.71 Dict.926 Dict.927; - ret Dict.925; - -procedure Dict.92 (Dict.529, Dict.530): - let Dict.1076 : U8 = CallByName Dict.22 Dict.529 Dict.530; - let Dict.531 : U64 = CallByName Num.133 Dict.1076; - let Dict.1075 : U64 = 1i64; - let Dict.1074 : U64 = CallByName Num.51 Dict.530 Dict.1075; - let Dict.1073 : U8 = CallByName Dict.22 Dict.529 Dict.1074; - let Dict.532 : U64 = CallByName Num.133 Dict.1073; - let Dict.1072 : U64 = 2i64; - let Dict.1071 : U64 = CallByName Num.51 Dict.530 Dict.1072; - let Dict.1070 : U8 = CallByName Dict.22 Dict.529 Dict.1071; - let Dict.533 : U64 = CallByName Num.133 Dict.1070; - let Dict.1069 : U64 = 3i64; - let Dict.1068 : U64 = CallByName Num.51 Dict.530 Dict.1069; - let Dict.1067 : U8 = CallByName Dict.22 Dict.529 Dict.1068; - let Dict.534 : U64 = CallByName Num.133 Dict.1067; - let Dict.1066 : U8 = 8i64; - let Dict.1065 : U64 = CallByName Num.72 Dict.532 Dict.1066; - let Dict.535 : U64 = CallByName Num.71 Dict.531 Dict.1065; - let Dict.1064 : U8 = 16i64; - let Dict.1061 : U64 = CallByName Num.72 Dict.533 Dict.1064; - let Dict.1063 : U8 = 24i64; - let Dict.1062 : U64 = CallByName Num.72 Dict.534 Dict.1063; - let Dict.536 : U64 = CallByName Num.71 Dict.1061 Dict.1062; - let Dict.1060 : U64 = CallByName Num.71 Dict.535 Dict.536; - ret Dict.1060; - -procedure Dict.93 (Dict.537, Dict.538, Dict.539): - let Dict.1054 : U8 = CallByName Dict.22 Dict.537 Dict.538; - let Dict.540 : U64 = CallByName Num.133 Dict.1054; - let Dict.1053 : U8 = 1i64; - let Dict.1052 : U64 = CallByName Num.74 Dict.539 Dict.1053; - let Dict.1051 : U64 = CallByName Num.51 Dict.1052 Dict.538; - let Dict.1050 : U8 = CallByName Dict.22 Dict.537 Dict.1051; - let Dict.541 : U64 = CallByName Num.133 Dict.1050; - let Dict.1049 : U64 = 1i64; - let Dict.1048 : U64 = CallByName Num.75 Dict.539 Dict.1049; - let Dict.1047 : U64 = CallByName Num.51 Dict.1048 Dict.538; - let Dict.1046 : U8 = CallByName Dict.22 Dict.537 Dict.1047; - let Dict.542 : U64 = CallByName Num.133 Dict.1046; - let Dict.1045 : U8 = 16i64; - let Dict.1042 : U64 = CallByName Num.72 Dict.540 Dict.1045; - let Dict.1044 : U8 = 8i64; - let Dict.1043 : U64 = CallByName Num.72 Dict.541 Dict.1044; - let Dict.543 : U64 = CallByName Num.71 Dict.1042 Dict.1043; - let Dict.1041 : U64 = CallByName Num.71 Dict.543 Dict.542; - ret Dict.1041; - -procedure Hash.19 (Hash.38, Hash.39): - let Hash.71 : List U8 = CallByName Str.12 Hash.39; - let Hash.70 : {U64, U64} = CallByName Dict.82 Hash.38 Hash.71; - dec Hash.71; - ret Hash.70; - -procedure Inspect.183 (Inspect.184, #Attr.12): - let Inspect.182 : {} = StructAtIndex 3 #Attr.12; - let Inspect.181 : {} = StructAtIndex 2 #Attr.12; - let Inspect.180 : {} = StructAtIndex 1 #Attr.12; - let Inspect.179 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = StructAtIndex 0 #Attr.12; - let Inspect.351 : Str = "{"; - let Inspect.324 : Str = CallByName Inspect.59 Inspect.184 Inspect.351; - dec Inspect.351; - let Inspect.325 : {{List {U32, U32}, List {Str, I64}, U64, Float32, U8}, {}, {}, {}} = Struct {Inspect.179, Inspect.180, Inspect.181, Inspect.182}; - let Inspect.320 : {Str, Int1} = CallByName Inspect.185 Inspect.324 Inspect.325; - dec Inspect.324; - let Inspect.321 : {} = Struct {}; - let Inspect.316 : Str = CallByName Inspect.197 Inspect.320; - let Inspect.317 : Str = "}"; - let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317; - dec Inspect.317; - ret Inspect.315; - -procedure Inspect.185 (Inspect.186, #Attr.12): - let Inspect.182 : {} = StructAtIndex 3 #Attr.12; - let Inspect.181 : {} = StructAtIndex 2 #Attr.12; - let Inspect.180 : {} = StructAtIndex 1 #Attr.12; - let Inspect.179 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = StructAtIndex 0 #Attr.12; - let Inspect.350 : Int1 = CallByName Bool.1; - inc Inspect.186; - let Inspect.328 : {Str, Int1} = Struct {Inspect.186, Inspect.350}; - let Inspect.329 : {{}, {}} = Struct {Inspect.181, Inspect.182}; - let Inspect.327 : {Str, Int1} = CallByName Dict.10 Inspect.179 Inspect.328 Inspect.329; - ret Inspect.327; - -procedure Inspect.187 (Inspect.330, Inspect.190, Inspect.191, #Attr.12): - let Inspect.182 : {} = StructAtIndex 1 #Attr.12; - let Inspect.181 : {} = StructAtIndex 0 #Attr.12; - let Inspect.188 : Str = StructAtIndex 0 Inspect.330; - let Inspect.189 : Int1 = StructAtIndex 1 Inspect.330; - joinpoint Inspect.348 Inspect.192: - let Inspect.345 : Str = CallByName Inspect.43 Inspect.190; - let Inspect.343 : Str = CallByName Inspect.31 Inspect.345 Inspect.192; - dec Inspect.345; - let Inspect.344 : Str = ": "; - let Inspect.337 : Str = CallByName Inspect.59 Inspect.343 Inspect.344; - dec Inspect.344; - let Inspect.338 : {I64, {}} = Struct {Inspect.191, Inspect.182}; - let Inspect.333 : Str = CallByName Inspect.193 Inspect.337 Inspect.338; - let Inspect.334 : {} = Struct {}; - let Inspect.332 : {Str, Int1} = CallByName Inspect.195 Inspect.333; - dec Inspect.333; - ret Inspect.332; - in - if Inspect.189 then - let Inspect.349 : Str = ", "; - let Inspect.347 : Str = CallByName Inspect.59 Inspect.188 Inspect.349; - dec Inspect.349; - jump Inspect.348 Inspect.347; - else - jump Inspect.348 Inspect.188; - -procedure Inspect.193 (Inspect.194, #Attr.12): - let Inspect.182 : {} = StructAtIndex 1 #Attr.12; - let Inspect.191 : I64 = StructAtIndex 0 #Attr.12; - let Inspect.341 : I64 = CallByName Inspect.53 Inspect.191; - let Inspect.340 : Str = CallByName Inspect.31 Inspect.341 Inspect.194; - ret Inspect.340; - -procedure Inspect.195 (Inspect.196): - let Inspect.336 : Int1 = CallByName Bool.2; - inc Inspect.196; - let Inspect.335 : {Str, Int1} = Struct {Inspect.196, Inspect.336}; - ret Inspect.335; - -procedure Inspect.197 (Inspect.322): - let Inspect.323 : Str = StructAtIndex 0 Inspect.322; - ret Inspect.323; - -procedure Inspect.246 (Inspect.247, Inspect.245): - let Inspect.366 : Str = "\""; - let Inspect.365 : Str = CallByName Inspect.59 Inspect.247 Inspect.366; - dec Inspect.366; - let Inspect.363 : Str = CallByName Inspect.59 Inspect.365 Inspect.245; - let Inspect.364 : Str = "\""; - let Inspect.362 : Str = CallByName Inspect.59 Inspect.363 Inspect.364; - dec Inspect.364; - ret Inspect.362; - -procedure Inspect.274 (Inspect.275, Inspect.273): - let Inspect.357 : Str = CallByName Num.96 Inspect.273; - let Inspect.356 : Str = CallByName Inspect.59 Inspect.275 Inspect.357; - dec Inspect.357; - ret Inspect.356; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.310 : Str = CallByName Inspect.183 Inspect.145 Inspect.299; - ret Inspect.310; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.342 : Str = CallByName Inspect.274 Inspect.145 Inspect.299; - ret Inspect.342; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.346 : Str = CallByName Inspect.246 Inspect.145 Inspect.299; - ret Inspect.346; - -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; - -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; - ret Inspect.307; - -procedure Inspect.38 (Inspect.179, Inspect.180, Inspect.181, Inspect.182): - let Inspect.312 : {{List {U32, U32}, List {Str, I64}, U64, Float32, U8}, {}, {}, {}} = Struct {Inspect.179, Inspect.180, Inspect.181, Inspect.182}; - let Inspect.311 : {{List {U32, U32}, List {Str, I64}, U64, Float32, U8}, {}, {}, {}} = CallByName Inspect.30 Inspect.312; - ret Inspect.311; - -procedure Inspect.43 (Inspect.245): - let Inspect.358 : Str = CallByName Inspect.30 Inspect.245; - ret Inspect.358; - -procedure Inspect.5 (Inspect.146): - let Inspect.308 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.36 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName Dict.120 Inspect.304 Inspect.308; - ret Inspect.303; - -procedure Inspect.53 (Inspect.273): - let Inspect.352 : I64 = CallByName Inspect.30 Inspect.273; - ret Inspect.352; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.319 : Str = CallByName Str.3 Inspect.296 Inspect.292; +procedure Inspect.187 (Inspect.188, #Attr.12): + let Inspect.186 : {} = StructAtIndex 3 #Attr.12; + let Inspect.185 : {} = StructAtIndex 2 #Attr.12; + let Inspect.184 : {} = StructAtIndex 1 #Attr.12; + let Inspect.183 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = StructAtIndex 0 #Attr.12; + let Inspect.355 : Str = "{"; + let Inspect.328 : Str = CallByName Inspect.63 Inspect.188 Inspect.355; + dec Inspect.355; + let Inspect.329 : {{List {U32, U32}, List {Str, I64}, U64, Float32, U8}, {}, {}, {}} = Struct {Inspect.183, Inspect.184, Inspect.185, Inspect.186}; + let Inspect.324 : {Str, Int1} = CallByName Inspect.189 Inspect.328 Inspect.329; + dec Inspect.328; + let Inspect.325 : {} = Struct {}; + let Inspect.320 : Str = CallByName Inspect.201 Inspect.324; + let Inspect.321 : Str = "}"; + let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321; + dec Inspect.321; ret Inspect.319; -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.189 (Inspect.190, #Attr.12): + let Inspect.186 : {} = StructAtIndex 3 #Attr.12; + let Inspect.185 : {} = StructAtIndex 2 #Attr.12; + let Inspect.184 : {} = StructAtIndex 1 #Attr.12; + let Inspect.183 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = StructAtIndex 0 #Attr.12; + let Inspect.354 : Int1 = CallByName Bool.1; + inc Inspect.190; + let Inspect.332 : {Str, Int1} = Struct {Inspect.190, Inspect.354}; + let Inspect.333 : {{}, {}} = Struct {Inspect.185, Inspect.186}; + let Inspect.331 : {Str, Int1} = CallByName Dict.10 Inspect.183 Inspect.332 Inspect.333; + ret Inspect.331; -procedure List.11 (List.141, List.142): - let List.684 : List {U32, U32} = CallByName List.68 List.142; - let List.683 : List {U32, U32} = CallByName List.90 List.141 List.142 List.684; - ret List.683; +procedure Inspect.191 (Inspect.334, Inspect.194, Inspect.195, #Attr.12): + let Inspect.186 : {} = StructAtIndex 1 #Attr.12; + let Inspect.185 : {} = StructAtIndex 0 #Attr.12; + let Inspect.192 : Str = StructAtIndex 0 Inspect.334; + let Inspect.193 : Int1 = StructAtIndex 1 Inspect.334; + joinpoint Inspect.352 Inspect.196: + let Inspect.349 : Str = CallByName Inspect.47 Inspect.194; + let Inspect.347 : Str = CallByName Inspect.31 Inspect.349 Inspect.196; + dec Inspect.349; + let Inspect.348 : Str = ": "; + let Inspect.341 : Str = CallByName Inspect.63 Inspect.347 Inspect.348; + dec Inspect.348; + let Inspect.342 : {I64, {}} = Struct {Inspect.195, Inspect.186}; + let Inspect.337 : Str = CallByName Inspect.197 Inspect.341 Inspect.342; + let Inspect.338 : {} = Struct {}; + let Inspect.336 : {Str, Int1} = CallByName Inspect.199 Inspect.337; + dec Inspect.337; + ret Inspect.336; + in + if Inspect.193 then + let Inspect.353 : Str = ", "; + let Inspect.351 : Str = CallByName Inspect.63 Inspect.192 Inspect.353; + dec Inspect.353; + jump Inspect.352 Inspect.351; + else + jump Inspect.352 Inspect.192; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure Inspect.197 (Inspect.198, #Attr.12): + let Inspect.186 : {} = StructAtIndex 1 #Attr.12; + let Inspect.195 : I64 = StructAtIndex 0 #Attr.12; + let Inspect.345 : I64 = CallByName Inspect.57 Inspect.195; + let Inspect.344 : Str = CallByName Inspect.31 Inspect.345 Inspect.198; + ret Inspect.344; -procedure List.18 (List.163, List.164, List.165): - let List.687 : U64 = 0i64; - let List.688 : U64 = CallByName List.6 List.163; - let List.686 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.687 List.688; +procedure Inspect.199 (Inspect.200): + let Inspect.340 : Int1 = CallByName Bool.2; + inc Inspect.200; + let Inspect.339 : {Str, Int1} = Struct {Inspect.200, Inspect.340}; + ret Inspect.339; + +procedure Inspect.201 (Inspect.326): + let Inspect.327 : Str = StructAtIndex 0 Inspect.326; + ret Inspect.327; + +procedure Inspect.250 (Inspect.251, Inspect.249): + let Inspect.370 : Str = "\""; + let Inspect.369 : Str = CallByName Inspect.63 Inspect.251 Inspect.370; + dec Inspect.370; + let Inspect.367 : Str = CallByName Inspect.63 Inspect.369 Inspect.249; + let Inspect.368 : Str = "\""; + let Inspect.366 : Str = CallByName Inspect.63 Inspect.367 Inspect.368; + dec Inspect.368; + ret Inspect.366; + +procedure Inspect.278 (Inspect.279, Inspect.277): + let Inspect.361 : Str = CallByName Num.96 Inspect.277; + let Inspect.360 : Str = CallByName Inspect.63 Inspect.279 Inspect.361; + dec Inspect.361; + ret Inspect.360; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.314 : Str = CallByName Inspect.187 Inspect.149 Inspect.303; + ret Inspect.314; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.346 : Str = CallByName Inspect.278 Inspect.149 Inspect.303; + ret Inspect.346; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.350 : Str = CallByName Inspect.250 Inspect.149 Inspect.303; + ret Inspect.350; + +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; + +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.42 (Inspect.183, Inspect.184, Inspect.185, Inspect.186): + let Inspect.316 : {{List {U32, U32}, List {Str, I64}, U64, Float32, U8}, {}, {}, {}} = Struct {Inspect.183, Inspect.184, Inspect.185, Inspect.186}; + let Inspect.315 : {{List {U32, U32}, List {Str, I64}, U64, Float32, U8}, {}, {}, {}} = CallByName Inspect.30 Inspect.316; + ret Inspect.315; + +procedure Inspect.47 (Inspect.249): + let Inspect.362 : Str = CallByName Inspect.30 Inspect.249; + ret Inspect.362; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.43 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName Dict.127 Inspect.308 Inspect.312; + ret Inspect.307; + +procedure Inspect.57 (Inspect.277): + let Inspect.356 : I64 = CallByName Inspect.30 Inspect.277; + ret Inspect.356; + +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.323 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.323; + +procedure Inspect.64 (Inspect.302): + ret Inspect.302; + +procedure List.11 (List.144, List.145): + let List.687 : List {U32, U32} = CallByName List.68 List.145; + let List.686 : List {U32, U32} = CallByName List.93 List.144 List.145 List.687; ret List.686; -procedure List.3 (List.119, List.120, List.121): - let List.648 : {List {U32, U32}, {U32, U32}} = CallByName List.64 List.119 List.120 List.121; - let List.647 : List {U32, U32} = StructAtIndex 0 List.648; - ret List.647; +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; -procedure List.3 (List.119, List.120, List.121): - let List.650 : {List {Str, I64}, {Str, I64}} = CallByName List.64 List.119 List.120 List.121; - let List.649 : List {Str, I64} = StructAtIndex 0 List.650; - let #Derived_gen.71 : {Str, I64} = StructAtIndex 1 List.650; +procedure List.18 (List.166, List.167, List.168): + let List.690 : U64 = 0i64; + let List.691 : U64 = CallByName List.6 List.166; + let List.689 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.690 List.691; + ret List.689; + +procedure List.3 (List.122, List.123, List.124): + let List.651 : {List {U32, U32}, {U32, U32}} = CallByName List.64 List.122 List.123 List.124; + let List.650 : List {U32, U32} = StructAtIndex 0 List.651; + ret List.650; + +procedure List.3 (List.122, List.123, List.124): + let List.653 : {List {Str, I64}, {Str, I64}} = CallByName List.64 List.122 List.123 List.124; + let List.652 : List {Str, I64} = StructAtIndex 0 List.653; + let #Derived_gen.71 : {Str, I64} = StructAtIndex 1 List.653; dec #Derived_gen.71; - ret List.649; + ret List.652; -procedure List.4 (List.127, List.128): - let List.659 : U64 = 1i64; - let List.657 : List {Str, I64} = CallByName List.70 List.127 List.659; - let List.656 : List {Str, I64} = CallByName List.71 List.657 List.128; - ret List.656; +procedure List.4 (List.130, List.131): + let List.662 : U64 = 1i64; + let List.660 : List {Str, I64} = CallByName List.70 List.130 List.662; + let List.659 : List {Str, I64} = CallByName List.71 List.660 List.131; + ret List.659; procedure List.6 (#Attr.2): - let List.638 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.638; + let List.641 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.641; procedure List.6 (#Attr.2): - let List.685 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.685; + let List.688 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.688; procedure List.6 (#Attr.2): - let List.697 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.697; + let List.700 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.700; -procedure List.64 (List.116, List.117, List.118): - let List.646 : U64 = CallByName List.6 List.116; - let List.643 : Int1 = CallByName Num.22 List.117 List.646; - if List.643 then - let List.644 : {List {U32, U32}, {U32, U32}} = CallByName List.67 List.116 List.117 List.118; - ret List.644; +procedure List.64 (List.119, List.120, List.121): + let List.649 : U64 = CallByName List.6 List.119; + let List.646 : Int1 = CallByName Num.22 List.120 List.649; + if List.646 then + let List.647 : {List {U32, U32}, {U32, U32}} = CallByName List.67 List.119 List.120 List.121; + ret List.647; else - let List.642 : {List {U32, U32}, {U32, U32}} = Struct {List.116, List.118}; - ret List.642; + let List.645 : {List {U32, U32}, {U32, U32}} = Struct {List.119, List.121}; + ret List.645; -procedure List.64 (List.116, List.117, List.118): - let List.655 : U64 = CallByName List.6 List.116; - let List.652 : Int1 = CallByName Num.22 List.117 List.655; - if List.652 then - let List.653 : {List {Str, I64}, {Str, I64}} = CallByName List.67 List.116 List.117 List.118; - ret List.653; +procedure List.64 (List.119, List.120, List.121): + let List.658 : U64 = CallByName List.6 List.119; + let List.655 : Int1 = CallByName Num.22 List.120 List.658; + if List.655 then + let List.656 : {List {Str, I64}, {Str, I64}} = CallByName List.67 List.119 List.120 List.121; + ret List.656; else - let List.651 : {List {Str, I64}, {Str, I64}} = Struct {List.116, List.118}; - ret List.651; + let List.654 : {List {Str, I64}, {Str, I64}} = Struct {List.119, List.121}; + ret List.654; procedure List.66 (#Attr.2, #Attr.3): - let List.696 : {Str, I64} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.696; + let List.699 : {Str, I64} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.699; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.645 : {List {U32, U32}, {U32, U32}} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.645; + let List.648 : {List {U32, U32}, {U32, U32}} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.648; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.654 : {List {Str, I64}, {Str, I64}} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.654; + let List.657 : {List {Str, I64}, {Str, I64}} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.657; procedure List.68 (#Attr.2): - let List.682 : List {U32, U32} = lowlevel ListWithCapacity #Attr.2; - ret List.682; + let List.685 : List {U32, U32} = lowlevel ListWithCapacity #Attr.2; + ret List.685; procedure List.70 (#Attr.2, #Attr.3): - let List.660 : List {Str, I64} = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.660; + let List.663 : List {Str, I64} = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.663; procedure List.71 (#Attr.2, #Attr.3): - let List.658 : List {Str, I64} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.658; - -procedure List.71 (#Attr.2, #Attr.3): - let List.679 : List {U32, U32} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.679; - -procedure List.83 (List.172, List.173, List.174): - let List.662 : U64 = 0i64; - let List.663 : U64 = CallByName List.6 List.172; - let List.661 : List {U32, U32} = CallByName List.93 List.172 List.173 List.174 List.662 List.663; + let List.661 : List {Str, I64} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; ret List.661; -procedure List.90 (#Derived_gen.33, #Derived_gen.34, #Derived_gen.35): - joinpoint List.673 List.143 List.144 List.145: - let List.681 : U64 = 0i64; - let List.675 : Int1 = CallByName Num.24 List.144 List.681; - if List.675 then - let List.680 : U64 = 1i64; - let List.677 : U64 = CallByName Num.75 List.144 List.680; - let List.678 : List {U32, U32} = CallByName List.71 List.145 List.143; - jump List.673 List.143 List.677 List.678; - else - ret List.145; - in - jump List.673 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35; +procedure List.71 (#Attr.2, #Attr.3): + let List.682 : List {U32, U32} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.682; -procedure List.92 (#Derived_gen.50, #Derived_gen.51, #Derived_gen.52, #Derived_gen.53, #Derived_gen.54): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : {Str, I64} = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.152 List.167 List.631; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; - else - dec List.166; - ret List.167; - in - inc #Derived_gen.50; - jump List.625 #Derived_gen.50 #Derived_gen.51 #Derived_gen.52 #Derived_gen.53 #Derived_gen.54; +procedure List.83 (List.175, List.176, List.177): + let List.665 : U64 = 0i64; + let List.666 : U64 = CallByName List.6 List.175; + let List.664 : List {U32, U32} = CallByName List.96 List.175 List.176 List.177 List.665 List.666; + ret List.664; -procedure List.92 (#Derived_gen.59, #Derived_gen.60, #Derived_gen.61, #Derived_gen.62, #Derived_gen.63): - joinpoint List.689 List.166 List.167 List.168 List.169 List.170: - let List.691 : Int1 = CallByName Num.22 List.169 List.170; - if List.691 then - let List.695 : {Str, I64} = CallByName List.66 List.166 List.169; - inc List.695; - let List.171 : {Str, Int1} = CallByName Dict.181 List.167 List.695 List.168; - let List.694 : U64 = 1i64; - let List.693 : U64 = CallByName Num.51 List.169 List.694; - jump List.689 List.166 List.171 List.168 List.693 List.170; +procedure List.93 (#Derived_gen.63, #Derived_gen.64, #Derived_gen.65): + joinpoint List.676 List.146 List.147 List.148: + let List.684 : U64 = 0i64; + let List.678 : Int1 = CallByName Num.24 List.147 List.684; + if List.678 then + let List.683 : U64 = 1i64; + let List.680 : U64 = CallByName Num.75 List.147 List.683; + let List.681 : List {U32, U32} = CallByName List.71 List.148 List.146; + jump List.676 List.146 List.680 List.681; else - dec List.166; - ret List.167; + ret List.148; in - inc #Derived_gen.59; - jump List.689 #Derived_gen.59 #Derived_gen.60 #Derived_gen.61 #Derived_gen.62 #Derived_gen.63; + jump List.676 #Derived_gen.63 #Derived_gen.64 #Derived_gen.65; -procedure List.93 (#Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27): - joinpoint List.664 List.175 List.176 List.177 List.178 List.179: - let List.666 : Int1 = CallByName Num.22 List.178 List.179; - if List.666 then - let List.670 : {Str, I64} = CallByName List.66 List.175 List.178; - inc List.670; - let List.180 : List {U32, U32} = CallByName Dict.398 List.176 List.670 List.178 List.177; - let List.669 : U64 = 1i64; - let List.668 : U64 = CallByName Num.51 List.178 List.669; - jump List.664 List.175 List.180 List.177 List.668 List.179; +procedure List.95 (#Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27): + joinpoint List.692 List.169 List.170 List.171 List.172 List.173: + let List.694 : Int1 = CallByName Num.22 List.172 List.173; + if List.694 then + let List.698 : {Str, I64} = CallByName List.66 List.169 List.172; + inc List.698; + let List.174 : {Str, Int1} = CallByName Dict.188 List.170 List.698 List.171; + let List.697 : U64 = 1i64; + let List.696 : U64 = CallByName Num.51 List.172 List.697; + jump List.692 List.169 List.174 List.171 List.696 List.173; else - dec List.175; - ret List.176; + dec List.169; + ret List.170; in inc #Derived_gen.23; - jump List.664 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27; + jump List.692 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27; + +procedure List.95 (#Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40, #Derived_gen.41): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : {Str, I64} = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.159 List.170 List.634; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; + else + dec List.169; + ret List.170; + in + inc #Derived_gen.37; + jump List.628 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41; + +procedure List.96 (#Derived_gen.56, #Derived_gen.57, #Derived_gen.58, #Derived_gen.59, #Derived_gen.60): + joinpoint List.667 List.178 List.179 List.180 List.181 List.182: + let List.669 : Int1 = CallByName Num.22 List.181 List.182; + if List.669 then + let List.673 : {Str, I64} = CallByName List.66 List.178 List.181; + inc List.673; + let List.183 : List {U32, U32} = CallByName Dict.405 List.179 List.673 List.181 List.180; + let List.672 : U64 = 1i64; + let List.671 : U64 = CallByName Num.51 List.181 List.672; + jump List.667 List.178 List.183 List.180 List.671 List.182; + else + dec List.178; + ret List.179; + in + inc #Derived_gen.56; + jump List.667 #Derived_gen.56 #Derived_gen.57 #Derived_gen.58 #Derived_gen.59 #Derived_gen.60; procedure Num.131 (#Attr.2): - let Num.287 : U32 = lowlevel NumIntCast #Attr.2; - ret Num.287; - -procedure Num.133 (#Attr.2): - let Num.295 : U64 = lowlevel NumIntCast #Attr.2; - ret Num.295; - -procedure Num.133 (#Attr.2): - let Num.344 : U64 = lowlevel NumIntCast #Attr.2; - ret Num.344; - -procedure Num.133 (#Attr.2): - let Num.359 : U64 = lowlevel NumIntCast #Attr.2; - ret Num.359; - -procedure Num.135 (#Attr.2): - let Num.365 : U128 = lowlevel NumIntCast #Attr.2; - ret Num.365; - -procedure Num.139 (#Attr.2): - let Num.313 : Float32 = lowlevel NumToFloatCast #Attr.2; - ret Num.313; - -procedure Num.148 (Num.223, Num.224): - let Num.315 : Int1 = CallByName Num.22 Num.223 Num.224; - if Num.315 then - ret Num.223; - else - ret Num.224; - -procedure Num.21 (#Attr.2, #Attr.3): - let Num.312 : Float32 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.312; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.309; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.438 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.438; - -procedure Num.23 (#Attr.2, #Attr.3): - let Num.431 : Int1 = lowlevel NumLte #Attr.2 #Attr.3; - ret Num.431; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.293 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.293; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.434 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.434; - -procedure Num.25 (#Attr.2, #Attr.3): - let Num.435 : Int1 = lowlevel NumGte #Attr.2 #Attr.3; - ret Num.435; - -procedure Num.50 (#Attr.2): - let Num.311 : U64 = lowlevel NumFloor #Attr.2; - ret Num.311; - -procedure Num.51 (#Attr.2, #Attr.3): - let Num.279 : U32 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.279; - -procedure Num.51 (#Attr.2, #Attr.3): - let Num.437 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.437; - -procedure Num.69 (#Attr.2, #Attr.3): - let Num.301 : U32 = lowlevel NumBitwiseAnd #Attr.2 #Attr.3; - ret Num.301; - -procedure Num.70 (#Attr.2, #Attr.3): - let Num.342 : U64 = lowlevel NumBitwiseXor #Attr.2 #Attr.3; - ret Num.342; - -procedure Num.71 (#Attr.2, #Attr.3): - let Num.300 : U32 = lowlevel NumBitwiseOr #Attr.2 #Attr.3; - ret Num.300; - -procedure Num.71 (#Attr.2, #Attr.3): - let Num.379 : U64 = lowlevel NumBitwiseOr #Attr.2 #Attr.3; - ret Num.379; - -procedure Num.72 (#Attr.2, #Attr.3): - let Num.282 : U32 = lowlevel NumShiftLeftBy #Attr.2 #Attr.3; - ret Num.282; - -procedure Num.72 (#Attr.2, #Attr.3): - let Num.394 : U64 = lowlevel NumShiftLeftBy #Attr.2 #Attr.3; - ret Num.394; - -procedure Num.74 (#Attr.2, #Attr.3): - let Num.360 : U128 = lowlevel NumShiftRightZfBy #Attr.2 #Attr.3; - ret Num.360; - -procedure Num.74 (#Attr.2, #Attr.3): - let Num.362 : U64 = lowlevel NumShiftRightZfBy #Attr.2 #Attr.3; - ret Num.362; - -procedure Num.75 (#Attr.2, #Attr.3): - let Num.289 : U32 = lowlevel NumSubWrap #Attr.2 #Attr.3; + let Num.289 : U32 = lowlevel NumIntCast #Attr.2; ret Num.289; -procedure Num.75 (#Attr.2, #Attr.3): - let Num.292 : U8 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.292; +procedure Num.133 (#Attr.2): + let Num.297 : U64 = lowlevel NumIntCast #Attr.2; + ret Num.297; -procedure Num.75 (#Attr.2, #Attr.3): - let Num.428 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.428; +procedure Num.133 (#Attr.2): + let Num.346 : U64 = lowlevel NumIntCast #Attr.2; + ret Num.346; -procedure Num.78 (#Attr.2, #Attr.3): - let Num.363 : U128 = lowlevel NumMulWrap #Attr.2 #Attr.3; - ret Num.363; +procedure Num.133 (#Attr.2): + let Num.361 : U64 = lowlevel NumIntCast #Attr.2; + ret Num.361; -procedure Num.96 (#Attr.2): - let Num.308 : Str = lowlevel NumToStr #Attr.2; - ret Num.308; +procedure Num.135 (#Attr.2): + let Num.367 : U128 = lowlevel NumIntCast #Attr.2; + ret Num.367; -procedure Num.96 (#Attr.2): - let Num.436 : Str = lowlevel NumToStr #Attr.2; +procedure Num.139 (#Attr.2): + let Num.315 : Float32 = lowlevel NumToFloatCast #Attr.2; + ret Num.315; + +procedure Num.148 (Num.225, Num.226): + let Num.317 : Int1 = CallByName Num.22 Num.225 Num.226; + if Num.317 then + ret Num.225; + else + ret Num.226; + +procedure Num.21 (#Attr.2, #Attr.3): + let Num.314 : Float32 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.314; + +procedure Num.22 (#Attr.2, #Attr.3): + let Num.311 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.311; + +procedure Num.22 (#Attr.2, #Attr.3): + let Num.440 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.440; + +procedure Num.23 (#Attr.2, #Attr.3): + let Num.433 : Int1 = lowlevel NumLte #Attr.2 #Attr.3; + ret Num.433; + +procedure Num.24 (#Attr.2, #Attr.3): + let Num.295 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.295; + +procedure Num.24 (#Attr.2, #Attr.3): + let Num.436 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; ret Num.436; +procedure Num.25 (#Attr.2, #Attr.3): + let Num.437 : Int1 = lowlevel NumGte #Attr.2 #Attr.3; + ret Num.437; + +procedure Num.50 (#Attr.2): + let Num.313 : U64 = lowlevel NumFloor #Attr.2; + ret Num.313; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.281 : U32 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.439 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.439; + +procedure Num.69 (#Attr.2, #Attr.3): + let Num.303 : U32 = lowlevel NumBitwiseAnd #Attr.2 #Attr.3; + ret Num.303; + +procedure Num.70 (#Attr.2, #Attr.3): + let Num.344 : U64 = lowlevel NumBitwiseXor #Attr.2 #Attr.3; + ret Num.344; + +procedure Num.71 (#Attr.2, #Attr.3): + let Num.302 : U32 = lowlevel NumBitwiseOr #Attr.2 #Attr.3; + ret Num.302; + +procedure Num.71 (#Attr.2, #Attr.3): + let Num.381 : U64 = lowlevel NumBitwiseOr #Attr.2 #Attr.3; + ret Num.381; + +procedure Num.72 (#Attr.2, #Attr.3): + let Num.284 : U32 = lowlevel NumShiftLeftBy #Attr.2 #Attr.3; + ret Num.284; + +procedure Num.72 (#Attr.2, #Attr.3): + let Num.396 : U64 = lowlevel NumShiftLeftBy #Attr.2 #Attr.3; + ret Num.396; + +procedure Num.74 (#Attr.2, #Attr.3): + let Num.362 : U128 = lowlevel NumShiftRightZfBy #Attr.2 #Attr.3; + ret Num.362; + +procedure Num.74 (#Attr.2, #Attr.3): + let Num.364 : U64 = lowlevel NumShiftRightZfBy #Attr.2 #Attr.3; + ret Num.364; + +procedure Num.75 (#Attr.2, #Attr.3): + let Num.291 : U32 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.291; + +procedure Num.75 (#Attr.2, #Attr.3): + let Num.294 : U8 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.294; + +procedure Num.75 (#Attr.2, #Attr.3): + let Num.430 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.430; + +procedure Num.78 (#Attr.2, #Attr.3): + let Num.365 : U128 = lowlevel NumMulWrap #Attr.2 #Attr.3; + ret Num.365; + +procedure Num.96 (#Attr.2): + let Num.310 : Str = lowlevel NumToStr #Attr.2; + ret Num.310; + +procedure Num.96 (#Attr.2): + let Num.438 : Str = lowlevel NumToStr #Attr.2; + ret Num.438; + procedure Str.12 (#Attr.2): - let Str.234 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.234; + let Str.238 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.238; procedure Str.3 (#Attr.2, #Attr.3): - let Str.235 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.235; + let Str.239 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.239; procedure Test.0 (): let Test.8 : Str = "a"; diff --git a/crates/compiler/test_mono/generated/inspect_derived_list.txt b/crates/compiler/test_mono/generated/inspect_derived_list.txt index 8a0989044d..3da42d1402 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_list.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_list.txt @@ -3,13 +3,13 @@ procedure #Derived.0 (#Derived.1): ret #Derived_gen.0; procedure #Derived.3 (#Derived.2): - let #Derived_gen.7 : I64 = CallByName Inspect.53 #Derived.2; + let #Derived_gen.7 : I64 = CallByName Inspect.57 #Derived.2; ret #Derived_gen.7; procedure #Derived.4 (#Derived.5, #Derived.1): let #Derived_gen.5 : {} = Struct {}; let #Derived_gen.6 : {} = Struct {}; - let #Derived_gen.4 : {List I64, {}, {}} = CallByName Inspect.36 #Derived.1 #Derived_gen.5 #Derived_gen.6; + let #Derived_gen.4 : {List I64, {}, {}} = CallByName Inspect.40 #Derived.1 #Derived_gen.5 #Derived_gen.6; let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.5; ret #Derived_gen.3; @@ -21,165 +21,165 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure Inspect.152 (Inspect.153, #Attr.12): - let Inspect.151 : {} = StructAtIndex 2 #Attr.12; - let Inspect.150 : {} = StructAtIndex 1 #Attr.12; - let Inspect.149 : List I64 = StructAtIndex 0 #Attr.12; - let Inspect.343 : Str = "["; - let Inspect.324 : Str = CallByName Inspect.59 Inspect.153 Inspect.343; - dec Inspect.343; - let Inspect.325 : {List I64, {}, {}} = Struct {Inspect.149, Inspect.150, Inspect.151}; - let Inspect.320 : {Str, Int1} = CallByName Inspect.154 Inspect.324 Inspect.325; - dec Inspect.324; - let Inspect.321 : {} = Struct {}; - let Inspect.316 : Str = CallByName Inspect.163 Inspect.320; - let Inspect.317 : Str = "]"; - let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317; - dec Inspect.317; - ret Inspect.315; - -procedure Inspect.154 (Inspect.155, #Attr.12): - let Inspect.151 : {} = StructAtIndex 2 #Attr.12; - let Inspect.150 : {} = StructAtIndex 1 #Attr.12; - let Inspect.149 : List I64 = StructAtIndex 0 #Attr.12; - let Inspect.342 : Int1 = CallByName Bool.1; - inc Inspect.155; - let Inspect.328 : {Str, Int1} = Struct {Inspect.155, Inspect.342}; - let Inspect.327 : {Str, Int1} = CallByName List.18 Inspect.149 Inspect.328 Inspect.151; - dec Inspect.149; - ret Inspect.327; - -procedure Inspect.156 (Inspect.330, Inspect.159, Inspect.151): - let Inspect.157 : Str = StructAtIndex 0 Inspect.330; - let Inspect.158 : Int1 = StructAtIndex 1 Inspect.330; - joinpoint Inspect.340 Inspect.160: - let Inspect.337 : I64 = CallByName #Derived.3 Inspect.159; - let Inspect.333 : Str = CallByName Inspect.31 Inspect.337 Inspect.160; - let Inspect.334 : {} = Struct {}; - let Inspect.332 : {Str, Int1} = CallByName Inspect.161 Inspect.333; - dec Inspect.333; - ret Inspect.332; - in - if Inspect.158 then - let Inspect.341 : Str = ", "; - let Inspect.339 : Str = CallByName Inspect.59 Inspect.157 Inspect.341; - dec Inspect.341; - jump Inspect.340 Inspect.339; - else - jump Inspect.340 Inspect.157; - -procedure Inspect.161 (Inspect.162): - let Inspect.336 : Int1 = CallByName Bool.2; - inc Inspect.162; - let Inspect.335 : {Str, Int1} = Struct {Inspect.162, Inspect.336}; - ret Inspect.335; - -procedure Inspect.163 (Inspect.322): - let Inspect.323 : Str = StructAtIndex 0 Inspect.322; - ret Inspect.323; - -procedure Inspect.274 (Inspect.275, Inspect.273): - let Inspect.349 : Str = CallByName Num.96 Inspect.273; - let Inspect.348 : Str = CallByName Inspect.59 Inspect.275 Inspect.349; - dec Inspect.349; - ret Inspect.348; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.310 : Str = CallByName Inspect.152 Inspect.145 Inspect.299; - ret Inspect.310; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.338 : Str = CallByName Inspect.274 Inspect.145 Inspect.299; - ret Inspect.338; - -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; - -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; - ret Inspect.307; - -procedure Inspect.36 (Inspect.149, Inspect.150, Inspect.151): - inc Inspect.149; - let Inspect.312 : {List I64, {}, {}} = Struct {Inspect.149, Inspect.150, Inspect.151}; - let Inspect.311 : {List I64, {}, {}} = CallByName Inspect.30 Inspect.312; - ret Inspect.311; - -procedure Inspect.5 (Inspect.146): - let Inspect.308 : List I64 = CallByName #Derived.0 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName #Derived.4 Inspect.304 Inspect.308; - dec Inspect.308; - ret Inspect.303; - -procedure Inspect.53 (Inspect.273): - let Inspect.344 : I64 = CallByName Inspect.30 Inspect.273; - ret Inspect.344; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.319 : Str = CallByName Str.3 Inspect.296 Inspect.292; +procedure Inspect.156 (Inspect.157, #Attr.12): + let Inspect.155 : {} = StructAtIndex 2 #Attr.12; + let Inspect.154 : {} = StructAtIndex 1 #Attr.12; + let Inspect.153 : List I64 = StructAtIndex 0 #Attr.12; + let Inspect.347 : Str = "["; + let Inspect.328 : Str = CallByName Inspect.63 Inspect.157 Inspect.347; + dec Inspect.347; + let Inspect.329 : {List I64, {}, {}} = Struct {Inspect.153, Inspect.154, Inspect.155}; + let Inspect.324 : {Str, Int1} = CallByName Inspect.158 Inspect.328 Inspect.329; + dec Inspect.328; + let Inspect.325 : {} = Struct {}; + let Inspect.320 : Str = CallByName Inspect.167 Inspect.324; + let Inspect.321 : Str = "]"; + let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321; + dec Inspect.321; ret Inspect.319; -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.158 (Inspect.159, #Attr.12): + let Inspect.155 : {} = StructAtIndex 2 #Attr.12; + let Inspect.154 : {} = StructAtIndex 1 #Attr.12; + let Inspect.153 : List I64 = StructAtIndex 0 #Attr.12; + let Inspect.346 : Int1 = CallByName Bool.1; + inc Inspect.159; + let Inspect.332 : {Str, Int1} = Struct {Inspect.159, Inspect.346}; + let Inspect.331 : {Str, Int1} = CallByName List.18 Inspect.153 Inspect.332 Inspect.155; + dec Inspect.153; + ret Inspect.331; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure Inspect.160 (Inspect.334, Inspect.163, Inspect.155): + let Inspect.161 : Str = StructAtIndex 0 Inspect.334; + let Inspect.162 : Int1 = StructAtIndex 1 Inspect.334; + joinpoint Inspect.344 Inspect.164: + let Inspect.341 : I64 = CallByName #Derived.3 Inspect.163; + let Inspect.337 : Str = CallByName Inspect.31 Inspect.341 Inspect.164; + let Inspect.338 : {} = Struct {}; + let Inspect.336 : {Str, Int1} = CallByName Inspect.165 Inspect.337; + dec Inspect.337; + ret Inspect.336; + in + if Inspect.162 then + let Inspect.345 : Str = ", "; + let Inspect.343 : Str = CallByName Inspect.63 Inspect.161 Inspect.345; + dec Inspect.345; + jump Inspect.344 Inspect.343; + else + jump Inspect.344 Inspect.161; + +procedure Inspect.165 (Inspect.166): + let Inspect.340 : Int1 = CallByName Bool.2; + inc Inspect.166; + let Inspect.339 : {Str, Int1} = Struct {Inspect.166, Inspect.340}; + ret Inspect.339; + +procedure Inspect.167 (Inspect.326): + let Inspect.327 : Str = StructAtIndex 0 Inspect.326; + ret Inspect.327; + +procedure Inspect.278 (Inspect.279, Inspect.277): + let Inspect.353 : Str = CallByName Num.96 Inspect.277; + let Inspect.352 : Str = CallByName Inspect.63 Inspect.279 Inspect.353; + dec Inspect.353; + ret Inspect.352; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.314 : Str = CallByName Inspect.156 Inspect.149 Inspect.303; + ret Inspect.314; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.342 : Str = CallByName Inspect.278 Inspect.149 Inspect.303; + ret Inspect.342; + +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; + +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.40 (Inspect.153, Inspect.154, Inspect.155): + inc Inspect.153; + let Inspect.316 : {List I64, {}, {}} = Struct {Inspect.153, Inspect.154, Inspect.155}; + let Inspect.315 : {List I64, {}, {}} = CallByName Inspect.30 Inspect.316; + ret Inspect.315; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : List I64 = CallByName #Derived.0 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName #Derived.4 Inspect.308 Inspect.312; + dec Inspect.312; + ret Inspect.307; + +procedure Inspect.57 (Inspect.277): + let Inspect.348 : I64 = CallByName Inspect.30 Inspect.277; + ret Inspect.348; + +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.323 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.323; + +procedure Inspect.64 (Inspect.302): + ret Inspect.302; + +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; procedure List.6 (#Attr.2): - let List.633 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.633; + let List.636 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.636; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; -procedure List.92 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : I64 = CallByName List.66 List.166 List.169; - let List.171 : {Str, Int1} = CallByName Inspect.156 List.167 List.631 List.168; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : I64 = CallByName List.66 List.169 List.172; + let List.174 : {Str, Int1} = CallByName Inspect.160 List.170 List.634 List.171; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in inc #Derived_gen.19; - jump List.625 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; + jump List.628 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; procedure Num.22 (#Attr.2, #Attr.3): - let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.283; procedure Num.51 (#Attr.2, #Attr.3): - let Num.280 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.282; procedure Num.96 (#Attr.2): - let Num.279 : Str = lowlevel NumToStr #Attr.2; - ret Num.279; + let Num.281 : Str = lowlevel NumToStr #Attr.2; + ret Num.281; procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.0 (): let Test.2 : List I64 = Array [1i64, 2i64, 3i64]; diff --git a/crates/compiler/test_mono/generated/inspect_derived_nested_record_string.txt b/crates/compiler/test_mono/generated/inspect_derived_nested_record_string.txt index 63e78496b5..e566737edf 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_nested_record_string.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_nested_record_string.txt @@ -7,7 +7,7 @@ procedure #Derived.2 (#Derived.3, #Derived.1): let #Derived_gen.8 : Str = CallByName #Derived.4 #Derived.1; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8}; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6]; - let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.41 #Derived_gen.5; + let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.45 #Derived_gen.5; let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3; dec #Derived_gen.4; ret #Derived_gen.3; @@ -18,10 +18,10 @@ procedure #Derived.4 (#Derived.5): procedure #Derived.6 (#Derived.7, #Derived.5): let #Derived_gen.17 : Str = "b"; - let #Derived_gen.18 : Str = CallByName Inspect.43 #Derived.5; + let #Derived_gen.18 : Str = CallByName Inspect.47 #Derived.5; let #Derived_gen.16 : {Str, Str} = Struct {#Derived_gen.17, #Derived_gen.18}; let #Derived_gen.15 : List {Str, Str} = Array [#Derived_gen.16]; - let #Derived_gen.14 : List {Str, Str} = CallByName Inspect.41 #Derived_gen.15; + let #Derived_gen.14 : List {Str, Str} = CallByName Inspect.45 #Derived_gen.15; let #Derived_gen.13 : Str = CallByName Inspect.31 #Derived_gen.14 #Derived.7; dec #Derived_gen.14; ret #Derived_gen.13; @@ -34,266 +34,266 @@ procedure Bool.2 (): let Bool.25 : Int1 = true; ret Bool.25; -procedure Inspect.225 (Inspect.226, Inspect.224): - let Inspect.348 : Str = "{"; - let Inspect.324 : Str = CallByName Inspect.59 Inspect.226 Inspect.348; - dec Inspect.348; - let Inspect.320 : {Str, Int1} = CallByName Inspect.227 Inspect.324 Inspect.224; - dec Inspect.324; - let Inspect.321 : {} = Struct {}; - let Inspect.316 : Str = CallByName Inspect.239 Inspect.320; - let Inspect.317 : Str = "}"; - let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317; - dec Inspect.317; - ret Inspect.315; +procedure Inspect.229 (Inspect.230, Inspect.228): + let Inspect.352 : Str = "{"; + let Inspect.328 : Str = CallByName Inspect.63 Inspect.230 Inspect.352; + dec Inspect.352; + let Inspect.324 : {Str, Int1} = CallByName Inspect.231 Inspect.328 Inspect.228; + dec Inspect.328; + let Inspect.325 : {} = Struct {}; + let Inspect.320 : Str = CallByName Inspect.243 Inspect.324; + let Inspect.321 : Str = "}"; + let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321; + dec Inspect.321; + ret Inspect.319; -procedure Inspect.225 (Inspect.226, Inspect.224): - let Inspect.388 : Str = "{"; - let Inspect.364 : Str = CallByName Inspect.59 Inspect.226 Inspect.388; - dec Inspect.388; - let Inspect.360 : {Str, Int1} = CallByName Inspect.227 Inspect.364 Inspect.224; - dec Inspect.364; - let Inspect.361 : {} = Struct {}; - let Inspect.356 : Str = CallByName Inspect.239 Inspect.360; - let Inspect.357 : Str = "}"; - let Inspect.355 : Str = CallByName Inspect.59 Inspect.356 Inspect.357; - dec Inspect.357; - ret Inspect.355; - -procedure Inspect.227 (Inspect.228, Inspect.224): - let Inspect.347 : Int1 = CallByName Bool.1; - inc Inspect.228; - let Inspect.328 : {Str, Int1} = Struct {Inspect.228, Inspect.347}; - let Inspect.329 : {} = Struct {}; - let Inspect.327 : {Str, Int1} = CallByName List.18 Inspect.224 Inspect.328 Inspect.329; - ret Inspect.327; - -procedure Inspect.227 (Inspect.228, Inspect.224): - let Inspect.387 : Int1 = CallByName Bool.1; - inc Inspect.228; - let Inspect.368 : {Str, Int1} = Struct {Inspect.228, Inspect.387}; - let Inspect.369 : {} = Struct {}; - let Inspect.367 : {Str, Int1} = CallByName List.18 Inspect.224 Inspect.368 Inspect.369; - ret Inspect.367; - -procedure Inspect.229 (Inspect.330, Inspect.331): - let Inspect.232 : Str = StructAtIndex 0 Inspect.331; - let Inspect.233 : Str = StructAtIndex 1 Inspect.331; - let Inspect.230 : Str = StructAtIndex 0 Inspect.330; - let Inspect.231 : Int1 = StructAtIndex 1 Inspect.330; - joinpoint Inspect.345 Inspect.234: - let Inspect.342 : Str = CallByName Inspect.59 Inspect.234 Inspect.232; - dec Inspect.232; - let Inspect.343 : Str = ": "; - let Inspect.337 : Str = CallByName Inspect.59 Inspect.342 Inspect.343; - dec Inspect.343; - let Inspect.333 : Str = CallByName Inspect.235 Inspect.337 Inspect.233; - let Inspect.334 : {} = Struct {}; - let Inspect.332 : {Str, Int1} = CallByName Inspect.237 Inspect.333; - dec Inspect.333; - ret Inspect.332; - in - if Inspect.231 then - let Inspect.346 : Str = ", "; - let Inspect.344 : Str = CallByName Inspect.59 Inspect.230 Inspect.346; - dec Inspect.346; - jump Inspect.345 Inspect.344; - else - jump Inspect.345 Inspect.230; - -procedure Inspect.229 (Inspect.330, Inspect.331): - let Inspect.232 : Str = StructAtIndex 0 Inspect.331; - let Inspect.233 : Str = StructAtIndex 1 Inspect.331; - let Inspect.230 : Str = StructAtIndex 0 Inspect.330; - let Inspect.231 : Int1 = StructAtIndex 1 Inspect.330; - joinpoint Inspect.385 Inspect.234: - let Inspect.382 : Str = CallByName Inspect.59 Inspect.234 Inspect.232; - dec Inspect.232; - let Inspect.383 : Str = ": "; - let Inspect.377 : Str = CallByName Inspect.59 Inspect.382 Inspect.383; - dec Inspect.383; - let Inspect.373 : Str = CallByName Inspect.235 Inspect.377 Inspect.233; - dec Inspect.233; - let Inspect.374 : {} = Struct {}; - let Inspect.372 : {Str, Int1} = CallByName Inspect.237 Inspect.373; - dec Inspect.373; - ret Inspect.372; - in - if Inspect.231 then - let Inspect.386 : Str = ", "; - let Inspect.384 : Str = CallByName Inspect.59 Inspect.230 Inspect.386; - dec Inspect.386; - jump Inspect.385 Inspect.384; - else - jump Inspect.385 Inspect.230; - -procedure Inspect.235 (Inspect.236, Inspect.233): - let Inspect.340 : Str = CallByName Inspect.31 Inspect.233 Inspect.236; - ret Inspect.340; - -procedure Inspect.235 (Inspect.236, Inspect.233): - let Inspect.380 : Str = CallByName Inspect.31 Inspect.233 Inspect.236; - ret Inspect.380; - -procedure Inspect.237 (Inspect.238): - let Inspect.376 : Int1 = CallByName Bool.2; - inc Inspect.238; - let Inspect.375 : {Str, Int1} = Struct {Inspect.238, Inspect.376}; - ret Inspect.375; - -procedure Inspect.239 (Inspect.322): - let Inspect.363 : Str = StructAtIndex 0 Inspect.322; - ret Inspect.363; - -procedure Inspect.246 (Inspect.247, Inspect.245): - let Inspect.397 : Str = "\""; - let Inspect.396 : Str = CallByName Inspect.59 Inspect.247 Inspect.397; - dec Inspect.397; - let Inspect.394 : Str = CallByName Inspect.59 Inspect.396 Inspect.245; - let Inspect.395 : Str = "\""; - let Inspect.393 : Str = CallByName Inspect.59 Inspect.394 Inspect.395; - dec Inspect.395; - ret Inspect.393; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.310 : Str = CallByName Inspect.225 Inspect.145 Inspect.299; - ret Inspect.310; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.341 : Str = CallByName #Derived.6 Inspect.145 Inspect.299; - ret Inspect.341; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.350 : Str = CallByName Inspect.225 Inspect.145 Inspect.299; - ret Inspect.350; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.381 : Str = CallByName Inspect.246 Inspect.145 Inspect.299; - ret Inspect.381; - -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; - -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; - ret Inspect.307; - -procedure Inspect.41 (Inspect.224): - let Inspect.311 : List {Str, Str} = CallByName Inspect.30 Inspect.224; - ret Inspect.311; - -procedure Inspect.41 (Inspect.224): - let Inspect.351 : List {Str, Str} = CallByName Inspect.30 Inspect.224; - ret Inspect.351; - -procedure Inspect.43 (Inspect.245): - let Inspect.389 : Str = CallByName Inspect.30 Inspect.245; - ret Inspect.389; - -procedure Inspect.5 (Inspect.146): - let Inspect.308 : Str = CallByName #Derived.0 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName #Derived.2 Inspect.304 Inspect.308; - ret Inspect.303; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.359 : Str = CallByName Str.3 Inspect.296 Inspect.292; +procedure Inspect.229 (Inspect.230, Inspect.228): + let Inspect.392 : Str = "{"; + let Inspect.368 : Str = CallByName Inspect.63 Inspect.230 Inspect.392; + dec Inspect.392; + let Inspect.364 : {Str, Int1} = CallByName Inspect.231 Inspect.368 Inspect.228; + dec Inspect.368; + let Inspect.365 : {} = Struct {}; + let Inspect.360 : Str = CallByName Inspect.243 Inspect.364; + let Inspect.361 : Str = "}"; + let Inspect.359 : Str = CallByName Inspect.63 Inspect.360 Inspect.361; + dec Inspect.361; ret Inspect.359; -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.231 (Inspect.232, Inspect.228): + let Inspect.351 : Int1 = CallByName Bool.1; + inc Inspect.232; + let Inspect.332 : {Str, Int1} = Struct {Inspect.232, Inspect.351}; + let Inspect.333 : {} = Struct {}; + let Inspect.331 : {Str, Int1} = CallByName List.18 Inspect.228 Inspect.332 Inspect.333; + ret Inspect.331; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure Inspect.231 (Inspect.232, Inspect.228): + let Inspect.391 : Int1 = CallByName Bool.1; + inc Inspect.232; + let Inspect.372 : {Str, Int1} = Struct {Inspect.232, Inspect.391}; + let Inspect.373 : {} = Struct {}; + let Inspect.371 : {Str, Int1} = CallByName List.18 Inspect.228 Inspect.372 Inspect.373; + ret Inspect.371; -procedure List.18 (List.163, List.164, List.165): - let List.635 : U64 = 0i64; - let List.636 : U64 = CallByName List.6 List.163; - let List.634 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.635 List.636; - ret List.634; +procedure Inspect.233 (Inspect.334, Inspect.335): + let Inspect.236 : Str = StructAtIndex 0 Inspect.335; + let Inspect.237 : Str = StructAtIndex 1 Inspect.335; + let Inspect.234 : Str = StructAtIndex 0 Inspect.334; + let Inspect.235 : Int1 = StructAtIndex 1 Inspect.334; + joinpoint Inspect.349 Inspect.238: + let Inspect.346 : Str = CallByName Inspect.63 Inspect.238 Inspect.236; + dec Inspect.236; + let Inspect.347 : Str = ": "; + let Inspect.341 : Str = CallByName Inspect.63 Inspect.346 Inspect.347; + dec Inspect.347; + let Inspect.337 : Str = CallByName Inspect.239 Inspect.341 Inspect.237; + let Inspect.338 : {} = Struct {}; + let Inspect.336 : {Str, Int1} = CallByName Inspect.241 Inspect.337; + dec Inspect.337; + ret Inspect.336; + in + if Inspect.235 then + let Inspect.350 : Str = ", "; + let Inspect.348 : Str = CallByName Inspect.63 Inspect.234 Inspect.350; + dec Inspect.350; + jump Inspect.349 Inspect.348; + else + jump Inspect.349 Inspect.234; + +procedure Inspect.233 (Inspect.334, Inspect.335): + let Inspect.236 : Str = StructAtIndex 0 Inspect.335; + let Inspect.237 : Str = StructAtIndex 1 Inspect.335; + let Inspect.234 : Str = StructAtIndex 0 Inspect.334; + let Inspect.235 : Int1 = StructAtIndex 1 Inspect.334; + joinpoint Inspect.389 Inspect.238: + let Inspect.386 : Str = CallByName Inspect.63 Inspect.238 Inspect.236; + dec Inspect.236; + let Inspect.387 : Str = ": "; + let Inspect.381 : Str = CallByName Inspect.63 Inspect.386 Inspect.387; + dec Inspect.387; + let Inspect.377 : Str = CallByName Inspect.239 Inspect.381 Inspect.237; + dec Inspect.237; + let Inspect.378 : {} = Struct {}; + let Inspect.376 : {Str, Int1} = CallByName Inspect.241 Inspect.377; + dec Inspect.377; + ret Inspect.376; + in + if Inspect.235 then + let Inspect.390 : Str = ", "; + let Inspect.388 : Str = CallByName Inspect.63 Inspect.234 Inspect.390; + dec Inspect.390; + jump Inspect.389 Inspect.388; + else + jump Inspect.389 Inspect.234; + +procedure Inspect.239 (Inspect.240, Inspect.237): + let Inspect.344 : Str = CallByName Inspect.31 Inspect.237 Inspect.240; + ret Inspect.344; + +procedure Inspect.239 (Inspect.240, Inspect.237): + let Inspect.384 : Str = CallByName Inspect.31 Inspect.237 Inspect.240; + ret Inspect.384; + +procedure Inspect.241 (Inspect.242): + let Inspect.380 : Int1 = CallByName Bool.2; + inc Inspect.242; + let Inspect.379 : {Str, Int1} = Struct {Inspect.242, Inspect.380}; + ret Inspect.379; + +procedure Inspect.243 (Inspect.326): + let Inspect.367 : Str = StructAtIndex 0 Inspect.326; + ret Inspect.367; + +procedure Inspect.250 (Inspect.251, Inspect.249): + let Inspect.401 : Str = "\""; + let Inspect.400 : Str = CallByName Inspect.63 Inspect.251 Inspect.401; + dec Inspect.401; + let Inspect.398 : Str = CallByName Inspect.63 Inspect.400 Inspect.249; + let Inspect.399 : Str = "\""; + let Inspect.397 : Str = CallByName Inspect.63 Inspect.398 Inspect.399; + dec Inspect.399; + ret Inspect.397; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.314 : Str = CallByName Inspect.229 Inspect.149 Inspect.303; + ret Inspect.314; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.345 : Str = CallByName #Derived.6 Inspect.149 Inspect.303; + ret Inspect.345; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.354 : Str = CallByName Inspect.229 Inspect.149 Inspect.303; + ret Inspect.354; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.385 : Str = CallByName Inspect.250 Inspect.149 Inspect.303; + ret Inspect.385; + +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; + +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.45 (Inspect.228): + let Inspect.315 : List {Str, Str} = CallByName Inspect.30 Inspect.228; + ret Inspect.315; + +procedure Inspect.45 (Inspect.228): + let Inspect.355 : List {Str, Str} = CallByName Inspect.30 Inspect.228; + ret Inspect.355; + +procedure Inspect.47 (Inspect.249): + let Inspect.393 : Str = CallByName Inspect.30 Inspect.249; + ret Inspect.393; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : Str = CallByName #Derived.0 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName #Derived.2 Inspect.308 Inspect.312; + ret Inspect.307; + +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.363 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.363; + +procedure Inspect.64 (Inspect.302): + ret Inspect.302; + +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; + +procedure List.18 (List.166, List.167, List.168): + let List.638 : U64 = 0i64; + let List.639 : U64 = CallByName List.6 List.166; + let List.637 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.638 List.639; + ret List.637; procedure List.6 (#Attr.2): - let List.633 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.633; + let List.636 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.636; procedure List.6 (#Attr.2): - let List.645 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.645; + let List.648 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.648; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; procedure List.66 (#Attr.2, #Attr.3): - let List.644 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.644; + let List.647 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.647; -procedure List.92 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): - joinpoint List.637 List.166 List.167 List.168 List.169 List.170: - let List.639 : Int1 = CallByName Num.22 List.169 List.170; - if List.639 then - let List.643 : {Str, Str} = CallByName List.66 List.166 List.169; - inc List.643; - let List.171 : {Str, Int1} = CallByName Inspect.229 List.167 List.643; - let List.642 : U64 = 1i64; - let List.641 : U64 = CallByName Num.51 List.169 List.642; - jump List.637 List.166 List.171 List.168 List.641 List.170; +procedure List.95 (#Derived_gen.22, #Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26): + joinpoint List.640 List.169 List.170 List.171 List.172 List.173: + let List.642 : Int1 = CallByName Num.22 List.172 List.173; + if List.642 then + let List.646 : {Str, Str} = CallByName List.66 List.169 List.172; + inc List.646; + let List.174 : {Str, Int1} = CallByName Inspect.233 List.170 List.646; + let List.645 : U64 = 1i64; + let List.644 : U64 = CallByName Num.51 List.172 List.645; + jump List.640 List.169 List.174 List.171 List.644 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.26; - jump List.637 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; + inc #Derived_gen.22; + jump List.640 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26; -procedure List.92 (#Derived_gen.39, #Derived_gen.40, #Derived_gen.41, #Derived_gen.42, #Derived_gen.43): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : {Str, Int1} = CallByName Inspect.229 List.167 List.631; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.43, #Derived_gen.44, #Derived_gen.45, #Derived_gen.46, #Derived_gen.47): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : {Str, Str} = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : {Str, Int1} = CallByName Inspect.233 List.170 List.634; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.39; - jump List.625 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42 #Derived_gen.43; + inc #Derived_gen.43; + jump List.628 #Derived_gen.43 #Derived_gen.44 #Derived_gen.45 #Derived_gen.46 #Derived_gen.47; procedure Num.22 (#Attr.2, #Attr.3): - let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.282; + let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.284; procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; procedure Str.3 (#Attr.2, #Attr.3): - let Str.233 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.233; + let Str.237 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.237; procedure Test.0 (): let Test.4 : Str = "bar"; diff --git a/crates/compiler/test_mono/generated/inspect_derived_record.txt b/crates/compiler/test_mono/generated/inspect_derived_record.txt index d07ceac535..259899afba 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_record.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_record.txt @@ -4,15 +4,15 @@ procedure #Derived.0 (#Derived.1): procedure #Derived.2 (#Derived.3, #Derived.1): let #Derived_gen.13 : I64 = StructAtIndex 1 #Derived.1; - let #Derived_gen.11 : [C I64, C Decimal] = CallByName Inspect.53 #Derived_gen.13; + let #Derived_gen.11 : [C I64, C Decimal] = CallByName Inspect.57 #Derived_gen.13; let #Derived_gen.12 : Str = "a"; let #Derived_gen.6 : {[C I64, C Decimal], Str} = Struct {#Derived_gen.11, #Derived_gen.12}; let #Derived_gen.10 : Decimal = StructAtIndex 0 #Derived.1; - let #Derived_gen.8 : [C I64, C Decimal] = CallByName Inspect.58 #Derived_gen.10; + let #Derived_gen.8 : [C I64, C Decimal] = CallByName Inspect.62 #Derived_gen.10; let #Derived_gen.9 : Str = "b"; let #Derived_gen.7 : {[C I64, C Decimal], Str} = Struct {#Derived_gen.8, #Derived_gen.9}; let #Derived_gen.5 : List {[C I64, C Decimal], Str} = Array [#Derived_gen.6, #Derived_gen.7]; - let #Derived_gen.4 : List {[C I64, C Decimal], Str} = CallByName Inspect.41 #Derived_gen.5; + let #Derived_gen.4 : List {[C I64, C Decimal], Str} = CallByName Inspect.45 #Derived_gen.5; let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3; dec #Derived_gen.4; ret #Derived_gen.3; @@ -25,192 +25,192 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure Inspect.225 (Inspect.226, Inspect.224): - let Inspect.349 : Str = "{"; - let Inspect.324 : Str = CallByName Inspect.59 Inspect.226 Inspect.349; - dec Inspect.349; - let Inspect.320 : {Str, Int1} = CallByName Inspect.227 Inspect.324 Inspect.224; - dec Inspect.324; - let Inspect.321 : {} = Struct {}; - let Inspect.316 : Str = CallByName Inspect.239 Inspect.320; - let Inspect.317 : Str = "}"; - let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317; - dec Inspect.317; - ret Inspect.315; - -procedure Inspect.227 (Inspect.228, Inspect.224): - let Inspect.348 : Int1 = CallByName Bool.1; - inc Inspect.228; - let Inspect.328 : {Str, Int1} = Struct {Inspect.228, Inspect.348}; - let Inspect.329 : {} = Struct {}; - let Inspect.327 : {Str, Int1} = CallByName List.18 Inspect.224 Inspect.328 Inspect.329; - ret Inspect.327; - -procedure Inspect.229 (Inspect.330, Inspect.331): - let Inspect.233 : [C I64, C Decimal] = StructAtIndex 0 Inspect.331; - let Inspect.232 : Str = StructAtIndex 1 Inspect.331; - let Inspect.230 : Str = StructAtIndex 0 Inspect.330; - let Inspect.231 : Int1 = StructAtIndex 1 Inspect.330; - joinpoint Inspect.346 Inspect.234: - let Inspect.343 : Str = CallByName Inspect.59 Inspect.234 Inspect.232; - dec Inspect.232; - let Inspect.344 : Str = ": "; - let Inspect.337 : Str = CallByName Inspect.59 Inspect.343 Inspect.344; - dec Inspect.344; - let Inspect.333 : Str = CallByName Inspect.235 Inspect.337 Inspect.233; - let Inspect.334 : {} = Struct {}; - let Inspect.332 : {Str, Int1} = CallByName Inspect.237 Inspect.333; - dec Inspect.333; - ret Inspect.332; - in - if Inspect.231 then - let Inspect.347 : Str = ", "; - let Inspect.345 : Str = CallByName Inspect.59 Inspect.230 Inspect.347; - dec Inspect.347; - jump Inspect.346 Inspect.345; - else - jump Inspect.346 Inspect.230; - -procedure Inspect.235 (Inspect.236, Inspect.233): - let Inspect.340 : Str = CallByName Inspect.31 Inspect.233 Inspect.236; - ret Inspect.340; - -procedure Inspect.237 (Inspect.238): - let Inspect.336 : Int1 = CallByName Bool.2; - inc Inspect.238; - let Inspect.335 : {Str, Int1} = Struct {Inspect.238, Inspect.336}; - ret Inspect.335; - -procedure Inspect.239 (Inspect.322): - let Inspect.323 : Str = StructAtIndex 0 Inspect.322; - ret Inspect.323; - -procedure Inspect.274 (Inspect.275, #Attr.12): - let Inspect.362 : I64 = UnionAtIndex (Id 0) (Index 0) #Attr.12; - let Inspect.361 : Str = CallByName Num.96 Inspect.362; - let Inspect.360 : Str = CallByName Inspect.59 Inspect.275 Inspect.361; - dec Inspect.361; - ret Inspect.360; - -procedure Inspect.289 (Inspect.290, #Attr.12): - let Inspect.356 : Decimal = UnionAtIndex (Id 1) (Index 0) #Attr.12; - let Inspect.355 : Str = CallByName Num.96 Inspect.356; - let Inspect.354 : Str = CallByName Inspect.59 Inspect.290 Inspect.355; - dec Inspect.355; - ret Inspect.354; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.310 : Str = CallByName Inspect.225 Inspect.145 Inspect.299; - ret Inspect.310; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.342 : U8 = GetTagId Inspect.299; - switch Inspect.342: - case 0: - let Inspect.341 : Str = CallByName Inspect.274 Inspect.145 Inspect.299; - ret Inspect.341; - - default: - let Inspect.341 : Str = CallByName Inspect.289 Inspect.145 Inspect.299; - ret Inspect.341; - - -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; - -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; - ret Inspect.307; - -procedure Inspect.41 (Inspect.224): - let Inspect.311 : List {[C I64, C Decimal], Str} = CallByName Inspect.30 Inspect.224; - ret Inspect.311; - -procedure Inspect.5 (Inspect.146): - let Inspect.308 : {Decimal, I64} = CallByName #Derived.0 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName #Derived.2 Inspect.304 Inspect.308; - ret Inspect.303; - -procedure Inspect.53 (Inspect.273): - let Inspect.358 : [C I64, C Decimal] = TagId(0) Inspect.273; - let Inspect.357 : [C I64, C Decimal] = CallByName Inspect.30 Inspect.358; - ret Inspect.357; - -procedure Inspect.58 (Inspect.288): - let Inspect.351 : [C I64, C Decimal] = TagId(1) Inspect.288; - let Inspect.350 : [C I64, C Decimal] = CallByName Inspect.30 Inspect.351; - ret Inspect.350; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.319 : Str = CallByName Str.3 Inspect.296 Inspect.292; +procedure Inspect.229 (Inspect.230, Inspect.228): + let Inspect.353 : Str = "{"; + let Inspect.328 : Str = CallByName Inspect.63 Inspect.230 Inspect.353; + dec Inspect.353; + let Inspect.324 : {Str, Int1} = CallByName Inspect.231 Inspect.328 Inspect.228; + dec Inspect.328; + let Inspect.325 : {} = Struct {}; + let Inspect.320 : Str = CallByName Inspect.243 Inspect.324; + let Inspect.321 : Str = "}"; + let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321; + dec Inspect.321; ret Inspect.319; -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.231 (Inspect.232, Inspect.228): + let Inspect.352 : Int1 = CallByName Bool.1; + inc Inspect.232; + let Inspect.332 : {Str, Int1} = Struct {Inspect.232, Inspect.352}; + let Inspect.333 : {} = Struct {}; + let Inspect.331 : {Str, Int1} = CallByName List.18 Inspect.228 Inspect.332 Inspect.333; + ret Inspect.331; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure Inspect.233 (Inspect.334, Inspect.335): + let Inspect.237 : [C I64, C Decimal] = StructAtIndex 0 Inspect.335; + let Inspect.236 : Str = StructAtIndex 1 Inspect.335; + let Inspect.234 : Str = StructAtIndex 0 Inspect.334; + let Inspect.235 : Int1 = StructAtIndex 1 Inspect.334; + joinpoint Inspect.350 Inspect.238: + let Inspect.347 : Str = CallByName Inspect.63 Inspect.238 Inspect.236; + dec Inspect.236; + let Inspect.348 : Str = ": "; + let Inspect.341 : Str = CallByName Inspect.63 Inspect.347 Inspect.348; + dec Inspect.348; + let Inspect.337 : Str = CallByName Inspect.239 Inspect.341 Inspect.237; + let Inspect.338 : {} = Struct {}; + let Inspect.336 : {Str, Int1} = CallByName Inspect.241 Inspect.337; + dec Inspect.337; + ret Inspect.336; + in + if Inspect.235 then + let Inspect.351 : Str = ", "; + let Inspect.349 : Str = CallByName Inspect.63 Inspect.234 Inspect.351; + dec Inspect.351; + jump Inspect.350 Inspect.349; + else + jump Inspect.350 Inspect.234; + +procedure Inspect.239 (Inspect.240, Inspect.237): + let Inspect.344 : Str = CallByName Inspect.31 Inspect.237 Inspect.240; + ret Inspect.344; + +procedure Inspect.241 (Inspect.242): + let Inspect.340 : Int1 = CallByName Bool.2; + inc Inspect.242; + let Inspect.339 : {Str, Int1} = Struct {Inspect.242, Inspect.340}; + ret Inspect.339; + +procedure Inspect.243 (Inspect.326): + let Inspect.327 : Str = StructAtIndex 0 Inspect.326; + ret Inspect.327; + +procedure Inspect.278 (Inspect.279, #Attr.12): + let Inspect.366 : I64 = UnionAtIndex (Id 0) (Index 0) #Attr.12; + let Inspect.365 : Str = CallByName Num.96 Inspect.366; + let Inspect.364 : Str = CallByName Inspect.63 Inspect.279 Inspect.365; + dec Inspect.365; + ret Inspect.364; + +procedure Inspect.293 (Inspect.294, #Attr.12): + let Inspect.360 : Decimal = UnionAtIndex (Id 1) (Index 0) #Attr.12; + let Inspect.359 : Str = CallByName Num.96 Inspect.360; + let Inspect.358 : Str = CallByName Inspect.63 Inspect.294 Inspect.359; + dec Inspect.359; + ret Inspect.358; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.314 : Str = CallByName Inspect.229 Inspect.149 Inspect.303; + ret Inspect.314; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.346 : U8 = GetTagId Inspect.303; + switch Inspect.346: + case 0: + let Inspect.345 : Str = CallByName Inspect.278 Inspect.149 Inspect.303; + ret Inspect.345; + + default: + let Inspect.345 : Str = CallByName Inspect.293 Inspect.149 Inspect.303; + ret Inspect.345; + + +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; + +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.45 (Inspect.228): + let Inspect.315 : List {[C I64, C Decimal], Str} = CallByName Inspect.30 Inspect.228; + ret Inspect.315; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : {Decimal, I64} = CallByName #Derived.0 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName #Derived.2 Inspect.308 Inspect.312; + ret Inspect.307; + +procedure Inspect.57 (Inspect.277): + let Inspect.362 : [C I64, C Decimal] = TagId(0) Inspect.277; + let Inspect.361 : [C I64, C Decimal] = CallByName Inspect.30 Inspect.362; + ret Inspect.361; + +procedure Inspect.62 (Inspect.292): + let Inspect.355 : [C I64, C Decimal] = TagId(1) Inspect.292; + let Inspect.354 : [C I64, C Decimal] = CallByName Inspect.30 Inspect.355; + ret Inspect.354; + +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.323 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.323; + +procedure Inspect.64 (Inspect.302): + ret Inspect.302; + +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; procedure List.6 (#Attr.2): - let List.633 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.633; + let List.636 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.636; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : {[C I64, C Decimal], Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : {[C I64, C Decimal], Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; -procedure List.92 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : {[C I64, C Decimal], Str} = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : {Str, Int1} = CallByName Inspect.229 List.167 List.631; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : {[C I64, C Decimal], Str} = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : {Str, Int1} = CallByName Inspect.233 List.170 List.634; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in inc #Derived_gen.26; - jump List.625 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; + jump List.628 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; procedure Num.22 (#Attr.2, #Attr.3): - let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.282; + let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.284; procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; + +procedure Num.96 (#Attr.2): + let Num.281 : Str = lowlevel NumToStr #Attr.2; ret Num.281; procedure Num.96 (#Attr.2): - let Num.279 : Str = lowlevel NumToStr #Attr.2; - ret Num.279; - -procedure Num.96 (#Attr.2): - let Num.280 : Str = lowlevel NumToStr #Attr.2; - ret Num.280; + let Num.282 : Str = lowlevel NumToStr #Attr.2; + ret Num.282; procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.0 (): let Test.3 : Decimal = 3dec; diff --git a/crates/compiler/test_mono/generated/inspect_derived_record_one_field_string.txt b/crates/compiler/test_mono/generated/inspect_derived_record_one_field_string.txt index 4a5e2edb17..4762bad1db 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_record_one_field_string.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_record_one_field_string.txt @@ -4,10 +4,10 @@ procedure #Derived.0 (#Derived.1): procedure #Derived.2 (#Derived.3, #Derived.1): let #Derived_gen.7 : Str = "a"; - let #Derived_gen.8 : Str = CallByName Inspect.43 #Derived.1; + let #Derived_gen.8 : Str = CallByName Inspect.47 #Derived.1; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8}; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6]; - let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.41 #Derived_gen.5; + let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.45 #Derived_gen.5; let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3; dec #Derived_gen.4; ret #Derived_gen.3; @@ -20,167 +20,167 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure Inspect.225 (Inspect.226, Inspect.224): - let Inspect.348 : Str = "{"; - let Inspect.324 : Str = CallByName Inspect.59 Inspect.226 Inspect.348; - dec Inspect.348; - let Inspect.320 : {Str, Int1} = CallByName Inspect.227 Inspect.324 Inspect.224; - dec Inspect.324; - let Inspect.321 : {} = Struct {}; - let Inspect.316 : Str = CallByName Inspect.239 Inspect.320; - let Inspect.317 : Str = "}"; - let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317; - dec Inspect.317; - ret Inspect.315; - -procedure Inspect.227 (Inspect.228, Inspect.224): - let Inspect.347 : Int1 = CallByName Bool.1; - inc Inspect.228; - let Inspect.328 : {Str, Int1} = Struct {Inspect.228, Inspect.347}; - let Inspect.329 : {} = Struct {}; - let Inspect.327 : {Str, Int1} = CallByName List.18 Inspect.224 Inspect.328 Inspect.329; - ret Inspect.327; - -procedure Inspect.229 (Inspect.330, Inspect.331): - let Inspect.232 : Str = StructAtIndex 0 Inspect.331; - let Inspect.233 : Str = StructAtIndex 1 Inspect.331; - let Inspect.230 : Str = StructAtIndex 0 Inspect.330; - let Inspect.231 : Int1 = StructAtIndex 1 Inspect.330; - joinpoint Inspect.345 Inspect.234: - let Inspect.342 : Str = CallByName Inspect.59 Inspect.234 Inspect.232; - dec Inspect.232; - let Inspect.343 : Str = ": "; - let Inspect.337 : Str = CallByName Inspect.59 Inspect.342 Inspect.343; - dec Inspect.343; - let Inspect.333 : Str = CallByName Inspect.235 Inspect.337 Inspect.233; - dec Inspect.233; - let Inspect.334 : {} = Struct {}; - let Inspect.332 : {Str, Int1} = CallByName Inspect.237 Inspect.333; - dec Inspect.333; - ret Inspect.332; - in - if Inspect.231 then - let Inspect.346 : Str = ", "; - let Inspect.344 : Str = CallByName Inspect.59 Inspect.230 Inspect.346; - dec Inspect.346; - jump Inspect.345 Inspect.344; - else - jump Inspect.345 Inspect.230; - -procedure Inspect.235 (Inspect.236, Inspect.233): - let Inspect.340 : Str = CallByName Inspect.31 Inspect.233 Inspect.236; - ret Inspect.340; - -procedure Inspect.237 (Inspect.238): - let Inspect.336 : Int1 = CallByName Bool.2; - inc Inspect.238; - let Inspect.335 : {Str, Int1} = Struct {Inspect.238, Inspect.336}; - ret Inspect.335; - -procedure Inspect.239 (Inspect.322): - let Inspect.323 : Str = StructAtIndex 0 Inspect.322; - ret Inspect.323; - -procedure Inspect.246 (Inspect.247, Inspect.245): - let Inspect.357 : Str = "\""; - let Inspect.356 : Str = CallByName Inspect.59 Inspect.247 Inspect.357; - dec Inspect.357; - let Inspect.354 : Str = CallByName Inspect.59 Inspect.356 Inspect.245; - let Inspect.355 : Str = "\""; - let Inspect.353 : Str = CallByName Inspect.59 Inspect.354 Inspect.355; - dec Inspect.355; - ret Inspect.353; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.310 : Str = CallByName Inspect.225 Inspect.145 Inspect.299; - ret Inspect.310; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.341 : Str = CallByName Inspect.246 Inspect.145 Inspect.299; - ret Inspect.341; - -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; - -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; - ret Inspect.307; - -procedure Inspect.41 (Inspect.224): - let Inspect.311 : List {Str, Str} = CallByName Inspect.30 Inspect.224; - ret Inspect.311; - -procedure Inspect.43 (Inspect.245): - let Inspect.349 : Str = CallByName Inspect.30 Inspect.245; - ret Inspect.349; - -procedure Inspect.5 (Inspect.146): - let Inspect.308 : Str = CallByName #Derived.0 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName #Derived.2 Inspect.304 Inspect.308; - ret Inspect.303; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.319 : Str = CallByName Str.3 Inspect.296 Inspect.292; +procedure Inspect.229 (Inspect.230, Inspect.228): + let Inspect.352 : Str = "{"; + let Inspect.328 : Str = CallByName Inspect.63 Inspect.230 Inspect.352; + dec Inspect.352; + let Inspect.324 : {Str, Int1} = CallByName Inspect.231 Inspect.328 Inspect.228; + dec Inspect.328; + let Inspect.325 : {} = Struct {}; + let Inspect.320 : Str = CallByName Inspect.243 Inspect.324; + let Inspect.321 : Str = "}"; + let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321; + dec Inspect.321; ret Inspect.319; -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.231 (Inspect.232, Inspect.228): + let Inspect.351 : Int1 = CallByName Bool.1; + inc Inspect.232; + let Inspect.332 : {Str, Int1} = Struct {Inspect.232, Inspect.351}; + let Inspect.333 : {} = Struct {}; + let Inspect.331 : {Str, Int1} = CallByName List.18 Inspect.228 Inspect.332 Inspect.333; + ret Inspect.331; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure Inspect.233 (Inspect.334, Inspect.335): + let Inspect.236 : Str = StructAtIndex 0 Inspect.335; + let Inspect.237 : Str = StructAtIndex 1 Inspect.335; + let Inspect.234 : Str = StructAtIndex 0 Inspect.334; + let Inspect.235 : Int1 = StructAtIndex 1 Inspect.334; + joinpoint Inspect.349 Inspect.238: + let Inspect.346 : Str = CallByName Inspect.63 Inspect.238 Inspect.236; + dec Inspect.236; + let Inspect.347 : Str = ": "; + let Inspect.341 : Str = CallByName Inspect.63 Inspect.346 Inspect.347; + dec Inspect.347; + let Inspect.337 : Str = CallByName Inspect.239 Inspect.341 Inspect.237; + dec Inspect.237; + let Inspect.338 : {} = Struct {}; + let Inspect.336 : {Str, Int1} = CallByName Inspect.241 Inspect.337; + dec Inspect.337; + ret Inspect.336; + in + if Inspect.235 then + let Inspect.350 : Str = ", "; + let Inspect.348 : Str = CallByName Inspect.63 Inspect.234 Inspect.350; + dec Inspect.350; + jump Inspect.349 Inspect.348; + else + jump Inspect.349 Inspect.234; + +procedure Inspect.239 (Inspect.240, Inspect.237): + let Inspect.344 : Str = CallByName Inspect.31 Inspect.237 Inspect.240; + ret Inspect.344; + +procedure Inspect.241 (Inspect.242): + let Inspect.340 : Int1 = CallByName Bool.2; + inc Inspect.242; + let Inspect.339 : {Str, Int1} = Struct {Inspect.242, Inspect.340}; + ret Inspect.339; + +procedure Inspect.243 (Inspect.326): + let Inspect.327 : Str = StructAtIndex 0 Inspect.326; + ret Inspect.327; + +procedure Inspect.250 (Inspect.251, Inspect.249): + let Inspect.361 : Str = "\""; + let Inspect.360 : Str = CallByName Inspect.63 Inspect.251 Inspect.361; + dec Inspect.361; + let Inspect.358 : Str = CallByName Inspect.63 Inspect.360 Inspect.249; + let Inspect.359 : Str = "\""; + let Inspect.357 : Str = CallByName Inspect.63 Inspect.358 Inspect.359; + dec Inspect.359; + ret Inspect.357; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.314 : Str = CallByName Inspect.229 Inspect.149 Inspect.303; + ret Inspect.314; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.345 : Str = CallByName Inspect.250 Inspect.149 Inspect.303; + ret Inspect.345; + +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; + +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.45 (Inspect.228): + let Inspect.315 : List {Str, Str} = CallByName Inspect.30 Inspect.228; + ret Inspect.315; + +procedure Inspect.47 (Inspect.249): + let Inspect.353 : Str = CallByName Inspect.30 Inspect.249; + ret Inspect.353; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : Str = CallByName #Derived.0 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName #Derived.2 Inspect.308 Inspect.312; + ret Inspect.307; + +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.323 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.323; + +procedure Inspect.64 (Inspect.302): + ret Inspect.302; + +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; procedure List.6 (#Attr.2): - let List.633 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.633; + let List.636 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.636; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; -procedure List.92 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : {Str, Int1} = CallByName Inspect.229 List.167 List.631; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : {Str, Str} = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : {Str, Int1} = CallByName Inspect.233 List.170 List.634; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.10; - jump List.625 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; + inc #Derived_gen.14; + jump List.628 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.0 (): let Test.3 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/inspect_derived_record_two_field_strings.txt b/crates/compiler/test_mono/generated/inspect_derived_record_two_field_strings.txt index 4b8a87ba09..cc591fb7b8 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_record_two_field_strings.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_record_two_field_strings.txt @@ -6,15 +6,15 @@ procedure #Derived.2 (#Derived.3, #Derived.1): let #Derived_gen.11 : Str = "a"; let #Derived_gen.13 : Str = StructAtIndex 0 #Derived.1; inc #Derived_gen.13; - let #Derived_gen.12 : Str = CallByName Inspect.43 #Derived_gen.13; + let #Derived_gen.12 : Str = CallByName Inspect.47 #Derived_gen.13; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.11, #Derived_gen.12}; let #Derived_gen.8 : Str = "b"; let #Derived_gen.10 : Str = StructAtIndex 1 #Derived.1; dec #Derived_gen.13; - let #Derived_gen.9 : Str = CallByName Inspect.43 #Derived_gen.10; + let #Derived_gen.9 : Str = CallByName Inspect.47 #Derived_gen.10; let #Derived_gen.7 : {Str, Str} = Struct {#Derived_gen.8, #Derived_gen.9}; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6, #Derived_gen.7]; - let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.41 #Derived_gen.5; + let #Derived_gen.4 : List {Str, Str} = CallByName Inspect.45 #Derived_gen.5; let #Derived_gen.3 : Str = CallByName Inspect.31 #Derived_gen.4 #Derived.3; dec #Derived_gen.4; ret #Derived_gen.3; @@ -27,167 +27,167 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure Inspect.225 (Inspect.226, Inspect.224): - let Inspect.348 : Str = "{"; - let Inspect.324 : Str = CallByName Inspect.59 Inspect.226 Inspect.348; - dec Inspect.348; - let Inspect.320 : {Str, Int1} = CallByName Inspect.227 Inspect.324 Inspect.224; - dec Inspect.324; - let Inspect.321 : {} = Struct {}; - let Inspect.316 : Str = CallByName Inspect.239 Inspect.320; - let Inspect.317 : Str = "}"; - let Inspect.315 : Str = CallByName Inspect.59 Inspect.316 Inspect.317; - dec Inspect.317; - ret Inspect.315; - -procedure Inspect.227 (Inspect.228, Inspect.224): - let Inspect.347 : Int1 = CallByName Bool.1; - inc Inspect.228; - let Inspect.328 : {Str, Int1} = Struct {Inspect.228, Inspect.347}; - let Inspect.329 : {} = Struct {}; - let Inspect.327 : {Str, Int1} = CallByName List.18 Inspect.224 Inspect.328 Inspect.329; - ret Inspect.327; - -procedure Inspect.229 (Inspect.330, Inspect.331): - let Inspect.232 : Str = StructAtIndex 0 Inspect.331; - let Inspect.233 : Str = StructAtIndex 1 Inspect.331; - let Inspect.230 : Str = StructAtIndex 0 Inspect.330; - let Inspect.231 : Int1 = StructAtIndex 1 Inspect.330; - joinpoint Inspect.345 Inspect.234: - let Inspect.342 : Str = CallByName Inspect.59 Inspect.234 Inspect.232; - dec Inspect.232; - let Inspect.343 : Str = ": "; - let Inspect.337 : Str = CallByName Inspect.59 Inspect.342 Inspect.343; - dec Inspect.343; - let Inspect.333 : Str = CallByName Inspect.235 Inspect.337 Inspect.233; - dec Inspect.233; - let Inspect.334 : {} = Struct {}; - let Inspect.332 : {Str, Int1} = CallByName Inspect.237 Inspect.333; - dec Inspect.333; - ret Inspect.332; - in - if Inspect.231 then - let Inspect.346 : Str = ", "; - let Inspect.344 : Str = CallByName Inspect.59 Inspect.230 Inspect.346; - dec Inspect.346; - jump Inspect.345 Inspect.344; - else - jump Inspect.345 Inspect.230; - -procedure Inspect.235 (Inspect.236, Inspect.233): - let Inspect.340 : Str = CallByName Inspect.31 Inspect.233 Inspect.236; - ret Inspect.340; - -procedure Inspect.237 (Inspect.238): - let Inspect.336 : Int1 = CallByName Bool.2; - inc Inspect.238; - let Inspect.335 : {Str, Int1} = Struct {Inspect.238, Inspect.336}; - ret Inspect.335; - -procedure Inspect.239 (Inspect.322): - let Inspect.323 : Str = StructAtIndex 0 Inspect.322; - ret Inspect.323; - -procedure Inspect.246 (Inspect.247, Inspect.245): - let Inspect.357 : Str = "\""; - let Inspect.356 : Str = CallByName Inspect.59 Inspect.247 Inspect.357; - dec Inspect.357; - let Inspect.354 : Str = CallByName Inspect.59 Inspect.356 Inspect.245; - let Inspect.355 : Str = "\""; - let Inspect.353 : Str = CallByName Inspect.59 Inspect.354 Inspect.355; - dec Inspect.355; - ret Inspect.353; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.310 : Str = CallByName Inspect.225 Inspect.145 Inspect.299; - ret Inspect.310; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.341 : Str = CallByName Inspect.246 Inspect.145 Inspect.299; - ret Inspect.341; - -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; - -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; - ret Inspect.307; - -procedure Inspect.41 (Inspect.224): - let Inspect.311 : List {Str, Str} = CallByName Inspect.30 Inspect.224; - ret Inspect.311; - -procedure Inspect.43 (Inspect.245): - let Inspect.358 : Str = CallByName Inspect.30 Inspect.245; - ret Inspect.358; - -procedure Inspect.5 (Inspect.146): - let Inspect.308 : {Str, Str} = CallByName #Derived.0 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName #Derived.2 Inspect.304 Inspect.308; - ret Inspect.303; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.319 : Str = CallByName Str.3 Inspect.296 Inspect.292; +procedure Inspect.229 (Inspect.230, Inspect.228): + let Inspect.352 : Str = "{"; + let Inspect.328 : Str = CallByName Inspect.63 Inspect.230 Inspect.352; + dec Inspect.352; + let Inspect.324 : {Str, Int1} = CallByName Inspect.231 Inspect.328 Inspect.228; + dec Inspect.328; + let Inspect.325 : {} = Struct {}; + let Inspect.320 : Str = CallByName Inspect.243 Inspect.324; + let Inspect.321 : Str = "}"; + let Inspect.319 : Str = CallByName Inspect.63 Inspect.320 Inspect.321; + dec Inspect.321; ret Inspect.319; -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.231 (Inspect.232, Inspect.228): + let Inspect.351 : Int1 = CallByName Bool.1; + inc Inspect.232; + let Inspect.332 : {Str, Int1} = Struct {Inspect.232, Inspect.351}; + let Inspect.333 : {} = Struct {}; + let Inspect.331 : {Str, Int1} = CallByName List.18 Inspect.228 Inspect.332 Inspect.333; + ret Inspect.331; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : {Str, Int1} = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure Inspect.233 (Inspect.334, Inspect.335): + let Inspect.236 : Str = StructAtIndex 0 Inspect.335; + let Inspect.237 : Str = StructAtIndex 1 Inspect.335; + let Inspect.234 : Str = StructAtIndex 0 Inspect.334; + let Inspect.235 : Int1 = StructAtIndex 1 Inspect.334; + joinpoint Inspect.349 Inspect.238: + let Inspect.346 : Str = CallByName Inspect.63 Inspect.238 Inspect.236; + dec Inspect.236; + let Inspect.347 : Str = ": "; + let Inspect.341 : Str = CallByName Inspect.63 Inspect.346 Inspect.347; + dec Inspect.347; + let Inspect.337 : Str = CallByName Inspect.239 Inspect.341 Inspect.237; + dec Inspect.237; + let Inspect.338 : {} = Struct {}; + let Inspect.336 : {Str, Int1} = CallByName Inspect.241 Inspect.337; + dec Inspect.337; + ret Inspect.336; + in + if Inspect.235 then + let Inspect.350 : Str = ", "; + let Inspect.348 : Str = CallByName Inspect.63 Inspect.234 Inspect.350; + dec Inspect.350; + jump Inspect.349 Inspect.348; + else + jump Inspect.349 Inspect.234; + +procedure Inspect.239 (Inspect.240, Inspect.237): + let Inspect.344 : Str = CallByName Inspect.31 Inspect.237 Inspect.240; + ret Inspect.344; + +procedure Inspect.241 (Inspect.242): + let Inspect.340 : Int1 = CallByName Bool.2; + inc Inspect.242; + let Inspect.339 : {Str, Int1} = Struct {Inspect.242, Inspect.340}; + ret Inspect.339; + +procedure Inspect.243 (Inspect.326): + let Inspect.327 : Str = StructAtIndex 0 Inspect.326; + ret Inspect.327; + +procedure Inspect.250 (Inspect.251, Inspect.249): + let Inspect.361 : Str = "\""; + let Inspect.360 : Str = CallByName Inspect.63 Inspect.251 Inspect.361; + dec Inspect.361; + let Inspect.358 : Str = CallByName Inspect.63 Inspect.360 Inspect.249; + let Inspect.359 : Str = "\""; + let Inspect.357 : Str = CallByName Inspect.63 Inspect.358 Inspect.359; + dec Inspect.359; + ret Inspect.357; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.314 : Str = CallByName Inspect.229 Inspect.149 Inspect.303; + ret Inspect.314; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.345 : Str = CallByName Inspect.250 Inspect.149 Inspect.303; + ret Inspect.345; + +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; + +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.45 (Inspect.228): + let Inspect.315 : List {Str, Str} = CallByName Inspect.30 Inspect.228; + ret Inspect.315; + +procedure Inspect.47 (Inspect.249): + let Inspect.362 : Str = CallByName Inspect.30 Inspect.249; + ret Inspect.362; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : {Str, Str} = CallByName #Derived.0 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName #Derived.2 Inspect.308 Inspect.312; + ret Inspect.307; + +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.323 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.323; + +procedure Inspect.64 (Inspect.302): + ret Inspect.302; + +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : {Str, Int1} = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; procedure List.6 (#Attr.2): - let List.633 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.633; + let List.636 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.636; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; -procedure List.92 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : {Str, Str} = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : {Str, Int1} = CallByName Inspect.229 List.167 List.631; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : {Str, Str} = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : {Str, Int1} = CallByName Inspect.233 List.170 List.634; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.14; - jump List.625 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; + inc #Derived_gen.18; + jump List.628 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.0 (): let Test.3 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/inspect_derived_string.txt b/crates/compiler/test_mono/generated/inspect_derived_string.txt index 1f6994deef..caf8cfe502 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_string.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_string.txt @@ -1,47 +1,47 @@ -procedure Inspect.246 (Inspect.247, Inspect.245): +procedure Inspect.250 (Inspect.251, Inspect.249): + let Inspect.323 : Str = "\""; + let Inspect.322 : Str = CallByName Inspect.63 Inspect.251 Inspect.323; + dec Inspect.323; + let Inspect.318 : Str = CallByName Inspect.63 Inspect.322 Inspect.249; let Inspect.319 : Str = "\""; - let Inspect.318 : Str = CallByName Inspect.59 Inspect.247 Inspect.319; + let Inspect.317 : Str = CallByName Inspect.63 Inspect.318 Inspect.319; dec Inspect.319; - let Inspect.314 : Str = CallByName Inspect.59 Inspect.318 Inspect.245; - let Inspect.315 : Str = "\""; - let Inspect.313 : Str = CallByName Inspect.59 Inspect.314 Inspect.315; - dec Inspect.315; - ret Inspect.313; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; - -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; - ret Inspect.307; - -procedure Inspect.43 (Inspect.245): - let Inspect.309 : Str = CallByName Inspect.30 Inspect.245; - ret Inspect.309; - -procedure Inspect.5 (Inspect.146): - let Inspect.308 : Str = CallByName Inspect.43 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName Inspect.246 Inspect.304 Inspect.308; - dec Inspect.308; - ret Inspect.303; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.317 : Str = CallByName Str.3 Inspect.296 Inspect.292; ret Inspect.317; -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; + +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.47 (Inspect.249): + let Inspect.313 : Str = CallByName Inspect.30 Inspect.249; + ret Inspect.313; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : Str = CallByName Inspect.47 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName Inspect.250 Inspect.308 Inspect.312; + dec Inspect.312; + ret Inspect.307; + +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.321 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.321; + +procedure Inspect.64 (Inspect.302): + ret Inspect.302; procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.0 (): let Test.2 : Str = "abc"; diff --git a/crates/compiler/test_mono/generated/inspect_derived_tag_one_field_string.txt b/crates/compiler/test_mono/generated/inspect_derived_tag_one_field_string.txt index 543ef054b4..eab6d2971c 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_tag_one_field_string.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_tag_one_field_string.txt @@ -8,9 +8,9 @@ procedure #Derived.3 (#Derived.4, #Derived.1): ret #Derived_gen.3; in let #Derived_gen.7 : Str = "A"; - let #Derived_gen.9 : Str = CallByName Inspect.43 #Derived.1; + let #Derived_gen.9 : Str = CallByName Inspect.47 #Derived.1; let #Derived_gen.8 : List Str = Array [#Derived_gen.9]; - let #Derived_gen.6 : [C Str, C Str List Str] = CallByName Inspect.39 #Derived_gen.7 #Derived_gen.8; + let #Derived_gen.6 : [C Str, C Str List Str] = CallByName Inspect.43 #Derived_gen.7 #Derived_gen.8; dec #Derived_gen.8; dec #Derived_gen.7; jump #Derived_gen.5 #Derived_gen.6; @@ -19,168 +19,168 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.23; -procedure Inspect.200 (Inspect.201, #Attr.12): - let Inspect.342 : Str = UnionAtIndex (Id 0) (Index 0) #Attr.12; - let Inspect.341 : Str = CallByName Inspect.59 Inspect.201 Inspect.342; - dec Inspect.342; - ret Inspect.341; +procedure Inspect.204 (Inspect.205, #Attr.12): + let Inspect.346 : Str = UnionAtIndex (Id 0) (Index 0) #Attr.12; + let Inspect.345 : Str = CallByName Inspect.63 Inspect.205 Inspect.346; + dec Inspect.346; + ret Inspect.345; -procedure Inspect.202 (Inspect.203, #Attr.12): - let Inspect.336 : List Str = UnionAtIndex (Id 1) (Index 1) #Attr.12; - let Inspect.335 : Str = UnionAtIndex (Id 1) (Index 0) #Attr.12; - let Inspect.334 : Str = "("; - let Inspect.333 : Str = CallByName Inspect.59 Inspect.203 Inspect.334; - dec Inspect.334; - let Inspect.321 : Str = CallByName Inspect.59 Inspect.333 Inspect.335; - dec Inspect.335; - let Inspect.317 : Str = CallByName Inspect.204 Inspect.321 Inspect.336; - dec Inspect.336; - let Inspect.318 : Str = ")"; - let Inspect.316 : Str = CallByName Inspect.59 Inspect.317 Inspect.318; - dec Inspect.318; - ret Inspect.316; - -procedure Inspect.204 (Inspect.205, Inspect.199): - let Inspect.325 : {} = Struct {}; - let Inspect.324 : Str = CallByName List.18 Inspect.199 Inspect.205 Inspect.325; - ret Inspect.324; - -procedure Inspect.206 (Inspect.207, Inspect.208): - let Inspect.332 : Str = " "; - let Inspect.327 : Str = CallByName Inspect.59 Inspect.207 Inspect.332; - dec Inspect.332; - let Inspect.326 : Str = CallByName Inspect.209 Inspect.327 Inspect.208; - ret Inspect.326; - -procedure Inspect.209 (Inspect.210, Inspect.208): - let Inspect.330 : Str = CallByName Inspect.31 Inspect.208 Inspect.210; - ret Inspect.330; - -procedure Inspect.246 (Inspect.247, Inspect.245): - let Inspect.351 : Str = "\""; - let Inspect.350 : Str = CallByName Inspect.59 Inspect.247 Inspect.351; - dec Inspect.351; - let Inspect.348 : Str = CallByName Inspect.59 Inspect.350 Inspect.245; - let Inspect.349 : Str = "\""; - let Inspect.347 : Str = CallByName Inspect.59 Inspect.348 Inspect.349; - dec Inspect.349; - ret Inspect.347; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.311 : U8 = GetTagId Inspect.299; - switch Inspect.311: - case 0: - let Inspect.310 : Str = CallByName Inspect.200 Inspect.145 Inspect.299; - ret Inspect.310; - - default: - let Inspect.310 : Str = CallByName Inspect.202 Inspect.145 Inspect.299; - ret Inspect.310; - - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.331 : Str = CallByName Inspect.246 Inspect.145 Inspect.299; - ret Inspect.331; - -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; - -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; - ret Inspect.307; - -procedure Inspect.39 (Inspect.198, Inspect.199): - let Inspect.337 : Int1 = CallByName List.1 Inspect.199; - if Inspect.337 then - inc Inspect.198; - let Inspect.339 : [C Str, C Str List Str] = TagId(0) Inspect.198; - let Inspect.338 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.339; - ret Inspect.338; - else - inc Inspect.199; - inc Inspect.198; - let Inspect.313 : [C Str, C Str List Str] = TagId(1) Inspect.198 Inspect.199; - let Inspect.312 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.313; - ret Inspect.312; - -procedure Inspect.43 (Inspect.245): - let Inspect.343 : Str = CallByName Inspect.30 Inspect.245; - ret Inspect.343; - -procedure Inspect.5 (Inspect.146): - let Inspect.308 : Str = CallByName #Derived.0 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName #Derived.3 Inspect.304 Inspect.308; - ret Inspect.303; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.320 : Str = CallByName Str.3 Inspect.296 Inspect.292; +procedure Inspect.206 (Inspect.207, #Attr.12): + let Inspect.340 : List Str = UnionAtIndex (Id 1) (Index 1) #Attr.12; + let Inspect.339 : Str = UnionAtIndex (Id 1) (Index 0) #Attr.12; + let Inspect.338 : Str = "("; + let Inspect.337 : Str = CallByName Inspect.63 Inspect.207 Inspect.338; + dec Inspect.338; + let Inspect.325 : Str = CallByName Inspect.63 Inspect.337 Inspect.339; + dec Inspect.339; + let Inspect.321 : Str = CallByName Inspect.208 Inspect.325 Inspect.340; + dec Inspect.340; + let Inspect.322 : Str = ")"; + let Inspect.320 : Str = CallByName Inspect.63 Inspect.321 Inspect.322; + dec Inspect.322; ret Inspect.320; -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.208 (Inspect.209, Inspect.203): + let Inspect.329 : {} = Struct {}; + let Inspect.328 : Str = CallByName List.18 Inspect.203 Inspect.209 Inspect.329; + ret Inspect.328; -procedure List.1 (List.110): - let List.635 : U64 = CallByName List.6 List.110; - let List.636 : U64 = 0i64; - let List.634 : Int1 = CallByName Bool.11 List.635 List.636; - ret List.634; +procedure Inspect.210 (Inspect.211, Inspect.212): + let Inspect.336 : Str = " "; + let Inspect.331 : Str = CallByName Inspect.63 Inspect.211 Inspect.336; + dec Inspect.336; + let Inspect.330 : Str = CallByName Inspect.213 Inspect.331 Inspect.212; + ret Inspect.330; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : Str = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure Inspect.213 (Inspect.214, Inspect.212): + let Inspect.334 : Str = CallByName Inspect.31 Inspect.212 Inspect.214; + ret Inspect.334; + +procedure Inspect.250 (Inspect.251, Inspect.249): + let Inspect.355 : Str = "\""; + let Inspect.354 : Str = CallByName Inspect.63 Inspect.251 Inspect.355; + dec Inspect.355; + let Inspect.352 : Str = CallByName Inspect.63 Inspect.354 Inspect.249; + let Inspect.353 : Str = "\""; + let Inspect.351 : Str = CallByName Inspect.63 Inspect.352 Inspect.353; + dec Inspect.353; + ret Inspect.351; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.315 : U8 = GetTagId Inspect.303; + switch Inspect.315: + case 0: + let Inspect.314 : Str = CallByName Inspect.204 Inspect.149 Inspect.303; + ret Inspect.314; + + default: + let Inspect.314 : Str = CallByName Inspect.206 Inspect.149 Inspect.303; + ret Inspect.314; + + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.335 : Str = CallByName Inspect.250 Inspect.149 Inspect.303; + ret Inspect.335; + +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; + +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.43 (Inspect.202, Inspect.203): + let Inspect.341 : Int1 = CallByName List.1 Inspect.203; + if Inspect.341 then + inc Inspect.202; + let Inspect.343 : [C Str, C Str List Str] = TagId(0) Inspect.202; + let Inspect.342 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.343; + ret Inspect.342; + else + inc Inspect.203; + inc Inspect.202; + let Inspect.317 : [C Str, C Str List Str] = TagId(1) Inspect.202 Inspect.203; + let Inspect.316 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.317; + ret Inspect.316; + +procedure Inspect.47 (Inspect.249): + let Inspect.347 : Str = CallByName Inspect.30 Inspect.249; + ret Inspect.347; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : Str = CallByName #Derived.0 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName #Derived.3 Inspect.308 Inspect.312; + ret Inspect.307; + +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.324 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.324; + +procedure Inspect.64 (Inspect.302): + ret Inspect.302; + +procedure List.1 (List.113): + let List.638 : U64 = CallByName List.6 List.113; + let List.639 : U64 = 0i64; + let List.637 : Int1 = CallByName Bool.11 List.638 List.639; + ret List.637; + +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : Str = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; procedure List.6 (#Attr.2): - let List.633 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.633; + let List.636 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.636; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; -procedure List.92 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : Str = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : Str = CallByName Inspect.206 List.167 List.631; - dec List.631; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : Str = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : Str = CallByName Inspect.210 List.170 List.634; + dec List.634; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.10; - jump List.625 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; + inc #Derived_gen.14; + jump List.628 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.0 (): let Test.4 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/inspect_derived_tag_two_payloads_string.txt b/crates/compiler/test_mono/generated/inspect_derived_tag_two_payloads_string.txt index ed92fb576b..8bd683c9e3 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_tag_two_payloads_string.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_tag_two_payloads_string.txt @@ -10,10 +10,10 @@ procedure #Derived.4 (#Derived.5, #Derived.1): let #Derived.2 : Str = StructAtIndex 0 #Derived.1; let #Derived.3 : Str = StructAtIndex 1 #Derived.1; let #Derived_gen.7 : Str = "A"; - let #Derived_gen.9 : Str = CallByName Inspect.43 #Derived.2; - let #Derived_gen.10 : Str = CallByName Inspect.43 #Derived.3; + let #Derived_gen.9 : Str = CallByName Inspect.47 #Derived.2; + let #Derived_gen.10 : Str = CallByName Inspect.47 #Derived.3; let #Derived_gen.8 : List Str = Array [#Derived_gen.9, #Derived_gen.10]; - let #Derived_gen.6 : [C Str, C Str List Str] = CallByName Inspect.39 #Derived_gen.7 #Derived_gen.8; + let #Derived_gen.6 : [C Str, C Str List Str] = CallByName Inspect.43 #Derived_gen.7 #Derived_gen.8; dec #Derived_gen.8; dec #Derived_gen.7; jump #Derived_gen.5 #Derived_gen.6; @@ -22,168 +22,168 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.23; -procedure Inspect.200 (Inspect.201, #Attr.12): - let Inspect.342 : Str = UnionAtIndex (Id 0) (Index 0) #Attr.12; - let Inspect.341 : Str = CallByName Inspect.59 Inspect.201 Inspect.342; - dec Inspect.342; - ret Inspect.341; +procedure Inspect.204 (Inspect.205, #Attr.12): + let Inspect.346 : Str = UnionAtIndex (Id 0) (Index 0) #Attr.12; + let Inspect.345 : Str = CallByName Inspect.63 Inspect.205 Inspect.346; + dec Inspect.346; + ret Inspect.345; -procedure Inspect.202 (Inspect.203, #Attr.12): - let Inspect.336 : List Str = UnionAtIndex (Id 1) (Index 1) #Attr.12; - let Inspect.335 : Str = UnionAtIndex (Id 1) (Index 0) #Attr.12; - let Inspect.334 : Str = "("; - let Inspect.333 : Str = CallByName Inspect.59 Inspect.203 Inspect.334; - dec Inspect.334; - let Inspect.321 : Str = CallByName Inspect.59 Inspect.333 Inspect.335; - dec Inspect.335; - let Inspect.317 : Str = CallByName Inspect.204 Inspect.321 Inspect.336; - dec Inspect.336; - let Inspect.318 : Str = ")"; - let Inspect.316 : Str = CallByName Inspect.59 Inspect.317 Inspect.318; - dec Inspect.318; - ret Inspect.316; - -procedure Inspect.204 (Inspect.205, Inspect.199): - let Inspect.325 : {} = Struct {}; - let Inspect.324 : Str = CallByName List.18 Inspect.199 Inspect.205 Inspect.325; - ret Inspect.324; - -procedure Inspect.206 (Inspect.207, Inspect.208): - let Inspect.332 : Str = " "; - let Inspect.327 : Str = CallByName Inspect.59 Inspect.207 Inspect.332; - dec Inspect.332; - let Inspect.326 : Str = CallByName Inspect.209 Inspect.327 Inspect.208; - ret Inspect.326; - -procedure Inspect.209 (Inspect.210, Inspect.208): - let Inspect.330 : Str = CallByName Inspect.31 Inspect.208 Inspect.210; - ret Inspect.330; - -procedure Inspect.246 (Inspect.247, Inspect.245): - let Inspect.351 : Str = "\""; - let Inspect.350 : Str = CallByName Inspect.59 Inspect.247 Inspect.351; - dec Inspect.351; - let Inspect.348 : Str = CallByName Inspect.59 Inspect.350 Inspect.245; - let Inspect.349 : Str = "\""; - let Inspect.347 : Str = CallByName Inspect.59 Inspect.348 Inspect.349; - dec Inspect.349; - ret Inspect.347; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.30 (Inspect.143): - ret Inspect.143; - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.311 : U8 = GetTagId Inspect.299; - switch Inspect.311: - case 0: - let Inspect.310 : Str = CallByName Inspect.200 Inspect.145 Inspect.299; - ret Inspect.310; - - default: - let Inspect.310 : Str = CallByName Inspect.202 Inspect.145 Inspect.299; - ret Inspect.310; - - -procedure Inspect.31 (Inspect.299, Inspect.145): - let Inspect.331 : Str = CallByName Inspect.246 Inspect.145 Inspect.299; - ret Inspect.331; - -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; - -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; - ret Inspect.307; - -procedure Inspect.39 (Inspect.198, Inspect.199): - let Inspect.337 : Int1 = CallByName List.1 Inspect.199; - if Inspect.337 then - inc Inspect.198; - let Inspect.339 : [C Str, C Str List Str] = TagId(0) Inspect.198; - let Inspect.338 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.339; - ret Inspect.338; - else - inc Inspect.199; - inc Inspect.198; - let Inspect.313 : [C Str, C Str List Str] = TagId(1) Inspect.198 Inspect.199; - let Inspect.312 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.313; - ret Inspect.312; - -procedure Inspect.43 (Inspect.245): - let Inspect.352 : Str = CallByName Inspect.30 Inspect.245; - ret Inspect.352; - -procedure Inspect.5 (Inspect.146): - let Inspect.308 : {Str, Str} = CallByName #Derived.0 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName #Derived.4 Inspect.304 Inspect.308; - ret Inspect.303; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.320 : Str = CallByName Str.3 Inspect.296 Inspect.292; +procedure Inspect.206 (Inspect.207, #Attr.12): + let Inspect.340 : List Str = UnionAtIndex (Id 1) (Index 1) #Attr.12; + let Inspect.339 : Str = UnionAtIndex (Id 1) (Index 0) #Attr.12; + let Inspect.338 : Str = "("; + let Inspect.337 : Str = CallByName Inspect.63 Inspect.207 Inspect.338; + dec Inspect.338; + let Inspect.325 : Str = CallByName Inspect.63 Inspect.337 Inspect.339; + dec Inspect.339; + let Inspect.321 : Str = CallByName Inspect.208 Inspect.325 Inspect.340; + dec Inspect.340; + let Inspect.322 : Str = ")"; + let Inspect.320 : Str = CallByName Inspect.63 Inspect.321 Inspect.322; + dec Inspect.322; ret Inspect.320; -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.208 (Inspect.209, Inspect.203): + let Inspect.329 : {} = Struct {}; + let Inspect.328 : Str = CallByName List.18 Inspect.203 Inspect.209 Inspect.329; + ret Inspect.328; -procedure List.1 (List.110): - let List.635 : U64 = CallByName List.6 List.110; - let List.636 : U64 = 0i64; - let List.634 : Int1 = CallByName Bool.11 List.635 List.636; - ret List.634; +procedure Inspect.210 (Inspect.211, Inspect.212): + let Inspect.336 : Str = " "; + let Inspect.331 : Str = CallByName Inspect.63 Inspect.211 Inspect.336; + dec Inspect.336; + let Inspect.330 : Str = CallByName Inspect.213 Inspect.331 Inspect.212; + ret Inspect.330; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : Str = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure Inspect.213 (Inspect.214, Inspect.212): + let Inspect.334 : Str = CallByName Inspect.31 Inspect.212 Inspect.214; + ret Inspect.334; + +procedure Inspect.250 (Inspect.251, Inspect.249): + let Inspect.355 : Str = "\""; + let Inspect.354 : Str = CallByName Inspect.63 Inspect.251 Inspect.355; + dec Inspect.355; + let Inspect.352 : Str = CallByName Inspect.63 Inspect.354 Inspect.249; + let Inspect.353 : Str = "\""; + let Inspect.351 : Str = CallByName Inspect.63 Inspect.352 Inspect.353; + dec Inspect.353; + ret Inspect.351; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.30 (Inspect.147): + ret Inspect.147; + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.315 : U8 = GetTagId Inspect.303; + switch Inspect.315: + case 0: + let Inspect.314 : Str = CallByName Inspect.204 Inspect.149 Inspect.303; + ret Inspect.314; + + default: + let Inspect.314 : Str = CallByName Inspect.206 Inspect.149 Inspect.303; + ret Inspect.314; + + +procedure Inspect.31 (Inspect.303, Inspect.149): + let Inspect.335 : Str = CallByName Inspect.250 Inspect.149 Inspect.303; + ret Inspect.335; + +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; + +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.43 (Inspect.202, Inspect.203): + let Inspect.341 : Int1 = CallByName List.1 Inspect.203; + if Inspect.341 then + inc Inspect.202; + let Inspect.343 : [C Str, C Str List Str] = TagId(0) Inspect.202; + let Inspect.342 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.343; + ret Inspect.342; + else + inc Inspect.203; + inc Inspect.202; + let Inspect.317 : [C Str, C Str List Str] = TagId(1) Inspect.202 Inspect.203; + let Inspect.316 : [C Str, C Str List Str] = CallByName Inspect.30 Inspect.317; + ret Inspect.316; + +procedure Inspect.47 (Inspect.249): + let Inspect.356 : Str = CallByName Inspect.30 Inspect.249; + ret Inspect.356; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : {Str, Str} = CallByName #Derived.0 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName #Derived.4 Inspect.308 Inspect.312; + ret Inspect.307; + +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.324 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.324; + +procedure Inspect.64 (Inspect.302): + ret Inspect.302; + +procedure List.1 (List.113): + let List.638 : U64 = CallByName List.6 List.113; + let List.639 : U64 = 0i64; + let List.637 : Int1 = CallByName Bool.11 List.638 List.639; + ret List.637; + +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : Str = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; procedure List.6 (#Attr.2): - let List.633 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.633; + let List.636 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.636; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; -procedure List.92 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : Str = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : Str = CallByName Inspect.206 List.167 List.631; - dec List.631; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : Str = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : Str = CallByName Inspect.210 List.170 List.634; + dec List.634; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in inc #Derived_gen.13; - jump List.625 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; + jump List.628 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.0 (): let Test.5 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/ir_int_add.txt b/crates/compiler/test_mono/generated/ir_int_add.txt index 300c0db798..08bec6d3c2 100644 --- a/crates/compiler/test_mono/generated/ir_int_add.txt +++ b/crates/compiler/test_mono/generated/ir_int_add.txt @@ -1,10 +1,10 @@ procedure List.6 (#Attr.2): - let List.622 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.622; + let List.625 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.625; procedure Num.19 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.283; procedure Test.0 (): let Test.1 : List I64 = Array [1i64, 2i64]; diff --git a/crates/compiler/test_mono/generated/ir_plus.txt b/crates/compiler/test_mono/generated/ir_plus.txt index 4e98a70eae..29a356d102 100644 --- a/crates/compiler/test_mono/generated/ir_plus.txt +++ b/crates/compiler/test_mono/generated/ir_plus.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.2 : I64 = 1i64; diff --git a/crates/compiler/test_mono/generated/ir_round.txt b/crates/compiler/test_mono/generated/ir_round.txt index bd95abe9e5..61cef3d782 100644 --- a/crates/compiler/test_mono/generated/ir_round.txt +++ b/crates/compiler/test_mono/generated/ir_round.txt @@ -1,6 +1,6 @@ procedure Num.45 (#Attr.2): - let Num.279 : I64 = lowlevel NumRound #Attr.2; - ret Num.279; + let Num.281 : I64 = lowlevel NumRound #Attr.2; + ret Num.281; procedure Test.0 (): let Test.2 : Decimal = 3.6dec; diff --git a/crates/compiler/test_mono/generated/ir_two_defs.txt b/crates/compiler/test_mono/generated/ir_two_defs.txt index 915eb3acd4..58534f57dd 100644 --- a/crates/compiler/test_mono/generated/ir_two_defs.txt +++ b/crates/compiler/test_mono/generated/ir_two_defs.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.1 : I64 = 3i64; diff --git a/crates/compiler/test_mono/generated/ir_when_idiv.txt b/crates/compiler/test_mono/generated/ir_when_idiv.txt index 0c17b3f39a..1e1cbccb19 100644 --- a/crates/compiler/test_mono/generated/ir_when_idiv.txt +++ b/crates/compiler/test_mono/generated/ir_when_idiv.txt @@ -1,22 +1,22 @@ procedure Num.157 (#Attr.2, #Attr.3): - let Num.281 : I64 = lowlevel NumDivTruncUnchecked #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : I64 = lowlevel NumDivTruncUnchecked #Attr.2 #Attr.3; + ret Num.283; procedure Num.30 (#Attr.2): - let Num.286 : I64 = 0i64; - let Num.285 : Int1 = lowlevel Eq #Attr.2 Num.286; - ret Num.285; + let Num.288 : I64 = 0i64; + let Num.287 : Int1 = lowlevel Eq #Attr.2 Num.288; + ret Num.287; -procedure Num.40 (Num.247, Num.248): - let Num.282 : Int1 = CallByName Num.30 Num.248; - if Num.282 then - let Num.284 : {} = Struct {}; - let Num.283 : [C {}, C I64] = TagId(0) Num.284; - ret Num.283; +procedure Num.40 (Num.249, Num.250): + let Num.284 : Int1 = CallByName Num.30 Num.250; + if Num.284 then + let Num.286 : {} = Struct {}; + let Num.285 : [C {}, C I64] = TagId(0) Num.286; + ret Num.285; else - let Num.280 : I64 = CallByName Num.157 Num.247 Num.248; - let Num.279 : [C {}, C I64] = TagId(1) Num.280; - ret Num.279; + let Num.282 : I64 = CallByName Num.157 Num.249 Num.250; + let Num.281 : [C {}, C I64] = TagId(1) Num.282; + ret Num.281; procedure Test.0 (): let Test.8 : I64 = 1000i64; diff --git a/crates/compiler/test_mono/generated/ir_when_just.txt b/crates/compiler/test_mono/generated/ir_when_just.txt index 316d2e16f6..b237e4b6ab 100644 --- a/crates/compiler/test_mono/generated/ir_when_just.txt +++ b/crates/compiler/test_mono/generated/ir_when_just.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.10 : I64 = 41i64; diff --git a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt index 57007102fd..d77df3bbcd 100644 --- a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt +++ b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt @@ -6,66 +6,66 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure List.2 (List.111, List.112): - let List.636 : U64 = CallByName List.6 List.111; - let List.632 : Int1 = CallByName Num.22 List.112 List.636; - if List.632 then - let List.634 : I64 = CallByName List.66 List.111 List.112; - let List.633 : [C {}, C I64] = TagId(1) List.634; - ret List.633; +procedure List.2 (List.114, List.115): + let List.639 : U64 = CallByName List.6 List.114; + let List.635 : Int1 = CallByName Num.22 List.115 List.639; + if List.635 then + let List.637 : I64 = CallByName List.66 List.114 List.115; + let List.636 : [C {}, C I64] = TagId(1) List.637; + ret List.636; else - let List.631 : {} = Struct {}; - let List.630 : [C {}, C I64] = TagId(0) List.631; - ret List.630; + let List.634 : {} = Struct {}; + let List.633 : [C {}, C I64] = TagId(0) List.634; + ret List.633; procedure List.6 (#Attr.2): - let List.637 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.637; + let List.640 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.640; procedure List.66 (#Attr.2, #Attr.3): - let List.635 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.635; + let List.638 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.638; -procedure List.9 (List.383): - let List.629 : U64 = 0i64; - let List.622 : [C {}, C I64] = CallByName List.2 List.383 List.629; - let List.626 : U8 = 1i64; - let List.627 : U8 = GetTagId List.622; - let List.628 : Int1 = lowlevel Eq List.626 List.627; - if List.628 then - let List.384 : I64 = UnionAtIndex (Id 1) (Index 0) List.622; - let List.623 : [C Int1, C I64] = TagId(1) List.384; - ret List.623; +procedure List.9 (List.386): + let List.632 : U64 = 0i64; + let List.625 : [C {}, C I64] = CallByName List.2 List.386 List.632; + let List.629 : U8 = 1i64; + let List.630 : U8 = GetTagId List.625; + let List.631 : Int1 = lowlevel Eq List.629 List.630; + if List.631 then + let List.387 : I64 = UnionAtIndex (Id 1) (Index 0) List.625; + let List.626 : [C Int1, C I64] = TagId(1) List.387; + ret List.626; else - let List.625 : Int1 = true; - let List.624 : [C Int1, C I64] = TagId(0) List.625; - ret List.624; + let List.628 : Int1 = true; + let List.627 : [C Int1, C I64] = TagId(0) List.628; + ret List.627; procedure Num.22 (#Attr.2, #Attr.3): - let Num.279 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.281; -procedure Str.27 (Str.78): - let Str.232 : [C Int1, C I64] = CallByName Str.60 Str.78; - ret Str.232; +procedure Str.27 (Str.82): + let Str.236 : [C Int1, C I64] = CallByName Str.64 Str.82; + ret Str.236; procedure Str.42 (#Attr.2): - let Str.240 : {I64, U8} = lowlevel StrToNum #Attr.2; - ret Str.240; + let Str.244 : {I64, U8} = lowlevel StrToNum #Attr.2; + ret Str.244; -procedure Str.60 (Str.185): - let Str.186 : {I64, U8} = CallByName Str.42 Str.185; - let Str.238 : U8 = StructAtIndex 1 Str.186; - let Str.239 : U8 = 0i64; - let Str.235 : Int1 = CallByName Bool.11 Str.238 Str.239; - if Str.235 then - let Str.237 : I64 = StructAtIndex 0 Str.186; - let Str.236 : [C Int1, C I64] = TagId(1) Str.237; - ret Str.236; +procedure Str.64 (Str.189): + let Str.190 : {I64, U8} = CallByName Str.42 Str.189; + let Str.242 : U8 = StructAtIndex 1 Str.190; + let Str.243 : U8 = 0i64; + let Str.239 : Int1 = CallByName Bool.11 Str.242 Str.243; + if Str.239 then + let Str.241 : I64 = StructAtIndex 0 Str.190; + let Str.240 : [C Int1, C I64] = TagId(1) Str.241; + ret Str.240; else - let Str.234 : Int1 = false; - let Str.233 : [C Int1, C I64] = TagId(0) Str.234; - ret Str.233; + let Str.238 : Int1 = false; + let Str.237 : [C Int1, C I64] = TagId(0) Str.238; + ret Str.237; procedure Test.0 (): let Test.3 : Int1 = CallByName Bool.2; diff --git a/crates/compiler/test_mono/generated/issue_4770.txt b/crates/compiler/test_mono/generated/issue_4770.txt index 57381074fd..084d50b611 100644 --- a/crates/compiler/test_mono/generated/issue_4770.txt +++ b/crates/compiler/test_mono/generated/issue_4770.txt @@ -6,137 +6,137 @@ procedure Bool.2 (): let Bool.24 : Int1 = true; ret Bool.24; -procedure List.107 (List.536, List.537, List.538): - let List.636 : U64 = 0i64; - let List.637 : U64 = CallByName List.6 List.536; - let List.635 : [C {}, C {}] = CallByName List.80 List.536 List.537 List.538 List.636 List.637; - ret List.635; - -procedure List.23 (List.278, List.279, List.280): - let List.672 : U64 = CallByName List.6 List.278; - let List.673 : U64 = CallByName List.6 List.279; - let List.281 : U64 = CallByName Num.148 List.672 List.673; - let List.658 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.68 List.281; - let List.659 : U64 = 0i64; - let List.657 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.97 List.278 List.279 List.658 List.280 List.659 List.281; - ret List.657; - -procedure List.239 (List.624, List.240, List.238): - let List.654 : Int1 = CallByName Test.1 List.240; - if List.654 then - let List.656 : {} = Struct {}; - let List.655 : [C {}, C {}] = TagId(1) List.656; - ret List.655; - else - let List.653 : {} = Struct {}; - let List.652 : [C {}, C {}] = TagId(0) List.653; - ret List.652; - -procedure List.56 (List.237, List.238): - let List.633 : {} = Struct {}; - let List.625 : [C {}, C {}] = CallByName List.107 List.237 List.633 List.238; - let List.630 : U8 = 1i64; - let List.631 : U8 = GetTagId List.625; - let List.632 : Int1 = lowlevel Eq List.630 List.631; - if List.632 then - let List.626 : Int1 = CallByName Bool.2; - ret List.626; - else - let List.627 : Int1 = CallByName Bool.1; - ret List.627; - -procedure List.6 (#Attr.2): - let List.623 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.623; - -procedure List.6 (#Attr.2): - let List.651 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.651; - -procedure List.66 (#Attr.2, #Attr.3): - let List.650 : {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.650; - -procedure List.66 (#Attr.2, #Attr.3): - let List.670 : [C I64, C List *self] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.670; - -procedure List.68 (#Attr.2): - let List.671 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListWithCapacity #Attr.2; - ret List.671; - -procedure List.71 (#Attr.2, #Attr.3): - let List.667 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.667; - -procedure List.80 (#Derived_gen.7, #Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11): - joinpoint List.638 List.539 List.540 List.541 List.542 List.543: - let List.640 : Int1 = CallByName Num.22 List.542 List.543; - if List.640 then - let List.649 : {[C I64, C List *self], [C I64, C List *self]} = CallByName List.66 List.539 List.542; - inc List.649; - let List.641 : [C {}, C {}] = CallByName List.239 List.540 List.649 List.541; - let List.646 : U8 = 1i64; - let List.647 : U8 = GetTagId List.641; - let List.648 : Int1 = lowlevel Eq List.646 List.647; - if List.648 then - let List.544 : {} = UnionAtIndex (Id 1) (Index 0) List.641; - let List.644 : U64 = 1i64; - let List.643 : U64 = CallByName Num.51 List.542 List.644; - jump List.638 List.539 List.544 List.541 List.643 List.543; - else - dec List.539; - let List.545 : {} = UnionAtIndex (Id 0) (Index 0) List.641; - let List.645 : [C {}, C {}] = TagId(0) List.545; - ret List.645; +procedure List.100 (#Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6): + joinpoint List.663 List.285 List.286 List.287 List.288 List.289 List.290: + let List.665 : Int1 = CallByName Num.22 List.289 List.290; + if List.665 then + let List.671 : [C I64, C List *self] = CallByName List.66 List.285 List.289; + inc List.671; + let List.672 : [C I64, C List *self] = CallByName List.66 List.286 List.289; + inc List.672; + let List.291 : {[C I64, C List *self], [C I64, C List *self]} = CallByName Test.15 List.671 List.672; + let List.667 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.71 List.287 List.291; + let List.669 : U64 = 1i64; + let List.668 : U64 = CallByName Num.51 List.289 List.669; + jump List.663 List.285 List.286 List.667 List.288 List.668 List.290; else - dec List.539; - let List.639 : [C {}, C {}] = TagId(1) List.540; - ret List.639; - in - inc #Derived_gen.7; - jump List.638 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11; - -procedure List.97 (#Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6): - joinpoint List.660 List.282 List.283 List.284 List.285 List.286 List.287: - let List.662 : Int1 = CallByName Num.22 List.286 List.287; - if List.662 then - let List.668 : [C I64, C List *self] = CallByName List.66 List.282 List.286; - inc List.668; - let List.669 : [C I64, C List *self] = CallByName List.66 List.283 List.286; - inc List.669; - let List.288 : {[C I64, C List *self], [C I64, C List *self]} = CallByName Test.15 List.668 List.669; - let List.664 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.71 List.284 List.288; - let List.666 : U64 = 1i64; - let List.665 : U64 = CallByName Num.51 List.286 List.666; - jump List.660 List.282 List.283 List.664 List.285 List.665 List.287; - else - dec List.283; - dec List.282; - ret List.284; + dec List.286; + dec List.285; + ret List.287; in inc #Derived_gen.1; inc #Derived_gen.2; - jump List.660 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6; + jump List.663 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6; -procedure Num.148 (Num.223, Num.224): - let Num.286 : Int1 = CallByName Num.22 Num.223 Num.224; - if Num.286 then - ret Num.223; +procedure List.110 (List.539, List.540, List.541): + let List.639 : U64 = 0i64; + let List.640 : U64 = CallByName List.6 List.539; + let List.638 : [C {}, C {}] = CallByName List.80 List.539 List.540 List.541 List.639 List.640; + ret List.638; + +procedure List.23 (List.281, List.282, List.283): + let List.675 : U64 = CallByName List.6 List.281; + let List.676 : U64 = CallByName List.6 List.282; + let List.284 : U64 = CallByName Num.148 List.675 List.676; + let List.661 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.68 List.284; + let List.662 : U64 = 0i64; + let List.660 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.100 List.281 List.282 List.661 List.283 List.662 List.284; + ret List.660; + +procedure List.242 (List.627, List.243, List.241): + let List.657 : Int1 = CallByName Test.1 List.243; + if List.657 then + let List.659 : {} = Struct {}; + let List.658 : [C {}, C {}] = TagId(1) List.659; + ret List.658; else - ret Num.224; + let List.656 : {} = Struct {}; + let List.655 : [C {}, C {}] = TagId(0) List.656; + ret List.655; + +procedure List.56 (List.240, List.241): + let List.636 : {} = Struct {}; + let List.628 : [C {}, C {}] = CallByName List.110 List.240 List.636 List.241; + let List.633 : U8 = 1i64; + let List.634 : U8 = GetTagId List.628; + let List.635 : Int1 = lowlevel Eq List.633 List.634; + if List.635 then + let List.629 : Int1 = CallByName Bool.2; + ret List.629; + else + let List.630 : Int1 = CallByName Bool.1; + ret List.630; + +procedure List.6 (#Attr.2): + let List.626 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.626; + +procedure List.6 (#Attr.2): + let List.654 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.654; + +procedure List.66 (#Attr.2, #Attr.3): + let List.653 : {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.653; + +procedure List.66 (#Attr.2, #Attr.3): + let List.673 : [C I64, C List *self] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.673; + +procedure List.68 (#Attr.2): + let List.674 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListWithCapacity #Attr.2; + ret List.674; + +procedure List.71 (#Attr.2, #Attr.3): + let List.670 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.670; + +procedure List.80 (#Derived_gen.7, #Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11): + joinpoint List.641 List.542 List.543 List.544 List.545 List.546: + let List.643 : Int1 = CallByName Num.22 List.545 List.546; + if List.643 then + let List.652 : {[C I64, C List *self], [C I64, C List *self]} = CallByName List.66 List.542 List.545; + inc List.652; + let List.644 : [C {}, C {}] = CallByName List.242 List.543 List.652 List.544; + let List.649 : U8 = 1i64; + let List.650 : U8 = GetTagId List.644; + let List.651 : Int1 = lowlevel Eq List.649 List.650; + if List.651 then + let List.547 : {} = UnionAtIndex (Id 1) (Index 0) List.644; + let List.647 : U64 = 1i64; + let List.646 : U64 = CallByName Num.51 List.545 List.647; + jump List.641 List.542 List.547 List.544 List.646 List.546; + else + dec List.542; + let List.548 : {} = UnionAtIndex (Id 0) (Index 0) List.644; + let List.648 : [C {}, C {}] = TagId(0) List.548; + ret List.648; + else + dec List.542; + let List.642 : [C {}, C {}] = TagId(1) List.543; + ret List.642; + in + inc #Derived_gen.7; + jump List.641 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11; + +procedure Num.148 (Num.225, Num.226): + let Num.288 : Int1 = CallByName Num.22 Num.225 Num.226; + if Num.288 then + ret Num.225; + else + ret Num.226; procedure Num.22 (#Attr.2, #Attr.3): - let Num.279 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.281; procedure Num.22 (#Attr.2, #Attr.3): - let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.284; + let Num.286 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.286; procedure Num.51 (#Attr.2, #Attr.3): - let Num.282 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.282; + let Num.284 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.284; procedure Test.1 (#Derived_gen.0): joinpoint Test.26 Test.6: diff --git a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt index 2ab52059e3..59f6e53573 100644 --- a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt +++ b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt @@ -6,43 +6,43 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.24; -procedure Decode.24 (Decode.101): - ret Decode.101; +procedure Decode.24 (Decode.105): + ret Decode.105; -procedure Decode.25 (Decode.102, Decode.121, Decode.104): - let Decode.124 : {List U8, [C {}, C Str]} = CallByName Test.76 Decode.102 Decode.104; - ret Decode.124; +procedure Decode.25 (Decode.106, Decode.125, Decode.108): + let Decode.128 : {List U8, [C {}, C Str]} = CallByName Test.76 Decode.106 Decode.108; + ret Decode.128; -procedure Decode.26 (Decode.105, Decode.106): - let Decode.123 : {} = CallByName Test.15; - let Decode.122 : {List U8, [C {}, C Str]} = CallByName Decode.25 Decode.105 Decode.123 Decode.106; - ret Decode.122; +procedure Decode.26 (Decode.109, Decode.110): + let Decode.127 : {} = CallByName Test.15; + let Decode.126 : {List U8, [C {}, C Str]} = CallByName Decode.25 Decode.109 Decode.127 Decode.110; + ret Decode.126; procedure Str.12 (#Attr.2): - let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.241; + let Str.245 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.245; -procedure Str.27 (Str.78): - let Str.232 : [C {}, C I64] = CallByName Str.60 Str.78; - ret Str.232; +procedure Str.27 (Str.82): + let Str.236 : [C {}, C I64] = CallByName Str.64 Str.82; + ret Str.236; procedure Str.42 (#Attr.2): - let Str.240 : {I64, U8} = lowlevel StrToNum #Attr.2; - ret Str.240; + let Str.244 : {I64, U8} = lowlevel StrToNum #Attr.2; + ret Str.244; -procedure Str.60 (Str.185): - let Str.186 : {I64, U8} = CallByName Str.42 Str.185; - let Str.238 : U8 = StructAtIndex 1 Str.186; - let Str.239 : U8 = 0i64; - let Str.235 : Int1 = CallByName Bool.11 Str.238 Str.239; - if Str.235 then - let Str.237 : I64 = StructAtIndex 0 Str.186; - let Str.236 : [C {}, C I64] = TagId(1) Str.237; - ret Str.236; +procedure Str.64 (Str.189): + let Str.190 : {I64, U8} = CallByName Str.42 Str.189; + let Str.242 : U8 = StructAtIndex 1 Str.190; + let Str.243 : U8 = 0i64; + let Str.239 : Int1 = CallByName Bool.11 Str.242 Str.243; + if Str.239 then + let Str.241 : I64 = StructAtIndex 0 Str.190; + let Str.240 : [C {}, C I64] = TagId(1) Str.241; + ret Str.240; else - let Str.234 : {} = Struct {}; - let Str.233 : [C {}, C I64] = TagId(0) Str.234; - ret Str.233; + let Str.238 : {} = Struct {}; + let Str.237 : [C {}, C I64] = TagId(0) Str.238; + ret Str.237; procedure Test.103 (): let Test.101 : [C Str, C {List U8, I64}] = CallByName Test.19; diff --git a/crates/compiler/test_mono/generated/issue_6196.txt b/crates/compiler/test_mono/generated/issue_6196.txt index b62b0e49a6..cb050be6a7 100644 --- a/crates/compiler/test_mono/generated/issue_6196.txt +++ b/crates/compiler/test_mono/generated/issue_6196.txt @@ -1,6 +1,6 @@ procedure Num.20 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (#Derived_gen.0, #Derived_gen.1): joinpoint Test.12 Test.2 Test.3: diff --git a/crates/compiler/test_mono/generated/lambda_capture_niche_u8_vs_u64.txt b/crates/compiler/test_mono/generated/lambda_capture_niche_u8_vs_u64.txt index 45025071cb..de4d802f41 100644 --- a/crates/compiler/test_mono/generated/lambda_capture_niche_u8_vs_u64.txt +++ b/crates/compiler/test_mono/generated/lambda_capture_niche_u8_vs_u64.txt @@ -1,10 +1,10 @@ procedure Num.96 (#Attr.2): - let Num.279 : Str = lowlevel NumToStr #Attr.2; - ret Num.279; + let Num.281 : Str = lowlevel NumToStr #Attr.2; + ret Num.281; procedure Num.96 (#Attr.2): - let Num.280 : Str = lowlevel NumToStr #Attr.2; - ret Num.280; + let Num.282 : Str = lowlevel NumToStr #Attr.2; + ret Num.282; procedure Test.1 (Test.4): let Test.13 : [C U8, C U64] = TagId(1) Test.4; diff --git a/crates/compiler/test_mono/generated/lambda_capture_niches_with_other_lambda_capture.txt b/crates/compiler/test_mono/generated/lambda_capture_niches_with_other_lambda_capture.txt index 494c52fe30..8d34667d12 100644 --- a/crates/compiler/test_mono/generated/lambda_capture_niches_with_other_lambda_capture.txt +++ b/crates/compiler/test_mono/generated/lambda_capture_niches_with_other_lambda_capture.txt @@ -1,6 +1,6 @@ procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.1 (Test.5): let Test.16 : [C {}, C U64, C Str] = TagId(0) Test.5; diff --git a/crates/compiler/test_mono/generated/lambda_set_with_imported_toplevels_issue_4733.txt b/crates/compiler/test_mono/generated/lambda_set_with_imported_toplevels_issue_4733.txt index 55ef9d7afa..de65cbc2da 100644 --- a/crates/compiler/test_mono/generated/lambda_set_with_imported_toplevels_issue_4733.txt +++ b/crates/compiler/test_mono/generated/lambda_set_with_imported_toplevels_issue_4733.txt @@ -7,12 +7,12 @@ procedure Bool.2 (): ret Bool.24; procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Num.21 (#Attr.2, #Attr.3): - let Num.280 : U64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : U64 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.282; procedure Test.0 (Test.8): let Test.20 : Int1 = CallByName Bool.2; diff --git a/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt b/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt index 6a975bbe69..2dba42c8eb 100644 --- a/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt +++ b/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt @@ -1,41 +1,41 @@ -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : [, C {[C *self, ], *self}] = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : [, C {[C *self, ], *self}] = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; procedure List.6 (#Attr.2): - let List.633 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.633; + let List.636 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.636; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : [C *self, ] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : [C *self, ] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; -procedure List.92 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : [C *self, ] = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : [, C {[C *self, ], *self}] = CallByName Test.7 List.167 List.631; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : [C *self, ] = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : [, C {[C *self, ], *self}] = CallByName Test.7 List.170 List.634; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in inc #Derived_gen.0; - jump List.625 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.628 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; procedure Test.7 (Test.11, Test.12): let Test.17 : {[C *self, ], [, C {[C *self, ], *self}]} = Struct {Test.12, Test.11}; diff --git a/crates/compiler/test_mono/generated/linked_list_filter.txt b/crates/compiler/test_mono/generated/linked_list_filter.txt index 04e3c3ff0d..08893f2bcb 100644 --- a/crates/compiler/test_mono/generated/linked_list_filter.txt +++ b/crates/compiler/test_mono/generated/linked_list_filter.txt @@ -1,11 +1,11 @@ -procedure Num.31 (Num.217): - let Num.280 : I64 = 2i64; - let Num.279 : Int1 = CallByName Num.86 Num.217 Num.280; - ret Num.279; +procedure Num.31 (Num.219): + let Num.282 : I64 = 2i64; + let Num.281 : Int1 = CallByName Num.86 Num.219 Num.282; + ret Num.281; procedure Num.86 (#Attr.2, #Attr.3): - let Num.281 : Int1 = lowlevel NumIsMultipleOf #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : Int1 = lowlevel NumIsMultipleOf #Attr.2 #Attr.3; + ret Num.283; procedure Test.2 (#Derived_gen.0, #Derived_gen.1): let #Derived_gen.3 : [, C I64 *self] = NullPointer; diff --git a/crates/compiler/test_mono/generated/linked_list_map.txt b/crates/compiler/test_mono/generated/linked_list_map.txt index 0638cfb231..3a21360c88 100644 --- a/crates/compiler/test_mono/generated/linked_list_map.txt +++ b/crates/compiler/test_mono/generated/linked_list_map.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.10 (Test.11): let Test.28 : I64 = 1i64; diff --git a/crates/compiler/test_mono/generated/list_append.txt b/crates/compiler/test_mono/generated/list_append.txt index d59e4f82cb..19886c2f75 100644 --- a/crates/compiler/test_mono/generated/list_append.txt +++ b/crates/compiler/test_mono/generated/list_append.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.127, List.128): - let List.625 : U64 = 1i64; - let List.623 : List I64 = CallByName List.70 List.127 List.625; - let List.622 : List I64 = CallByName List.71 List.623 List.128; - ret List.622; +procedure List.4 (List.130, List.131): + let List.628 : U64 = 1i64; + let List.626 : List I64 = CallByName List.70 List.130 List.628; + let List.625 : List I64 = CallByName List.71 List.626 List.131; + ret List.625; procedure List.70 (#Attr.2, #Attr.3): - let List.626 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.626; + let List.629 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.629; procedure List.71 (#Attr.2, #Attr.3): - let List.624 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.624; + let List.627 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.627; procedure Test.0 (): let Test.2 : List I64 = Array [1i64]; diff --git a/crates/compiler/test_mono/generated/list_append_closure.txt b/crates/compiler/test_mono/generated/list_append_closure.txt index b3390f9233..bac1571547 100644 --- a/crates/compiler/test_mono/generated/list_append_closure.txt +++ b/crates/compiler/test_mono/generated/list_append_closure.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.127, List.128): - let List.625 : U64 = 1i64; - let List.623 : List I64 = CallByName List.70 List.127 List.625; - let List.622 : List I64 = CallByName List.71 List.623 List.128; - ret List.622; +procedure List.4 (List.130, List.131): + let List.628 : U64 = 1i64; + let List.626 : List I64 = CallByName List.70 List.130 List.628; + let List.625 : List I64 = CallByName List.71 List.626 List.131; + ret List.625; procedure List.70 (#Attr.2, #Attr.3): - let List.626 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.626; + let List.629 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.629; procedure List.71 (#Attr.2, #Attr.3): - let List.624 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.624; + let List.627 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.627; procedure Test.1 (Test.2): let Test.6 : I64 = 42i64; diff --git a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt index 8569bb00cd..9aa88090dd 100644 --- a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt +++ b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt @@ -1,33 +1,33 @@ -procedure List.3 (List.119, List.120, List.121): - let List.625 : {List I64, I64} = CallByName List.64 List.119 List.120 List.121; - let List.624 : List I64 = StructAtIndex 0 List.625; - ret List.624; +procedure List.3 (List.122, List.123, List.124): + let List.628 : {List I64, I64} = CallByName List.64 List.122 List.123 List.124; + let List.627 : List I64 = StructAtIndex 0 List.628; + ret List.627; procedure List.6 (#Attr.2): - let List.623 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.623; + let List.626 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.626; -procedure List.64 (List.116, List.117, List.118): - let List.630 : U64 = CallByName List.6 List.116; - let List.627 : Int1 = CallByName Num.22 List.117 List.630; - if List.627 then - let List.628 : {List I64, I64} = CallByName List.67 List.116 List.117 List.118; - ret List.628; +procedure List.64 (List.119, List.120, List.121): + let List.633 : U64 = CallByName List.6 List.119; + let List.630 : Int1 = CallByName Num.22 List.120 List.633; + if List.630 then + let List.631 : {List I64, I64} = CallByName List.67 List.119 List.120 List.121; + ret List.631; else - let List.626 : {List I64, I64} = Struct {List.116, List.118}; - ret List.626; + let List.629 : {List I64, I64} = Struct {List.119, List.121}; + ret List.629; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.629 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.629; + let List.632 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.632; procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Test.1 (): let Test.8 : List I64 = Array [1i64, 2i64, 3i64]; diff --git a/crates/compiler/test_mono/generated/list_get.txt b/crates/compiler/test_mono/generated/list_get.txt index a08c9cf648..ae71bf6b5f 100644 --- a/crates/compiler/test_mono/generated/list_get.txt +++ b/crates/compiler/test_mono/generated/list_get.txt @@ -1,26 +1,26 @@ -procedure List.2 (List.111, List.112): - let List.628 : U64 = CallByName List.6 List.111; - let List.624 : Int1 = CallByName Num.22 List.112 List.628; - if List.624 then - let List.626 : I64 = CallByName List.66 List.111 List.112; - let List.625 : [C {}, C I64] = TagId(1) List.626; - ret List.625; +procedure List.2 (List.114, List.115): + let List.631 : U64 = CallByName List.6 List.114; + let List.627 : Int1 = CallByName Num.22 List.115 List.631; + if List.627 then + let List.629 : I64 = CallByName List.66 List.114 List.115; + let List.628 : [C {}, C I64] = TagId(1) List.629; + ret List.628; else - let List.623 : {} = Struct {}; - let List.622 : [C {}, C I64] = TagId(0) List.623; - ret List.622; + let List.626 : {} = Struct {}; + let List.625 : [C {}, C I64] = TagId(0) List.626; + ret List.625; procedure List.6 (#Attr.2): - let List.629 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.629; + let List.632 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.632; procedure List.66 (#Attr.2, #Attr.3): - let List.627 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.627; + let List.630 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.630; procedure Num.22 (#Attr.2, #Attr.3): - let Num.279 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (Test.2): let Test.6 : List I64 = Array [1i64, 2i64, 3i64]; diff --git a/crates/compiler/test_mono/generated/list_len.txt b/crates/compiler/test_mono/generated/list_len.txt index 56d1a8b2e0..f432807345 100644 --- a/crates/compiler/test_mono/generated/list_len.txt +++ b/crates/compiler/test_mono/generated/list_len.txt @@ -1,14 +1,14 @@ procedure List.6 (#Attr.2): - let List.622 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.622; + let List.625 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.625; procedure List.6 (#Attr.2): - let List.623 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.623; + let List.626 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.626; procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.1 : List I64 = Array [1i64, 2i64, 3i64]; diff --git a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt index b30e2c4fe1..b28196b01e 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt @@ -1,82 +1,82 @@ -procedure List.18 (List.163, List.164, List.165): - let List.634 : U64 = 0i64; - let List.635 : U64 = CallByName List.6 List.163; - let List.633 : List Str = CallByName List.92 List.163 List.164 List.165 List.634 List.635; - ret List.633; +procedure List.18 (List.166, List.167, List.168): + let List.637 : U64 = 0i64; + let List.638 : U64 = CallByName List.6 List.166; + let List.636 : List Str = CallByName List.95 List.166 List.167 List.168 List.637 List.638; + ret List.636; -procedure List.2 (List.111, List.112): - let List.628 : U64 = CallByName List.6 List.111; - let List.624 : Int1 = CallByName Num.22 List.112 List.628; - if List.624 then - let List.626 : Str = CallByName List.66 List.111 List.112; - inc List.626; - let List.625 : [C {}, C Str] = TagId(1) List.626; - ret List.625; +procedure List.2 (List.114, List.115): + let List.631 : U64 = CallByName List.6 List.114; + let List.627 : Int1 = CallByName Num.22 List.115 List.631; + if List.627 then + let List.629 : Str = CallByName List.66 List.114 List.115; + inc List.629; + let List.628 : [C {}, C Str] = TagId(1) List.629; + ret List.628; else - let List.623 : {} = Struct {}; - let List.622 : [C {}, C Str] = TagId(0) List.623; - ret List.622; + let List.626 : {} = Struct {}; + let List.625 : [C {}, C Str] = TagId(0) List.626; + ret List.625; -procedure List.275 (List.276, List.277, List.273): - let List.645 : Str = CallByName Test.3 List.277; - let List.644 : List Str = CallByName List.71 List.276 List.645; - ret List.644; - -procedure List.5 (List.272, List.273): - let List.274 : U64 = CallByName List.6 List.272; - let List.631 : List Str = CallByName List.68 List.274; - let List.630 : List Str = CallByName List.18 List.272 List.631 List.273; - ret List.630; - -procedure List.6 (#Attr.2): - let List.629 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.629; - -procedure List.66 (#Attr.2, #Attr.3): - let List.627 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.627; - -procedure List.68 (#Attr.2): - let List.647 : List Str = lowlevel ListWithCapacity #Attr.2; +procedure List.278 (List.279, List.280, List.276): + let List.648 : Str = CallByName Test.3 List.280; + let List.647 : List Str = CallByName List.71 List.279 List.648; ret List.647; -procedure List.71 (#Attr.2, #Attr.3): - let List.646 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.646; +procedure List.5 (List.275, List.276): + let List.277 : U64 = CallByName List.6 List.275; + let List.634 : List Str = CallByName List.68 List.277; + let List.633 : List Str = CallByName List.18 List.275 List.634 List.276; + ret List.633; -procedure List.92 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.636 List.166 List.167 List.168 List.169 List.170: - let List.638 : Int1 = CallByName Num.22 List.169 List.170; - if List.638 then - let List.642 : Str = CallByName List.66 List.166 List.169; - inc List.642; - let List.171 : List Str = CallByName List.275 List.167 List.642 List.168; - dec List.642; - let List.641 : U64 = 1i64; - let List.640 : U64 = CallByName Num.51 List.169 List.641; - jump List.636 List.166 List.171 List.168 List.640 List.170; +procedure List.6 (#Attr.2): + let List.632 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.632; + +procedure List.66 (#Attr.2, #Attr.3): + let List.630 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.630; + +procedure List.68 (#Attr.2): + let List.650 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.650; + +procedure List.71 (#Attr.2, #Attr.3): + let List.649 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.649; + +procedure List.95 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.639 List.169 List.170 List.171 List.172 List.173: + let List.641 : Int1 = CallByName Num.22 List.172 List.173; + if List.641 then + let List.645 : Str = CallByName List.66 List.169 List.172; + inc List.645; + let List.174 : List Str = CallByName List.278 List.170 List.645 List.171; + dec List.645; + let List.644 : U64 = 1i64; + let List.643 : U64 = CallByName Num.51 List.172 List.644; + jump List.639 List.169 List.174 List.171 List.643 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.3; - jump List.636 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + inc #Derived_gen.0; + jump List.639 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; procedure Str.16 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrRepeat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrRepeat #Attr.2 #Attr.3; + ret Str.236; procedure Str.3 (#Attr.2, #Attr.3): - let Str.233 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.233; + let Str.237 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.237; procedure Test.1 (): let Test.21 : Str = "lllllllllllllllllllllooooooooooong"; diff --git a/crates/compiler/test_mono/generated/list_map_closure_owns.txt b/crates/compiler/test_mono/generated/list_map_closure_owns.txt index 5ac7391200..aa33ca7088 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_owns.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_owns.txt @@ -1,77 +1,77 @@ -procedure List.18 (List.163, List.164, List.165): - let List.634 : U64 = 0i64; - let List.635 : U64 = CallByName List.6 List.163; - let List.633 : List Str = CallByName List.92 List.163 List.164 List.165 List.634 List.635; - ret List.633; +procedure List.18 (List.166, List.167, List.168): + let List.637 : U64 = 0i64; + let List.638 : U64 = CallByName List.6 List.166; + let List.636 : List Str = CallByName List.95 List.166 List.167 List.168 List.637 List.638; + ret List.636; -procedure List.2 (List.111, List.112): - let List.628 : U64 = CallByName List.6 List.111; - let List.624 : Int1 = CallByName Num.22 List.112 List.628; - if List.624 then - let List.626 : Str = CallByName List.66 List.111 List.112; - inc List.626; - let List.625 : [C {}, C Str] = TagId(1) List.626; - ret List.625; +procedure List.2 (List.114, List.115): + let List.631 : U64 = CallByName List.6 List.114; + let List.627 : Int1 = CallByName Num.22 List.115 List.631; + if List.627 then + let List.629 : Str = CallByName List.66 List.114 List.115; + inc List.629; + let List.628 : [C {}, C Str] = TagId(1) List.629; + ret List.628; else - let List.623 : {} = Struct {}; - let List.622 : [C {}, C Str] = TagId(0) List.623; - ret List.622; + let List.626 : {} = Struct {}; + let List.625 : [C {}, C Str] = TagId(0) List.626; + ret List.625; -procedure List.275 (List.276, List.277, List.273): - let List.645 : Str = CallByName Test.3 List.277; - let List.644 : List Str = CallByName List.71 List.276 List.645; - ret List.644; - -procedure List.5 (List.272, List.273): - let List.274 : U64 = CallByName List.6 List.272; - let List.631 : List Str = CallByName List.68 List.274; - let List.630 : List Str = CallByName List.18 List.272 List.631 List.273; - ret List.630; - -procedure List.6 (#Attr.2): - let List.629 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.629; - -procedure List.66 (#Attr.2, #Attr.3): - let List.627 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.627; - -procedure List.68 (#Attr.2): - let List.647 : List Str = lowlevel ListWithCapacity #Attr.2; +procedure List.278 (List.279, List.280, List.276): + let List.648 : Str = CallByName Test.3 List.280; + let List.647 : List Str = CallByName List.71 List.279 List.648; ret List.647; -procedure List.71 (#Attr.2, #Attr.3): - let List.646 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.646; +procedure List.5 (List.275, List.276): + let List.277 : U64 = CallByName List.6 List.275; + let List.634 : List Str = CallByName List.68 List.277; + let List.633 : List Str = CallByName List.18 List.275 List.634 List.276; + ret List.633; -procedure List.92 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.636 List.166 List.167 List.168 List.169 List.170: - let List.638 : Int1 = CallByName Num.22 List.169 List.170; - if List.638 then - let List.642 : Str = CallByName List.66 List.166 List.169; - inc List.642; - let List.171 : List Str = CallByName List.275 List.167 List.642 List.168; - let List.641 : U64 = 1i64; - let List.640 : U64 = CallByName Num.51 List.169 List.641; - jump List.636 List.166 List.171 List.168 List.640 List.170; +procedure List.6 (#Attr.2): + let List.632 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.632; + +procedure List.66 (#Attr.2, #Attr.3): + let List.630 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.630; + +procedure List.68 (#Attr.2): + let List.650 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.650; + +procedure List.71 (#Attr.2, #Attr.3): + let List.649 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.649; + +procedure List.95 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.639 List.169 List.170 List.171 List.172 List.173: + let List.641 : Int1 = CallByName Num.22 List.172 List.173; + if List.641 then + let List.645 : Str = CallByName List.66 List.169 List.172; + inc List.645; + let List.174 : List Str = CallByName List.278 List.170 List.645 List.171; + let List.644 : U64 = 1i64; + let List.643 : U64 = CallByName Num.51 List.172 List.644; + jump List.639 List.169 List.174 List.171 List.643 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.3; - jump List.636 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + inc #Derived_gen.0; + jump List.639 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; procedure Str.3 (#Attr.2, #Attr.3): - let Str.233 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.233; + let Str.237 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.237; procedure Test.1 (): let Test.21 : Str = "lllllllllllllllllllllooooooooooong"; diff --git a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt index 1b8c02599a..2cde098ebb 100644 --- a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt +++ b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt @@ -1,78 +1,78 @@ -procedure List.18 (List.163, List.164, List.165): - let List.626 : U64 = 0i64; - let List.627 : U64 = CallByName List.6 List.163; - let List.625 : List U8 = CallByName List.92 List.163 List.164 List.165 List.626 List.627; - ret List.625; +procedure List.18 (List.166, List.167, List.168): + let List.629 : U64 = 0i64; + let List.630 : U64 = CallByName List.6 List.166; + let List.628 : List U8 = CallByName List.95 List.166 List.167 List.168 List.629 List.630; + ret List.628; -procedure List.275 (List.276, List.277, List.273): - let List.641 : U8 = GetTagId List.273; - joinpoint List.642 List.639: - let List.638 : List U8 = CallByName List.71 List.276 List.639; - ret List.638; +procedure List.278 (List.279, List.280, List.276): + let List.644 : U8 = GetTagId List.276; + joinpoint List.645 List.642: + let List.641 : List U8 = CallByName List.71 List.279 List.642; + ret List.641; in - switch List.641: + switch List.644: case 0: - let List.643 : U8 = CallByName Test.4 List.277 List.273; - jump List.642 List.643; + let List.646 : U8 = CallByName Test.4 List.280 List.276; + jump List.645 List.646; case 1: - let List.643 : U8 = CallByName Test.6 List.277 List.273; - jump List.642 List.643; + let List.646 : U8 = CallByName Test.6 List.280 List.276; + jump List.645 List.646; default: - let List.643 : U8 = CallByName Test.8 List.277; - jump List.642 List.643; + let List.646 : U8 = CallByName Test.8 List.280; + jump List.645 List.646; -procedure List.5 (List.272, List.273): - let List.274 : U64 = CallByName List.6 List.272; - let List.623 : List U8 = CallByName List.68 List.274; - let List.622 : List U8 = CallByName List.18 List.272 List.623 List.273; - ret List.622; +procedure List.5 (List.275, List.276): + let List.277 : U64 = CallByName List.6 List.275; + let List.626 : List U8 = CallByName List.68 List.277; + let List.625 : List U8 = CallByName List.18 List.275 List.626 List.276; + ret List.625; procedure List.6 (#Attr.2): - let List.636 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.636; + let List.639 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.639; procedure List.66 (#Attr.2, #Attr.3): - let List.635 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.635; + let List.638 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.638; procedure List.68 (#Attr.2): - let List.644 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.644; + let List.647 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.647; procedure List.71 (#Attr.2, #Attr.3): - let List.640 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.640; + let List.643 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.643; -procedure List.92 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.628 List.166 List.167 List.168 List.169 List.170: - let List.630 : Int1 = CallByName Num.22 List.169 List.170; - if List.630 then - let List.634 : U8 = CallByName List.66 List.166 List.169; - let List.171 : List U8 = CallByName List.275 List.167 List.634 List.168; - let List.633 : U64 = 1i64; - let List.632 : U64 = CallByName Num.51 List.169 List.633; - jump List.628 List.166 List.171 List.168 List.632 List.170; +procedure List.95 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.631 List.169 List.170 List.171 List.172 List.173: + let List.633 : Int1 = CallByName Num.22 List.172 List.173; + if List.633 then + let List.637 : U8 = CallByName List.66 List.169 List.172; + let List.174 : List U8 = CallByName List.278 List.170 List.637 List.171; + let List.636 : U64 = 1i64; + let List.635 : U64 = CallByName Num.51 List.172 List.636; + jump List.631 List.169 List.174 List.171 List.635 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in inc #Derived_gen.0; - jump List.628 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.631 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.19 (#Attr.2, #Attr.3): - let Num.281 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.281; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + let Num.283 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; ret Num.283; +procedure Num.22 (#Attr.2, #Attr.3): + let Num.285 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.285; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.282 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.282; + let Num.284 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.284; procedure Test.4 (Test.5, #Attr.12): let Test.16 : U8 = UnionAtIndex (Id 0) (Index 0) #Attr.12; diff --git a/crates/compiler/test_mono/generated/list_pass_to_function.txt b/crates/compiler/test_mono/generated/list_pass_to_function.txt index 1217f00839..c999a24853 100644 --- a/crates/compiler/test_mono/generated/list_pass_to_function.txt +++ b/crates/compiler/test_mono/generated/list_pass_to_function.txt @@ -1,29 +1,29 @@ -procedure List.3 (List.119, List.120, List.121): - let List.623 : {List I64, I64} = CallByName List.64 List.119 List.120 List.121; - let List.622 : List I64 = StructAtIndex 0 List.623; - ret List.622; +procedure List.3 (List.122, List.123, List.124): + let List.626 : {List I64, I64} = CallByName List.64 List.122 List.123 List.124; + let List.625 : List I64 = StructAtIndex 0 List.626; + ret List.625; procedure List.6 (#Attr.2): - let List.629 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.629; + let List.632 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.632; -procedure List.64 (List.116, List.117, List.118): - let List.628 : U64 = CallByName List.6 List.116; - let List.625 : Int1 = CallByName Num.22 List.117 List.628; - if List.625 then - let List.626 : {List I64, I64} = CallByName List.67 List.116 List.117 List.118; - ret List.626; +procedure List.64 (List.119, List.120, List.121): + let List.631 : U64 = CallByName List.6 List.119; + let List.628 : Int1 = CallByName Num.22 List.120 List.631; + if List.628 then + let List.629 : {List I64, I64} = CallByName List.67 List.119 List.120 List.121; + ret List.629; else - let List.624 : {List I64, I64} = Struct {List.116, List.118}; - ret List.624; + let List.627 : {List I64, I64} = Struct {List.119, List.121}; + ret List.627; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.627 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.627; + let List.630 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.630; procedure Num.22 (#Attr.2, #Attr.3): - let Num.279 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.281; procedure Test.2 (Test.3): let Test.6 : U64 = 0i64; diff --git a/crates/compiler/test_mono/generated/list_sort_asc.txt b/crates/compiler/test_mono/generated/list_sort_asc.txt index 9d95e0061e..7143b80093 100644 --- a/crates/compiler/test_mono/generated/list_sort_asc.txt +++ b/crates/compiler/test_mono/generated/list_sort_asc.txt @@ -1,15 +1,15 @@ procedure List.28 (#Attr.2, #Attr.3): - let List.624 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; - ret List.624; + let List.627 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; + ret List.627; -procedure List.59 (List.378): - let List.623 : {} = Struct {}; - let List.622 : List I64 = CallByName List.28 List.378 List.623; - ret List.622; +procedure List.59 (List.381): + let List.626 : {} = Struct {}; + let List.625 : List I64 = CallByName List.28 List.381 List.626; + ret List.625; procedure Num.46 (#Attr.2, #Attr.3): - let Num.279 : U8 = lowlevel NumCompare #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U8 = lowlevel NumCompare #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.2 : List I64 = Array [4i64, 3i64, 2i64, 1i64]; diff --git a/crates/compiler/test_mono/generated/multiline_record_pattern.txt b/crates/compiler/test_mono/generated/multiline_record_pattern.txt index 1566d74105..baecd19d98 100644 --- a/crates/compiler/test_mono/generated/multiline_record_pattern.txt +++ b/crates/compiler/test_mono/generated/multiline_record_pattern.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.280 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.282; procedure Test.0 (): let Test.7 : I64 = 1i64; diff --git a/crates/compiler/test_mono/generated/nested_optional_field_with_binary_op.txt b/crates/compiler/test_mono/generated/nested_optional_field_with_binary_op.txt index 07d6ad3b21..617adedd42 100644 --- a/crates/compiler/test_mono/generated/nested_optional_field_with_binary_op.txt +++ b/crates/compiler/test_mono/generated/nested_optional_field_with_binary_op.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.17 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/nested_pattern_match.txt b/crates/compiler/test_mono/generated/nested_pattern_match.txt index a270831662..32875666f6 100644 --- a/crates/compiler/test_mono/generated/nested_pattern_match.txt +++ b/crates/compiler/test_mono/generated/nested_pattern_match.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.19 : I64 = 41i64; diff --git a/crates/compiler/test_mono/generated/num_width_gt_u8_layout_as_float.txt b/crates/compiler/test_mono/generated/num_width_gt_u8_layout_as_float.txt index d2de4a4424..936b6203e1 100644 --- a/crates/compiler/test_mono/generated/num_width_gt_u8_layout_as_float.txt +++ b/crates/compiler/test_mono/generated/num_width_gt_u8_layout_as_float.txt @@ -1,6 +1,6 @@ procedure Num.37 (#Attr.2, #Attr.3): - let Num.279 : Decimal = lowlevel NumDivFrac #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : Decimal = lowlevel NumDivFrac #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.2 : Decimal = 1dec; diff --git a/crates/compiler/test_mono/generated/optional_field_with_binary_op.txt b/crates/compiler/test_mono/generated/optional_field_with_binary_op.txt index e0abf66bdc..4e2be037b4 100644 --- a/crates/compiler/test_mono/generated/optional_field_with_binary_op.txt +++ b/crates/compiler/test_mono/generated/optional_field_with_binary_op.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.5 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/optional_when.txt b/crates/compiler/test_mono/generated/optional_when.txt index c1e0877034..c1ceb98a6e 100644 --- a/crates/compiler/test_mono/generated/optional_when.txt +++ b/crates/compiler/test_mono/generated/optional_when.txt @@ -1,6 +1,6 @@ procedure Num.21 (#Attr.2, #Attr.3): - let Num.281 : I64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : I64 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.283; procedure Test.1 (Test.6): let Test.21 : Int1 = false; diff --git a/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt b/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt index 1e74803e85..d93fcaf31a 100644 --- a/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt +++ b/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt @@ -3,8 +3,8 @@ procedure Bool.11 (#Attr.2, #Attr.3): ret Bool.23; procedure Str.3 (#Attr.2, #Attr.3): - let Str.233 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.233; + let Str.237 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.237; procedure Test.2 (Test.7): let Test.24 : Str = ".trace(\""; diff --git a/crates/compiler/test_mono/generated/quicksort_help.txt b/crates/compiler/test_mono/generated/quicksort_help.txt index 26912208f7..5f2d3e63e8 100644 --- a/crates/compiler/test_mono/generated/quicksort_help.txt +++ b/crates/compiler/test_mono/generated/quicksort_help.txt @@ -1,14 +1,14 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Num.20 (#Attr.2, #Attr.3): - let Num.280 : I64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : I64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.282; procedure Num.22 (#Attr.2, #Attr.3): - let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.283; procedure Test.1 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2): joinpoint Test.12 Test.2 Test.3 Test.4: diff --git a/crates/compiler/test_mono/generated/quicksort_swap.txt b/crates/compiler/test_mono/generated/quicksort_swap.txt index f105943482..427ce71ca0 100644 --- a/crates/compiler/test_mono/generated/quicksort_swap.txt +++ b/crates/compiler/test_mono/generated/quicksort_swap.txt @@ -1,45 +1,45 @@ -procedure List.2 (List.111, List.112): - let List.644 : U64 = CallByName List.6 List.111; - let List.641 : Int1 = CallByName Num.22 List.112 List.644; - if List.641 then - let List.643 : I64 = CallByName List.66 List.111 List.112; - let List.642 : [C {}, C I64] = TagId(1) List.643; - ret List.642; +procedure List.2 (List.114, List.115): + let List.647 : U64 = CallByName List.6 List.114; + let List.644 : Int1 = CallByName Num.22 List.115 List.647; + if List.644 then + let List.646 : I64 = CallByName List.66 List.114 List.115; + let List.645 : [C {}, C I64] = TagId(1) List.646; + ret List.645; else - let List.640 : {} = Struct {}; - let List.639 : [C {}, C I64] = TagId(0) List.640; - ret List.639; + let List.643 : {} = Struct {}; + let List.642 : [C {}, C I64] = TagId(0) List.643; + ret List.642; -procedure List.3 (List.119, List.120, List.121): - let List.631 : {List I64, I64} = CallByName List.64 List.119 List.120 List.121; - let List.630 : List I64 = StructAtIndex 0 List.631; - ret List.630; +procedure List.3 (List.122, List.123, List.124): + let List.634 : {List I64, I64} = CallByName List.64 List.122 List.123 List.124; + let List.633 : List I64 = StructAtIndex 0 List.634; + ret List.633; procedure List.6 (#Attr.2): - let List.629 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.629; + let List.632 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.632; -procedure List.64 (List.116, List.117, List.118): - let List.628 : U64 = CallByName List.6 List.116; - let List.625 : Int1 = CallByName Num.22 List.117 List.628; - if List.625 then - let List.626 : {List I64, I64} = CallByName List.67 List.116 List.117 List.118; - ret List.626; +procedure List.64 (List.119, List.120, List.121): + let List.631 : U64 = CallByName List.6 List.119; + let List.628 : Int1 = CallByName Num.22 List.120 List.631; + if List.628 then + let List.629 : {List I64, I64} = CallByName List.67 List.119 List.120 List.121; + ret List.629; else - let List.624 : {List I64, I64} = Struct {List.116, List.118}; - ret List.624; + let List.627 : {List I64, I64} = Struct {List.119, List.121}; + ret List.627; procedure List.66 (#Attr.2, #Attr.3): - let List.637 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.637; + let List.640 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.640; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.627 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.627; + let List.630 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.630; procedure Num.22 (#Attr.2, #Attr.3): - let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.283; procedure Test.1 (Test.2): let Test.28 : U64 = 0i64; diff --git a/crates/compiler/test_mono/generated/rb_tree_fbip.txt b/crates/compiler/test_mono/generated/rb_tree_fbip.txt index 57f8438abd..2bfdeb6006 100644 --- a/crates/compiler/test_mono/generated/rb_tree_fbip.txt +++ b/crates/compiler/test_mono/generated/rb_tree_fbip.txt @@ -1,10 +1,10 @@ procedure Num.22 (#Attr.2, #Attr.3): - let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.282; + let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.284; procedure Num.24 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.282; procedure Test.3 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2): let #Derived_gen.4 : [C *self I64 *self I32 Int1, ] = NullPointer; diff --git a/crates/compiler/test_mono/generated/record_optional_field_function_no_use_default.txt b/crates/compiler/test_mono/generated/record_optional_field_function_no_use_default.txt index ff574612f5..0bf4a409e4 100644 --- a/crates/compiler/test_mono/generated/record_optional_field_function_no_use_default.txt +++ b/crates/compiler/test_mono/generated/record_optional_field_function_no_use_default.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (Test.4): let Test.2 : I64 = StructAtIndex 0 Test.4; diff --git a/crates/compiler/test_mono/generated/record_optional_field_function_use_default.txt b/crates/compiler/test_mono/generated/record_optional_field_function_use_default.txt index 4e6ae59c9c..63d2b8e07f 100644 --- a/crates/compiler/test_mono/generated/record_optional_field_function_use_default.txt +++ b/crates/compiler/test_mono/generated/record_optional_field_function_use_default.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (Test.4): let Test.2 : I64 = 10i64; diff --git a/crates/compiler/test_mono/generated/record_optional_field_let_no_use_default.txt b/crates/compiler/test_mono/generated/record_optional_field_let_no_use_default.txt index bcc459113a..f8ee86c57d 100644 --- a/crates/compiler/test_mono/generated/record_optional_field_let_no_use_default.txt +++ b/crates/compiler/test_mono/generated/record_optional_field_let_no_use_default.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (Test.2): let Test.3 : I64 = StructAtIndex 0 Test.2; diff --git a/crates/compiler/test_mono/generated/record_optional_field_let_use_default.txt b/crates/compiler/test_mono/generated/record_optional_field_let_use_default.txt index 61016fa3aa..d877cdf19c 100644 --- a/crates/compiler/test_mono/generated/record_optional_field_let_use_default.txt +++ b/crates/compiler/test_mono/generated/record_optional_field_let_use_default.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (Test.2): let Test.3 : I64 = 10i64; diff --git a/crates/compiler/test_mono/generated/record_update.txt b/crates/compiler/test_mono/generated/record_update.txt index 096eeeeb61..b7d8532913 100644 --- a/crates/compiler/test_mono/generated/record_update.txt +++ b/crates/compiler/test_mono/generated/record_update.txt @@ -1,29 +1,29 @@ -procedure List.3 (List.119, List.120, List.121): - let List.631 : {List U64, U64} = CallByName List.64 List.119 List.120 List.121; - let List.630 : List U64 = StructAtIndex 0 List.631; - ret List.630; +procedure List.3 (List.122, List.123, List.124): + let List.634 : {List U64, U64} = CallByName List.64 List.122 List.123 List.124; + let List.633 : List U64 = StructAtIndex 0 List.634; + ret List.633; procedure List.6 (#Attr.2): - let List.629 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.629; + let List.632 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.632; -procedure List.64 (List.116, List.117, List.118): - let List.628 : U64 = CallByName List.6 List.116; - let List.625 : Int1 = CallByName Num.22 List.117 List.628; - if List.625 then - let List.626 : {List U64, U64} = CallByName List.67 List.116 List.117 List.118; - ret List.626; +procedure List.64 (List.119, List.120, List.121): + let List.631 : U64 = CallByName List.6 List.119; + let List.628 : Int1 = CallByName Num.22 List.120 List.631; + if List.628 then + let List.629 : {List U64, U64} = CallByName List.67 List.119 List.120 List.121; + ret List.629; else - let List.624 : {List U64, U64} = Struct {List.116, List.118}; - ret List.624; + let List.627 : {List U64, U64} = Struct {List.119, List.121}; + ret List.627; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.627 : {List U64, U64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.627; + let List.630 : {List U64, U64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.630; procedure Num.22 (#Attr.2, #Attr.3): - let Num.279 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (Test.2): let Test.6 : List U64 = StructAtIndex 0 Test.2; diff --git a/crates/compiler/test_mono/generated/recursive_call_capturing_function.txt b/crates/compiler/test_mono/generated/recursive_call_capturing_function.txt index 43a40b2a33..85f788c9cb 100644 --- a/crates/compiler/test_mono/generated/recursive_call_capturing_function.txt +++ b/crates/compiler/test_mono/generated/recursive_call_capturing_function.txt @@ -3,8 +3,8 @@ procedure Bool.2 (): ret Bool.23; procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : U32 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U32 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (Test.2): let Test.8 : U32 = 0i64; diff --git a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt index 751ab4c0d8..2931f9146a 100644 --- a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt +++ b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt @@ -1,60 +1,60 @@ -procedure List.18 (List.163, List.164, List.165): - let List.626 : U64 = 0i64; - let List.627 : U64 = CallByName List.6 List.163; - let List.625 : List [C List *self] = CallByName List.92 List.163 List.164 List.165 List.626 List.627; - ret List.625; +procedure List.18 (List.166, List.167, List.168): + let List.629 : U64 = 0i64; + let List.630 : U64 = CallByName List.6 List.166; + let List.628 : List [C List *self] = CallByName List.95 List.166 List.167 List.168 List.629 List.630; + ret List.628; -procedure List.275 (List.276, List.277, List.273): - let List.639 : [C List *self] = CallByName Test.2 List.277; - let List.638 : List [C List *self] = CallByName List.71 List.276 List.639; - ret List.638; - -procedure List.5 (List.272, List.273): - let List.274 : U64 = CallByName List.6 List.272; - let List.623 : List [C List *self] = CallByName List.68 List.274; - let List.622 : List [C List *self] = CallByName List.18 List.272 List.623 List.273; - ret List.622; - -procedure List.6 (#Attr.2): - let List.636 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.636; - -procedure List.66 (#Attr.2, #Attr.3): - let List.635 : [C List *self] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.635; - -procedure List.68 (#Attr.2): - let List.641 : List [C List *self] = lowlevel ListWithCapacity #Attr.2; +procedure List.278 (List.279, List.280, List.276): + let List.642 : [C List *self] = CallByName Test.2 List.280; + let List.641 : List [C List *self] = CallByName List.71 List.279 List.642; ret List.641; -procedure List.71 (#Attr.2, #Attr.3): - let List.640 : List [C List *self] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.640; +procedure List.5 (List.275, List.276): + let List.277 : U64 = CallByName List.6 List.275; + let List.626 : List [C List *self] = CallByName List.68 List.277; + let List.625 : List [C List *self] = CallByName List.18 List.275 List.626 List.276; + ret List.625; -procedure List.92 (#Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8): - joinpoint List.628 List.166 List.167 List.168 List.169 List.170: - let List.630 : Int1 = CallByName Num.22 List.169 List.170; - if List.630 then - let List.634 : [C List *self] = CallByName List.66 List.166 List.169; - inc List.634; - let List.171 : List [C List *self] = CallByName List.275 List.167 List.634 List.168; - let List.633 : U64 = 1i64; - let List.632 : U64 = CallByName Num.51 List.169 List.633; - jump List.628 List.166 List.171 List.168 List.632 List.170; +procedure List.6 (#Attr.2): + let List.639 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.639; + +procedure List.66 (#Attr.2, #Attr.3): + let List.638 : [C List *self] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.638; + +procedure List.68 (#Attr.2): + let List.644 : List [C List *self] = lowlevel ListWithCapacity #Attr.2; + ret List.644; + +procedure List.71 (#Attr.2, #Attr.3): + let List.643 : List [C List *self] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.643; + +procedure List.95 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.631 List.169 List.170 List.171 List.172 List.173: + let List.633 : Int1 = CallByName Num.22 List.172 List.173; + if List.633 then + let List.637 : [C List *self] = CallByName List.66 List.169 List.172; + inc List.637; + let List.174 : List [C List *self] = CallByName List.278 List.170 List.637 List.171; + let List.636 : U64 = 1i64; + let List.635 : U64 = CallByName Num.51 List.172 List.636; + jump List.631 List.169 List.174 List.171 List.635 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.4; - jump List.628 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8; + inc #Derived_gen.0; + jump List.631 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.22 (#Attr.2, #Attr.3): - let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.279 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; procedure Test.2 (Test.5): let Test.6 : List [C List *self] = UnionAtIndex (Id 0) (Index 0) Test.5; diff --git a/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt b/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt index 2e9faa9d1b..f679a2e5d0 100644 --- a/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt +++ b/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt @@ -3,12 +3,12 @@ procedure Bool.11 (#Attr.2, #Attr.3): ret Bool.23; procedure Num.20 (#Attr.2, #Attr.3): - let Num.280 : U8 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : U8 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.282; procedure Num.21 (#Attr.2, #Attr.3): - let Num.279 : U8 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U8 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (#Derived_gen.0, #Derived_gen.1): joinpoint Test.11 Test.2 Test.3: diff --git a/crates/compiler/test_mono/generated/recursively_build_effect.txt b/crates/compiler/test_mono/generated/recursively_build_effect.txt index a6bcf407a8..87e8e672ac 100644 --- a/crates/compiler/test_mono/generated/recursively_build_effect.txt +++ b/crates/compiler/test_mono/generated/recursively_build_effect.txt @@ -1,10 +1,10 @@ procedure Num.20 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.281; procedure Str.3 (#Attr.2, #Attr.3): - let Str.234 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.234; + let Str.238 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.238; procedure Test.11 (Test.29, #Attr.12): let Test.32 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12; diff --git a/crates/compiler/test_mono/generated/rigids.txt b/crates/compiler/test_mono/generated/rigids.txt index 3a501053b6..6a20a5f1f5 100644 --- a/crates/compiler/test_mono/generated/rigids.txt +++ b/crates/compiler/test_mono/generated/rigids.txt @@ -1,45 +1,45 @@ -procedure List.2 (List.111, List.112): - let List.644 : U64 = CallByName List.6 List.111; - let List.641 : Int1 = CallByName Num.22 List.112 List.644; - if List.641 then - let List.643 : I64 = CallByName List.66 List.111 List.112; - let List.642 : [C {}, C I64] = TagId(1) List.643; - ret List.642; +procedure List.2 (List.114, List.115): + let List.647 : U64 = CallByName List.6 List.114; + let List.644 : Int1 = CallByName Num.22 List.115 List.647; + if List.644 then + let List.646 : I64 = CallByName List.66 List.114 List.115; + let List.645 : [C {}, C I64] = TagId(1) List.646; + ret List.645; else - let List.640 : {} = Struct {}; - let List.639 : [C {}, C I64] = TagId(0) List.640; - ret List.639; + let List.643 : {} = Struct {}; + let List.642 : [C {}, C I64] = TagId(0) List.643; + ret List.642; -procedure List.3 (List.119, List.120, List.121): - let List.631 : {List I64, I64} = CallByName List.64 List.119 List.120 List.121; - let List.630 : List I64 = StructAtIndex 0 List.631; - ret List.630; +procedure List.3 (List.122, List.123, List.124): + let List.634 : {List I64, I64} = CallByName List.64 List.122 List.123 List.124; + let List.633 : List I64 = StructAtIndex 0 List.634; + ret List.633; procedure List.6 (#Attr.2): - let List.629 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.629; + let List.632 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.632; -procedure List.64 (List.116, List.117, List.118): - let List.628 : U64 = CallByName List.6 List.116; - let List.625 : Int1 = CallByName Num.22 List.117 List.628; - if List.625 then - let List.626 : {List I64, I64} = CallByName List.67 List.116 List.117 List.118; - ret List.626; +procedure List.64 (List.119, List.120, List.121): + let List.631 : U64 = CallByName List.6 List.119; + let List.628 : Int1 = CallByName Num.22 List.120 List.631; + if List.628 then + let List.629 : {List I64, I64} = CallByName List.67 List.119 List.120 List.121; + ret List.629; else - let List.624 : {List I64, I64} = Struct {List.116, List.118}; - ret List.624; + let List.627 : {List I64, I64} = Struct {List.119, List.121}; + ret List.627; procedure List.66 (#Attr.2, #Attr.3): - let List.637 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.637; + let List.640 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.640; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.627 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.627; + let List.630 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.630; procedure Num.22 (#Attr.2, #Attr.3): - let Num.281 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.283; procedure Test.1 (Test.2, Test.3, Test.4): let Test.29 : [C {}, C I64] = CallByName List.2 Test.4 Test.3; diff --git a/crates/compiler/test_mono/generated/specialize_after_match.txt b/crates/compiler/test_mono/generated/specialize_after_match.txt index 832e559bd4..cb95b4a71a 100644 --- a/crates/compiler/test_mono/generated/specialize_after_match.txt +++ b/crates/compiler/test_mono/generated/specialize_after_match.txt @@ -1,10 +1,10 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.280 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.282; procedure Num.24 (#Attr.2, #Attr.3): - let Num.281 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.283; procedure Test.2 (Test.9, Test.10): let Test.38 : U8 = 1i64; diff --git a/crates/compiler/test_mono/generated/specialize_closures.txt b/crates/compiler/test_mono/generated/specialize_closures.txt index 8998ad0832..ad9a4917a7 100644 --- a/crates/compiler/test_mono/generated/specialize_closures.txt +++ b/crates/compiler/test_mono/generated/specialize_closures.txt @@ -3,12 +3,12 @@ procedure Bool.2 (): ret Bool.24; procedure Num.19 (#Attr.2, #Attr.3): - let Num.280 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.282; procedure Num.21 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (Test.2, Test.3): let Test.15 : U8 = GetTagId Test.2; diff --git a/crates/compiler/test_mono/generated/specialize_lowlevel.txt b/crates/compiler/test_mono/generated/specialize_lowlevel.txt index 5c288fc665..d160decc95 100644 --- a/crates/compiler/test_mono/generated/specialize_lowlevel.txt +++ b/crates/compiler/test_mono/generated/specialize_lowlevel.txt @@ -3,12 +3,12 @@ procedure Bool.2 (): ret Bool.23; procedure Num.19 (#Attr.2, #Attr.3): - let Num.280 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.282; procedure Num.21 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.281; procedure Test.6 (Test.8, #Attr.12): let Test.20 : I64 = UnionAtIndex (Id 0) (Index 0) #Attr.12; diff --git a/crates/compiler/test_mono/generated/tail_call_elimination.txt b/crates/compiler/test_mono/generated/tail_call_elimination.txt index f6e047d6cc..a79c088324 100644 --- a/crates/compiler/test_mono/generated/tail_call_elimination.txt +++ b/crates/compiler/test_mono/generated/tail_call_elimination.txt @@ -1,10 +1,10 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Num.20 (#Attr.2, #Attr.3): - let Num.280 : I64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : I64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.282; procedure Test.1 (#Derived_gen.0, #Derived_gen.1): joinpoint Test.7 Test.2 Test.3: diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt index c4bb03fb05..5f6d6112b2 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt @@ -2,109 +2,109 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.111 : List U8 = CallByName Test.213 Encode.99 Encode.101 Encode.107; - ret Encode.111; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.113 : List U8 = CallByName Test.213 Encode.101 Encode.103 Encode.109; + ret Encode.113; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.115 : List U8 = CallByName Test.63 Encode.99 Encode.101 Encode.107; - ret Encode.115; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.117 : List U8 = CallByName Test.63 Encode.101 Encode.103 Encode.109; + ret Encode.117; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.116 : List U8 = CallByName Test.59 Encode.99 Encode.101 Encode.107; - ret Encode.116; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.118 : List U8 = CallByName Test.59 Encode.101 Encode.103 Encode.109; + ret Encode.118; -procedure Encode.26 (Encode.105, Encode.106): - let Encode.109 : List U8 = Array []; - let Encode.110 : {Str, Str} = CallByName Test.49 Encode.105; - let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; - ret Encode.108; +procedure Encode.26 (Encode.107, Encode.108): + let Encode.111 : List U8 = Array []; + let Encode.112 : {Str, Str} = CallByName Test.49 Encode.107; + let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; + ret Encode.110; procedure List.13 (#Attr.2, #Attr.3): - let List.648 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.648; + let List.651 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.651; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; -procedure List.4 (List.127, List.128): - let List.644 : U64 = 1i64; - let List.643 : List U8 = CallByName List.70 List.127 List.644; - let List.642 : List U8 = CallByName List.71 List.643 List.128; - ret List.642; +procedure List.4 (List.130, List.131): + let List.647 : U64 = 1i64; + let List.646 : List U8 = CallByName List.70 List.130 List.647; + let List.645 : List U8 = CallByName List.71 List.646 List.131; + ret List.645; procedure List.6 (#Attr.2): - let List.647 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.647; + let List.650 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.650; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; procedure List.70 (#Attr.2, #Attr.3): - let List.638 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.638; + let List.641 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.641; procedure List.71 (#Attr.2, #Attr.3): - let List.636 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.636; + let List.639 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.639; procedure List.8 (#Attr.2, #Attr.3): - let List.646 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.646; + let List.649 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.649; -procedure List.92 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : Str = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : List U8 = CallByName Test.66 List.167 List.631 List.168; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : Str = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : List U8 = CallByName Test.66 List.170 List.634 List.171; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.0; - jump List.625 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + inc #Derived_gen.9; + jump List.628 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13; procedure Num.127 (#Attr.2): - let Num.280 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.280; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + let Num.282 : U8 = lowlevel NumIntCast #Attr.2; ret Num.282; +procedure Num.22 (#Attr.2, #Attr.3): + let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.284; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; procedure Num.96 (#Attr.2): - let Num.279 : Str = lowlevel NumToStr #Attr.2; - ret Num.279; + let Num.281 : Str = lowlevel NumToStr #Attr.2; + ret Num.281; procedure Str.12 (#Attr.2): - let Str.233 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.233; + let Str.237 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.237; procedure Str.36 (#Attr.2): - let Str.234 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; - ret Str.234; + let Str.238 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.238; procedure Test.20 (Test.58): let Test.295 : Str = CallByName Encode.23 Test.58; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt index 2b3b551e4e..3c8a491dd6 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt @@ -34,170 +34,170 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.23 (Encode.98): - ret Encode.98; +procedure Encode.23 (Encode.100): + ret Encode.100; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.111 : List U8 = CallByName Test.213 Encode.99 Encode.101 Encode.107; - ret Encode.111; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.113 : List U8 = CallByName Test.213 Encode.101 Encode.103 Encode.109; + ret Encode.113; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.115 : List U8 = CallByName Test.63 Encode.99 Encode.101 Encode.107; - ret Encode.115; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.117 : List U8 = CallByName Test.63 Encode.101 Encode.103 Encode.109; + ret Encode.117; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.117 : U8 = GetTagId Encode.107; - switch Encode.117: +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.119 : U8 = GetTagId Encode.109; + switch Encode.119: case 0: - let Encode.116 : List U8 = CallByName #Derived.2 Encode.99 Encode.101 Encode.107; - ret Encode.116; + let Encode.118 : List U8 = CallByName #Derived.2 Encode.101 Encode.103 Encode.109; + ret Encode.118; case 1: - let Encode.116 : List U8 = CallByName #Derived.7 Encode.99 Encode.101 Encode.107; - ret Encode.116; + let Encode.118 : List U8 = CallByName #Derived.7 Encode.101 Encode.103 Encode.109; + ret Encode.118; default: - let Encode.116 : List U8 = CallByName Test.59 Encode.99 Encode.101 Encode.107; - ret Encode.116; + let Encode.118 : List U8 = CallByName Test.59 Encode.101 Encode.103 Encode.109; + ret Encode.118; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.121 : List U8 = CallByName Test.63 Encode.99 Encode.101 Encode.107; - ret Encode.121; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.123 : List U8 = CallByName Test.63 Encode.101 Encode.103 Encode.109; + ret Encode.123; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.124 : List U8 = CallByName Test.59 Encode.99 Encode.101 Encode.107; - ret Encode.124; +procedure Encode.24 (Encode.101, Encode.109, Encode.103): + let Encode.126 : List U8 = CallByName Test.59 Encode.101 Encode.103 Encode.109; + ret Encode.126; -procedure Encode.26 (Encode.105, Encode.106): - let Encode.109 : List U8 = Array []; - let Encode.110 : {{}, {}} = CallByName Test.49 Encode.105; - let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; - ret Encode.108; +procedure Encode.26 (Encode.107, Encode.108): + let Encode.111 : List U8 = Array []; + let Encode.112 : {{}, {}} = CallByName Test.49 Encode.107; + let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; + ret Encode.110; procedure List.13 (#Attr.2, #Attr.3): - let List.648 : List [C {}, C {}, C Str] = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.648; + let List.651 : List [C {}, C {}, C Str] = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.651; procedure List.13 (#Attr.2, #Attr.3): - let List.676 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.676; + let List.679 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.679; -procedure List.18 (List.163, List.164, List.165): - let List.623 : U64 = 0i64; - let List.624 : U64 = CallByName List.6 List.163; - let List.622 : List U8 = CallByName List.92 List.163 List.164 List.165 List.623 List.624; - ret List.622; +procedure List.18 (List.166, List.167, List.168): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.166; + let List.625 : List U8 = CallByName List.95 List.166 List.167 List.168 List.626 List.627; + ret List.625; -procedure List.18 (List.163, List.164, List.165): - let List.650 : U64 = 0i64; - let List.651 : U64 = CallByName List.6 List.163; - let List.649 : List U8 = CallByName List.92 List.163 List.164 List.165 List.650 List.651; - ret List.649; +procedure List.18 (List.166, List.167, List.168): + let List.653 : U64 = 0i64; + let List.654 : U64 = CallByName List.6 List.166; + let List.652 : List U8 = CallByName List.95 List.166 List.167 List.168 List.653 List.654; + ret List.652; -procedure List.4 (List.127, List.128): - let List.671 : U64 = 1i64; - let List.670 : List U8 = CallByName List.70 List.127 List.671; - let List.669 : List U8 = CallByName List.71 List.670 List.128; - ret List.669; +procedure List.4 (List.130, List.131): + let List.674 : U64 = 1i64; + let List.673 : List U8 = CallByName List.70 List.130 List.674; + let List.672 : List U8 = CallByName List.71 List.673 List.131; + ret List.672; procedure List.6 (#Attr.2): - let List.647 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.647; + let List.650 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.650; procedure List.6 (#Attr.2): - let List.674 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.674; + let List.677 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.677; procedure List.66 (#Attr.2, #Attr.3): - let List.632 : [C {}, C {}, C Str] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.632; + let List.635 : [C {}, C {}, C Str] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; procedure List.66 (#Attr.2, #Attr.3): - let List.659 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.659; + let List.662 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.662; procedure List.70 (#Attr.2, #Attr.3): - let List.665 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.665; + let List.668 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.668; procedure List.71 (#Attr.2, #Attr.3): - let List.663 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.663; + let List.666 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.666; procedure List.8 (#Attr.2, #Attr.3): - let List.673 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.673; + let List.676 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.676; -procedure List.92 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): - joinpoint List.625 List.166 List.167 List.168 List.169 List.170: - let List.627 : Int1 = CallByName Num.22 List.169 List.170; - if List.627 then - let List.631 : [C {}, C {}, C Str] = CallByName List.66 List.166 List.169; - inc List.631; - let List.171 : List U8 = CallByName Test.66 List.167 List.631 List.168; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.51 List.169 List.630; - jump List.625 List.166 List.171 List.168 List.629 List.170; +procedure List.95 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): + joinpoint List.628 List.169 List.170 List.171 List.172 List.173: + let List.630 : Int1 = CallByName Num.22 List.172 List.173; + if List.630 then + let List.634 : [C {}, C {}, C Str] = CallByName List.66 List.169 List.172; + inc List.634; + let List.174 : List U8 = CallByName Test.66 List.170 List.634 List.171; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.172 List.633; + jump List.628 List.169 List.174 List.171 List.632 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.29; - jump List.625 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; + inc #Derived_gen.26; + jump List.628 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; -procedure List.92 (#Derived_gen.52, #Derived_gen.53, #Derived_gen.54, #Derived_gen.55, #Derived_gen.56): - joinpoint List.652 List.166 List.167 List.168 List.169 List.170: - let List.654 : Int1 = CallByName Num.22 List.169 List.170; - if List.654 then - let List.658 : Str = CallByName List.66 List.166 List.169; - inc List.658; - let List.171 : List U8 = CallByName Test.66 List.167 List.658 List.168; - let List.657 : U64 = 1i64; - let List.656 : U64 = CallByName Num.51 List.169 List.657; - jump List.652 List.166 List.171 List.168 List.656 List.170; +procedure List.95 (#Derived_gen.34, #Derived_gen.35, #Derived_gen.36, #Derived_gen.37, #Derived_gen.38): + joinpoint List.655 List.169 List.170 List.171 List.172 List.173: + let List.657 : Int1 = CallByName Num.22 List.172 List.173; + if List.657 then + let List.661 : Str = CallByName List.66 List.169 List.172; + inc List.661; + let List.174 : List U8 = CallByName Test.66 List.170 List.661 List.171; + let List.660 : U64 = 1i64; + let List.659 : U64 = CallByName Num.51 List.172 List.660; + jump List.655 List.169 List.174 List.171 List.659 List.173; else - dec List.166; - ret List.167; + dec List.169; + ret List.170; in - inc #Derived_gen.52; - jump List.652 #Derived_gen.52 #Derived_gen.53 #Derived_gen.54 #Derived_gen.55 #Derived_gen.56; + inc #Derived_gen.34; + jump List.655 #Derived_gen.34 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38; procedure Num.127 (#Attr.2): - let Num.284 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.284; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.286 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + let Num.286 : U8 = lowlevel NumIntCast #Attr.2; ret Num.286; +procedure Num.22 (#Attr.2, #Attr.3): + let Num.288 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.288; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.285 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.285; + let Num.287 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.287; procedure Num.96 (#Attr.2): - let Num.283 : Str = lowlevel NumToStr #Attr.2; - ret Num.283; + let Num.285 : Str = lowlevel NumToStr #Attr.2; + ret Num.285; procedure Str.12 (#Attr.2): - let Str.236 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.236; + let Str.240 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.240; procedure Str.36 (#Attr.2): - let Str.237 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; - ret Str.237; + let Str.241 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.241; procedure Test.20 (Test.58): inc Test.58; diff --git a/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt b/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt index 5714f000b3..b6a1673dce 100644 --- a/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt +++ b/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt @@ -2,93 +2,93 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.23; -procedure List.107 (List.536, List.537, List.538): - let List.640 : U64 = 0i64; - let List.641 : U64 = CallByName List.6 List.536; - let List.639 : [C U64, C U64] = CallByName List.80 List.536 List.537 List.538 List.640 List.641; - ret List.639; +procedure List.110 (List.539, List.540, List.541): + let List.643 : U64 = 0i64; + let List.644 : U64 = CallByName List.6 List.539; + let List.642 : [C U64, C U64] = CallByName List.80 List.539 List.540 List.541 List.643 List.644; + ret List.642; -procedure List.26 (List.204, List.205, List.206): - let List.633 : [C U64, C U64] = CallByName List.107 List.204 List.205 List.206; - let List.636 : U8 = 1i64; - let List.637 : U8 = GetTagId List.633; - let List.638 : Int1 = lowlevel Eq List.636 List.637; - if List.638 then - let List.207 : U64 = UnionAtIndex (Id 1) (Index 0) List.633; - ret List.207; +procedure List.26 (List.207, List.208, List.209): + let List.636 : [C U64, C U64] = CallByName List.110 List.207 List.208 List.209; + let List.639 : U8 = 1i64; + let List.640 : U8 = GetTagId List.636; + let List.641 : Int1 = lowlevel Eq List.639 List.640; + if List.641 then + let List.210 : U64 = UnionAtIndex (Id 1) (Index 0) List.636; + ret List.210; else - let List.208 : U64 = UnionAtIndex (Id 0) (Index 0) List.633; - ret List.208; + let List.211 : U64 = UnionAtIndex (Id 0) (Index 0) List.636; + ret List.211; -procedure List.38 (List.392, List.393): - let List.632 : U64 = CallByName List.6 List.392; - let List.394 : U64 = CallByName Num.77 List.632 List.393; - let List.622 : List U8 = CallByName List.43 List.392 List.394; - ret List.622; - -procedure List.43 (List.390, List.391): - let List.630 : U64 = CallByName List.6 List.390; - let List.629 : U64 = CallByName Num.77 List.630 List.391; - let List.624 : {U64, U64} = Struct {List.391, List.629}; - let List.623 : List U8 = CallByName List.49 List.390 List.624; - ret List.623; - -procedure List.49 (List.468, List.469): - let List.626 : U64 = StructAtIndex 1 List.469; - let List.627 : U64 = StructAtIndex 0 List.469; - let List.625 : List U8 = CallByName List.72 List.468 List.626 List.627; +procedure List.38 (List.395, List.396): + let List.635 : U64 = CallByName List.6 List.395; + let List.397 : U64 = CallByName Num.77 List.635 List.396; + let List.625 : List U8 = CallByName List.43 List.395 List.397; ret List.625; -procedure List.6 (#Attr.2): - let List.631 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.631; +procedure List.43 (List.393, List.394): + let List.633 : U64 = CallByName List.6 List.393; + let List.632 : U64 = CallByName Num.77 List.633 List.394; + let List.627 : {U64, U64} = Struct {List.394, List.632}; + let List.626 : List U8 = CallByName List.49 List.393 List.627; + ret List.626; -procedure List.66 (#Attr.2, #Attr.3): - let List.654 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.654; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.628 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; +procedure List.49 (List.471, List.472): + let List.629 : U64 = StructAtIndex 1 List.472; + let List.630 : U64 = StructAtIndex 0 List.472; + let List.628 : List U8 = CallByName List.72 List.471 List.629 List.630; ret List.628; +procedure List.6 (#Attr.2): + let List.634 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.634; + +procedure List.66 (#Attr.2, #Attr.3): + let List.657 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.657; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.631 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.631; + procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.642 List.539 List.540 List.541 List.542 List.543: - let List.644 : Int1 = CallByName Num.22 List.542 List.543; - if List.644 then - let List.653 : U8 = CallByName List.66 List.539 List.542; - let List.645 : [C U64, C U64] = CallByName Test.3 List.540 List.653; - let List.650 : U8 = 1i64; - let List.651 : U8 = GetTagId List.645; - let List.652 : Int1 = lowlevel Eq List.650 List.651; - if List.652 then - let List.544 : U64 = UnionAtIndex (Id 1) (Index 0) List.645; - let List.648 : U64 = 1i64; - let List.647 : U64 = CallByName Num.51 List.542 List.648; - jump List.642 List.539 List.544 List.541 List.647 List.543; + joinpoint List.645 List.542 List.543 List.544 List.545 List.546: + let List.647 : Int1 = CallByName Num.22 List.545 List.546; + if List.647 then + let List.656 : U8 = CallByName List.66 List.542 List.545; + let List.648 : [C U64, C U64] = CallByName Test.3 List.543 List.656; + let List.653 : U8 = 1i64; + let List.654 : U8 = GetTagId List.648; + let List.655 : Int1 = lowlevel Eq List.653 List.654; + if List.655 then + let List.547 : U64 = UnionAtIndex (Id 1) (Index 0) List.648; + let List.651 : U64 = 1i64; + let List.650 : U64 = CallByName Num.51 List.545 List.651; + jump List.645 List.542 List.547 List.544 List.650 List.546; else - dec List.539; - let List.545 : U64 = UnionAtIndex (Id 0) (Index 0) List.645; - let List.649 : [C U64, C U64] = TagId(0) List.545; - ret List.649; + dec List.542; + let List.548 : U64 = UnionAtIndex (Id 0) (Index 0) List.648; + let List.652 : [C U64, C U64] = TagId(0) List.548; + ret List.652; else - dec List.539; - let List.643 : [C U64, C U64] = TagId(1) List.540; - ret List.643; + dec List.542; + let List.646 : [C U64, C U64] = TagId(1) List.543; + ret List.646; in inc #Derived_gen.0; - jump List.642 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.645 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.22 (#Attr.2, #Attr.3): - let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.282; + let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.284; procedure Num.51 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.281; + let Num.283 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.283; procedure Num.77 (#Attr.2, #Attr.3): - let Num.280 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3; - ret Num.280; + let Num.282 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3; + ret Num.282; procedure Test.3 (Test.4, Test.12): let Test.13 : [C U64, C U64] = TagId(0) Test.4; diff --git a/crates/compiler/test_mono/generated/when_guard_appears_multiple_times_in_compiled_decision_tree_issue_5176.txt b/crates/compiler/test_mono/generated/when_guard_appears_multiple_times_in_compiled_decision_tree_issue_5176.txt index 8844496ae5..bdd8a6188c 100644 --- a/crates/compiler/test_mono/generated/when_guard_appears_multiple_times_in_compiled_decision_tree_issue_5176.txt +++ b/crates/compiler/test_mono/generated/when_guard_appears_multiple_times_in_compiled_decision_tree_issue_5176.txt @@ -3,8 +3,8 @@ procedure Bool.2 (): ret Bool.25; procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.1 (Test.2): joinpoint Test.12: diff --git a/crates/compiler/test_mono/generated/when_nested_maybe.txt b/crates/compiler/test_mono/generated/when_nested_maybe.txt index a270831662..32875666f6 100644 --- a/crates/compiler/test_mono/generated/when_nested_maybe.txt +++ b/crates/compiler/test_mono/generated/when_nested_maybe.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.19 : I64 = 41i64; diff --git a/crates/compiler/test_mono/generated/when_on_record.txt b/crates/compiler/test_mono/generated/when_on_record.txt index b890935ed7..9da4345549 100644 --- a/crates/compiler/test_mono/generated/when_on_record.txt +++ b/crates/compiler/test_mono/generated/when_on_record.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.5 : I64 = 2i64; diff --git a/crates/compiler/test_mono/generated/when_on_two_values.txt b/crates/compiler/test_mono/generated/when_on_two_values.txt index a98325d7d5..742cb21af2 100644 --- a/crates/compiler/test_mono/generated/when_on_two_values.txt +++ b/crates/compiler/test_mono/generated/when_on_two_values.txt @@ -1,6 +1,6 @@ procedure Num.19 (#Attr.2, #Attr.3): - let Num.279 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.279; + let Num.281 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.281; procedure Test.0 (): let Test.15 : I64 = 3i64; diff --git a/crates/compiler/test_syntax/src/minimize.rs b/crates/compiler/test_syntax/src/minimize.rs index 946b31147e..7cd87bd922 100644 --- a/crates/compiler/test_syntax/src/minimize.rs +++ b/crates/compiler/test_syntax/src/minimize.rs @@ -7,7 +7,7 @@ use crate::test_helpers::{Input, InputKind}; use bumpalo::Bump; -use roc_parse::{ast::Malformed, remove_spaces::RemoveSpaces}; +use roc_parse::{ast::Malformed, normalize::Normalize}; pub fn print_minimizations(text: &str, kind: InputKind) { let Some(original_error) = round_trip_once_and_extract_error(text, kind) else { @@ -81,12 +81,7 @@ fn round_trip_once(input: Input<'_>) -> Option { let actual = match input.parse_in(&arena) { Ok(a) => a, - Err(e) => { - return Some(format!( - "Initial parse failed: {:?}", - e.remove_spaces(&arena) - )) - } + Err(e) => return Some(format!("Initial parse failed: {:?}", e.normalize(&arena))), }; if actual.is_malformed() { @@ -97,11 +92,11 @@ fn round_trip_once(input: Input<'_>) -> Option { let reparsed_ast = match output.as_ref().parse_in(&arena) { Ok(r) => r, - Err(e) => return Some(format!("Reparse failed: {:?}", e.remove_spaces(&arena))), + Err(e) => return Some(format!("Reparse failed: {:?}", e.normalize(&arena))), }; - let ast_normalized = actual.remove_spaces(&arena); - let reparsed_ast_normalized = reparsed_ast.remove_spaces(&arena); + let ast_normalized = actual.normalize(&arena); + let reparsed_ast_normalized = reparsed_ast.normalize(&arena); if format!("{ast_normalized:?}") != format!("{reparsed_ast_normalized:?}") { return Some("Different ast".to_string()); diff --git a/crates/compiler/test_syntax/src/test_helpers.rs b/crates/compiler/test_syntax/src/test_helpers.rs index 64411b54e6..c16c17d001 100644 --- a/crates/compiler/test_syntax/src/test_helpers.rs +++ b/crates/compiler/test_syntax/src/test_helpers.rs @@ -1,10 +1,10 @@ use bumpalo::Bump; -use roc_fmt::{annotation::Formattable, module::fmt_module}; +use roc_fmt::{annotation::Formattable, header::fmt_header}; use roc_parse::{ - ast::{Defs, Expr, Malformed, Module}, - module::parse_module_defs, + ast::{Defs, Expr, FullAst, Header, Malformed, SpacesBefore}, + header::parse_module_defs, + normalize::Normalize, parser::{Parser, SyntaxError}, - remove_spaces::RemoveSpaces, state::State, test_helpers::{parse_defs_with, parse_expr_with, parse_header_with}, }; @@ -70,16 +70,13 @@ impl InputOwned { /// Output AST of a successful parse #[derive(Debug, Clone)] pub enum Output<'a> { - Header(Module<'a>), + Header(SpacesBefore<'a, Header<'a>>), ModuleDefs(Defs<'a>), Expr(Expr<'a>), - Full { - header: Module<'a>, - module_defs: Defs<'a>, - }, + Full(FullAst<'a>), } impl<'a> Output<'a> { @@ -88,7 +85,7 @@ impl<'a> Output<'a> { let mut buf = Buf::new_in(&arena); match self { Output::Header(header) => { - fmt_module(&mut buf, header); + fmt_header(&mut buf, header); buf.fmt_end_of_file(); InputOwned::Header(buf.as_str().to_string()) } @@ -101,12 +98,9 @@ impl<'a> Output<'a> { expr.format(&mut buf, 0); InputOwned::Expr(buf.as_str().to_string()) } - Output::Full { - header, - module_defs, - } => { - fmt_module(&mut buf, header); - module_defs.format(&mut buf, 0); + Output::Full(full) => { + fmt_header(&mut buf, &full.header); + full.defs.format(&mut buf, 0); buf.fmt_end_of_file(); InputOwned::Full(buf.as_str().to_string()) } @@ -129,27 +123,18 @@ impl<'a> Malformed for Output<'a> { Output::Header(header) => header.is_malformed(), Output::ModuleDefs(defs) => defs.is_malformed(), Output::Expr(expr) => expr.is_malformed(), - Output::Full { - header, - module_defs, - } => header.is_malformed() || module_defs.is_malformed(), + Output::Full(full) => full.is_malformed(), } } } -impl<'a> RemoveSpaces<'a> for Output<'a> { - fn remove_spaces(&self, arena: &'a Bump) -> Self { +impl<'a> Normalize<'a> for Output<'a> { + fn normalize(&self, arena: &'a Bump) -> Self { match self { - Output::Header(header) => Output::Header(header.remove_spaces(arena)), - Output::ModuleDefs(defs) => Output::ModuleDefs(defs.remove_spaces(arena)), - Output::Expr(expr) => Output::Expr(expr.remove_spaces(arena)), - Output::Full { - header, - module_defs, - } => Output::Full { - header: header.remove_spaces(arena), - module_defs: module_defs.remove_spaces(arena), - }, + Output::Header(header) => Output::Header(header.normalize(arena)), + Output::ModuleDefs(defs) => Output::ModuleDefs(defs.normalize(arena)), + Output::Expr(expr) => Output::Expr(expr.normalize(arena)), + Output::Full(full) => Output::Full(full.normalize(arena)), } } } @@ -185,18 +170,19 @@ impl<'a> Input<'a> { let state = State::new(input.as_bytes()); let min_indent = 0; - let (_, header, state) = roc_parse::module::header() + let (_, header, state) = roc_parse::header::header() .parse(arena, state.clone(), min_indent) .map_err(|(_, fail)| SyntaxError::Header(fail))?; - let (header, defs) = header.upgrade_header_imports(arena); + let (new_header, defs) = header.item.upgrade_header_imports(arena); + let header = SpacesBefore { + before: header.before, + item: new_header, + }; - let module_defs = parse_module_defs(arena, state, defs)?; + let defs = parse_module_defs(arena, state, defs)?; - Ok(Output::Full { - header, - module_defs, - }) + Ok(Output::Full(FullAst { header, defs })) } } } @@ -235,8 +221,8 @@ impl<'a> Input<'a> { ); }); - let ast_normalized = actual.remove_spaces(&arena); - let reparsed_ast_normalized = reparsed_ast.remove_spaces(&arena); + let ast_normalized = actual.normalize(&arena); + let reparsed_ast_normalized = reparsed_ast.normalize(&arena); // HACK! // We compare the debug format strings of the ASTs, because I'm finding in practice that _somewhere_ deep inside the ast, diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/empty_app_header.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/empty_app_header.header.result-ast index 800a60761e..0b814c3e80 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/empty_app_header.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/empty_app_header.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: App( +SpacesBefore { + before: [], + item: App( AppHeader { before_provides: [], provides: [], diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/empty_hosted_header.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/empty_hosted_header.header.result-ast index 2bd537602b..f8fd0929b3 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/empty_hosted_header.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/empty_hosted_header.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Hosted( +SpacesBefore { + before: [], + item: Hosted( HostedHeader { before_name: [], name: @7-10 ModuleName( diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/empty_module_header.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/empty_module_header.header.result-ast index 63a181db53..6307f56478 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/empty_module_header.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/empty_module_header.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Module( +SpacesBefore { + before: [], + item: Module( ModuleHeader { after_keyword: [], params: None, diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/empty_package_header.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/empty_package_header.header.result-ast index 8dff2a08df..a1e7380689 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/empty_package_header.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/empty_package_header.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Package( +SpacesBefore { + before: [], + item: Package( PackageHeader { before_exposes: [], exposes: [], diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/empty_platform_header.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/empty_platform_header.header.result-ast index e93effb371..51892ce9b2 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/empty_platform_header.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/empty_platform_header.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Platform( +SpacesBefore { + before: [], + item: Platform( PlatformHeader { before_name: [], name: @9-25 PackageName( diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/full_app_header.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/full_app_header.header.result-ast index f9f1093ed4..7484bead1a 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/full_app_header.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/full_app_header.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: App( +SpacesBefore { + before: [], + item: App( AppHeader { before_provides: [], provides: [ diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/full_app_header_trailing_commas.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/full_app_header_trailing_commas.header.result-ast index 0c5bfd7ec8..6bb7c3c186 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/full_app_header_trailing_commas.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/full_app_header_trailing_commas.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: App( +SpacesBefore { + before: [], + item: App( AppHeader { before_provides: [], provides: [ diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/function_effect_types.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/function_effect_types.header.result-ast index b607aa0d84..9b28638e99 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/function_effect_types.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/function_effect_types.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Platform( +SpacesBefore { + before: [], + item: Platform( PlatformHeader { before_name: [], name: @9-14 PackageName( diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/import_with_params.moduledefs.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/import_with_params.moduledefs.result-ast index 94c9cf7137..3ddffef04b 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/import_with_params.moduledefs.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/import_with_params.moduledefs.result-ast @@ -45,7 +45,7 @@ Defs { params: Some( ModuleImportParams { before: [], - params: [ + params: @15-29 [ @17-21 LabelOnly( @17-21 "echo", ), @@ -71,7 +71,7 @@ Defs { params: Some( ModuleImportParams { before: [], - params: [ + params: @42-60 [ @44-48 LabelOnly( @44-48 "echo", ), @@ -102,7 +102,7 @@ Defs { params: Some( ModuleImportParams { before: [], - params: [ + params: @73-91 [ @75-79 LabelOnly( @75-79 "echo", ), @@ -144,7 +144,7 @@ Defs { params: Some( ModuleImportParams { before: [], - params: [ + params: @109-123 [ @111-115 LabelOnly( @111-115 "echo", ), diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/minimal_app_header.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/minimal_app_header.header.result-ast index d3a8418da9..962f4a7a7c 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/minimal_app_header.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/minimal_app_header.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: App( +SpacesBefore { + before: [], + item: App( AppHeader { before_provides: [], provides: [], diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/module_multiline_exposes.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/module_multiline_exposes.header.result-ast index 43e46e8755..edf4d77b77 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/module_multiline_exposes.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/module_multiline_exposes.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Module( +SpacesBefore { + before: [], + item: Module( ModuleHeader { after_keyword: [], params: None, diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/module_with_multiline_params_and_exposes.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/module_with_multiline_params_and_exposes.header.result-ast index 6fd765312d..bb8c0b200e 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/module_with_multiline_params_and_exposes.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/module_with_multiline_params_and_exposes.header.result-ast @@ -1,11 +1,11 @@ -Module { - comments: [], - header: Module( +SpacesBefore { + before: [], + item: Module( ModuleHeader { after_keyword: [], params: Some( ModuleParams { - params: [ + pattern: @7-45 [ @8-12 Identifier { ident: "echo", }, diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/module_with_newline.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/module_with_newline.header.result-ast index 63a181db53..6307f56478 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/module_with_newline.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/module_with_newline.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Module( +SpacesBefore { + before: [], + item: Module( ModuleHeader { after_keyword: [], params: None, diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/module_with_optional_param.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/module_with_optional_param.header.result-ast index 139cf2718d..931877cbc2 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/module_with_optional_param.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/module_with_optional_param.header.result-ast @@ -1,11 +1,11 @@ -Module { - comments: [], - header: Module( +SpacesBefore { + before: [], + item: Module( ModuleHeader { after_keyword: [], params: Some( ModuleParams { - params: [ + pattern: @7-20 [ @9-10 Identifier { ident: "x", }, diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/module_with_params.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/module_with_params.header.result-ast index a39e3e01bf..157d2bf0be 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/module_with_params.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/module_with_params.header.result-ast @@ -1,11 +1,11 @@ -Module { - comments: [], - header: Module( +SpacesBefore { + before: [], + item: Module( ModuleHeader { after_keyword: [], params: Some( ModuleParams { - params: [ + pattern: @7-20 [ @8-12 Identifier { ident: "echo", }, diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/module_with_params_and_multiline_exposes.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/module_with_params_and_multiline_exposes.header.result-ast index 5c31993249..ef4810ff1f 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/module_with_params_and_multiline_exposes.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/module_with_params_and_multiline_exposes.header.result-ast @@ -1,11 +1,11 @@ -Module { - comments: [], - header: Module( +SpacesBefore { + before: [], + item: Module( ModuleHeader { after_keyword: [], params: Some( ModuleParams { - params: [ + pattern: @7-20 [ @8-12 Identifier { ident: "echo", }, diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast index 616fe065f8..7e12303321 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast @@ -1,81 +1,83 @@ -Full { - header: Module { - comments: [], - header: App( - AppHeader { - before_provides: [], - provides: [ - @5-9 ExposedName( - "main", - ), - ], - before_packages: [], - packages: @11-134 [ - @13-132 SpaceAfter( - PackageEntry { - shorthand: "pf", - spaces_after_shorthand: [ +Full( + FullAst { + header: SpacesBefore { + before: [], + item: App( + AppHeader { + before_provides: [], + provides: [ + @5-9 ExposedName( + "main", + ), + ], + before_packages: [], + packages: @11-134 [ + @13-132 SpaceAfter( + PackageEntry { + shorthand: "pf", + spaces_after_shorthand: [ + Newline, + ], + platform_marker: None, + package_name: @17-132 PackageName( + "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br", + ), + }, + [ Newline, ], - platform_marker: None, - package_name: @17-132 PackageName( - "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br", - ), - }, + ), + ], + old_imports: None, + old_provides_to_new_package: None, + }, + ), + }, + defs: Defs { + tags: [ + Index(2147483648), + ], + regions: [ + @136-183, + ], + space_before: [ + Slice(start = 0, length = 2), + ], + space_after: [ + Slice(start = 2, length = 1), + ], + spaces: [ + Newline, + Newline, + Newline, + ], + type_defs: [], + value_defs: [ + Body( + @136-140 Identifier { + ident: "main", + }, + @147-183 SpaceBefore( + Apply( + @147-158 Var { + module_name: "Stdout", + ident: "line", + }, + [ + @159-183 Str( + PlainLine( + "I'm a Roc application!", + ), + ), + ], + Space, + ), [ Newline, ], ), - ], - old_imports: None, - old_provides_to_new_package: None, - }, - ), - }, - module_defs: Defs { - tags: [ - Index(2147483648), - ], - regions: [ - @136-183, - ], - space_before: [ - Slice(start = 0, length = 2), - ], - space_after: [ - Slice(start = 2, length = 1), - ], - spaces: [ - Newline, - Newline, - Newline, - ], - type_defs: [], - value_defs: [ - Body( - @136-140 Identifier { - ident: "main", - }, - @147-183 SpaceBefore( - Apply( - @147-158 Var { - module_name: "Stdout", - ident: "line", - }, - [ - @159-183 Str( - PlainLine( - "I'm a Roc application!", - ), - ), - ], - Space, - ), - [ - Newline, - ], ), - ), - ], + ], + }, }, -} +) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_hosted_header.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_hosted_header.header.result-ast index 7688f73379..a8b20a24dc 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_hosted_header.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_hosted_header.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Hosted( +SpacesBefore { + before: [], + item: Hosted( HostedHeader { before_name: [], name: @7-10 ModuleName( diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_package_header.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_package_header.header.result-ast index 1fcdaa9159..0d80e8e4dc 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_package_header.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_package_header.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Package( +SpacesBefore { + before: [], + item: Package( PackageHeader { before_exposes: [], exposes: [ diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_platform_header.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_platform_header.header.result-ast index 9a94accb8d..0f01119e5e 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_platform_header.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/nonempty_platform_header.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Platform( +SpacesBefore { + before: [], + item: Platform( PlatformHeader { before_name: [], name: @9-21 PackageName( diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/old_app_header.full.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/old_app_header.full.result-ast index acb6368daa..abf05b2687 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/old_app_header.full.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/old_app_header.full.result-ast @@ -1,117 +1,119 @@ -Full { - header: Module { - comments: [], - header: App( - AppHeader { - before_provides: [ - Newline, - ], - provides: [ - @143-147 ExposedName( - "main", - ), - ], - before_packages: [ - Newline, - ], - packages: @20-88 Collection { - items: [ - @44-81 SpaceBefore( - PackageEntry { - shorthand: "cli", - spaces_after_shorthand: [], - platform_marker: Some( - [], - ), - package_name: @49-81 PackageName( - "../basic-cli/platform/main.roc", - ), - }, - [ - Newline, - ], - ), - ], - final_comments: [ +Full( + FullAst { + header: SpacesBefore { + before: [], + item: App( + AppHeader { + before_provides: [ Newline, ], - }, - old_imports: None, - old_provides_to_new_package: None, - }, - ), - }, - module_defs: Defs { - tags: [ - Index(2147483648), - Index(2147483649), - ], - regions: [ - @111-121, - @157-187, - ], - space_before: [ - Slice(start = 0, length = 3), - Slice(start = 6, length = 2), - ], - space_after: [ - Slice(start = 3, length = 3), - Slice(start = 8, length = 2), - ], - spaces: [ - Newline, - Newline, - Newline, - Newline, - Newline, - Newline, - Newline, - Newline, - Newline, - Newline, - ], - type_defs: [], - value_defs: [ - ModuleImport( - ModuleImport { - before_name: [], - name: @111-121 ImportedModuleName { - package: Some( - "cli", + provides: [ + @143-147 ExposedName( + "main", ), - name: ModuleName( - "Stdout", - ), - }, - params: None, - alias: None, - exposed: None, - }, - ), - Body( - @157-161 Identifier { - ident: "main", - }, - @168-187 SpaceBefore( - Apply( - @168-179 Var { - module_name: "Stdout", - ident: "line", - }, - [ - @180-187 Str( - PlainLine( - "hello", - ), + ], + before_packages: [ + Newline, + ], + packages: @20-88 Collection { + items: [ + @44-81 SpaceBefore( + PackageEntry { + shorthand: "cli", + spaces_after_shorthand: [], + platform_marker: Some( + [], + ), + package_name: @49-81 PackageName( + "../basic-cli/platform/main.roc", + ), + }, + [ + Newline, + ], ), ], - Space, - ), - [ - Newline, - ], - ), + final_comments: [ + Newline, + ], + }, + old_imports: None, + old_provides_to_new_package: None, + }, ), - ], + }, + defs: Defs { + tags: [ + Index(2147483648), + Index(2147483649), + ], + regions: [ + @111-121, + @157-187, + ], + space_before: [ + Slice(start = 0, length = 3), + Slice(start = 6, length = 2), + ], + space_after: [ + Slice(start = 3, length = 3), + Slice(start = 8, length = 2), + ], + spaces: [ + Newline, + Newline, + Newline, + Newline, + Newline, + Newline, + Newline, + Newline, + Newline, + Newline, + ], + type_defs: [], + value_defs: [ + ModuleImport( + ModuleImport { + before_name: [], + name: @111-121 ImportedModuleName { + package: Some( + "cli", + ), + name: ModuleName( + "Stdout", + ), + }, + params: None, + alias: None, + exposed: None, + }, + ), + Body( + @157-161 Identifier { + ident: "main", + }, + @168-187 SpaceBefore( + Apply( + @168-179 Var { + module_name: "Stdout", + ident: "line", + }, + [ + @180-187 Str( + PlainLine( + "hello", + ), + ), + ], + Space, + ), + [ + Newline, + ], + ), + ), + ], + }, }, -} +) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/old_interface_header.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/old_interface_header.header.result-ast index f51600adad..bc9534217d 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/old_interface_header.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/old_interface_header.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Module( +SpacesBefore { + before: [], + item: Module( ModuleHeader { after_keyword: [], params: None, diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/provides_type.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/provides_type.header.result-ast index 6dcb447fe4..c71493cd9a 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/provides_type.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/provides_type.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: App( +SpacesBefore { + before: [], + item: App( AppHeader { before_provides: [], provides: [ diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/record_builder.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder.expr.formatted.roc new file mode 100644 index 0000000000..911a0f8c04 --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder.expr.formatted.roc @@ -0,0 +1,4 @@ +{ Foo.Bar.baz <- + x: 5, + y: 0, +} \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/record_builder.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder.expr.result-ast new file mode 100644 index 0000000000..b3d94466f1 --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder.expr.result-ast @@ -0,0 +1,32 @@ +SpaceAfter( + RecordBuilder { + mapper: @2-13 Var { + module_name: "Foo.Bar", + ident: "baz", + }, + fields: [ + @17-21 RequiredValue( + @17-18 "x", + [], + @20-21 Num( + "5", + ), + ), + @23-27 SpaceAfter( + RequiredValue( + @23-24 "y", + [], + @26-27 Num( + "0", + ), + ), + [ + Newline, + ], + ), + ], + }, + [ + Newline, + ], +) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/record_builder.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder.expr.roc new file mode 100644 index 0000000000..9a075a9e5c --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder.expr.roc @@ -0,0 +1,2 @@ +{ Foo.Bar.baz <- x: 5, y: 0 +} diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/record_builder_ignored_fields.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder_ignored_fields.expr.formatted.roc new file mode 100644 index 0000000000..2bf71d9a44 --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder_ignored_fields.expr.formatted.roc @@ -0,0 +1,6 @@ +{ Foo.Bar.baz <- + x: 5, + y: 0, + _z: 3, + _: 2, +} \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/record_builder_ignored_fields.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder_ignored_fields.expr.result-ast new file mode 100644 index 0000000000..af37c9c12e --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder_ignored_fields.expr.result-ast @@ -0,0 +1,46 @@ +SpaceAfter( + RecordBuilder { + mapper: @2-13 Var { + module_name: "Foo.Bar", + ident: "baz", + }, + fields: [ + @17-21 RequiredValue( + @17-18 "x", + [], + @20-21 Num( + "5", + ), + ), + @23-27 RequiredValue( + @23-24 "y", + [], + @26-27 Num( + "0", + ), + ), + @29-34 IgnoredValue( + @29-31 "z", + [], + @33-34 Num( + "3", + ), + ), + @36-40 SpaceAfter( + IgnoredValue( + @36-37 "", + [], + @39-40 Num( + "2", + ), + ), + [ + Newline, + ], + ), + ], + }, + [ + Newline, + ], +) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/record_builder_ignored_fields.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder_ignored_fields.expr.roc new file mode 100644 index 0000000000..f42ce74566 --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/record_builder_ignored_fields.expr.roc @@ -0,0 +1,2 @@ +{ Foo.Bar.baz <- x: 5, y: 0, _z: 3, _: 2 +} diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/requires_type.header.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/requires_type.header.result-ast index 013bac0e27..1641edbb83 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/requires_type.header.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/requires_type.header.result-ast @@ -1,6 +1,6 @@ -Module { - comments: [], - header: Platform( +SpacesBefore { + before: [], + item: Platform( PlatformHeader { before_name: [], name: @9-21 PackageName( diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/space_before_colon.full.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/space_before_colon.full.result-ast index b3777d5493..09323e239d 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/space_before_colon.full.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/space_before_colon.full.result-ast @@ -1,71 +1,73 @@ -Full { - header: Module { - comments: [], - header: App( - AppHeader { - before_provides: [], - provides: [ - @6-10 ExposedName( - "main", - ), - ], - before_packages: [], - packages: @13-37 [ - @15-35 PackageEntry { - shorthand: "pf", - spaces_after_shorthand: [], - platform_marker: Some( - [], - ), - package_name: @29-35 PackageName( - "path", - ), - }, - ], - old_imports: None, - old_provides_to_new_package: None, - }, - ), - }, - module_defs: Defs { - tags: [ - Index(2147483648), - ], - regions: [ - @39-65, - ], - space_before: [ - Slice(start = 0, length = 2), - ], - space_after: [ - Slice(start = 2, length = 1), - ], - spaces: [ - Newline, - Newline, - Newline, - ], - type_defs: [], - value_defs: [ - Body( - @39-43 Identifier { - ident: "main", - }, - @46-65 Apply( - @46-57 Var { - module_name: "Stdout", - ident: "line", - }, - [ - @58-65 Str( - PlainLine( - "Hello", - ), +Full( + FullAst { + header: SpacesBefore { + before: [], + item: App( + AppHeader { + before_provides: [], + provides: [ + @6-10 ExposedName( + "main", ), ], - Space, - ), + before_packages: [], + packages: @13-37 [ + @15-35 PackageEntry { + shorthand: "pf", + spaces_after_shorthand: [], + platform_marker: Some( + [], + ), + package_name: @29-35 PackageName( + "path", + ), + }, + ], + old_imports: None, + old_provides_to_new_package: None, + }, ), - ], + }, + defs: Defs { + tags: [ + Index(2147483648), + ], + regions: [ + @39-65, + ], + space_before: [ + Slice(start = 0, length = 2), + ], + space_after: [ + Slice(start = 2, length = 1), + ], + spaces: [ + Newline, + Newline, + Newline, + ], + type_defs: [], + value_defs: [ + Body( + @39-43 Identifier { + ident: "main", + }, + @46-65 Apply( + @46-57 Var { + module_name: "Stdout", + ident: "line", + }, + [ + @58-65 Str( + PlainLine( + "Hello", + ), + ), + ], + Space, + ), + ), + ], + }, }, -} +) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_one_def.full.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_one_def.full.result-ast index 6f8c31abc0..b124b30b99 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_one_def.full.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_one_def.full.result-ast @@ -1,209 +1,211 @@ -Full { - header: Module { - comments: [], - header: App( - AppHeader { - before_provides: [], - provides: [ - @5-9 ExposedName( - "main", - ), - ], - before_packages: [], - packages: @11-55 Collection { - items: [ - @15-52 SpaceBefore( - PackageEntry { - shorthand: "cli", - spaces_after_shorthand: [], - platform_marker: None, - package_name: @20-52 PackageName( - "../basic-cli/platform/main.roc", - ), - }, - [ - Newline, - ], +Full( + FullAst { + header: SpacesBefore { + before: [], + item: App( + AppHeader { + before_provides: [], + provides: [ + @5-9 ExposedName( + "main", ), ], - final_comments: [ - Newline, - ], - }, - old_imports: None, - old_provides_to_new_package: None, - }, - ), - }, - module_defs: Defs { - tags: [ - Index(2147483648), - Index(2147483649), - ], - regions: [ - @57-74, - @76-220, - ], - space_before: [ - Slice(start = 0, length = 2), - Slice(start = 2, length = 2), - ], - space_after: [ - Slice(start = 2, length = 0), - Slice(start = 4, length = 2), - ], - spaces: [ - Newline, - Newline, - Newline, - Newline, - Newline, - Newline, - ], - type_defs: [], - value_defs: [ - ModuleImport( - ModuleImport { - before_name: [], - name: @64-74 ImportedModuleName { - package: Some( - "cli", - ), - name: ModuleName( - "Stdout", - ), - }, - params: None, - alias: None, - exposed: None, - }, - ), - Body( - @76-80 Identifier { - ident: "main", - }, - @120-220 SpaceBefore( - Defs( - Defs { - tags: [ - Index(2147483648), - Index(2147483649), - ], - regions: [ - @120-133, - @162-205, - ], - space_before: [ - Slice(start = 0, length = 0), - Slice(start = 0, length = 3), - ], - space_after: [ - Slice(start = 0, length = 0), - Slice(start = 3, length = 0), - ], - spaces: [ - Newline, - Newline, - LineComment( - " what about this?", - ), - ], - type_defs: [], - value_defs: [ - Stmt( - @120-133 BinOps( - [ - ( - @120-125 Str( - PlainLine( - "Foo", - ), - ), - @126-128 Pizza, - ), - ], - @129-132 TaskAwaitBang( - Var { - module_name: "A", - ident: "x", - }, - ), + before_packages: [], + packages: @11-55 Collection { + items: [ + @15-52 SpaceBefore( + PackageEntry { + shorthand: "cli", + spaces_after_shorthand: [], + platform_marker: None, + package_name: @20-52 PackageName( + "../basic-cli/platform/main.roc", ), - ), - Stmt( - @162-205 BinOps( - [ - ( - @162-167 Str( - PlainLine( - "Bar", - ), - ), - @168-170 Pizza, - ), - ], - @171-205 Apply( - @171-174 TaskAwaitBang( - Var { - module_name: "B", - ident: "y", - }, - ), - [ - @185-205 SpaceBefore( - Record( - [ - @187-203 RequiredValue( - @187-193 "config", - [], - @195-203 Str( - PlainLine( - "config", - ), - ), - ), - ], - ), - [ - Newline, - ], - ), - ], - Space, - ), - ), - ), - ], - }, - @211-220 SpaceBefore( - Apply( - @211-214 Var { - module_name: "C", - ident: "z", }, [ - @215-220 Str( - PlainLine( - "Bar", + Newline, + ], + ), + ], + final_comments: [ + Newline, + ], + }, + old_imports: None, + old_provides_to_new_package: None, + }, + ), + }, + defs: Defs { + tags: [ + Index(2147483648), + Index(2147483649), + ], + regions: [ + @57-74, + @76-220, + ], + space_before: [ + Slice(start = 0, length = 2), + Slice(start = 2, length = 2), + ], + space_after: [ + Slice(start = 2, length = 0), + Slice(start = 4, length = 2), + ], + spaces: [ + Newline, + Newline, + Newline, + Newline, + Newline, + Newline, + ], + type_defs: [], + value_defs: [ + ModuleImport( + ModuleImport { + before_name: [], + name: @64-74 ImportedModuleName { + package: Some( + "cli", + ), + name: ModuleName( + "Stdout", + ), + }, + params: None, + alias: None, + exposed: None, + }, + ), + Body( + @76-80 Identifier { + ident: "main", + }, + @120-220 SpaceBefore( + Defs( + Defs { + tags: [ + Index(2147483648), + Index(2147483649), + ], + regions: [ + @120-133, + @162-205, + ], + space_before: [ + Slice(start = 0, length = 0), + Slice(start = 0, length = 3), + ], + space_after: [ + Slice(start = 0, length = 0), + Slice(start = 3, length = 0), + ], + spaces: [ + Newline, + Newline, + LineComment( + " what about this?", + ), + ], + type_defs: [], + value_defs: [ + Stmt( + @120-133 BinOps( + [ + ( + @120-125 Str( + PlainLine( + "Foo", + ), + ), + @126-128 Pizza, + ), + ], + @129-132 TaskAwaitBang( + Var { + module_name: "A", + ident: "x", + }, + ), + ), + ), + Stmt( + @162-205 BinOps( + [ + ( + @162-167 Str( + PlainLine( + "Bar", + ), + ), + @168-170 Pizza, + ), + ], + @171-205 Apply( + @171-174 TaskAwaitBang( + Var { + module_name: "B", + ident: "y", + }, + ), + [ + @185-205 SpaceBefore( + Record( + [ + @187-203 RequiredValue( + @187-193 "config", + [], + @195-203 Str( + PlainLine( + "config", + ), + ), + ), + ], + ), + [ + Newline, + ], + ), + ], + Space, + ), ), ), ], - Space, + }, + @211-220 SpaceBefore( + Apply( + @211-214 Var { + module_name: "C", + ident: "z", + }, + [ + @215-220 Str( + PlainLine( + "Bar", + ), + ), + ], + Space, + ), + [ + Newline, + Newline, + ], ), - [ - Newline, - Newline, - ], ), + [ + Newline, + LineComment( + " is this a valid statement?", + ), + ], ), - [ - Newline, - LineComment( - " is this a valid statement?", - ), - ], ), - ), - ], + ], + }, }, -} +) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_optional_last.full.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_optional_last.full.result-ast index c4e24e09b6..78f12e6ffd 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_optional_last.full.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_optional_last.full.result-ast @@ -1,131 +1,133 @@ -Full { - header: Module { - comments: [], - header: App( - AppHeader { - before_provides: [ - Newline, - ], - provides: [ - @74-78 ExposedName( - "main", - ), - ], - before_packages: [ - Newline, - ], - packages: @6-44 Collection { - items: [ - @30-37 SpaceBefore( - PackageEntry { - shorthand: "cli", - spaces_after_shorthand: [], - platform_marker: Some( - [], - ), - package_name: @35-37 PackageName( - "", - ), - }, - [ - Newline, - ], - ), - ], - final_comments: [ +Full( + FullAst { + header: SpacesBefore { + before: [], + item: App( + AppHeader { + before_provides: [ Newline, ], - }, - old_imports: None, - old_provides_to_new_package: None, - }, - ), - }, - module_defs: Defs { - tags: [ - Index(2147483648), - ], - regions: [ - @88-202, - ], - space_before: [ - Slice(start = 0, length = 2), - ], - space_after: [ - Slice(start = 2, length = 1), - ], - spaces: [ - Newline, - Newline, - Newline, - ], - type_defs: [], - value_defs: [ - Body( - @88-92 Identifier { - ident: "main", - }, - @100-202 SpaceBefore( - BinOps( - [ - ( - @100-114 SpaceAfter( - Str( - PlainLine( - "jq --version", - ), + provides: [ + @74-78 ExposedName( + "main", + ), + ], + before_packages: [ + Newline, + ], + packages: @6-44 Collection { + items: [ + @30-37 SpaceBefore( + PackageEntry { + shorthand: "cli", + spaces_after_shorthand: [], + platform_marker: Some( + [], ), - [ - Newline, - ], - ), - @123-125 Pizza, - ), - ( - @126-133 SpaceAfter( - Var { - module_name: "Cmd", - ident: "new", - }, - [ - Newline, - ], - ), - @142-144 Pizza, - ), - ( - @145-155 SpaceAfter( - Var { - module_name: "Cmd", - ident: "status", - }, - [ - Newline, - ], - ), - @164-166 Pizza, + package_name: @35-37 PackageName( + "", + ), + }, + [ + Newline, + ], ), ], - @167-202 Apply( - @167-178 TaskAwaitBang( - Var { - module_name: "Task", - ident: "mapErr", - }, - ), + final_comments: [ + Newline, + ], + }, + old_imports: None, + old_provides_to_new_package: None, + }, + ), + }, + defs: Defs { + tags: [ + Index(2147483648), + ], + regions: [ + @88-202, + ], + space_before: [ + Slice(start = 0, length = 2), + ], + space_after: [ + Slice(start = 2, length = 1), + ], + spaces: [ + Newline, + Newline, + Newline, + ], + type_defs: [], + value_defs: [ + Body( + @88-92 Identifier { + ident: "main", + }, + @100-202 SpaceBefore( + BinOps( [ - @180-202 Tag( - "UnableToCheckJQVersion", + ( + @100-114 SpaceAfter( + Str( + PlainLine( + "jq --version", + ), + ), + [ + Newline, + ], + ), + @123-125 Pizza, + ), + ( + @126-133 SpaceAfter( + Var { + module_name: "Cmd", + ident: "new", + }, + [ + Newline, + ], + ), + @142-144 Pizza, + ), + ( + @145-155 SpaceAfter( + Var { + module_name: "Cmd", + ident: "status", + }, + [ + Newline, + ], + ), + @164-166 Pizza, ), ], - Space, + @167-202 Apply( + @167-178 TaskAwaitBang( + Var { + module_name: "Task", + ident: "mapErr", + }, + ), + [ + @180-202 Tag( + "UnableToCheckJQVersion", + ), + ], + Space, + ), ), + [ + Newline, + ], ), - [ - Newline, - ], ), - ), - ], + ], + }, }, -} +) diff --git a/crates/compiler/test_syntax/tests/test_fmt.rs b/crates/compiler/test_syntax/tests/test_fmt.rs index 434b343f98..026605d825 100644 --- a/crates/compiler/test_syntax/tests/test_fmt.rs +++ b/crates/compiler/test_syntax/tests/test_fmt.rs @@ -5,10 +5,10 @@ extern crate indoc; mod test_fmt { use bumpalo::Bump; use roc_fmt::def::fmt_defs; - use roc_fmt::module::fmt_module; + use roc_fmt::header::fmt_header; use roc_fmt::Buf; - use roc_parse::ast::{Defs, Module}; - use roc_parse::module::{self, parse_module_defs}; + use roc_parse::ast::{Defs, Header, SpacesBefore}; + use roc_parse::header::{self, parse_module_defs}; use roc_parse::state::State; use roc_test_utils::assert_multiline_str_eq; use roc_test_utils_dir::workspace_root; @@ -32,11 +32,11 @@ mod test_fmt { fn fmt_module_and_defs<'a>( arena: &Bump, src: &str, - module: &Module<'a>, + header: &SpacesBefore<'a, Header<'a>>, state: State<'a>, buf: &mut Buf<'_>, ) { - fmt_module(buf, module); + fmt_header(buf, header); match parse_module_defs(arena, state, Defs::default()) { Ok(loc_defs) => { @@ -61,9 +61,9 @@ mod test_fmt { let src = src.trim(); let expected = expected.trim(); - match module::parse_header(&arena, State::new(src.as_bytes())) { + match header::parse_header(&arena, State::new(src.as_bytes())) { Ok((actual, state)) => { - use roc_parse::remove_spaces::RemoveSpaces; + use roc_parse::normalize::Normalize; let mut buf = Buf::new_in(&arena); @@ -71,14 +71,14 @@ mod test_fmt { let output = buf.as_str().trim(); - let (reparsed_ast, state) = module::parse_header(&arena, State::new(output.as_bytes())).unwrap_or_else(|err| { + let (reparsed_ast, state) = header::parse_header(&arena, State::new(output.as_bytes())).unwrap_or_else(|err| { panic!( "After formatting, the source code no longer parsed!\n\nParse error was: {err:?}\n\nThe code that failed to parse:\n\n{output}\n\n" ); }); - let ast_normalized = actual.remove_spaces(&arena); - let reparsed_ast_normalized = reparsed_ast.remove_spaces(&arena); + let ast_normalized = actual.normalize(&arena); + let reparsed_ast_normalized = reparsed_ast.normalize(&arena); // HACK! // We compare the debug format strings of the ASTs, because I'm finding in practice that _somewhere_ deep inside the ast, diff --git a/crates/compiler/test_syntax/tests/test_snapshots.rs b/crates/compiler/test_syntax/tests/test_snapshots.rs index 27736ae7a6..44fb528d4c 100644 --- a/crates/compiler/test_syntax/tests/test_snapshots.rs +++ b/crates/compiler/test_syntax/tests/test_snapshots.rs @@ -449,6 +449,8 @@ mod test_snapshots { pass/qualified_field.expr, pass/qualified_var.expr, pass/record_access_after_tuple.expr, + pass/record_builder.expr, + pass/record_builder_ignored_fields.expr, pass/record_destructure_def.expr, pass/record_func_type_decl.expr, pass/record_type_with_function.expr, diff --git a/crates/compiler/types/src/subs.rs b/crates/compiler/types/src/subs.rs index a14e61a817..fe22db881f 100644 --- a/crates/compiler/types/src/subs.rs +++ b/crates/compiler/types/src/subs.rs @@ -4518,6 +4518,7 @@ pub struct ExposedTypesStorageSubs { pub stored_specialization_lambda_set_vars: VecMap, /// ability member signature in other module -> var in storage subs pub stored_ability_member_vars: VecMap, + pub stored_params_var: Option, } #[derive(Clone, Debug)] diff --git a/crates/compiler/types/src/types.rs b/crates/compiler/types/src/types.rs index d04d1f9690..f6757247c9 100644 --- a/crates/compiler/types/src/types.rs +++ b/crates/compiler/types/src/types.rs @@ -11,7 +11,7 @@ use roc_error_macros::internal_error; use roc_module::called_via::CalledVia; use roc_module::ident::{ForeignSymbol, Lowercase, TagName}; use roc_module::low_level::LowLevel; -use roc_module::symbol::{Interns, Symbol}; +use roc_module::symbol::{Interns, ModuleId, Symbol}; use roc_region::all::{Loc, Region}; use std::fmt; use std::fmt::Write; @@ -3424,6 +3424,7 @@ pub enum Reason { def_region: Region, }, CrashArg, + ImportParams(ModuleId), } #[derive(PartialEq, Eq, Debug, Clone)] diff --git a/crates/compiler/uitest/tests/ability/specialize/inspect/opaque_automatic.txt b/crates/compiler/uitest/tests/ability/specialize/inspect/opaque_automatic.txt index 6a41dfcbcf..e980ad4d98 100644 --- a/crates/compiler/uitest/tests/ability/specialize/inspect/opaque_automatic.txt +++ b/crates/compiler/uitest/tests/ability/specialize/inspect/opaque_automatic.txt @@ -8,46 +8,46 @@ main = 1 # -emit:mono -procedure Inspect.248 (Inspect.249): - let Inspect.313 : Str = ""; - let Inspect.312 : Str = CallByName Inspect.59 Inspect.249 Inspect.313; - dec Inspect.313; - ret Inspect.312; +procedure Inspect.252 (Inspect.253): + let Inspect.317 : Str = ""; + let Inspect.316 : Str = CallByName Inspect.63 Inspect.253 Inspect.317; + dec Inspect.317; + ret Inspect.316; -procedure Inspect.30 (Inspect.143): - ret Inspect.143; +procedure Inspect.30 (Inspect.147): + ret Inspect.147; -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.48 (Inspect.299): + let Inspect.314 : {} = Struct {}; + let Inspect.313 : {} = CallByName Inspect.30 Inspect.314; + ret Inspect.313; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : {} = CallByName Inspect.48 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName Inspect.252 Inspect.308; ret Inspect.307; -procedure Inspect.44 (Inspect.295): - let Inspect.310 : {} = Struct {}; - let Inspect.309 : {} = CallByName Inspect.30 Inspect.310; - ret Inspect.309; +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.319 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.319; -procedure Inspect.5 (Inspect.146): - let Inspect.308 : {} = CallByName Inspect.44 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName Inspect.248 Inspect.304; - ret Inspect.303; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.315 : Str = CallByName Str.3 Inspect.296 Inspect.292; - ret Inspect.315; - -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.64 (Inspect.302): + ret Inspect.302; procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.0 (): let Test.4 : {} = Struct {}; diff --git a/crates/compiler/uitest/tests/ability/specialize/inspect/opaque_automatic_late.txt b/crates/compiler/uitest/tests/ability/specialize/inspect/opaque_automatic_late.txt index d637bf9352..184d94c0db 100644 --- a/crates/compiler/uitest/tests/ability/specialize/inspect/opaque_automatic_late.txt +++ b/crates/compiler/uitest/tests/ability/specialize/inspect/opaque_automatic_late.txt @@ -11,46 +11,46 @@ main = late (@Op {}) # -emit:mono -procedure Inspect.248 (Inspect.249): - let Inspect.313 : Str = ""; - let Inspect.312 : Str = CallByName Inspect.59 Inspect.249 Inspect.313; - dec Inspect.313; - ret Inspect.312; +procedure Inspect.252 (Inspect.253): + let Inspect.317 : Str = ""; + let Inspect.316 : Str = CallByName Inspect.63 Inspect.253 Inspect.317; + dec Inspect.317; + ret Inspect.316; -procedure Inspect.30 (Inspect.143): - ret Inspect.143; +procedure Inspect.30 (Inspect.147): + ret Inspect.147; -procedure Inspect.33 (Inspect.148): - let Inspect.301 : Str = CallByName Inspect.5 Inspect.148; - let Inspect.300 : Str = CallByName Inspect.60 Inspect.301; - ret Inspect.300; +procedure Inspect.33 (Inspect.152): + let Inspect.305 : Str = CallByName Inspect.5 Inspect.152; + let Inspect.304 : Str = CallByName Inspect.64 Inspect.305; + ret Inspect.304; -procedure Inspect.35 (Inspect.297): - let Inspect.307 : Str = ""; +procedure Inspect.39 (Inspect.301): + let Inspect.311 : Str = ""; + ret Inspect.311; + +procedure Inspect.48 (Inspect.299): + let Inspect.314 : {} = Struct {}; + let Inspect.313 : {} = CallByName Inspect.30 Inspect.314; + ret Inspect.313; + +procedure Inspect.5 (Inspect.150): + let Inspect.312 : {} = CallByName Inspect.48 Inspect.150; + let Inspect.309 : {} = Struct {}; + let Inspect.308 : Str = CallByName Inspect.39 Inspect.309; + let Inspect.307 : Str = CallByName Inspect.252 Inspect.308; ret Inspect.307; -procedure Inspect.44 (Inspect.295): - let Inspect.310 : {} = Struct {}; - let Inspect.309 : {} = CallByName Inspect.30 Inspect.310; - ret Inspect.309; +procedure Inspect.63 (Inspect.300, Inspect.296): + let Inspect.319 : Str = CallByName Str.3 Inspect.300 Inspect.296; + ret Inspect.319; -procedure Inspect.5 (Inspect.146): - let Inspect.308 : {} = CallByName Inspect.44 Inspect.146; - let Inspect.305 : {} = Struct {}; - let Inspect.304 : Str = CallByName Inspect.35 Inspect.305; - let Inspect.303 : Str = CallByName Inspect.248 Inspect.304; - ret Inspect.303; - -procedure Inspect.59 (Inspect.296, Inspect.292): - let Inspect.315 : Str = CallByName Str.3 Inspect.296 Inspect.292; - ret Inspect.315; - -procedure Inspect.60 (Inspect.298): - ret Inspect.298; +procedure Inspect.64 (Inspect.302): + ret Inspect.302; procedure Str.3 (#Attr.2, #Attr.3): - let Str.232 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.232; + let Str.236 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.236; procedure Test.2 (Test.3): let Test.4 : Str = CallByName Inspect.33 Test.3; diff --git a/crates/compiler/uitest/tests/ability/specialize/set_eq_issue_4761.txt b/crates/compiler/uitest/tests/ability/specialize/set_eq_issue_4761.txt index 3173fa4bcc..3656f86edc 100644 --- a/crates/compiler/uitest/tests/ability/specialize/set_eq_issue_4761.txt +++ b/crates/compiler/uitest/tests/ability/specialize/set_eq_issue_4761.txt @@ -8,5 +8,5 @@ main = s2 = Set.empty {} Bool.isEq s1 s1 && Bool.isEq s2 s2 -# ^^^^^^^^^ Set#Bool.isEq(25): Set Str, Set Str -[[Set.isEq(25)]]-> Bool -# ^^^^^^^^^ Set#Bool.isEq(25): Set U8, Set U8 -[[Set.isEq(25)]]-> Bool +# ^^^^^^^^^ Set#Bool.isEq(31): Set Str, Set Str -[[Set.isEq(31)]]-> Bool +# ^^^^^^^^^ Set#Bool.isEq(31): Set U8, Set U8 -[[Set.isEq(31)]]-> Bool diff --git a/crates/compiler/uitest/tests/specialize/record_update_between_modules.txt b/crates/compiler/uitest/tests/specialize/record_update_between_modules.txt index a126e60f37..f9164a7a8f 100644 --- a/crates/compiler/uitest/tests/specialize/record_update_between_modules.txt +++ b/crates/compiler/uitest/tests/specialize/record_update_between_modules.txt @@ -23,10 +23,10 @@ procedure Dep.0 (): ret Dep.1; procedure Test.0 (): - let Test.5 : {Str, Str} = CallByName Dep.0; - let Test.2 : Str = StructAtIndex 0 Test.5; - let #Derived_gen.0 : Str = StructAtIndex 1 Test.5; + let Test.6 : {Str, Str} = CallByName Dep.0; + let Test.3 : Str = StructAtIndex 0 Test.6; + let #Derived_gen.0 : Str = StructAtIndex 1 Test.6; dec #Derived_gen.0; - let Test.4 : Str = "http://www.example.com"; - let Test.1 : {Str, Str} = Struct {Test.2, Test.4}; - ret Test.1; + let Test.5 : Str = "http://www.example.com"; + let Test.2 : {Str, Str} = Struct {Test.3, Test.5}; + ret Test.2; diff --git a/crates/docs/src/lib.rs b/crates/docs/src/lib.rs index 69c2168bc5..2ff8341d56 100644 --- a/crates/docs/src/lib.rs +++ b/crates/docs/src/lib.rs @@ -933,7 +933,7 @@ fn doc_url<'a>( // current module's name, but it also could be a different // module - for example, if this is in scope from an // unqualified import. - module_name = symbol.module_string(interns); + module_name = symbol.symbol.module_string(interns); } Err(_) => { return Err((format!("[{ident}]"), LinkProblem::AutoLinkIdentNotInScope)); diff --git a/crates/glue/src/types.rs b/crates/glue/src/types.rs index d1b9e7576b..d90bd74435 100644 --- a/crates/glue/src/types.rs +++ b/crates/glue/src/types.rs @@ -2219,21 +2219,24 @@ fn single_tag_payload_fields<'a, 'b>( types: &mut Types, ) -> (String, RocSingleTagPayload) { let layout = env.layout_cache.interner.get(in_layout); - // There should be a glue_procs_by_layout entry iff this layout has a closure in it, - // so we shouldn't need to separately check that. Howeevr, we still do a debug_assert - // anyway just so we have some warning in case that relationship somehow didn't hold! - debug_assert_eq!( - env.glue_procs_by_layout.get(&layout).is_some(), - env.layout_cache - .interner - .has_varying_stack_size(in_layout, env.arena), - "glue_procs_by_layout for {:?} was {:?}, but the layout cache said its has_varying_stack_size was {}", - &layout, - env.glue_procs_by_layout.get(&layout), + + if std::env::var("SINGLE_TAG_GLUE_CHECK_OFF").as_deref() != Ok("1") { + // There should be a glue_procs_by_layout entry iff this layout has a closure in it, + // so we shouldn't need to separately check that. Howeevr, we still do a debug_assert + // anyway just so we have some warning in case that relationship somehow didn't hold! + debug_assert_eq!( + env.glue_procs_by_layout.get(&layout).is_some(), env.layout_cache .interner - .has_varying_stack_size(in_layout, env.arena) - ); + .has_varying_stack_size(in_layout, env.arena), + "glue_procs_by_layout for {:?} was {:?}, but the layout cache said its has_varying_stack_size was {}", + &layout, + env.glue_procs_by_layout.get(&layout), + env.layout_cache + .interner + .has_varying_stack_size(in_layout, env.arena) + ); + } let (tag_name, payload_vars) = single_tag_payload(union_tags, subs); diff --git a/crates/language_server/src/analysis/parse_ast.rs b/crates/language_server/src/analysis/parse_ast.rs index ac751c3e9e..aeac795765 100644 --- a/crates/language_server/src/analysis/parse_ast.rs +++ b/crates/language_server/src/analysis/parse_ast.rs @@ -1,8 +1,8 @@ use bumpalo::Bump; use roc_fmt::Buf; use roc_parse::{ - ast::{Defs, Module}, - module::parse_module_defs, + ast::{Defs, Header, SpacesBefore}, + header::parse_module_defs, parser::SyntaxError, }; use roc_region::all::Loc; @@ -15,23 +15,26 @@ mod format; pub struct Ast<'a> { arena: &'a Bump, - module: Module<'a>, + module: SpacesBefore<'a, Header<'a>>, defs: Defs<'a>, } impl<'a> Ast<'a> { pub fn parse(arena: &'a Bump, src: &'a str) -> Result, SyntaxError<'a>> { - use roc_parse::{module::parse_header, state::State}; + use roc_parse::{header::parse_header, state::State}; let (module, state) = parse_header(arena, State::new(src.as_bytes())) .map_err(|e| SyntaxError::Header(e.problem))?; - let (module, defs) = module.upgrade_header_imports(arena); + let (header, defs) = module.item.upgrade_header_imports(arena); let defs = parse_module_defs(arena, state, defs)?; Ok(Ast { - module, + module: SpacesBefore { + before: module.before, + item: header, + }, defs, arena, }) @@ -40,7 +43,7 @@ impl<'a> Ast<'a> { pub fn fmt(&self) -> FormattedAst<'a> { let mut buf = Buf::new_in(self.arena); - roc_fmt::module::fmt_module(&mut buf, &self.module); + roc_fmt::header::fmt_header(&mut buf, &self.module); roc_fmt::def::fmt_defs(&mut buf, &self.defs, 0); @@ -50,7 +53,7 @@ impl<'a> Ast<'a> { } pub fn semantic_tokens(&self) -> impl IntoIterator> + '_ { - let header_tokens = self.module.iter_tokens(self.arena); + let header_tokens = self.module.item.iter_tokens(self.arena); let body_tokens = self.defs.iter_tokens(self.arena); header_tokens.into_iter().chain(body_tokens) diff --git a/crates/language_server/src/analysis/tokens.rs b/crates/language_server/src/analysis/tokens.rs index 982d67c612..394b028bd9 100644 --- a/crates/language_server/src/analysis/tokens.rs +++ b/crates/language_server/src/analysis/tokens.rs @@ -6,8 +6,8 @@ use roc_module::called_via::{BinOp, UnaryOp}; use roc_parse::{ ast::{ AbilityImpls, AbilityMember, AssignedField, Collection, Defs, Expr, Header, Implements, - ImplementsAbilities, ImplementsAbility, ImplementsClause, Module, OldRecordBuilderField, - Pattern, PatternAs, Spaced, StrLiteral, Tag, TypeAnnotation, TypeDef, TypeHeader, ValueDef, + ImplementsAbilities, ImplementsAbility, ImplementsClause, OldRecordBuilderField, Pattern, + PatternAs, Spaced, StrLiteral, Tag, TypeAnnotation, TypeDef, TypeHeader, ValueDef, WhenBranch, }, header::{ @@ -189,16 +189,6 @@ impl IterTokens for (T, U) { } } -impl IterTokens for Module<'_> { - fn iter_tokens<'a>(&self, arena: &'a Bump) -> BumpVec<'a, Loc> { - let Self { - comments: _, - header, - } = self; - header.iter_tokens(arena) - } -} - impl IterTokens for Header<'_> { fn iter_tokens<'a>(&self, arena: &'a Bump) -> BumpVec<'a, Loc> { match self { @@ -243,12 +233,12 @@ where impl IterTokens for ModuleParams<'_> { fn iter_tokens<'a>(&self, arena: &'a Bump) -> BumpVec<'a, Loc> { let Self { - params, + pattern, before_arrow: _, after_arrow: _, } = self; - params.iter_tokens(arena) + pattern.value.iter_tokens(arena) } } @@ -446,7 +436,8 @@ where fn iter_tokens<'a>(&self, arena: &'a Bump) -> BumpVec<'a, Loc> { match self { AssignedField::RequiredValue(field, _, ty) - | AssignedField::OptionalValue(field, _, ty) => (field_token(field.region, arena) + | AssignedField::OptionalValue(field, _, ty) + | AssignedField::IgnoredValue(field, _, ty) => (field_token(field.region, arena) .into_iter()) .chain(ty.iter_tokens(arena)) .collect_in(arena), diff --git a/crates/packaging/src/tarball.rs b/crates/packaging/src/tarball.rs index 088f1081fc..165ed8a90e 100644 --- a/crates/packaging/src/tarball.rs +++ b/crates/packaging/src/tarball.rs @@ -2,10 +2,10 @@ use brotli::enc::BrotliEncoderParams; use bumpalo::Bump; use flate2::write::GzEncoder; use roc_parse::ast::{ - Header, IngestedFileImport, Module, RecursiveValueDefIter, StrLiteral, ValueDef, + Header, IngestedFileImport, RecursiveValueDefIter, SpacesBefore, StrLiteral, ValueDef, }; use roc_parse::header::PlatformHeader; -use roc_parse::module::{parse_header, parse_module_defs}; +use roc_parse::header::{parse_header, parse_module_defs}; use roc_parse::state::State; use std::ffi::OsStr; use std::fs::File; @@ -129,7 +129,7 @@ fn write_archive(path: &Path, writer: W) -> io::Result<()> { // TODO use this when finding .roc files by discovering them from the root module. // let other_modules: &[Module<'_>] = - match read_header(&arena, &mut buf, path)?.0.header { + match read_header(&arena, &mut buf, path)?.0.item { Header::Module(_) => { todo!(); // TODO report error @@ -261,7 +261,7 @@ fn read_header<'a>( arena: &'a Bump, buf: &'a mut Vec, path: &'a Path, -) -> io::Result<(Module<'a>, State<'a>)> { +) -> io::Result<(SpacesBefore<'a, Header<'a>>, State<'a>)> { // Read all the bytes into the buffer. { let mut file = File::open(path)?; @@ -287,8 +287,8 @@ fn add_ingested_files( builder: &mut tar::Builder, ) -> io::Result<()> { let mut buf = Vec::new(); - let (module, state) = read_header(arena, &mut buf, dot_roc_path)?; - let (_, defs) = module.upgrade_header_imports(arena); + let (header, state) = read_header(arena, &mut buf, dot_roc_path)?; + let (_, defs) = header.item.upgrade_header_imports(arena); let defs = parse_module_defs(arena, state, defs).unwrap_or_else(|err| { panic!("{} failed to parse: {:?}", dot_roc_path.display(), err); diff --git a/crates/reporting/src/error/canonicalize.rs b/crates/reporting/src/error/canonicalize.rs index cfb9e4308f..01d04a44be 100644 --- a/crates/reporting/src/error/canonicalize.rs +++ b/crates/reporting/src/error/canonicalize.rs @@ -1,10 +1,10 @@ use roc_collections::all::MutSet; use roc_module::ident::{Ident, Lowercase, ModuleName}; -use roc_module::symbol::{ScopeModuleSource, DERIVABLE_ABILITIES}; +use roc_module::symbol::DERIVABLE_ABILITIES; use roc_problem::can::PrecedenceProblem::BothNonAssociative; use roc_problem::can::{ BadPattern, CycleEntry, ExtensionTypeKind, FloatErrorKind, IntErrorKind, Problem, RuntimeError, - ShadowKind, + ScopeModuleSource, ShadowKind, }; use roc_problem::Severity; use roc_region::all::{LineColumn, LineColumnRegion, LineInfo, Loc, Region}; @@ -390,6 +390,7 @@ pub fn can_problem<'b>( TopLevelDef => "a top-level definition:", DefExpr => "a value definition:", FunctionArg => "function arguments:", + ModuleParams => "module params:", WhenBranch => unreachable!("all patterns are allowed in a When"), }; diff --git a/crates/reporting/src/error/parse.rs b/crates/reporting/src/error/parse.rs index c37482cfb6..e801da8aab 100644 --- a/crates/reporting/src/error/parse.rs +++ b/crates/reporting/src/error/parse.rs @@ -545,7 +545,7 @@ fn to_expr_report<'a>( to_record_report(alloc, lines, filename, erecord, *pos, start) } - EExpr::OptionalValueInRecordBuilder(region) => { + EExpr::OptionalValueInOldRecordBuilder(region) => { let surroundings = Region::new(start, region.end()); let region = lines.convert_region(*region); @@ -565,7 +565,7 @@ fn to_expr_report<'a>( } } - EExpr::RecordUpdateAccumulator(region) => { + EExpr::RecordUpdateOldBuilderField(region) => { let surroundings = Region::new(start, region.end()); let region = lines.convert_region(*region); @@ -1580,6 +1580,25 @@ fn to_import_report<'a>( severity, } } + Params(EImportParams::RecordIgnoredFieldFound(region), _) => { + let surroundings = Region::new(start, region.end()); + let region = lines.convert_region(*region); + + let doc = alloc.stack([ + alloc.reflow("I was partway through parsing module params, but I got stuck here:"), + alloc.region_with_subregion(lines.convert_region(surroundings), region, severity), + alloc.reflow( + "This is an ignored record field, but those are not allowed in module params.", + ), + ]); + + Report { + filename, + doc, + title: "IGNORED RECORD FIELD IN MODULE PARAMS".to_string(), + severity, + } + } Params(EImportParams::RecordUpdateFound(region), _) => { let surroundings = Region::new(start, region.end()); let region = lines.convert_region(*region); diff --git a/crates/reporting/src/error/type.rs b/crates/reporting/src/error/type.rs index 4211b89cc8..e3c18b5bf3 100644 --- a/crates/reporting/src/error/type.rs +++ b/crates/reporting/src/error/type.rs @@ -247,6 +247,73 @@ pub fn type_problem<'b>( severity, }) } + UnexpectedModuleParams(region, module_id) => { + let stack = [ + alloc.reflow("This import specifies module params:"), + alloc.region(lines.convert_region(region), severity), + alloc.concat([ + alloc.reflow("However, "), + alloc.module(module_id), + alloc.reflow( + " does not expect any. Did you intend to import a different module?", + ), + ]), + ]; + + Some(Report { + title: "UNEXPECTED MODULE PARAMS".to_string(), + filename, + doc: alloc.stack(stack), + severity, + }) + } + MissingModuleParams(region, module_id, expected) => { + let stack = [ + alloc.reflow("This import specifies no module params:"), + alloc.region(lines.convert_region(region), severity), + alloc.concat([ + alloc.reflow("However, "), + alloc.module(module_id), + alloc.reflow(" expects the following to be provided:"), + ]), + alloc.type_block(error_type_to_doc(alloc, expected)), + alloc.reflow("You can provide params after the module name, like:"), + alloc + .parser_suggestion("import Menu { echo, read }") + .indent(4), + ]; + Some(Report { + title: "MISSING MODULE PARAMS".to_string(), + filename, + doc: alloc.stack(stack), + severity, + }) + } + ModuleParamsMismatch(region, module_id, actual_type, expected_type) => { + let stack = [ + alloc.reflow("Something is off with the params provided by this import:"), + alloc.region(lines.convert_region(region), severity), + type_comparison( + alloc, + actual_type, + expected_type, + ExpectationContext::Arbitrary, + alloc.reflow("This is the type I inferred:"), + alloc.concat([ + alloc.reflow("However, "), + alloc.module(module_id), + alloc.reflow(" expects:"), + ]), + None, + ), + ]; + Some(Report { + title: "MODULE PARAMS MISMATCH".to_string(), + filename, + doc: alloc.stack(stack), + severity, + }) + } } } @@ -1592,6 +1659,7 @@ fn to_expr_report<'b>( Reason::RecordDefaultField(_) => { unimplemented!("record default field is not implemented yet") } + Reason::ImportParams(_) => unreachable!(), }, } } diff --git a/devtools/debug_tips.md b/devtools/debug_tips.md new file mode 100644 index 0000000000..afd0918a33 --- /dev/null +++ b/devtools/debug_tips.md @@ -0,0 +1,17 @@ +# Debug Tips + +## General + +- When using github search to find similar errors/issues use `org:roc-lang`, for example: `org:roc-lang valgrind unrecognised instruction`. This will search in basic-cli, basic-webserver, ... as well. Just using `roc` instead of `org:roc-lang` may yield useful results as well. +- Use a debug build of the compiler. We have many asserts enabled in the debug compiler that can alert you to something going wrong. When building from source, build the debug compiler with `cargo build --bin roc`, the binary is at `roc/target/debug/roc`. When using roc through a nix flake like in [basic-cli](https://github.com/roc-lang/basic-cli), use `rocPkgs.cli-debug` instead of `rocPkgs.cli`. +- At the bottom of [.cargo/config.toml](https://github.com/roc-lang/roc/blob/main/.cargo/config.toml) we have useful debug flags that activate certain debug prints and extra checks. +- For Roc code; minimize the code that produces the issue. +- If you plan to look at the data used and produced inside the compiler, try to reproduce your issue with a very simple platform like our [minimal Rust platform](https://github.com/roc-lang/roc/tree/main/examples/platform-switching/rust-platform) instead of for example basic-cli. + +## Segmentation Faults + +- In general we recommend using linux to investigate, it has better tools for this. +- If your segfault also happens when using `--linker=legacy`, use it to improve valgrind output. For example: `roc build myApp.roc --linker=legacy` followed by `valgrind ./myApp`. +- Use gdb to step through the code, [this gdb script](https://roc.zulipchat.com/#narrow/stream/395097-compiler-development/topic/gdb.20script/near/424422545) can be helpful. +- Use objdump to look at the assembly of the code, for example `objdump -d -M intel ./examples/Arithmetic/main`. Replace `-M intel` with the appropriate flag for your CPU. +- Inspect the generated LLVM IR (`roc build myApp.roc --emit-llvm-ir`) between Roc code that encounters the segfault and code that doesn't. \ No newline at end of file diff --git a/www/content/install/getting_started.md b/www/content/install/getting_started.md index 623e36d37c..714e7b1c50 100644 --- a/www/content/install/getting_started.md +++ b/www/content/install/getting_started.md @@ -11,7 +11,7 @@ If you have a specific question, the [FAQ](/faq) might have an answer, although ## [Installation](#installation){#installation} - [🐧 Linux x86_64](/install/linux_x86_64) -- [❄️ Nix Linux/MacOS](/install/nix) +- [❄️ Nix](/install/nix) - [🍏 MacOS Apple Silicon](/install/macos_apple_silicon) - [🍏 MacOS x86_64](/install/macos_x86_64) - [🟦 Windows](/install/windows) diff --git a/www/content/tutorial.md b/www/content/tutorial.md index 78ff40a1af..3adc8fafe1 100644 --- a/www/content/tutorial.md +++ b/www/content/tutorial.md @@ -2226,33 +2226,65 @@ For this reason, any time you see a function that only runs a `when` on its only ### [Record Builder](#record-builder) {#record-builder} -The record builder syntax sugar is a useful feature which leverages the functional programming concept of [applicative functors](https://lucamug.medium.com/functors-applicatives-and-monads-in-pictures-784c2b5786f7), to provide a flexible method for constructing complex types. +Record builders are a syntax sugar for sequencing actions and collecting the intermediate results as fields in a record. All you need to build a record is a `map2`-style function that takes two values of the same type and combines them using a provided combiner function. There are many convenient APIs we can build with this simple syntax. -The record builder syntax sugar helps to build up a record by applying a series of functions to it. - -For example, let's say we write a record-builder as follows: +For example, let's say we want a record builder to match URLs as follows: ```roc -{ aliceID, bobID, trudyID } = - initIDCount { - aliceID: <- incID, - bobID: <- incID, - trudyID: <- incID, - } |> extractState +combineMatchers : UrlMatcher a, UrlMatcher b, (a, b -> c) -> UrlMatcher c +combineMatchers = \matcherA, matcherB, combiner -> ... + +userTabMatcher : UrlMatcher { users: {}, userId: U64, tab: Str } +userTabMatcher = + { combineMatchers <- + users: exactSegment "users", + userId: u64Segment, + tab: anySegment, + } + +expect + userTabMatcher + |> matchOnUrl "/users/123/account" + == Ok { users: {}, userId: 123, tab: "account" } ``` -The above desguars to the following. +The `userTabMatcher` record builder desugars to the following: ```roc -{ aliceID, bobID, trudyID } = - initIDCount (\aID -> \bID -> \cID -> { aliceID: aID, bobID: bID, trudyID: cID }) - |> incID - |> incID - |> incID - |> extractState +userTabMatcher = + combineMatchers + (exactSegment "users") + ( + combineMatchers + u64Segment + anySegment + \userId, tab -> (userId, tab) + ) + \users, (userId, tab) -> { users, userId, tab } ``` -See the [Record Builder Example](https://www.roc-lang.org/examples/RecordBuilder/README.html) for an explanation of how to use this feature. +You can see that the `combineMatchers` builder function is simply applied in sequence, pairing up all fields until a record is created. + +You'll notice that the `users` field above holds an empty record, and isn't a useful part of the result. If you want to ignore such a field in the record builder, prefix its name with an underscore as you would do to ignore a variable: + +```roc +userTabMatcher : UrlMatcher { userId: U64 } +userTabMatcher = + { combineMatchers <- + _: exactSegment "users", + userId: u64Segment, + _tab: anySegment, + } + +expect + userTabMatcher + |> matchOnUrl "/users/123/account" + == Ok { userId: 123 } +``` + +If you want to see other examples of using record builders, look at the [Record Builder Example](https://www.roc-lang.org/examples/RecordBuilder/README.html) for a moderately-sized example or the [Arg.Builder](https://github.com/roc-lang/basic-cli/blob/main/platform/Arg/Builder.roc) module in our `basic-cli` platform for a complex example. + +_Note: This syntax replaces the old `field: <- value` record builder syntax using applicative functors because it is much simpler to understand and use. The old syntax will be removed soon._ ### [Reserved Keywords](#reserved-keywords) {#reserved-keywords}