diff --git a/crates/ast/src/lang/core/expr/expr_to_expr2.rs b/crates/ast/src/lang/core/expr/expr_to_expr2.rs index e47fe69bab..62d6a5d6dd 100644 --- a/crates/ast/src/lang/core/expr/expr_to_expr2.rs +++ b/crates/ast/src/lang/core/expr/expr_to_expr2.rs @@ -352,7 +352,7 @@ pub fn expr_to_expr2<'a>( for (node_id, branch) in can_branches.iter_node_ids().zip(branches.iter()) { let (can_when_branch, branch_references) = - canonicalize_when_branch(env, scope, *branch, &mut output); + canonicalize_when_branch(env, scope, branch, &mut output); output.references.union_mut(branch_references); diff --git a/crates/ast/src/lang/core/expr/introduced_vars.rs b/crates/ast/src/lang/core/expr/introduced_vars.rs index 26bbe6b738..91d5b7cdbe 100644 --- a/crates/ast/src/lang/core/expr/introduced_vars.rs +++ b/crates/ast/src/lang/core/expr/introduced_vars.rs @@ -3,7 +3,7 @@ use roc_module::ident::Lowercase; use roc_module::symbol::Symbol; use roc_types::subs::Variable; -#[derive(Clone, Debug, PartialEq, Default)] +#[derive(Clone, Debug, PartialEq, Eq, Default)] pub struct IntroducedVariables { // Rigids must be unique within a type annotation. // E.g. in `identity : a -> a`, there should only be one diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index 67e86bdd4e..bebd47ff0b 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -301,8 +301,8 @@ mod cli_run { test_many_cli_commands: bool, // buildOnly, buildAndRun and buildAndRunIfNoErrors ) { let file_name = file_path_from_root(dir_name, roc_filename); + let mut roc_app_args: Vec = Vec::new(); - let mut roc_app_args: Vec = vec![]; for arg in args { match arg { Arg::ExamplePath(file) => { @@ -320,10 +320,10 @@ mod cli_run { } // workaround for surgical linker issue, see PR #3990 - let mut custom_flags: Vec<&str> = vec![]; + let mut custom_flags: Vec<&str> = Vec::new(); match executable_filename { - "form" | "hello-gui" | "breakout" | "ruby" => { + "form" | "hello-gui" | "breakout" | "libhello" => { // Since these require things the build system often doesn't have // (e.g. GUIs open a window, Ruby needs ruby installed, WASM needs a browser) // we do `roc build` on them but don't run them. @@ -1154,7 +1154,7 @@ fn run_with_wasmer(wasm_path: &std::path::Path, stdin: &[&str]) -> String { // .unwrap(); let store = Store::default(); - let module = Module::from_file(&store, &wasm_path).unwrap(); + let module = Module::from_file(&store, wasm_path).unwrap(); let mut fake_stdin = wasmer_wasi::Pipe::new(); let fake_stdout = wasmer_wasi::Pipe::new(); diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index b37c235d77..a31669a34f 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -124,7 +124,7 @@ pub fn build_zig_host_native( bitcode::get_builtins_host_obj_path() }; - zig_cmd.args(&[ + zig_cmd.args([ "build-exe", "-fPIE", "-rdynamic", // make sure roc_alloc and friends are exposed @@ -132,10 +132,10 @@ pub fn build_zig_host_native( &builtins_obj, ]); } else { - zig_cmd.args(&["build-obj", "-fPIC"]); + zig_cmd.args(["build-obj", "-fPIC"]); } - zig_cmd.args(&[ + zig_cmd.args([ zig_host_src, &format!("-femit-bin={}", emit_bin), "--pkg-begin", @@ -154,7 +154,7 @@ pub fn build_zig_host_native( // when we use zig 0.9. It looks like zig 0.10 is going to fix // this problem for us, so this is a temporary workaround if !target.contains("windows") { - zig_cmd.args(&[ + zig_cmd.args([ // include the zig runtime "-fcompiler-rt", ]); @@ -162,13 +162,13 @@ pub fn build_zig_host_native( // valgrind does not yet support avx512 instructions, see #1963. if env::var("NO_AVX512").is_ok() { - zig_cmd.args(&["-mcpu", "x86_64"]); + zig_cmd.args(["-mcpu", "x86_64"]); } if matches!(opt_level, OptLevel::Optimize) { - zig_cmd.args(&["-O", "ReleaseSafe"]); + zig_cmd.args(["-O", "ReleaseSafe"]); } else if matches!(opt_level, OptLevel::Size) { - zig_cmd.args(&["-O", "ReleaseSmall"]); + zig_cmd.args(["-O", "ReleaseSmall"]); } zig_cmd @@ -378,9 +378,9 @@ pub fn build_zig_host_wasm32( .args(args); if matches!(opt_level, OptLevel::Optimize) { - zig_cmd.args(&["-O", "ReleaseSafe"]); + zig_cmd.args(["-O", "ReleaseSafe"]); } else if matches!(opt_level, OptLevel::Size) { - zig_cmd.args(&["-O", "ReleaseSmall"]); + zig_cmd.args(["-O", "ReleaseSmall"]); } zig_cmd @@ -400,11 +400,11 @@ pub fn build_c_host_native( let mut clang_cmd = clang(); clang_cmd .env_clear() - .env("PATH", &env_path) - .env("CPATH", &env_cpath) - .env("HOME", &env_home) + .env("PATH", env_path) + .env("CPATH", env_cpath) + .env("HOME", env_home) .args(sources) - .args(&["-o", dest]); + .args(["-o", dest]); if let Some(shared_lib_path) = shared_lib_path { match target.operating_system { OperatingSystem::Windows => { @@ -425,7 +425,7 @@ pub fn build_c_host_native( ); } _ => { - clang_cmd.args(&[ + clang_cmd.args([ shared_lib_path.to_str().unwrap(), // This line is commented out because // @bhansconnect: With the addition of Str.graphemes, always @@ -444,7 +444,7 @@ pub fn build_c_host_native( } } } else { - clang_cmd.args(&["-fPIC", "-c"]); + clang_cmd.args(["-fPIC", "-c"]); } if matches!(opt_level, OptLevel::Optimize) { clang_cmd.arg("-O3"); @@ -473,8 +473,8 @@ pub fn build_swift_host_native( let mut command = Command::new("arch"); command .env_clear() - .env("PATH", &env_path) - .env("HOME", &env_home); + .env("PATH", env_path) + .env("HOME", env_home); match arch { Architecture::Aarch64(_) => command.arg("-arm64"), @@ -487,10 +487,10 @@ pub fn build_swift_host_native( .args(sources) .arg("-emit-object") .arg("-parse-as-library") - .args(&["-o", dest]); + .args(["-o", dest]); if let Some(objc_header) = objc_header_path { - command.args(&["-import-objc-header", objc_header]); + command.args(["-import-objc-header", objc_header]); } if matches!(opt_level, OptLevel::Optimize) { @@ -641,7 +641,7 @@ pub fn rebuild_host( let source_file = if shared_lib_path.is_some() { cargo_cmd.env("RUSTFLAGS", "-C link-dead-code"); - cargo_cmd.args(&["--bin", "host"]); + cargo_cmd.args(["--bin", "host"]); "src/main.rs" } else { cargo_cmd.arg("--lib"); @@ -673,7 +673,7 @@ pub fn rebuild_host( let mut ld_cmd = Command::new("ld"); - ld_cmd.env_clear().env("PATH", &env_path).args(&[ + ld_cmd.env_clear().env("PATH", &env_path).args([ "-r", "-L", cargo_out_dir.to_str().unwrap(), @@ -693,7 +693,7 @@ pub fn rebuild_host( } else if rust_host_src.exists() { // Compile and link host.rs, if it exists let mut rustc_cmd = Command::new("rustc"); - rustc_cmd.args(&[ + rustc_cmd.args([ rust_host_src.to_str().unwrap(), "-o", rust_host_dest.to_str().unwrap(), @@ -739,7 +739,7 @@ pub fn rebuild_host( let mut ld_cmd = Command::new("ld"); - ld_cmd.env_clear().env("PATH", &env_path).args(&[ + ld_cmd.env_clear().env("PATH", &env_path).args([ "-r", c_host_dest.to_str().unwrap(), rust_host_dest.to_str().unwrap(), @@ -856,9 +856,9 @@ fn link_linux( if let Architecture::X86_32(_) = target.architecture { return Ok(( zig() - .args(&["build-exe"]) + .args(["build-exe"]) .args(input_paths) - .args(&[ + .args([ "-target", "i386-linux-musl", "-lc", @@ -1011,7 +1011,7 @@ fn link_linux( .filter(|&(ref k, _)| k.starts_with("NIX_")) .collect::>(), ) - .args(&[ + .args([ "--gc-sections", "--eh-frame-hdr", "-A", @@ -1021,11 +1021,11 @@ fn link_linux( &*crtn_path.to_string_lossy(), ]) .args(&base_args) - .args(&["-dynamic-linker", ld_linux]) + .args(["-dynamic-linker", ld_linux]) .args(input_paths) // ld.lld requires this argument, and does not accept --arch // .args(&["-L/usr/lib/x86_64-linux-gnu"]) - .args(&[ + .args([ // Libraries - see https://github.com/roc-lang/roc/pull/554#discussion_r496365925 // for discussion and further references "-lc", @@ -1076,7 +1076,7 @@ fn link_macos( // The `-l` flags should go after the `.o` arguments // Don't allow LD_ env vars to affect this .env_clear() - .args(&[ + .args([ // NOTE: we don't do --gc-sections on macOS because the default // macOS linker doesn't support it, but it's a performance // optimization, so if we ever switch to a different linker, @@ -1108,7 +1108,7 @@ fn link_macos( ld_command.arg(roc_link_flag); } - ld_command.args(&[ + ld_command.args([ // Libraries - see https://github.com/roc-lang/roc/pull/554#discussion_r496392274 // for discussion and further references "-lSystem", @@ -1148,7 +1148,7 @@ fn link_macos( Architecture::Aarch64(_) => { ld_child.wait()?; let codesign_child = Command::new("codesign") - .args(&["-s", "-", output_path.to_str().unwrap()]) + .args(["-s", "-", output_path.to_str().unwrap()]) .spawn()?; Ok((codesign_child, output_path)) @@ -1187,7 +1187,7 @@ fn link_wasm32( let child = zig() // .env_clear() // .env("PATH", &env_path) - .args(&["build-exe"]) + .args(["build-exe"]) .args(input_paths) .args([ // include wasi libc @@ -1222,7 +1222,7 @@ fn link_windows( match link_type { LinkType::Dylib => { let child = zig() - .args(&["build-lib"]) + .args(["build-lib"]) .args(input_paths) .args([ "-lc", @@ -1244,7 +1244,7 @@ fn link_windows( } LinkType::Executable => { let child = zig() - .args(&["build-exe"]) + .args(["build-exe"]) .args(input_paths) .args([ "-target", diff --git a/crates/compiler/build/src/program.rs b/crates/compiler/build/src/program.rs index 50ddf387c0..99bb3d62fa 100644 --- a/crates/compiler/build/src/program.rs +++ b/crates/compiler/build/src/program.rs @@ -347,7 +347,7 @@ fn gen_from_mono_module_llvm( // run the debugir https://github.com/vaivaswatha/debugir tool match Command::new("debugir") - .args(&["-instnamer", app_ll_file.to_str().unwrap()]) + .args(["-instnamer", app_ll_file.to_str().unwrap()]) .output() { Ok(_) => {} @@ -369,7 +369,7 @@ fn gen_from_mono_module_llvm( | Architecture::Aarch64(_) | Architecture::Wasm32 => { let ll_to_bc = Command::new("llvm-as") - .args(&[ + .args([ app_ll_dbg_file.to_str().unwrap(), "-o", app_bc_file.to_str().unwrap(), diff --git a/crates/compiler/builtins/build.rs b/crates/compiler/builtins/build.rs index 6b937fa18c..b72aa3673f 100644 --- a/crates/compiler/builtins/build.rs +++ b/crates/compiler/builtins/build.rs @@ -90,7 +90,7 @@ fn generate_object_file(bitcode_path: &Path, zig_object: &str, object_file_name: let mut zig_cmd = zig(); zig_cmd - .current_dir(&bitcode_path) + .current_dir(bitcode_path) .args(["build", zig_object, "-Drelease=true"]); run_command(zig_cmd, 0); @@ -126,7 +126,7 @@ fn generate_bc_file(bitcode_path: &Path, zig_object: &str, file_name: &str) { let mut zig_cmd = zig(); zig_cmd - .current_dir(&bitcode_path) + .current_dir(bitcode_path) .args(["build", zig_object, "-Drelease=true"]); run_command(zig_cmd, 0); @@ -168,7 +168,7 @@ fn copy_zig_builtins_to_target_dir(bitcode_path: &Path) { // recursively copy all the .zig files from this directory, but do *not* recurse into zig-cache/ fn cp_unless_zig_cache(src_dir: &Path, target_dir: &Path) -> io::Result<()> { // Make sure the destination directory exists before we try to copy anything into it. - std::fs::create_dir_all(&target_dir).unwrap_or_else(|err| { + std::fs::create_dir_all(target_dir).unwrap_or_else(|err| { panic!( "Failed to create output library directory for zig bitcode {:?}: {:?}", target_dir, err diff --git a/crates/compiler/builtins/roc/Dict.roc b/crates/compiler/builtins/roc/Dict.roc index cb83d06b7c..e217f87e0d 100644 --- a/crates/compiler/builtins/roc/Dict.roc +++ b/crates/compiler/builtins/roc/Dict.roc @@ -223,18 +223,18 @@ expect update (single "a" Bool.true) "a" alterValue == empty ## Dict.empty ## |> Dict.insert 1234 "5678" ## |> Dict.contains 1234 -## |> Bool.isEq Bool.true contains : Dict k v, k -> Bool | k has Eq contains = \@Dict list, needle -> - step = \_, Pair key _val -> - if key == needle then - Break {} - else - Continue {} + List.any list \Pair key _val -> key == needle - when List.iterate list {} step is - Continue _ -> Bool.false - Break _ -> Bool.true +expect contains empty "a" == Bool.false +expect contains (single "a" {}) "a" == Bool.true +expect contains (single "b" {}) "a" == Bool.false +expect + Dict.empty + |> Dict.insert 1234 "5678" + |> Dict.contains 1234 + |> Bool.isEq Bool.true ## Returns a dictionary containing the key and value provided as input. ## diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index 0e06253a22..e968d35712 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -8,7 +8,6 @@ interface List map, len, withCapacity, - iterate, walkBackwards, concat, first, diff --git a/crates/compiler/can/src/abilities.rs b/crates/compiler/can/src/abilities.rs index cab1a7d929..1dde05adab 100644 --- a/crates/compiler/can/src/abilities.rs +++ b/crates/compiler/can/src/abilities.rs @@ -28,7 +28,7 @@ pub struct MemberVariables { /// The member and its signature is defined locally, in the module the store is created for. /// We need to instantiate and introduce this during solving. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ResolvedMemberType(Variable); /// Member type information that needs to be resolved from imports. @@ -56,7 +56,7 @@ impl ResolvePhase for Pending { type MemberType = PendingMemberType; } -#[derive(Default, Debug, Clone, Copy, PartialEq)] +#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)] pub struct Resolved; impl ResolvePhase for Resolved { type MemberType = ResolvedMemberType; diff --git a/crates/compiler/can/src/def.rs b/crates/compiler/can/src/def.rs index 20c648125b..24fba9813d 100644 --- a/crates/compiler/can/src/def.rs +++ b/crates/compiler/can/src/def.rs @@ -1821,7 +1821,7 @@ pub(crate) fn sort_can_defs( .strongly_connected_components_subset(group); debug_assert!( - !group.iter_ones().any(|index| matches!((&defs[index]).as_ref().unwrap().loc_pattern.value, Pattern::AbilityMemberSpecialization{..})), + !group.iter_ones().any(|index| matches!(defs[index].as_ref().unwrap().loc_pattern.value, Pattern::AbilityMemberSpecialization{..})), "A specialization is involved in a recursive cycle - this should not be knowable until solving"); let declaration = if direct_sccs.groups().count() == 1 { diff --git a/crates/compiler/can/src/expr.rs b/crates/compiler/can/src/expr.rs index 4e7e9d13d4..fad9e313df 100644 --- a/crates/compiler/can/src/expr.rs +++ b/crates/compiler/can/src/expr.rs @@ -65,7 +65,7 @@ impl Output { } } -#[derive(Clone, Debug, PartialEq, Copy)] +#[derive(Clone, Debug, PartialEq, Eq, Copy)] pub enum IntValue { I128([u8; 16]), U128([u8; 16]), @@ -345,7 +345,7 @@ pub struct ClosureData { /// /// We distinguish them from closures so we can have better error messages /// during constraint generation. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct AccessorData { pub name: Symbol, pub function_var: Variable, @@ -485,7 +485,7 @@ pub struct Field { pub loc_expr: Box>, } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Recursive { NotRecursive = 0, Recursive = 1, @@ -888,7 +888,7 @@ pub fn canonicalize_expr<'a>( var_store, inner_scope, region, - *branch, + branch, &mut output, ) }); @@ -1493,7 +1493,7 @@ fn canonicalize_fields<'a>( let mut output = Output::default(); for loc_field in fields.iter() { - match canonicalize_field(env, var_store, scope, &loc_field.value, loc_field.region) { + match canonicalize_field(env, var_store, scope, &loc_field.value) { Ok((label, field_expr, field_out, field_var)) => { let field = Field { var: field_var, @@ -1546,7 +1546,6 @@ fn canonicalize_field<'a>( var_store: &mut VarStore, scope: &mut Scope, field: &'a ast::AssignedField<'a, ast::Expr<'a>>, - region: Region, ) -> Result<(Lowercase, Loc, Output, Variable), CanonicalizeFieldProblem> { use roc_parse::ast::AssignedField::*; @@ -1576,7 +1575,7 @@ fn canonicalize_field<'a>( } SpaceBefore(sub_field, _) | SpaceAfter(sub_field, _) => { - canonicalize_field(env, var_store, scope, sub_field, region) + canonicalize_field(env, var_store, scope, sub_field) } Malformed(_string) => { @@ -1652,7 +1651,7 @@ fn canonicalize_var_lookup( } /// Currently uses the heuristic of "only inline if it's a builtin" -pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> Expr { +pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr { use Expr::*; match expr { @@ -1681,7 +1680,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> let mut new_elems = Vec::with_capacity(loc_elems.len()); for loc_elem in loc_elems { - let value = inline_calls(var_store, scope, loc_elem.value); + let value = inline_calls(var_store, loc_elem.value); new_elems.push(Loc { value, @@ -1706,20 +1705,20 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> } => { let loc_cond = Box::new(Loc { region: loc_cond.region, - value: inline_calls(var_store, scope, loc_cond.value), + value: inline_calls(var_store, loc_cond.value), }); let mut new_branches = Vec::with_capacity(branches.len()); for branch in branches { let value = Loc { - value: inline_calls(var_store, scope, branch.value.value), + value: inline_calls(var_store, branch.value.value), region: branch.value.region, }; let guard = match branch.guard { Some(loc_expr) => Some(Loc { region: loc_expr.region, - value: inline_calls(var_store, scope, loc_expr.value), + value: inline_calls(var_store, loc_expr.value), }), None => None, }; @@ -1753,12 +1752,12 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> for (loc_cond, loc_expr) in branches { let loc_cond = Loc { - value: inline_calls(var_store, scope, loc_cond.value), + value: inline_calls(var_store, loc_cond.value), region: loc_cond.region, }; let loc_expr = Loc { - value: inline_calls(var_store, scope, loc_expr.value), + value: inline_calls(var_store, loc_expr.value), region: loc_expr.region, }; @@ -1767,7 +1766,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> let final_else = Box::new(Loc { region: final_else.region, - value: inline_calls(var_store, scope, final_else.value), + value: inline_calls(var_store, final_else.value), }); If { @@ -1785,12 +1784,12 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> } => { let loc_condition = Loc { region: loc_condition.region, - value: inline_calls(var_store, scope, loc_condition.value), + value: inline_calls(var_store, loc_condition.value), }; let loc_continuation = Loc { region: loc_continuation.region, - value: inline_calls(var_store, scope, loc_continuation.value), + value: inline_calls(var_store, loc_continuation.value), }; Expect { @@ -1807,12 +1806,12 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> } => { let loc_condition = Loc { region: loc_condition.region, - value: inline_calls(var_store, scope, loc_condition.value), + value: inline_calls(var_store, loc_condition.value), }; let loc_continuation = Loc { region: loc_continuation.region, - value: inline_calls(var_store, scope, loc_continuation.value), + value: inline_calls(var_store, loc_continuation.value), }; ExpectFx { @@ -1830,7 +1829,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> loc_pattern: def.loc_pattern, loc_expr: Loc { region: def.loc_expr.region, - value: inline_calls(var_store, scope, def.loc_expr.value), + value: inline_calls(var_store, def.loc_expr.value), }, expr_var: def.expr_var, pattern_vars: def.pattern_vars, @@ -1840,7 +1839,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> let loc_expr = Loc { region: loc_expr.region, - value: inline_calls(var_store, scope, loc_expr.value), + value: inline_calls(var_store, loc_expr.value), }; LetRec(new_defs, Box::new(loc_expr), mark) @@ -1851,7 +1850,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> loc_pattern: def.loc_pattern, loc_expr: Loc { region: def.loc_expr.region, - value: inline_calls(var_store, scope, def.loc_expr.value), + value: inline_calls(var_store, def.loc_expr.value), }, expr_var: def.expr_var, pattern_vars: def.pattern_vars, @@ -1860,7 +1859,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> let loc_expr = Loc { region: loc_expr.region, - value: inline_calls(var_store, scope, loc_expr.value), + value: inline_calls(var_store, loc_expr.value), }; LetNonRec(Box::new(def), Box::new(loc_expr)) @@ -1878,7 +1877,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> }) => { let loc_expr = *loc_body; let loc_expr = Loc { - value: inline_calls(var_store, scope, loc_expr.value), + value: inline_calls(var_store, loc_expr.value), region: loc_expr.region, }; @@ -1938,7 +1937,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) -> let (var, loc_expr) = *argument; let argument = Box::new(( var, - loc_expr.map_owned(|expr| inline_calls(var_store, scope, expr)), + loc_expr.map_owned(|expr| inline_calls(var_store, expr)), )); OpaqueRef { @@ -2737,7 +2736,7 @@ fn get_lookup_symbols(expr: &Expr) -> Vec { | Expr::ExpectFx { loc_continuation, .. } => { - stack.push(&(*loc_continuation).value); + stack.push(&loc_continuation.value); // Intentionally ignore the lookups in the nested `expect` condition itself, // because they couldn't possibly influence the outcome of this `expect`! diff --git a/crates/compiler/can/src/operator.rs b/crates/compiler/can/src/operator.rs index 9a46592f0a..fac3cf2b37 100644 --- a/crates/compiler/can/src/operator.rs +++ b/crates/compiler/can/src/operator.rs @@ -79,7 +79,7 @@ fn desugar_value_def<'a>(arena: &'a Bump, def: &'a ValueDef<'a>) -> ValueDef<'a> ann_pattern, ann_type, comment: *comment, - body_pattern: *body_pattern, + body_pattern, body_expr: desugar_expr(arena, body_expr), }, Expect { diff --git a/crates/compiler/collections/src/vec_set.rs b/crates/compiler/collections/src/vec_set.rs index d5fd02a63c..8415bbc102 100644 --- a/crates/compiler/collections/src/vec_set.rs +++ b/crates/compiler/collections/src/vec_set.rs @@ -1,6 +1,6 @@ use std::{borrow::Borrow, iter::FromIterator}; -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct VecSet { elements: Vec, } diff --git a/crates/compiler/derive/src/lib.rs b/crates/compiler/derive/src/lib.rs index 1f63ac3734..43d547ddb5 100644 --- a/crates/compiler/derive/src/lib.rs +++ b/crates/compiler/derive/src/lib.rs @@ -99,14 +99,11 @@ impl DerivedModule { exposed_by_module: &ExposedByModule, key: DeriveKey, ) -> &(Symbol, Def, SpecializationLambdaSets) { - match self.map.get(&key) { - Some(entry) => { - // rustc won't let us return an immutable reference *and* continue using - // `self.map` immutably below, but this is safe, because we are not returning - // an immutable reference to the entry. - return unsafe { std::mem::transmute(entry) }; - } - None => {} + if let Some(entry) = self.map.get(&key) { + // rustc won't let us return an immutable reference *and* continue using + // `self.map` immutably below, but this is safe, because we are not returning + // an immutable reference to the entry. + return unsafe { std::mem::transmute(entry) }; } let ident_id = if cfg!(debug_assertions) || cfg!(feature = "debug-derived-symbols") { diff --git a/crates/compiler/derive_key/src/lib.rs b/crates/compiler/derive_key/src/lib.rs index 65a0062a7d..a994a622e3 100644 --- a/crates/compiler/derive_key/src/lib.rs +++ b/crates/compiler/derive_key/src/lib.rs @@ -25,7 +25,7 @@ use hash::{FlatHash, FlatHashKey}; use roc_module::symbol::Symbol; use roc_types::subs::{Subs, Variable}; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum DeriveError { /// Unbound variable present in the type-to-derive. It may be possible to derive for this type /// once the unbound variable is resolved. diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index 9fcdb4bf12..e3cd669f67 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -166,8 +166,8 @@ impl<'a> Formattable for TypeAnnotation<'a> { Wildcard | Inferred | BoundVariable(_) | Malformed(_) => false, Function(args, result) => { - (&result.value).is_multiline() - || args.iter().any(|loc_arg| (&loc_arg.value).is_multiline()) + result.value.is_multiline() + || args.iter().any(|loc_arg| loc_arg.value.is_multiline()) } Apply(_, _, args) => args.iter().any(|loc_arg| loc_arg.value.is_multiline()), As(lhs, _, _) => lhs.value.is_multiline(), @@ -226,7 +226,7 @@ impl<'a> Formattable for TypeAnnotation<'a> { buf.newline(); } - (&argument.value).format_with_options( + argument.value.format_with_options( buf, Parens::InFunctionType, Newlines::No, @@ -251,7 +251,8 @@ impl<'a> Formattable for TypeAnnotation<'a> { buf.push_str("->"); buf.spaces(1); - (&ret.value).format_with_options(buf, Parens::InFunctionType, Newlines::No, indent); + ret.value + .format_with_options(buf, Parens::InFunctionType, Newlines::No, indent); if needs_parens { buf.push(')') @@ -275,12 +276,9 @@ impl<'a> Formattable for TypeAnnotation<'a> { for argument in *arguments { buf.spaces(1); - (&argument.value).format_with_options( - buf, - Parens::InApply, - Newlines::No, - indent, - ); + argument + .value + .format_with_options(buf, Parens::InApply, Newlines::No, indent); } if write_parens { @@ -371,12 +369,12 @@ impl<'a> Formattable for AssignedField<'a, TypeAnnotation<'a>> { fn format_with_options<'buf>( &self, buf: &mut Buf<'buf>, - parens: Parens, + _parens: Parens, newlines: Newlines, indent: u16, ) { // we abuse the `Newlines` type to decide between multiline or single-line layout - format_assigned_field_help(self, buf, parens, indent, 1, newlines == Newlines::Yes); + format_assigned_field_help(self, buf, indent, 1, newlines == Newlines::Yes); } } @@ -388,12 +386,12 @@ impl<'a> Formattable for AssignedField<'a, Expr<'a>> { fn format_with_options<'buf>( &self, buf: &mut Buf<'buf>, - parens: Parens, + _parens: Parens, newlines: Newlines, indent: u16, ) { // we abuse the `Newlines` type to decide between multiline or single-line layout - format_assigned_field_help(self, buf, parens, indent, 0, newlines == Newlines::Yes); + format_assigned_field_help(self, buf, indent, 0, newlines == Newlines::Yes); } } @@ -413,7 +411,6 @@ fn is_multiline_assigned_field_help(afield: &AssignedField<'_, T fn format_assigned_field_help<'a, 'buf, T>( zelf: &AssignedField<'a, T>, buf: &mut Buf<'buf>, - parens: Parens, indent: u16, separator_spaces: usize, is_multiline: bool, @@ -466,24 +463,10 @@ fn format_assigned_field_help<'a, 'buf, T>( } AssignedField::SpaceBefore(sub_field, spaces) => { fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent); - format_assigned_field_help( - sub_field, - buf, - parens, - indent, - separator_spaces, - is_multiline, - ); + format_assigned_field_help(sub_field, buf, indent, separator_spaces, is_multiline); } AssignedField::SpaceAfter(sub_field, spaces) => { - format_assigned_field_help( - sub_field, - buf, - parens, - indent, - separator_spaces, - is_multiline, - ); + format_assigned_field_help(sub_field, buf, indent, separator_spaces, is_multiline); fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent); } Malformed(raw) => { @@ -497,7 +480,7 @@ impl<'a> Formattable for Tag<'a> { use self::Tag::*; match self { - Apply { args, .. } => args.iter().any(|arg| (&arg.value).is_multiline()), + Apply { args, .. } => args.iter().any(|arg| arg.value.is_multiline()), Tag::SpaceBefore(_, _) | Tag::SpaceAfter(_, _) => true, Malformed(text) => text.chars().any(|c| c == '\n'), } diff --git a/crates/compiler/fmt/src/expr.rs b/crates/compiler/fmt/src/expr.rs index f5395e6d24..6cb1709863 100644 --- a/crates/compiler/fmt/src/expr.rs +++ b/crates/compiler/fmt/src/expr.rs @@ -542,7 +542,7 @@ fn fmt_binops<'a, 'buf>( indent: u16, ) { let is_multiline = part_of_multi_line_binops - || (&loc_right_side.value).is_multiline() + || loc_right_side.value.is_multiline() || lefts.iter().any(|(expr, _)| expr.value.is_multiline()); for (loc_left_side, loc_binop) in lefts { @@ -1045,7 +1045,7 @@ fn fmt_closure<'a, 'buf>( buf.push_str("->"); - let is_multiline = (&loc_ret.value).is_multiline(); + let is_multiline = loc_ret.value.is_multiline(); // If the body is multiline, go down a line and indent. let body_indent = if is_multiline { @@ -1156,7 +1156,7 @@ fn fmt_backpassing<'a, 'buf>( buf.push_str("<-"); - let is_multiline = (&loc_ret.value).is_multiline(); + let is_multiline = loc_ret.value.is_multiline(); // If the body is multiline, go down a line and indent. let body_indent = if is_multiline { diff --git a/crates/compiler/gen_dev/src/generic64/disassembler_test_macro.rs b/crates/compiler/gen_dev/src/generic64/disassembler_test_macro.rs index f6af4bd81a..5461c54fd0 100644 --- a/crates/compiler/gen_dev/src/generic64/disassembler_test_macro.rs +++ b/crates/compiler/gen_dev/src/generic64/disassembler_test_macro.rs @@ -19,7 +19,7 @@ macro_rules! disassembler_test { // TODO: Not sure if there is a better way to merge these together, // but I like the end use of this a lot better than the old tests. ($assemble_fn: expr, $format_fn: expr) => {{ - use crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers; + use $crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers; let arena = bumpalo::Bump::new(); let (mut buf, cs) = setup_capstone_and_arena(&arena); $assemble_fn(&mut buf); diff --git a/crates/compiler/gen_dev/src/generic64/x86_64.rs b/crates/compiler/gen_dev/src/generic64/x86_64.rs index fce88a8178..37ee037557 100644 --- a/crates/compiler/gen_dev/src/generic64/x86_64.rs +++ b/crates/compiler/gen_dev/src/generic64/x86_64.rs @@ -1011,7 +1011,7 @@ impl Assembler for X86_64Assembler { #[inline(always)] fn call(buf: &mut Vec<'_, u8>, relocs: &mut Vec<'_, Relocation>, fn_name: String) { - buf.extend(&[0xE8, 0x00, 0x00, 0x00, 0x00]); + buf.extend([0xE8, 0x00, 0x00, 0x00, 0x00]); relocs.push(Relocation::LinkedFunction { offset: buf.len() as u64 - 4, name: fn_name, @@ -1478,7 +1478,7 @@ fn binop_reg64_reg64( let rex = add_reg_extension(src, rex); let dst_mod = dst as u8 % 8; let src_mod = (src as u8 % 8) << 3; - buf.extend(&[rex, op_code, 0xC0 | dst_mod | src_mod]); + buf.extend([rex, op_code, 0xC0 | dst_mod | src_mod]); } #[inline(always)] @@ -1493,7 +1493,7 @@ fn extended_binop_reg64_reg64( let rex = add_reg_extension(src, rex); let dst_mod = dst as u8 % 8; let src_mod = (src as u8 % 8) << 3; - buf.extend(&[rex, op_code1, op_code2, 0xC0 | dst_mod | src_mod]); + buf.extend([rex, op_code1, op_code2, 0xC0 | dst_mod | src_mod]); } // Below here are the functions for all of the assembly instructions. @@ -1508,8 +1508,8 @@ fn add_reg64_imm32(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i32) { let rex = add_rm_extension(dst, REX_W); let dst_mod = dst as u8 % 8; buf.reserve(7); - buf.extend(&[rex, 0x81, 0xC0 | dst_mod]); - buf.extend(&imm.to_le_bytes()); + buf.extend([rex, 0x81, 0xC0 | dst_mod]); + buf.extend(imm.to_le_bytes()); } /// `ADD r/m64,r64` -> Add r64 to r/m64. @@ -1547,7 +1547,7 @@ fn addsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF2, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1555,7 +1555,7 @@ fn addsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF2, 0x0F, 0x58, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF2, 0x0F, 0x58, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1567,7 +1567,7 @@ fn addss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF3, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1575,7 +1575,7 @@ fn addss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF3, 0x0F, 0x58, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF3, 0x0F, 0x58, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1587,7 +1587,7 @@ fn mulsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF2, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1595,7 +1595,7 @@ fn mulsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF2, 0x0F, 0x59, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF2, 0x0F, 0x59, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1607,7 +1607,7 @@ fn divss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF3, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1615,7 +1615,7 @@ fn divss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF3, 0x0F, 0x5E, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF3, 0x0F, 0x5E, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1627,7 +1627,7 @@ fn divsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF2, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1635,7 +1635,7 @@ fn divsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF2, 0x0F, 0x5E, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF2, 0x0F, 0x5E, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1647,7 +1647,7 @@ fn mulss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF3, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1655,7 +1655,7 @@ fn mulss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF3, 0x0F, 0x59, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF3, 0x0F, 0x59, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1667,7 +1667,7 @@ fn andpd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0x66, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1675,7 +1675,7 @@ fn andpd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0x66, 0x0F, 0x54, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0x66, 0x0F, 0x54, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1684,7 +1684,7 @@ fn andpd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64Fl fn and_reg64_imm8(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i8) { let rex = add_rm_extension(dst, REX_W); let dst_mod = dst as u8 % 8; - buf.extend(&[rex, 0x83, 0xE0 | dst_mod, imm as u8]); + buf.extend([rex, 0x83, 0xE0 | dst_mod, imm as u8]); } /// `CMOVL r64,r/m64` -> Move if less (SF≠ OF). @@ -1694,7 +1694,7 @@ fn cmovl_reg64_reg64(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, src: X86_64Ge let rex = add_rm_extension(src, rex); let dst_mod = (dst as u8 % 8) << 3; let src_mod = src as u8 % 8; - buf.extend(&[rex, 0x0F, 0x4C, 0xC0 | dst_mod | src_mod]); + buf.extend([rex, 0x0F, 0x4C, 0xC0 | dst_mod | src_mod]); } /// `CMP r/m64,i32` -> Compare i32 to r/m64. @@ -1703,8 +1703,8 @@ fn cmp_reg64_imm32(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i32) { let rex = add_rm_extension(dst, REX_W); let dst_mod = dst as u8 % 8; buf.reserve(7); - buf.extend(&[rex, 0x81, 0xF8 | dst_mod]); - buf.extend(&imm.to_le_bytes()); + buf.extend([rex, 0x81, 0xF8 | dst_mod]); + buf.extend(imm.to_le_bytes()); } /// `CMP r/m64,r64` -> Compare r64 to r/m64. @@ -1738,7 +1738,7 @@ fn mul_reg64_reg64(buf: &mut Vec<'_, u8>, src: X86_64GeneralReg) { rex |= REX_PREFIX_B; } - buf.extend(&[rex, 0xF7, 0b1110_0000 | (src as u8 % 8)]); + buf.extend([rex, 0xF7, 0b1110_0000 | (src as u8 % 8)]); } /// `IDIV r/m64` -> Signed divide RDX:RAX by r/m64, with result stored in RAX ← Quotient, RDX ← Remainder. @@ -1756,9 +1756,9 @@ fn idiv_reg64_reg64(buf: &mut Vec<'_, u8>, src: X86_64GeneralReg) { // // The CQO instruction (available in 64-bit mode only) copies the sign (bit 63) // of the value in the RAX register into every bit position in the RDX register - buf.extend(&[0x48, 0x99]); + buf.extend([0x48, 0x99]); - buf.extend(&[rex, 0xF7, 0b1111_1000 | (src as u8 % 8)]); + buf.extend([rex, 0xF7, 0b1111_1000 | (src as u8 % 8)]); } /// `DIV r/m64` -> Unsigned divide RDX:RAX by r/m64, with result stored in RAX ← Quotient, RDX ← Remainder. @@ -1776,10 +1776,10 @@ fn udiv_reg64_reg64(buf: &mut Vec<'_, u8>, src: X86_64GeneralReg) { // // The CQO instruction (available in 64-bit mode only) copies the sign (bit 63) // of the value in the RAX register into every bit position in the RDX register - buf.extend(&[0x48, 0x99]); + buf.extend([0x48, 0x99]); // adds a cqo (convert doubleword to quadword) - buf.extend(&[rex, 0xF7, 0b1111_0000 | (src as u8 % 8)]); + buf.extend([rex, 0xF7, 0b1111_0000 | (src as u8 % 8)]); } /// Jump near, relative, RIP = RIP + 32-bit displacement sign extended to 64-bits. @@ -1787,7 +1787,7 @@ fn udiv_reg64_reg64(buf: &mut Vec<'_, u8>, src: X86_64GeneralReg) { fn jmp_imm32(buf: &mut Vec<'_, u8>, imm: i32) { buf.reserve(5); buf.push(0xE9); - buf.extend(&imm.to_le_bytes()); + buf.extend(imm.to_le_bytes()); } /// Jump near if not equal (ZF=0). @@ -1796,7 +1796,7 @@ fn jne_imm32(buf: &mut Vec<'_, u8>, imm: i32) { buf.reserve(6); buf.push(0x0F); buf.push(0x85); - buf.extend(&imm.to_le_bytes()); + buf.extend(imm.to_le_bytes()); } /// `MOV r/m64, imm32` -> Move imm32 sign extended to 64-bits to r/m64. @@ -1805,8 +1805,8 @@ fn mov_reg64_imm32(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i32) { let rex = add_rm_extension(dst, REX_W); let dst_mod = dst as u8 % 8; buf.reserve(7); - buf.extend(&[rex, 0xC7, 0xC0 | dst_mod]); - buf.extend(&imm.to_le_bytes()); + buf.extend([rex, 0xC7, 0xC0 | dst_mod]); + buf.extend(imm.to_le_bytes()); } /// `MOV r64, imm64` -> Move imm64 to r64. @@ -1818,8 +1818,8 @@ fn mov_reg64_imm64(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i64) { let rex = add_opcode_extension(dst, REX_W); let dst_mod = dst as u8 % 8; buf.reserve(10); - buf.extend(&[rex, 0xB8 | dst_mod]); - buf.extend(&imm.to_le_bytes()); + buf.extend([rex, 0xB8 | dst_mod]); + buf.extend(imm.to_le_bytes()); } } @@ -1854,12 +1854,12 @@ fn mov_base64_offset32_reg64( let src_mod = (src as u8 % 8) << 3; let base_mod = base as u8 % 8; buf.reserve(8); - buf.extend(&[rex, 0x89, 0x80 | src_mod | base_mod]); + buf.extend([rex, 0x89, 0x80 | src_mod | base_mod]); // Using RSP or R12 requires a secondary index byte. if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { buf.push(0x24); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `MOV r64,r/m64` -> Move r/m64 to r64, where m64 references a base + offset. @@ -1875,12 +1875,12 @@ fn mov_reg64_base64_offset32( let dst_mod = (dst as u8 % 8) << 3; let base_mod = base as u8 % 8; buf.reserve(8); - buf.extend(&[rex, 0x8B, 0x80 | dst_mod | base_mod]); + buf.extend([rex, 0x8B, 0x80 | dst_mod | base_mod]); // Using RSP or R12 requires a secondary index byte. if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { buf.push(0x24); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `MOVZX r64,r/m8` -> Move r/m8 with zero extention to r64, where m8 references a base + offset. @@ -1896,12 +1896,12 @@ fn movzx_reg64_base8_offset32( let dst_mod = (dst as u8 % 8) << 3; let base_mod = base as u8 % 8; buf.reserve(9); - buf.extend(&[rex, 0x0F, 0xB6, 0x80 | dst_mod | base_mod]); + buf.extend([rex, 0x0F, 0xB6, 0x80 | dst_mod | base_mod]); // Using RSP or R12 requires a secondary index byte. if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { buf.push(0x24); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `MOVSD xmm1,xmm2` -> Move scalar double-precision floating-point value from xmm2 to xmm1 register. @@ -1922,7 +1922,7 @@ fn raw_movsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_ let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF2, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1930,7 +1930,7 @@ fn raw_movsd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_ 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF2, 0x0F, 0x10, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF2, 0x0F, 0x10, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1952,7 +1952,7 @@ fn raw_movss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_ let src_high = src as u8 > 7; let src_mod = src as u8 % 8; if dst_high || src_high { - buf.extend(&[ + buf.extend([ 0xF3, 0x40 | ((dst_high as u8) << 2) | (src_high as u8), 0x0F, @@ -1960,7 +1960,7 @@ fn raw_movss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_ 0xC0 | (dst_mod << 3) | (src_mod), ]) } else { - buf.extend(&[0xF3, 0x0F, 0x10, 0xC0 | (dst_mod << 3) | (src_mod)]) + buf.extend([0xF3, 0x0F, 0x10, 0xC0 | (dst_mod << 3) | (src_mod)]) } } @@ -1970,12 +1970,12 @@ fn movss_freg32_rip_offset32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, offset: let dst_mod = dst as u8 % 8; if dst as u8 > 7 { buf.reserve(9); - buf.extend(&[0xF3, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); + buf.extend([0xF3, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); } else { buf.reserve(8); - buf.extend(&[0xF3, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); + buf.extend([0xF3, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } // `MOVSD xmm, m64` -> Load scalar double-precision floating-point value from m64 to xmm register. @@ -1984,12 +1984,12 @@ fn movsd_freg64_rip_offset32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, offset: let dst_mod = dst as u8 % 8; if dst as u8 > 7 { buf.reserve(9); - buf.extend(&[0xF2, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); + buf.extend([0xF2, 0x44, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); } else { buf.reserve(8); - buf.extend(&[0xF2, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); + buf.extend([0xF2, 0x0F, 0x10, 0x05 | (dst_mod << 3)]); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `MOVSD r/m64,xmm1` -> Move xmm1 to r/m64. where m64 references the base pointer. @@ -2009,12 +2009,12 @@ fn movsd_base64_offset32_freg64( if src as u8 > 7 || base as u8 > 7 { buf.push(rex); } - buf.extend(&[0x0F, 0x11, 0x80 | src_mod | base_mod]); + buf.extend([0x0F, 0x11, 0x80 | src_mod | base_mod]); // Using RSP or R12 requires a secondary index byte. if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { buf.push(0x24); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `MOVSD xmm1,r/m64` -> Move r/m64 to xmm1. where m64 references the base pointer. @@ -2034,12 +2034,12 @@ fn movsd_freg64_base64_offset32( if dst as u8 > 7 || base as u8 > 7 { buf.push(rex); } - buf.extend(&[0x0F, 0x10, 0x80 | dst_mod | base_mod]); + buf.extend([0x0F, 0x10, 0x80 | dst_mod | base_mod]); // Using RSP or R12 requires a secondary index byte. if base == X86_64GeneralReg::RSP || base == X86_64GeneralReg::R12 { buf.push(0x24); } - buf.extend(&offset.to_le_bytes()); + buf.extend(offset.to_le_bytes()); } /// `NEG r/m64` -> Two's complement negate r/m64. @@ -2047,7 +2047,7 @@ fn movsd_freg64_base64_offset32( fn neg_reg64(buf: &mut Vec<'_, u8>, reg: X86_64GeneralReg) { let rex = add_rm_extension(reg, REX_W); let reg_mod = reg as u8 % 8; - buf.extend(&[rex, 0xF7, 0xD8 | reg_mod]); + buf.extend([rex, 0xF7, 0xD8 | reg_mod]); } // helper function for `set*` instructions @@ -2060,10 +2060,10 @@ fn set_reg64_help(op_code: u8, buf: &mut Vec<'_, u8>, reg: X86_64GeneralReg) { let reg_mod = reg as u8 % 8; use X86_64GeneralReg::*; match reg { - RAX | RCX | RDX | RBX => buf.extend(&[0x0F, op_code, 0xC0 | reg_mod]), - RSP | RBP | RSI | RDI => buf.extend(&[REX, 0x0F, op_code, 0xC0 | reg_mod]), + RAX | RCX | RDX | RBX => buf.extend([0x0F, op_code, 0xC0 | reg_mod]), + RSP | RBP | RSI | RDI => buf.extend([REX, 0x0F, op_code, 0xC0 | reg_mod]), R8 | R9 | R10 | R11 | R12 | R13 | R14 | R15 => { - buf.extend(&[REX | 1, 0x0F, op_code, 0xC0 | reg_mod]) + buf.extend([REX | 1, 0x0F, op_code, 0xC0 | reg_mod]) } } @@ -2085,7 +2085,7 @@ fn cvtsi2_help( let mod1 = (dst.value() % 8) << 3; let mod2 = src.value() % 8; - buf.extend(&[op_code1, rex, 0x0F, op_code2, 0xC0 | mod1 | mod2]) + buf.extend([op_code1, rex, 0x0F, op_code2, 0xC0 | mod1 | mod2]) } #[inline(always)] @@ -2099,7 +2099,7 @@ fn cvtsx2_help( let mod1 = (dst.value() % 8) << 3; let mod2 = src.value() % 8; - buf.extend(&[op_code1, 0x0F, op_code2, 0xC0 | mod1 | mod2]) + buf.extend([op_code1, 0x0F, op_code2, 0xC0 | mod1 | mod2]) } /// `SETE r/m64` -> Set Byte on Condition - zero/equal (ZF=1) @@ -2183,8 +2183,8 @@ fn sub_reg64_imm32(buf: &mut Vec<'_, u8>, dst: X86_64GeneralReg, imm: i32) { let rex = add_rm_extension(dst, REX_W); let dst_mod = dst as u8 % 8; buf.reserve(7); - buf.extend(&[rex, 0x81, 0xE8 | dst_mod]); - buf.extend(&imm.to_le_bytes()); + buf.extend([rex, 0x81, 0xE8 | dst_mod]); + buf.extend(imm.to_le_bytes()); } /// `SUB r/m64,r64` -> Sub r64 to r/m64. @@ -2199,7 +2199,7 @@ fn pop_reg64(buf: &mut Vec<'_, u8>, reg: X86_64GeneralReg) { let reg_mod = reg as u8 % 8; if reg as u8 > 7 { let rex = add_opcode_extension(reg, REX); - buf.extend(&[rex, 0x58 | reg_mod]); + buf.extend([rex, 0x58 | reg_mod]); } else { buf.push(0x58 | reg_mod); } @@ -2211,7 +2211,7 @@ fn push_reg64(buf: &mut Vec<'_, u8>, reg: X86_64GeneralReg) { let reg_mod = reg as u8 % 8; if reg as u8 > 7 { let rex = add_opcode_extension(reg, REX); - buf.extend(&[rex, 0x50 | reg_mod]); + buf.extend([rex, 0x50 | reg_mod]); } else { buf.push(0x50 | reg_mod); } diff --git a/crates/compiler/gen_dev/src/lib.rs b/crates/compiler/gen_dev/src/lib.rs index caef1c4ead..a8147cdab7 100644 --- a/crates/compiler/gen_dev/src/lib.rs +++ b/crates/compiler/gen_dev/src/lib.rs @@ -159,7 +159,7 @@ trait Backend<'a> { let module_id = env.module_id; let ident_ids = interns.all_ident_ids.get_mut(&module_id).unwrap(); - rc_proc_gen.expand_refcount_stmt(ident_ids, layout, modify, *following) + rc_proc_gen.expand_refcount_stmt(ident_ids, layout, modify, following) }; for spec in new_specializations.into_iter() { diff --git a/crates/compiler/gen_dev/src/object_builder.rs b/crates/compiler/gen_dev/src/object_builder.rs index 85cb925361..51b90f7735 100644 --- a/crates/compiler/gen_dev/src/object_builder.rs +++ b/crates/compiler/gen_dev/src/object_builder.rs @@ -421,7 +421,7 @@ fn build_proc<'a, B: Backend<'a>>( } Relocation::LinkedFunction { offset, name } => { // If the symbol is an undefined roc function, we need to add it here. - if output.symbol_id(name.as_bytes()) == None && name.starts_with("roc_") { + if output.symbol_id(name.as_bytes()).is_none() && name.starts_with("roc_") { let builtin_symbol = Symbol { name: name.as_bytes().to_vec(), value: 0, @@ -435,7 +435,7 @@ fn build_proc<'a, B: Backend<'a>>( output.add_symbol(builtin_symbol); } // If the symbol is an undefined reference counting procedure, we need to add it here. - if output.symbol_id(name.as_bytes()) == None { + if output.symbol_id(name.as_bytes()).is_none() { for (sym, rc_name) in rc_proc_names.iter() { if name == rc_name { let section_id = output.add_section( diff --git a/crates/compiler/gen_llvm/src/llvm/bitcode.rs b/crates/compiler/gen_llvm/src/llvm/bitcode.rs index 686fa688bf..21183dae66 100644 --- a/crates/compiler/gen_llvm/src/llvm/bitcode.rs +++ b/crates/compiler/gen_llvm/src/llvm/bitcode.rs @@ -411,16 +411,16 @@ fn build_rc_wrapper<'a, 'ctx, 'env>( match rc_operation { Mode::Inc => { let n = 1; - increment_refcount_layout(env, function_value, layout_ids, n, value, layout); + increment_refcount_layout(env, layout_ids, n, value, layout); } Mode::IncN => { let n = it.next().unwrap().into_int_value(); n.set_name(Symbol::ARG_2.as_str(&env.interns)); - increment_n_refcount_layout(env, function_value, layout_ids, n, value, layout); + increment_n_refcount_layout(env, layout_ids, n, value, layout); } Mode::Dec => { - decrement_refcount_layout(env, function_value, layout_ids, value, layout); + decrement_refcount_layout(env, layout_ids, value, layout); } } diff --git a/crates/compiler/gen_llvm/src/llvm/build.rs b/crates/compiler/gen_llvm/src/llvm/build.rs index 73126c90b1..9a6ffcfc3c 100644 --- a/crates/compiler/gen_llvm/src/llvm/build.rs +++ b/crates/compiler/gen_llvm/src/llvm/build.rs @@ -126,7 +126,7 @@ impl<'ctx> Iterator for FunctionIterator<'ctx> { } } -#[derive(Default, Debug, Clone, PartialEq)] +#[derive(Default, Debug, Clone, PartialEq, Eq)] pub struct Scope<'a, 'ctx> { symbols: ImMap, BasicValueEnum<'ctx>)>, pub top_level_thunks: ImMap, FunctionValue<'ctx>)>, @@ -973,7 +973,7 @@ pub fn build_exp_literal<'a, 'ctx, 'env>( _ => unreachable!("incorrect small_str_bytes"), } } else { - let ptr = define_global_str_literal_ptr(env, *str_literal); + let ptr = define_global_str_literal_ptr(env, str_literal); let number_of_elements = env.ptr_int().const_int(str_literal.len() as u64, false); let alloca = @@ -2723,14 +2723,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>( let layout = *layout; if layout.contains_refcounted(env.layout_interner) { - increment_refcount_layout( - env, - parent, - layout_ids, - *inc_amount, - value, - &layout, - ); + increment_refcount_layout(env, layout_ids, *inc_amount, value, &layout); } build_exp_stmt(env, layout_ids, func_spec_solutions, scope, parent, cont) @@ -2739,7 +2732,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>( let (value, layout) = load_symbol_and_layout(scope, symbol); if layout.contains_refcounted(env.layout_interner) { - decrement_refcount_layout(env, parent, layout_ids, value, layout); + decrement_refcount_layout(env, layout_ids, value, layout); } build_exp_stmt(env, layout_ids, func_spec_solutions, scope, parent, cont) @@ -3847,12 +3840,9 @@ fn expose_function_to_host_help_c_abi_v2<'a, 'ctx, 'env>( arg_type.into_pointer_type().get_element_type(), ); // C return pointer goes at the beginning of params, and we must skip it if it exists. - let param_index = (i - + (if matches!(cc_return, CCReturn::ByPointer) { - 1 - } else { - 0 - })) as u32; + let returns_pointer = matches!(cc_return, CCReturn::ByPointer); + let param_index = i as u32 + returns_pointer as u32; + c_function.add_attribute(AttributeLoc::Param(param_index), byval); c_function.add_attribute(AttributeLoc::Param(param_index), nonnull); } @@ -4554,7 +4544,7 @@ fn build_procedures_help<'a, 'ctx, 'env>( fn_val.print_to_stderr(); if let Some(app_ll_file) = debug_output_file { - env.module.print_to_file(&app_ll_file).unwrap(); + env.module.print_to_file(app_ll_file).unwrap(); panic!( r"😱 LLVM errors when defining function {:?}; I wrote the full LLVM IR to {:?}", @@ -6209,14 +6199,7 @@ fn run_low_level<'a, 'ctx, 'env>( let element_layout = list_element_layout!(list_layout); - list_get_unsafe( - env, - layout_ids, - parent, - element_layout, - elem_index, - wrapper_struct, - ) + list_get_unsafe(env, layout_ids, element_layout, elem_index, wrapper_struct) } ListReplaceUnsafe => { let list = load_symbol(scope, &args[0]); diff --git a/crates/compiler/gen_llvm/src/llvm/build_list.rs b/crates/compiler/gen_llvm/src/llvm/build_list.rs index e2dccc7593..c8fd1f425a 100644 --- a/crates/compiler/gen_llvm/src/llvm/build_list.rs +++ b/crates/compiler/gen_llvm/src/llvm/build_list.rs @@ -121,7 +121,6 @@ pub(crate) fn list_with_capacity<'a, 'ctx, 'env>( pub(crate) fn list_get_unsafe<'a, 'ctx, 'env>( env: &Env<'a, 'ctx, 'env>, layout_ids: &mut LayoutIds<'a>, - parent: FunctionValue<'ctx>, element_layout: &Layout<'a>, elem_index: IntValue<'ctx>, wrapper_struct: StructValue<'ctx>, @@ -140,7 +139,7 @@ pub(crate) fn list_get_unsafe<'a, 'ctx, 'env>( let result = load_roc_value(env, *element_layout, elem_ptr, "list_get_load_element"); - increment_refcount_layout(env, parent, layout_ids, 1, result, element_layout); + increment_refcount_layout(env, layout_ids, 1, result, element_layout); result } diff --git a/crates/compiler/gen_llvm/src/llvm/refcounting.rs b/crates/compiler/gen_llvm/src/llvm/refcounting.rs index 25cbea9e1c..467110004b 100644 --- a/crates/compiler/gen_llvm/src/llvm/refcounting.rs +++ b/crates/compiler/gen_llvm/src/llvm/refcounting.rs @@ -327,8 +327,6 @@ fn modify_refcount_struct_help<'a, 'ctx, 'env>( arg_val.set_name(arg_symbol.as_str(&env.interns)); - let parent = fn_val; - let wrapper_struct = arg_val.into_struct_value(); for (i, field_layout) in layouts.iter().enumerate() { @@ -347,7 +345,6 @@ fn modify_refcount_struct_help<'a, 'ctx, 'env>( modify_refcount_layout_help( env, - parent, layout_ids, mode.to_call_mode(fn_val), when_recursive, @@ -362,42 +359,32 @@ fn modify_refcount_struct_help<'a, 'ctx, 'env>( pub fn increment_refcount_layout<'a, 'ctx, 'env>( env: &Env<'a, 'ctx, 'env>, - parent: FunctionValue<'ctx>, layout_ids: &mut LayoutIds<'a>, inc_amount: u64, value: BasicValueEnum<'ctx>, layout: &Layout<'a>, ) { let amount = env.ptr_int().const_int(inc_amount, false); - increment_n_refcount_layout(env, parent, layout_ids, amount, value, layout); + increment_n_refcount_layout(env, layout_ids, amount, value, layout); } pub fn increment_n_refcount_layout<'a, 'ctx, 'env>( env: &Env<'a, 'ctx, 'env>, - parent: FunctionValue<'ctx>, layout_ids: &mut LayoutIds<'a>, amount: IntValue<'ctx>, value: BasicValueEnum<'ctx>, layout: &Layout<'a>, ) { - modify_refcount_layout( - env, - parent, - layout_ids, - CallMode::Inc(amount), - value, - layout, - ); + modify_refcount_layout(env, layout_ids, CallMode::Inc(amount), value, layout); } pub fn decrement_refcount_layout<'a, 'ctx, 'env>( env: &Env<'a, 'ctx, 'env>, - parent: FunctionValue<'ctx>, layout_ids: &mut LayoutIds<'a>, value: BasicValueEnum<'ctx>, layout: &Layout<'a>, ) { - modify_refcount_layout(env, parent, layout_ids, CallMode::Dec, value, layout); + modify_refcount_layout(env, layout_ids, CallMode::Dec, value, layout); } fn modify_refcount_builtin<'a, 'ctx, 'env>( @@ -435,7 +422,6 @@ fn modify_refcount_builtin<'a, 'ctx, 'env>( fn modify_refcount_layout<'a, 'ctx, 'env>( env: &Env<'a, 'ctx, 'env>, - parent: FunctionValue<'ctx>, layout_ids: &mut LayoutIds<'a>, call_mode: CallMode<'ctx>, value: BasicValueEnum<'ctx>, @@ -443,7 +429,6 @@ fn modify_refcount_layout<'a, 'ctx, 'env>( ) { modify_refcount_layout_help( env, - parent, layout_ids, call_mode, &WhenRecursive::Unreachable, @@ -460,7 +445,6 @@ enum WhenRecursive<'a> { fn modify_refcount_layout_help<'a, 'ctx, 'env>( env: &Env<'a, 'ctx, 'env>, - parent: FunctionValue<'ctx>, layout_ids: &mut LayoutIds<'a>, call_mode: CallMode<'ctx>, when_recursive: &WhenRecursive<'a>, @@ -474,7 +458,6 @@ fn modify_refcount_layout_help<'a, 'ctx, 'env>( let function = match modify_refcount_layout_build_function( env, - parent, layout_ids, mode, when_recursive, @@ -538,7 +521,6 @@ fn call_help<'a, 'ctx, 'env>( fn modify_refcount_layout_build_function<'a, 'ctx, 'env>( env: &Env<'a, 'ctx, 'env>, - parent: FunctionValue<'ctx>, layout_ids: &mut LayoutIds<'a>, mode: Mode, when_recursive: &WhenRecursive<'a>, @@ -603,7 +585,6 @@ fn modify_refcount_layout_build_function<'a, 'ctx, 'env>( let function = modify_refcount_layout_build_function( env, - parent, layout_ids, mode, when_recursive, @@ -615,7 +596,6 @@ fn modify_refcount_layout_build_function<'a, 'ctx, 'env>( }, LambdaSet(lambda_set) => modify_refcount_layout_build_function( env, - parent, layout_ids, mode, when_recursive, @@ -731,7 +711,6 @@ fn modify_refcount_list_help<'a, 'ctx, 'env>( let loop_fn = |_index, element| { modify_refcount_layout_help( env, - parent, layout_ids, mode.to_call_mode(fn_val), when_recursive, @@ -1302,7 +1281,6 @@ fn build_rec_union_recursive_decrement<'a, 'ctx, 'env>( for (field, field_layout) in deferred_nonrec { modify_refcount_layout_help( env, - parent, layout_ids, mode.to_call_mode(decrement_fn), when_recursive, @@ -1366,7 +1344,7 @@ fn union_layout_tags<'a>( match union_layout { NullableWrapped { other_tags: tags, .. - } => *tags, + } => tags, NullableUnwrapped { other_fields, .. } => arena.alloc([*other_fields]), NonNullableUnwrapped(fields) => arena.alloc([*fields]), Recursive(tags) => tags, @@ -1687,7 +1665,6 @@ fn modify_refcount_union_help<'a, 'ctx, 'env>( modify_refcount_layout_help( env, - parent, layout_ids, mode.to_call_mode(fn_val), when_recursive, @@ -1709,7 +1686,6 @@ fn modify_refcount_union_help<'a, 'ctx, 'env>( modify_refcount_layout_help( env, - parent, layout_ids, mode.to_call_mode(fn_val), when_recursive, diff --git a/crates/compiler/gen_wasm/src/backend.rs b/crates/compiler/gen_wasm/src/backend.rs index 1b8b26f3d7..53f6a48981 100644 --- a/crates/compiler/gen_wasm/src/backend.rs +++ b/crates/compiler/gen_wasm/src/backend.rs @@ -1237,7 +1237,7 @@ impl<'a> WasmBackend<'a> { } CallType::HigherOrder(higher_order_lowlevel) => { - call_higher_order_lowlevel(self, ret_sym, ret_layout, *higher_order_lowlevel) + call_higher_order_lowlevel(self, ret_sym, ret_layout, higher_order_lowlevel) } CallType::Foreign { diff --git a/crates/compiler/gen_wasm/src/wasm_module/code_builder.rs b/crates/compiler/gen_wasm/src/wasm_module/code_builder.rs index 5adb833a60..d4b1ef3c36 100644 --- a/crates/compiler/gen_wasm/src/wasm_module/code_builder.rs +++ b/crates/compiler/gen_wasm/src/wasm_module/code_builder.rs @@ -69,7 +69,7 @@ impl std::fmt::Debug for VmBlock<'_> { /// Rust representation matches Wasm encoding. /// It's an error to specify alignment higher than the "natural" alignment of the instruction #[repr(u8)] -#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd)] pub enum Align { Bytes1 = 0, Bytes2 = 1, @@ -111,7 +111,7 @@ impl From for Align { } } -#[derive(Debug, Clone, PartialEq, Copy)] +#[derive(Debug, Clone, PartialEq, Eq, Copy)] pub enum VmSymbolState { /// Value doesn't exist yet NotYetPushed, diff --git a/crates/compiler/gen_wasm/src/wasm_module/sections.rs b/crates/compiler/gen_wasm/src/wasm_module/sections.rs index dfb69bc7dd..705fd1442d 100644 --- a/crates/compiler/gen_wasm/src/wasm_module/sections.rs +++ b/crates/compiler/gen_wasm/src/wasm_module/sections.rs @@ -303,7 +303,7 @@ impl<'a> Serialize for TypeSection<'a> { * *******************************************************************/ -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum ImportDesc { Func { signature_index: u32 }, Table { ty: TableType }, @@ -359,7 +359,7 @@ impl Serialize for ImportDesc { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct Import<'a> { pub module: &'a str, pub name: &'a str, @@ -551,7 +551,7 @@ impl Parse<()> for RefType { } } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct TableType { pub ref_type: RefType, pub limits: Limits, @@ -659,7 +659,7 @@ impl Serialize for TableSection { * *******************************************************************/ -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Limits { Min(u32), MinMax(u32, u32), @@ -749,7 +749,7 @@ section_impl!(MemorySection, SectionId::Memory); * *******************************************************************/ -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct GlobalType { pub value_type: ValueType, pub is_mutable: bool, diff --git a/crates/compiler/load/build.rs b/crates/compiler/load/build.rs index 204f6af893..e13232efc8 100644 --- a/crates/compiler/load/build.rs +++ b/crates/compiler/load/build.rs @@ -44,7 +44,7 @@ fn write_subs_for_module(module_id: ModuleId, filename: &str) { println!("cargo:rerun-if-changed={}", filepath.to_str().unwrap()); let mut output_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()); - output_path.extend(&[filename]); + output_path.extend([filename]); output_path.set_extension("dat"); #[cfg(not(windows))] @@ -64,7 +64,7 @@ fn write_subs_for_module(module_id: ModuleId, filename: &str) { fn write_types_for_module_dummy(output_path: &Path) { // write out a dummy file - std::fs::write(output_path, &[]).unwrap(); + std::fs::write(output_path, []).unwrap(); } #[cfg(not(windows))] @@ -107,7 +107,7 @@ fn write_types_for_module_real(module_id: ModuleId, filename: &str, output_path: let abilities = module.abilities_store; let solved_implementations = module.resolved_implementations; - let mut file = std::fs::File::create(&output_path).unwrap(); + let mut file = std::fs::File::create(output_path).unwrap(); let type_state = TypeState { subs, diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index 31d280dca7..9bbf5c37d1 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -3100,7 +3100,7 @@ fn load_platform_module<'a>( ) -> Result, LoadingProblem<'a>> { let module_start_time = Instant::now(); let file_io_start = Instant::now(); - let file = fs::read(&filename); + let file = fs::read(filename); let file_io_duration = file_io_start.elapsed(); match file { diff --git a/crates/compiler/module/src/called_via.rs b/crates/compiler/module/src/called_via.rs index bc314e0eec..17017a1917 100644 --- a/crates/compiler/module/src/called_via.rs +++ b/crates/compiler/module/src/called_via.rs @@ -70,7 +70,7 @@ pub enum ArgSide { Right, } -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Associativity { /// left-associative operators: /// diff --git a/crates/compiler/module/src/symbol.rs b/crates/compiler/module/src/symbol.rs index f01026f0e3..e373557750 100644 --- a/crates/compiler/module/src/symbol.rs +++ b/crates/compiler/module/src/symbol.rs @@ -44,7 +44,7 @@ const SYMBOL_HAS_NICHE: () = // register_debug_idents calls (which should be made in debug mode). // Set it to false if you want to see the raw ModuleId and IdentId ints, // but please set it back to true before checking in the result! -#[cfg(debug_assertions)] +#[cfg(any(debug_assertions, feature = "debug-symbols"))] const PRETTY_PRINT_DEBUG_SYMBOLS: bool = true; pub const DERIVABLE_ABILITIES: &[(Symbol, &[Symbol])] = &[ @@ -183,7 +183,7 @@ impl Symbol { /// /// `Foo.bar` impl fmt::Debug for Symbol { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, feature = "debug-symbols"))] #[allow(clippy::print_in_format_impl)] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if PRETTY_PRINT_DEBUG_SYMBOLS { @@ -216,7 +216,7 @@ impl fmt::Debug for Symbol { } } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, feature = "debug-symbols")))] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fallback_debug_fmt(*self, f) } @@ -256,7 +256,7 @@ fn fallback_debug_fmt(symbol: Symbol, f: &mut fmt::Formatter) -> fmt::Result { // end up using it in release builds anyway. Right? ...Right? lazy_static! {} -#[cfg(debug_assertions)] +#[cfg(any(debug_assertions, feature = "debug-symbols"))] lazy_static! { /// This is used in Debug builds only, to let us have a Debug instance /// which displays not only the Module ID, but also the Module Name which @@ -399,7 +399,7 @@ impl fmt::Debug for ModuleId { /// needs a global mutex, so we don't do this in release builds. This means /// the Debug impl in release builds only shows the number, not the name (which /// it does not have available, due to having never stored it in the mutexed intern table.) - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, feature = "debug-symbols"))] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // Originally, this printed both name and numeric ID, but the numeric ID // didn't seem to add anything useful. Feel free to temporarily re-add it @@ -425,7 +425,7 @@ impl fmt::Debug for ModuleId { } /// In release builds, all we have access to is the number, so only display that. - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, feature = "debug-symbols")))] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.0.fmt(f) } @@ -470,7 +470,7 @@ impl<'a> PackageModuleIds<'a> { // didn't find it, so we'll add it let module_id = ModuleId::from_zero_indexed(self.by_id.len()); self.by_id.push(module_name.clone()); - if cfg!(debug_assertions) { + if cfg!(any(debug_assertions, feature = "debug-symbols")) { Self::insert_debug_name(module_id, module_name); } @@ -487,7 +487,7 @@ impl<'a> PackageModuleIds<'a> { ModuleIds { by_id } } - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, feature = "debug-symbols"))] fn insert_debug_name(module_id: ModuleId, module_name: &PQModuleName) { let mut names = DEBUG_MODULE_ID_NAMES.lock().expect("Failed to acquire lock for Debug interning into DEBUG_MODULE_ID_NAMES, presumably because a thread panicked."); @@ -503,7 +503,7 @@ impl<'a> PackageModuleIds<'a> { } } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, feature = "debug-symbols")))] fn insert_debug_name(_module_id: ModuleId, _module_name: &PQModuleName) { // By design, this is a no-op in release builds! } @@ -557,14 +557,14 @@ impl ModuleIds { // didn't find it, so we'll add it let module_id = ModuleId::from_zero_indexed(self.by_id.len()); self.by_id.push(module_name.clone()); - if cfg!(debug_assertions) { + if cfg!(any(debug_assertions, feature = "debug-symbols")) { Self::insert_debug_name(module_id, module_name); } module_id } - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, feature = "debug-symbols"))] fn insert_debug_name(module_id: ModuleId, module_name: &ModuleName) { let mut names = DEBUG_MODULE_ID_NAMES.lock().expect("Failed to acquire lock for Debug interning into DEBUG_MODULE_ID_NAMES, presumably because a thread panicked."); @@ -574,7 +574,7 @@ impl ModuleIds { } } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, feature = "debug-symbols")))] fn insert_debug_name(_module_id: ModuleId, _module_name: &ModuleName) { // By design, this is a no-op in release builds! } @@ -868,7 +868,7 @@ macro_rules! define_builtins { IdentIds{ interner } }; - if cfg!(debug_assertions) { + if cfg!(any(debug_assertions, feature = "debug-symbols")) { let name = PQModuleName::Unqualified($module_name.into()); PackageModuleIds::insert_debug_name(module_id, &name); module_id.register_debug_idents(&ident_ids); @@ -910,7 +910,7 @@ macro_rules! define_builtins { let mut insert_both = |id: ModuleId, name_str: &'static str| { let name: ModuleName = name_str.into(); - if cfg!(debug_assertions) { + if cfg!(any(debug_assertions, feature = "debug-symbols")) { Self::insert_debug_name(id, &name); } @@ -936,7 +936,7 @@ macro_rules! define_builtins { let raw_name: IdentStr = name_str.into(); let name = PQModuleName::Unqualified(raw_name.into()); - if cfg!(debug_assertions) { + if cfg!(any(debug_assertions, feature = "debug-symbols")) { Self::insert_debug_name(id, &name); } diff --git a/crates/compiler/mono/src/code_gen_help/mod.rs b/crates/compiler/mono/src/code_gen_help/mod.rs index a9532aed88..07a27df060 100644 --- a/crates/compiler/mono/src/code_gen_help/mod.rs +++ b/crates/compiler/mono/src/code_gen_help/mod.rs @@ -471,7 +471,7 @@ impl<'a> CodeGenHelp<'a> { ) -> (bool, Vec<'a, Option>) { use UnionLayout::*; match union { - NonRecursive(_) => return (false, bumpalo::vec![in self.arena]), + NonRecursive(_) => (false, bumpalo::vec![in self.arena]), Recursive(tags) => self.union_tail_recursion_fields_help(tags), diff --git a/crates/compiler/mono/src/ir.rs b/crates/compiler/mono/src/ir.rs index 0dfdf0cdf8..98face2034 100644 --- a/crates/compiler/mono/src/ir.rs +++ b/crates/compiler/mono/src/ir.rs @@ -284,7 +284,7 @@ impl AbilityAliases { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum CapturedSymbols<'a> { None, Captured(&'a [(Symbol, Variable)]), @@ -317,7 +317,7 @@ pub struct Proc<'a> { pub host_exposed_layouts: HostExposedLayouts<'a>, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum HostExposedLayouts<'a> { NotHostExposed, HostExposed { @@ -326,13 +326,13 @@ pub enum HostExposedLayouts<'a> { }, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum SelfRecursive { NotSelfRecursive, SelfRecursive(JoinPointId), } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Parens { NotNeeded, InTypeParam, @@ -1575,7 +1575,7 @@ impl<'a, 'i> Env<'a, 'i> { #[derive(Clone, Debug, PartialEq, Copy, Eq, Hash)] pub struct JoinPointId(pub Symbol); -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct Param<'a> { pub symbol: Symbol, pub borrow: bool, @@ -1659,7 +1659,7 @@ pub enum Stmt<'a> { } /// in the block below, symbol `scrutinee` is assumed be be of shape `tag_id` -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum BranchInfo<'a> { None, Constructor { @@ -1702,7 +1702,7 @@ impl<'a> BranchInfo<'a> { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum ModifyRc { /// Increment a reference count Inc(Symbol, u64), @@ -1848,7 +1848,7 @@ impl<'a> Call<'a> { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct CallSpecId { id: u32, } @@ -1863,7 +1863,7 @@ impl CallSpecId { pub const BACKEND_DUMMY: Self = Self { id: 0 }; } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct UpdateModeId { id: u32, } @@ -1878,7 +1878,7 @@ impl UpdateModeId { pub const BACKEND_DUMMY: Self = Self { id: 0 }; } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct UpdateModeIds { next: u32, } @@ -1895,7 +1895,7 @@ impl UpdateModeIds { } } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum CallType<'a> { ByName { name: LambdaName<'a>, @@ -1914,7 +1914,7 @@ pub enum CallType<'a> { HigherOrder(&'a HigherOrderLowLevel<'a>), } -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct PassedFunction<'a> { /// name of the top-level function that is passed as an argument /// e.g. in `List.map xs Num.abs` this would be `Num.abs` @@ -1931,7 +1931,7 @@ pub struct PassedFunction<'a> { pub owns_captured_environment: bool, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct HigherOrderLowLevel<'a> { pub op: crate::low_level::HigherOrder, @@ -7009,7 +7009,7 @@ fn substitute_in_call<'a>( } => substitute(subs, name.name()).map(|new| CallType::ByName { name: name.replace_name(new), arg_layouts, - ret_layout: *ret_layout, + ret_layout, specialization_id: *specialization_id, }), CallType::Foreign { .. } => None, @@ -7158,7 +7158,7 @@ fn substitute_in_expr<'a>( } => match substitute(subs, *structure) { Some(structure) => Some(StructAtIndex { index: *index, - field_layouts: *field_layouts, + field_layouts, structure, }), None => None, diff --git a/crates/compiler/mono/src/low_level.rs b/crates/compiler/mono/src/low_level.rs index 3856e95ba9..ddad554c81 100644 --- a/crates/compiler/mono/src/low_level.rs +++ b/crates/compiler/mono/src/low_level.rs @@ -1,6 +1,6 @@ use roc_module::symbol::Symbol; -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum HigherOrder { ListMap { xs: Symbol, diff --git a/crates/compiler/mono/src/reset_reuse.rs b/crates/compiler/mono/src/reset_reuse.rs index feec4fe8e4..6b2447c250 100644 --- a/crates/compiler/mono/src/reset_reuse.rs +++ b/crates/compiler/mono/src/reset_reuse.rs @@ -128,7 +128,7 @@ fn function_s<'a, 'i>( remainder, } => { let id = *id; - let body: &Stmt = *body; + let body: &Stmt = body; let new_body = function_s(env, w, c, body); let new_join = if std::ptr::eq(body, new_body) || body == new_body { @@ -179,7 +179,7 @@ fn function_s<'a, 'i>( arena.alloc(new_switch) } Refcounting(op, continuation) => { - let continuation: &Stmt = *continuation; + let continuation: &Stmt = continuation; let new_continuation = function_s(env, w, c, continuation); if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation { @@ -198,7 +198,7 @@ fn function_s<'a, 'i>( layouts, remainder, } => { - let continuation: &Stmt = *remainder; + let continuation: &Stmt = remainder; let new_continuation = function_s(env, w, c, continuation); if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation { @@ -223,7 +223,7 @@ fn function_s<'a, 'i>( layouts, remainder, } => { - let continuation: &Stmt = *remainder; + let continuation: &Stmt = remainder; let new_continuation = function_s(env, w, c, continuation); if std::ptr::eq(continuation, new_continuation) || continuation == new_continuation { diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index 16ce506c3d..1ec6995a8f 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -109,7 +109,7 @@ pub enum StrSegment<'a> { Interpolated(Loc<&'a Expr<'a>>), // e.g. (name) in "Hi, \(name)!" } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum EscapedChar { Newline, // \n Tab, // \t @@ -581,7 +581,7 @@ pub enum AssignedField<'a, Val> { Malformed(&'a str), } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum CommentOrNewline<'a> { Newline, LineComment(&'a str), @@ -880,7 +880,7 @@ impl<'a, T> Collection<'a, T> { pub fn final_comments(&self) -> &'a [CommentOrNewline<'a>] { if let Some(final_comments) = self.final_comments { - *final_comments + final_comments } else { &[] } diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 757af05a69..8f181c2833 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -346,6 +346,7 @@ fn parse_expr_start<'a>( loc!(move |a, s, m| parse_expr_operator_chain(m, options, a, s)), fail_expr_start_e() ] + .trace("expr_start") .parse(arena, state, min_indent) } @@ -546,7 +547,7 @@ fn numeric_negate_expression<'a, T>( expr: Loc>, spaces: &'a [CommentOrNewline<'a>], ) -> Loc> { - debug_assert_eq!(state.bytes().get(0), Some(&b'-')); + debug_assert_eq!(state.bytes().first(), Some(&b'-')); // for overflow reasons, we must make the unary minus part of the number literal. let start = state.pos(); let region = Region::new(start, expr.region.end()); @@ -941,7 +942,7 @@ fn parse_defs_end<'a>( ann_type: arena.alloc(*ann_type), comment, body_pattern: arena.alloc(loc_pattern), - body_expr: *arena.alloc(loc_def_expr), + body_expr: arena.alloc(loc_def_expr), }; let region = @@ -980,7 +981,7 @@ fn parse_defs_end<'a>( ann_type: arena.alloc(*ann_type), comment, body_pattern: arena.alloc(loc_pattern), - body_expr: *arena.alloc(loc_def_expr), + body_expr: arena.alloc(loc_def_expr), }; let region = @@ -1904,7 +1905,7 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result Err(()), Expr::Str(string) => Ok(Pattern::StrLiteral(*string)), - Expr::SingleQuote(string) => Ok(Pattern::SingleQuote(*string)), + Expr::SingleQuote(string) => Ok(Pattern::SingleQuote(string)), Expr::MalformedIdent(string, _problem) => Ok(Pattern::Malformed(string)), } } @@ -2076,10 +2077,10 @@ mod when { parser::keyword_e(keyword::IS, EWhen::Is) ) ), - move |arena, state, progress, (case_indent, loc_condition), min_indent| { + move |arena, state, _progress, (case_indent, loc_condition), min_indent| { if case_indent < min_indent { return Err(( - progress, + MadeProgress, // TODO maybe pass case_indent here? EWhen::PatternAlignment(5, state.pos()), state, @@ -2089,15 +2090,18 @@ mod when { // Everything in the branches must be indented at least as much as the case itself. let min_indent = case_indent; - let (p1, branches, state) = branches(options).parse(arena, state, min_indent)?; + let (_p1, branches, state) = branches(options) + .parse(arena, state, min_indent) + .map_err(|(_p, e, s)| (MadeProgress, e, s))?; Ok(( - progress.or(p1), + MadeProgress, Expr::When(arena.alloc(loc_condition), branches.into_bump_slice()), state, )) }, ) + .trace("when") } /// Parsing when with indentation. diff --git a/crates/compiler/parse/src/header.rs b/crates/compiler/parse/src/header.rs index 4fd3266e65..8c09f2daf1 100644 --- a/crates/compiler/parse/src/header.rs +++ b/crates/compiler/parse/src/header.rs @@ -52,7 +52,7 @@ pub enum VersionComparison { DisallowsEqual, } -#[derive(Copy, Clone, PartialEq, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct PackageName<'a>(&'a str); impl<'a> PackageName<'a> { @@ -160,7 +160,7 @@ pub struct HostedHeader<'a> { pub after_with: &'a [CommentOrNewline<'a>], } -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum To<'a> { ExistingPackage(&'a str), NewPackage(PackageName<'a>), @@ -262,7 +262,7 @@ pub struct TypedIdent<'a> { pub ann: Loc>, } -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct PackageEntry<'a> { pub shorthand: &'a str, pub spaces_after_shorthand: &'a [CommentOrNewline<'a>], diff --git a/crates/compiler/parse/src/parser.rs b/crates/compiler/parse/src/parser.rs index bd00602b9a..328d4b3b0a 100644 --- a/crates/compiler/parse/src/parser.rs +++ b/crates/compiler/parse/src/parser.rs @@ -737,6 +737,7 @@ pub trait Parser<'a, Output, Error> { ) -> ParseResult<'a, Output, Error>; #[cfg(not(feature = "parse_debug_trace"))] + #[inline(always)] fn trace(self, _message: &'static str) -> Self where Self: Sized, @@ -789,7 +790,7 @@ impl<'a, O: std::fmt::Debug, E: std::fmt::Debug, P: Parser<'a, O, E>> Parser<'a, where E: 'a, { - fn parse(&self, arena: &'a Bump, state: State<'a>) -> ParseResult<'a, O, E> { + fn parse(&self, arena: &'a Bump, state: State<'a>, min_indent: u32) -> ParseResult<'a, O, E> { use std::cell::RefCell; thread_local! { @@ -803,7 +804,7 @@ where let cur_indent = INDENT.with(|i| *i.borrow()); println!( - "{:>5?}: {}{:<50}", + "{:<5?}: {}{:<50}", state.pos(), &indent_text[..cur_indent * 2], self.message @@ -1379,11 +1380,12 @@ macro_rules! and { macro_rules! one_of { ($p1:expr, $p2:expr) => { move |arena: &'a bumpalo::Bump, state: $crate::state::State<'a>, min_indent: u32| { + let original_state = state.clone(); match $p1.parse(arena, state, min_indent) { valid @ Ok(_) => valid, Err((MadeProgress, fail, state)) => Err((MadeProgress, fail, state)), - Err((NoProgress, _, state)) => $p2.parse(arena, state, min_indent), + Err((NoProgress, _, _)) => $p2.parse(arena, original_state, min_indent), } } }; diff --git a/crates/compiler/parse/src/string_literal.rs b/crates/compiler/parse/src/string_literal.rs index a0a957c2c0..dedff7ebc6 100644 --- a/crates/compiler/parse/src/string_literal.rs +++ b/crates/compiler/parse/src/string_literal.rs @@ -122,10 +122,7 @@ pub fn parse_single_quote<'a>() -> impl Parser<'a, &'a str, EString<'a>> { } } -fn consume_indent<'a>( - mut state: State<'a>, - mut indent: u32, -) -> Result, State<'a>)> { +fn consume_indent(mut state: State, mut indent: u32) -> Result { while indent > 0 { match state.bytes().first() { Some(b' ') => { diff --git a/crates/compiler/parse/tests/snapshots/fail/pattern_binds_keyword.expr.result-ast b/crates/compiler/parse/tests/snapshots/fail/pattern_binds_keyword.expr.result-ast new file mode 100644 index 0000000000..0843d5c707 --- /dev/null +++ b/crates/compiler/parse/tests/snapshots/fail/pattern_binds_keyword.expr.result-ast @@ -0,0 +1 @@ +Expr(When(Arrow(@24), @24), @0) \ No newline at end of file diff --git a/crates/compiler/parse/tests/snapshots/fail/pattern_binds_keyword.expr.roc b/crates/compiler/parse/tests/snapshots/fail/pattern_binds_keyword.expr.roc new file mode 100644 index 0000000000..e44e443eb0 --- /dev/null +++ b/crates/compiler/parse/tests/snapshots/fail/pattern_binds_keyword.expr.roc @@ -0,0 +1,6 @@ +when Just 4 is + Just when -> + 4 + + _ -> + 2 \ No newline at end of file diff --git a/crates/compiler/parse/tests/snapshots/fail/when_missing_arrow.expr.result-ast b/crates/compiler/parse/tests/snapshots/fail/when_missing_arrow.expr.result-ast new file mode 100644 index 0000000000..bd2fce1211 --- /dev/null +++ b/crates/compiler/parse/tests/snapshots/fail/when_missing_arrow.expr.result-ast @@ -0,0 +1 @@ +Expr(When(Arrow(@26), @20), @0) \ No newline at end of file diff --git a/crates/compiler/parse/tests/snapshots/fail/when_missing_arrow.expr.roc b/crates/compiler/parse/tests/snapshots/fail/when_missing_arrow.expr.roc new file mode 100644 index 0000000000..31fb667aa9 --- /dev/null +++ b/crates/compiler/parse/tests/snapshots/fail/when_missing_arrow.expr.roc @@ -0,0 +1,3 @@ +when 5 is + 1 -> 2 + _ \ No newline at end of file diff --git a/crates/compiler/parse/tests/test_parse.rs b/crates/compiler/parse/tests/test_parse.rs index 86c5123cc1..8b38116a26 100644 --- a/crates/compiler/parse/tests/test_parse.rs +++ b/crates/compiler/parse/tests/test_parse.rs @@ -124,6 +124,8 @@ mod test_parse { fail/lambda_missing_indent.expr, fail/type_argument_no_arrow.expr, fail/type_double_comma.expr, + fail/when_missing_arrow.expr, + fail/pattern_binds_keyword.expr, pass/ability_demand_signature_is_multiline.expr, pass/ability_multi_line.expr, pass/ability_single_line.expr, diff --git a/crates/compiler/problem/src/can.rs b/crates/compiler/problem/src/can.rs index 627b97a1ad..c97c78a075 100644 --- a/crates/compiler/problem/src/can.rs +++ b/crates/compiler/problem/src/can.rs @@ -7,19 +7,19 @@ use roc_parse::pattern::PatternType; use roc_region::all::{Loc, Region}; use roc_types::types::AliasKind; -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct CycleEntry { pub symbol: Symbol, pub symbol_region: Region, pub expr_region: Region, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum BadPattern { Unsupported(PatternType), } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum ShadowKind { Variable, Alias(Symbol), @@ -28,7 +28,7 @@ pub enum ShadowKind { } /// Problems that can occur in the course of canonicalization. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum Problem { UnusedDef(Symbol, Region), UnusedImport(Symbol, Region), @@ -190,13 +190,13 @@ pub enum Problem { }, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum ExtensionTypeKind { Record, TagUnion, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum PrecedenceProblem { BothNonAssociative(Region, Loc, Loc), } @@ -245,7 +245,7 @@ pub enum FloatErrorKind { IntSuffix, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum RuntimeError { Shadowing { original_region: Region, @@ -368,7 +368,7 @@ impl RuntimeError { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum MalformedPatternProblem { MalformedInt, MalformedFloat, diff --git a/crates/compiler/region/src/all.rs b/crates/compiler/region/src/all.rs index 3eed5060d5..457810cdf9 100644 --- a/crates/compiler/region/src/all.rs +++ b/crates/compiler/region/src/all.rs @@ -133,7 +133,8 @@ impl Position { impl Debug for Position { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "@{}", self.offset) + write!(f, "@")?; + self.offset.fmt(f) } } diff --git a/crates/compiler/solve/src/ability.rs b/crates/compiler/solve/src/ability.rs index 130dcf3447..fc85ba7b94 100644 --- a/crates/compiler/solve/src/ability.rs +++ b/crates/compiler/solve/src/ability.rs @@ -31,7 +31,7 @@ pub enum AbilityImplError { } /// Indexes a requested deriving of an ability for an opaque type. -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct RequestedDeriveKey { pub opaque: Symbol, pub ability: Symbol, diff --git a/crates/compiler/solve_problem/src/lib.rs b/crates/compiler/solve_problem/src/lib.rs index db2fe70177..3e618057cf 100644 --- a/crates/compiler/solve_problem/src/lib.rs +++ b/crates/compiler/solve_problem/src/lib.rs @@ -32,7 +32,7 @@ pub enum TypeError { }, } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum Unfulfilled { /// No claimed implementation of an ability for an opaque type. OpaqueDoesNotImplement { typ: Symbol, ability: Symbol }, @@ -52,7 +52,7 @@ pub enum Unfulfilled { }, } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum UnderivableReason { NotABuiltin, /// The surface type is not derivable @@ -61,7 +61,7 @@ pub enum UnderivableReason { NestedNotDerivable(ErrorType, NotDerivableContext), } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum NotDerivableContext { NoContext, Function, @@ -71,12 +71,12 @@ pub enum NotDerivableContext { Eq(NotDerivableEq), } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum NotDerivableDecode { OptionalRecordField(Lowercase), } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum NotDerivableEq { FloatingPoint, } diff --git a/crates/compiler/test_gen/src/helpers/llvm.rs b/crates/compiler/test_gen/src/helpers/llvm.rs index 896c050d72..70856acc73 100644 --- a/crates/compiler/test_gen/src/helpers/llvm.rs +++ b/crates/compiler/test_gen/src/helpers/llvm.rs @@ -341,11 +341,11 @@ fn annotate_with_debug_info<'ctx>( let app_bc_file = "/tmp/roc-debugir.bc"; // write the ll code to a file, so we can modify it - module.print_to_file(&app_ll_file).unwrap(); + module.print_to_file(app_ll_file).unwrap(); // run the debugir https://github.com/vaivaswatha/debugir tool match Command::new("debugir") - .args(&["-instnamer", app_ll_file]) + .args(["-instnamer", app_ll_file]) .output() { Ok(_) => {} @@ -361,11 +361,11 @@ fn annotate_with_debug_info<'ctx>( } Command::new("llvm-as") - .args(&[app_dbg_ll_file, "-o", app_bc_file]) + .args([app_dbg_ll_file, "-o", app_bc_file]) .output() .unwrap(); - inkwell::module::Module::parse_bitcode_from_path(&app_bc_file, context).unwrap() + inkwell::module::Module::parse_bitcode_from_path(app_bc_file, context).unwrap() } #[allow(dead_code)] @@ -459,7 +459,7 @@ fn llvm_module_to_wasm_file( let output = zig() .current_dir(dir_path) - .args(&[ + .args([ "wasm-ld", concat!(env!("OUT_DIR"), "/wasm_test_platform.wasm"), test_a_path.to_str().unwrap(), diff --git a/crates/compiler/test_mono/Cargo.toml b/crates/compiler/test_mono/Cargo.toml index 8b8c8c4261..dbde1764de 100644 --- a/crates/compiler/test_mono/Cargo.toml +++ b/crates/compiler/test_mono/Cargo.toml @@ -12,7 +12,7 @@ path = "src/tests.rs" [dev-dependencies] roc_collections = { path = "../collections" } -roc_module = { path = "../module" } +roc_module = { path = "../module", features = ["debug-symbols"] } roc_builtins = { path = "../builtins" } roc_load = { path = "../load" } roc_can = { path = "../can" } 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 d6a64cf200..5e5af921e0 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,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.380 : List {} = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.409 : List {} = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.380; + ret List.409; 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 2b758f2f1e..947e114ed7 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,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.380 : List [] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.409 : List [] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.380; + ret List.409; procedure Test.2 (Test.3): let Test.7 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/choose_i128_layout.txt b/crates/compiler/test_mono/generated/choose_i128_layout.txt index a8df0f6aeb..811ac35b19 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.258 : I128 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.258; + let Num.257 : I128 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.257; 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 cbed3ede38..acf76c6677 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.257 : U128 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : U128 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; 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 8f967decc8..7a88a19504 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.257 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; 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 6741c034f9..a5d2cfc8c8 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.380 : U64 = lowlevel ListLen #Attr.2; - ret List.380; + let List.409 : U64 = lowlevel ListLen #Attr.2; + ret List.409; procedure Test.1 (Test.5): let Test.2 : I64 = 41i64; diff --git a/crates/compiler/test_mono/generated/dict.txt b/crates/compiler/test_mono/generated/dict.txt index 8f4ea5f8b6..560247d7f4 100644 --- a/crates/compiler/test_mono/generated/dict.txt +++ b/crates/compiler/test_mono/generated/dict.txt @@ -1,14 +1,14 @@ procedure Dict.1 (): - let Dict.100 : List {[], []} = Array []; - ret Dict.100; + let Dict.318 : List {[], []} = Array []; + ret Dict.318; -procedure Dict.7 (Dict.94): - let Dict.99 : U64 = CallByName List.6 Dict.94; - ret Dict.99; +procedure Dict.7 (Dict.312): + let Dict.317 : U64 = CallByName List.6 Dict.312; + ret Dict.317; procedure List.6 (#Attr.2): - let List.380 : U64 = lowlevel ListLen #Attr.2; - ret List.380; + let List.409 : U64 = lowlevel ListLen #Attr.2; + ret List.409; procedure Test.0 (): let Test.2 : List {[], []} = CallByName Dict.1; 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 8b9698c414..50831ffd48 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 @@ -1,30 +1,30 @@ procedure Bool.1 (): - let Bool.11 : Int1 = false; - ret Bool.11; + let Bool.23 : Int1 = false; + ret Bool.23; -procedure List.2 (List.90, List.91): - let List.386 : U64 = CallByName List.6 List.90; - let List.382 : Int1 = CallByName Num.22 List.91 List.386; - if List.382 then - let List.384 : {} = CallByName List.66 List.90 List.91; - let List.383 : [C {}, C {}] = TagId(1) List.384; - ret List.383; +procedure List.2 (List.94, List.95): + let List.415 : U64 = CallByName List.6 List.94; + let List.411 : Int1 = CallByName Num.22 List.95 List.415; + if List.411 then + let List.413 : {} = CallByName List.66 List.94 List.95; + let List.412 : [C {}, C {}] = TagId(1) List.413; + ret List.412; else - let List.381 : {} = Struct {}; - let List.380 : [C {}, C {}] = TagId(0) List.381; - ret List.380; + let List.410 : {} = Struct {}; + let List.409 : [C {}, C {}] = TagId(0) List.410; + ret List.409; procedure List.6 (#Attr.2): - let List.387 : U64 = lowlevel ListLen #Attr.2; - ret List.387; + let List.416 : U64 = lowlevel ListLen #Attr.2; + ret List.416; procedure List.66 (#Attr.2, #Attr.3): - let List.385 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.385; + let List.414 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.414; procedure Num.22 (#Attr.2, #Attr.3): - let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.256; 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 5a72793ccf..d2c1a0d87a 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.101, List.102): - let List.383 : U64 = 1i64; - let List.381 : List U8 = CallByName List.70 List.101 List.383; - let List.380 : List U8 = CallByName List.71 List.381 List.102; - ret List.380; +procedure List.4 (List.105, List.106): + let List.412 : U64 = 1i64; + let List.410 : List U8 = CallByName List.70 List.105 List.412; + let List.409 : List U8 = CallByName List.71 List.410 List.106; + ret List.409; procedure List.70 (#Attr.2, #Attr.3): - let List.384 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.384; + let List.413 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.413; procedure List.71 (#Attr.2, #Attr.3): - let List.382 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.382; + let List.411 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.411; 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 6fa4d2ee16..069b904448 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 @@ -44,7 +44,7 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.106; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.113 : List U8 = CallByName Json.113 Encode.94 Encode.96 Encode.102; + let Encode.113 : List U8 = CallByName Json.112 Encode.94 Encode.96 Encode.102; ret Encode.113; procedure Encode.23 (Encode.94, Encode.102, Encode.96): @@ -52,11 +52,11 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.115; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.125 : List U8 = CallByName Json.113 Encode.94 Encode.96 Encode.102; + let Encode.125 : List U8 = CallByName Json.112 Encode.94 Encode.96 Encode.102; ret Encode.125; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.128 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; + let Encode.128 : List U8 = CallByName Json.96 Encode.94 Encode.96 Encode.102; ret Encode.128; procedure Encode.25 (Encode.100, Encode.101): @@ -66,284 +66,284 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.396 : {} = Struct {}; - ret Json.396; + let Json.394 : {} = Struct {}; + ret Json.394; -procedure Json.113 (Json.114, Json.399, Json.112): - let Json.432 : I32 = 123i64; - let Json.431 : U8 = CallByName Num.123 Json.432; - let Json.116 : List U8 = CallByName List.4 Json.114 Json.431; - let Json.430 : U64 = CallByName List.6 Json.112; - let Json.407 : {List U8, U64} = Struct {Json.116, Json.430}; - let Json.408 : {} = Struct {}; - let Json.406 : {List U8, U64} = CallByName List.18 Json.112 Json.407 Json.408; - dec Json.112; - let Json.118 : List U8 = StructAtIndex 0 Json.406; - inc Json.118; - dec Json.406; - let Json.405 : I32 = 125i64; - let Json.404 : U8 = CallByName Num.123 Json.405; - let Json.403 : List U8 = CallByName List.4 Json.118 Json.404; - ret Json.403; +procedure Json.112 (Json.113, Json.397, Json.111): + let Json.430 : I64 = 123i64; + let Json.429 : U8 = CallByName Num.125 Json.430; + let Json.115 : List U8 = CallByName List.4 Json.113 Json.429; + let Json.428 : U64 = CallByName List.6 Json.111; + let Json.405 : {List U8, U64} = Struct {Json.115, Json.428}; + let Json.406 : {} = Struct {}; + let Json.404 : {List U8, U64} = CallByName List.18 Json.111 Json.405 Json.406; + dec Json.111; + let Json.117 : List U8 = StructAtIndex 0 Json.404; + inc Json.117; + dec Json.404; + let Json.403 : I64 = 125i64; + let Json.402 : U8 = CallByName Num.125 Json.403; + let Json.401 : List U8 = CallByName List.4 Json.117 Json.402; + ret Json.401; -procedure Json.113 (Json.114, Json.399, Json.112): - let Json.472 : I32 = 123i64; - let Json.471 : U8 = CallByName Num.123 Json.472; - let Json.116 : List U8 = CallByName List.4 Json.114 Json.471; - let Json.470 : U64 = CallByName List.6 Json.112; - let Json.447 : {List U8, U64} = Struct {Json.116, Json.470}; - let Json.448 : {} = Struct {}; - let Json.446 : {List U8, U64} = CallByName List.18 Json.112 Json.447 Json.448; - dec Json.112; - let Json.118 : List U8 = StructAtIndex 0 Json.446; - inc Json.118; - dec Json.446; - let Json.445 : I32 = 125i64; - let Json.444 : U8 = CallByName Num.123 Json.445; - let Json.443 : List U8 = CallByName List.4 Json.118 Json.444; - ret Json.443; +procedure Json.112 (Json.113, Json.397, Json.111): + let Json.470 : I64 = 123i64; + let Json.469 : U8 = CallByName Num.125 Json.470; + let Json.115 : List U8 = CallByName List.4 Json.113 Json.469; + let Json.468 : U64 = CallByName List.6 Json.111; + let Json.445 : {List U8, U64} = Struct {Json.115, Json.468}; + let Json.446 : {} = Struct {}; + let Json.444 : {List U8, U64} = CallByName List.18 Json.111 Json.445 Json.446; + dec Json.111; + let Json.117 : List U8 = StructAtIndex 0 Json.444; + inc Json.117; + dec Json.444; + let Json.443 : I64 = 125i64; + let Json.442 : U8 = CallByName Num.125 Json.443; + let Json.441 : List U8 = CallByName List.4 Json.117 Json.442; + ret Json.441; -procedure Json.115 (Json.401, Json.402): - let Json.121 : Str = StructAtIndex 0 Json.402; +procedure Json.114 (Json.399, Json.400): + let Json.120 : Str = StructAtIndex 0 Json.400; + inc Json.120; + let Json.121 : Str = StructAtIndex 1 Json.400; inc Json.121; - let Json.122 : Str = StructAtIndex 1 Json.402; - inc Json.122; - dec Json.402; - let Json.119 : List U8 = StructAtIndex 0 Json.401; - inc Json.119; - let Json.120 : U64 = StructAtIndex 1 Json.401; - dec Json.401; - let Json.429 : I32 = 34i64; - let Json.428 : U8 = CallByName Num.123 Json.429; - let Json.426 : List U8 = CallByName List.4 Json.119 Json.428; - let Json.427 : List U8 = CallByName Str.12 Json.121; - let Json.423 : List U8 = CallByName List.8 Json.426 Json.427; - let Json.425 : I32 = 34i64; - let Json.424 : U8 = CallByName Num.123 Json.425; - let Json.420 : List U8 = CallByName List.4 Json.423 Json.424; - let Json.422 : I32 = 58i64; - let Json.421 : U8 = CallByName Num.123 Json.422; - let Json.418 : List U8 = CallByName List.4 Json.420 Json.421; - let Json.419 : {} = Struct {}; - let Json.123 : List U8 = CallByName Encode.23 Json.418 Json.122 Json.419; - joinpoint Json.413 Json.124: - let Json.411 : U64 = 1i64; - let Json.410 : U64 = CallByName Num.20 Json.120 Json.411; - let Json.409 : {List U8, U64} = Struct {Json.124, Json.410}; - ret Json.409; + dec Json.400; + let Json.118 : List U8 = StructAtIndex 0 Json.399; + inc Json.118; + let Json.119 : U64 = StructAtIndex 1 Json.399; + dec Json.399; + let Json.427 : I64 = 34i64; + let Json.426 : U8 = CallByName Num.125 Json.427; + let Json.424 : List U8 = CallByName List.4 Json.118 Json.426; + let Json.425 : List U8 = CallByName Str.12 Json.120; + let Json.421 : List U8 = CallByName List.8 Json.424 Json.425; + let Json.423 : I64 = 34i64; + let Json.422 : U8 = CallByName Num.125 Json.423; + let Json.418 : List U8 = CallByName List.4 Json.421 Json.422; + let Json.420 : I64 = 58i64; + let Json.419 : U8 = CallByName Num.125 Json.420; + let Json.416 : List U8 = CallByName List.4 Json.418 Json.419; + let Json.417 : {} = Struct {}; + let Json.122 : List U8 = CallByName Encode.23 Json.416 Json.121 Json.417; + joinpoint Json.411 Json.123: + let Json.409 : U64 = 1i64; + let Json.408 : U64 = CallByName Num.20 Json.119 Json.409; + let Json.407 : {List U8, U64} = Struct {Json.123, Json.408}; + ret Json.407; in - let Json.417 : U64 = 1i64; - let Json.414 : Int1 = CallByName Num.24 Json.120 Json.417; - if Json.414 then - let Json.416 : I32 = 44i64; - let Json.415 : U8 = CallByName Num.123 Json.416; - let Json.412 : List U8 = CallByName List.4 Json.123 Json.415; - jump Json.413 Json.412; + let Json.415 : U64 = 1i64; + let Json.412 : Int1 = CallByName Num.24 Json.119 Json.415; + if Json.412 then + let Json.414 : I64 = 44i64; + let Json.413 : U8 = CallByName Num.125 Json.414; + let Json.410 : List U8 = CallByName List.4 Json.122 Json.413; + jump Json.411 Json.410; else - jump Json.413 Json.123; + jump Json.411 Json.122; -procedure Json.115 (Json.401, Json.402): - let Json.121 : Str = StructAtIndex 0 Json.402; +procedure Json.114 (Json.399, Json.400): + let Json.120 : Str = StructAtIndex 0 Json.400; + inc Json.120; + let Json.121 : Str = StructAtIndex 1 Json.400; inc Json.121; - let Json.122 : Str = StructAtIndex 1 Json.402; - inc Json.122; - dec Json.402; - let Json.119 : List U8 = StructAtIndex 0 Json.401; - inc Json.119; - let Json.120 : U64 = StructAtIndex 1 Json.401; - dec Json.401; - let Json.469 : I32 = 34i64; - let Json.468 : U8 = CallByName Num.123 Json.469; - let Json.466 : List U8 = CallByName List.4 Json.119 Json.468; - let Json.467 : List U8 = CallByName Str.12 Json.121; - let Json.463 : List U8 = CallByName List.8 Json.466 Json.467; - let Json.465 : I32 = 34i64; - let Json.464 : U8 = CallByName Num.123 Json.465; - let Json.460 : List U8 = CallByName List.4 Json.463 Json.464; - let Json.462 : I32 = 58i64; - let Json.461 : U8 = CallByName Num.123 Json.462; - let Json.458 : List U8 = CallByName List.4 Json.460 Json.461; - let Json.459 : {} = Struct {}; - let Json.123 : List U8 = CallByName Encode.23 Json.458 Json.122 Json.459; - joinpoint Json.453 Json.124: - let Json.451 : U64 = 1i64; - let Json.450 : U64 = CallByName Num.20 Json.120 Json.451; - let Json.449 : {List U8, U64} = Struct {Json.124, Json.450}; - ret Json.449; + dec Json.400; + let Json.118 : List U8 = StructAtIndex 0 Json.399; + inc Json.118; + let Json.119 : U64 = StructAtIndex 1 Json.399; + dec Json.399; + let Json.467 : I64 = 34i64; + let Json.466 : U8 = CallByName Num.125 Json.467; + let Json.464 : List U8 = CallByName List.4 Json.118 Json.466; + let Json.465 : List U8 = CallByName Str.12 Json.120; + let Json.461 : List U8 = CallByName List.8 Json.464 Json.465; + let Json.463 : I64 = 34i64; + let Json.462 : U8 = CallByName Num.125 Json.463; + let Json.458 : List U8 = CallByName List.4 Json.461 Json.462; + let Json.460 : I64 = 58i64; + let Json.459 : U8 = CallByName Num.125 Json.460; + let Json.456 : List U8 = CallByName List.4 Json.458 Json.459; + let Json.457 : {} = Struct {}; + let Json.122 : List U8 = CallByName Encode.23 Json.456 Json.121 Json.457; + joinpoint Json.451 Json.123: + let Json.449 : U64 = 1i64; + let Json.448 : U64 = CallByName Num.20 Json.119 Json.449; + let Json.447 : {List U8, U64} = Struct {Json.123, Json.448}; + ret Json.447; in - let Json.457 : U64 = 1i64; - let Json.454 : Int1 = CallByName Num.24 Json.120 Json.457; - if Json.454 then - let Json.456 : I32 = 44i64; - let Json.455 : U8 = CallByName Num.123 Json.456; - let Json.452 : List U8 = CallByName List.4 Json.123 Json.455; - jump Json.453 Json.452; + let Json.455 : U64 = 1i64; + let Json.452 : Int1 = CallByName Num.24 Json.119 Json.455; + if Json.452 then + let Json.454 : I64 = 44i64; + let Json.453 : U8 = CallByName Num.125 Json.454; + let Json.450 : List U8 = CallByName List.4 Json.122 Json.453; + jump Json.451 Json.450; else - jump Json.453 Json.123; + jump Json.451 Json.122; -procedure Json.18 (Json.96): - let Json.473 : Str = CallByName Encode.22 Json.96; - ret Json.473; +procedure Json.18 (Json.95): + let Json.471 : Str = CallByName Encode.22 Json.95; + ret Json.471; -procedure Json.20 (Json.112): - let Json.397 : List {Str, Str} = CallByName Encode.22 Json.112; - ret Json.397; +procedure Json.20 (Json.111): + let Json.395 : List {Str, Str} = CallByName Encode.22 Json.111; + ret Json.395; -procedure Json.20 (Json.112): - let Json.439 : List {Str, Str} = CallByName Encode.22 Json.112; - ret Json.439; +procedure Json.20 (Json.111): + let Json.437 : List {Str, Str} = CallByName Encode.22 Json.111; + ret Json.437; -procedure Json.97 (Json.98, Json.475, Json.96): - let Json.484 : I32 = 34i64; - let Json.483 : U8 = CallByName Num.123 Json.484; - let Json.481 : List U8 = CallByName List.4 Json.98 Json.483; - let Json.482 : List U8 = CallByName Str.12 Json.96; - let Json.478 : List U8 = CallByName List.8 Json.481 Json.482; - let Json.480 : I32 = 34i64; - let Json.479 : U8 = CallByName Num.123 Json.480; - let Json.477 : List U8 = CallByName List.4 Json.478 Json.479; - ret Json.477; +procedure Json.96 (Json.97, Json.473, Json.95): + let Json.482 : I64 = 34i64; + let Json.481 : U8 = CallByName Num.125 Json.482; + let Json.479 : List U8 = CallByName List.4 Json.97 Json.481; + let Json.480 : List U8 = CallByName Str.12 Json.95; + let Json.476 : List U8 = CallByName List.8 Json.479 Json.480; + let Json.478 : I64 = 34i64; + let Json.477 : U8 = CallByName Num.125 Json.478; + let Json.475 : List U8 = CallByName List.4 Json.476 Json.477; + ret Json.475; -procedure List.133 (List.134, List.135, List.132): - let List.420 : {List U8, U64} = CallByName Json.115 List.134 List.135; - ret List.420; +procedure List.137 (List.138, List.139, List.136): + let List.449 : {List U8, U64} = CallByName Json.114 List.138 List.139; + ret List.449; -procedure List.133 (List.134, List.135, List.132): - let List.492 : {List U8, U64} = CallByName Json.115 List.134 List.135; - ret List.492; +procedure List.137 (List.138, List.139, List.136): + let List.521 : {List U8, U64} = CallByName Json.114 List.138 List.139; + ret List.521; -procedure List.18 (List.130, List.131, List.132): - let List.402 : {List U8, U64} = CallByName List.75 List.130 List.131 List.132; - ret List.402; +procedure List.18 (List.134, List.135, List.136): + let List.431 : {List U8, U64} = CallByName List.89 List.134 List.135 List.136; + ret List.431; -procedure List.18 (List.130, List.131, List.132): - let List.474 : {List U8, U64} = CallByName List.75 List.130 List.131 List.132; - ret List.474; +procedure List.18 (List.134, List.135, List.136): + let List.503 : {List U8, U64} = CallByName List.89 List.134 List.135 List.136; + ret List.503; -procedure List.4 (List.101, List.102): - let List.473 : U64 = 1i64; - let List.472 : List U8 = CallByName List.70 List.101 List.473; - let List.471 : List U8 = CallByName List.71 List.472 List.102; - ret List.471; +procedure List.4 (List.105, List.106): + let List.502 : U64 = 1i64; + let List.501 : List U8 = CallByName List.70 List.105 List.502; + let List.500 : List U8 = CallByName List.71 List.501 List.106; + ret List.500; procedure List.6 (#Attr.2): - let List.380 : U64 = lowlevel ListLen #Attr.2; - ret List.380; + let List.409 : U64 = lowlevel ListLen #Attr.2; + ret List.409; procedure List.6 (#Attr.2): - let List.422 : U64 = lowlevel ListLen #Attr.2; - ret List.422; + let List.451 : U64 = lowlevel ListLen #Attr.2; + ret List.451; procedure List.6 (#Attr.2): - let List.495 : U64 = lowlevel ListLen #Attr.2; - ret List.495; + let List.524 : U64 = lowlevel ListLen #Attr.2; + ret List.524; procedure List.66 (#Attr.2, #Attr.3): - let List.417 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.417; + let List.446 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.446; procedure List.66 (#Attr.2, #Attr.3): - let List.489 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.489; + let List.518 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.518; procedure List.70 (#Attr.2, #Attr.3): - let List.452 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.452; + let List.481 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.481; procedure List.71 (#Attr.2, #Attr.3): - let List.450 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.450; - -procedure List.75 (List.356, List.357, List.358): - let List.406 : U64 = 0i64; - let List.407 : U64 = CallByName List.6 List.356; - let List.405 : {List U8, U64} = CallByName List.86 List.356 List.357 List.358 List.406 List.407; - ret List.405; - -procedure List.75 (List.356, List.357, List.358): - let List.478 : U64 = 0i64; - let List.479 : U64 = CallByName List.6 List.356; - let List.477 : {List U8, U64} = CallByName List.86 List.356 List.357 List.358 List.478 List.479; - ret List.477; + let List.479 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.479; procedure List.8 (#Attr.2, #Attr.3): - let List.494 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.494; + let List.523 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.523; -procedure List.86 (List.432, List.433, List.434, List.435, List.436): - joinpoint List.408 List.359 List.360 List.361 List.362 List.363: - let List.410 : Int1 = CallByName Num.22 List.362 List.363; - if List.410 then - let List.416 : {Str, Str} = CallByName List.66 List.359 List.362; - let List.411 : {List U8, U64} = CallByName List.133 List.360 List.416 List.361; - let List.414 : U64 = 1i64; - let List.413 : U64 = CallByName Num.19 List.362 List.414; - jump List.408 List.359 List.411 List.361 List.413 List.363; +procedure List.89 (List.385, List.386, List.387): + let List.435 : U64 = 0i64; + let List.436 : U64 = CallByName List.6 List.385; + let List.434 : {List U8, U64} = CallByName List.90 List.385 List.386 List.387 List.435 List.436; + ret List.434; + +procedure List.89 (List.385, List.386, List.387): + let List.507 : U64 = 0i64; + let List.508 : U64 = CallByName List.6 List.385; + let List.506 : {List U8, U64} = CallByName List.90 List.385 List.386 List.387 List.507 List.508; + ret List.506; + +procedure List.90 (List.461, List.462, List.463, List.464, List.465): + joinpoint List.437 List.388 List.389 List.390 List.391 List.392: + let List.439 : Int1 = CallByName Num.22 List.391 List.392; + if List.439 then + let List.445 : {Str, Str} = CallByName List.66 List.388 List.391; + let List.440 : {List U8, U64} = CallByName List.137 List.389 List.445 List.390; + let List.443 : U64 = 1i64; + let List.442 : U64 = CallByName Num.19 List.391 List.443; + jump List.437 List.388 List.440 List.390 List.442 List.392; else - ret List.360; + ret List.389; in - jump List.408 List.432 List.433 List.434 List.435 List.436; + jump List.437 List.461 List.462 List.463 List.464 List.465; -procedure List.86 (List.505, List.506, List.507, List.508, List.509): - joinpoint List.480 List.359 List.360 List.361 List.362 List.363: - let List.482 : Int1 = CallByName Num.22 List.362 List.363; - if List.482 then - let List.488 : {Str, Str} = CallByName List.66 List.359 List.362; - let List.483 : {List U8, U64} = CallByName List.133 List.360 List.488 List.361; - let List.486 : U64 = 1i64; - let List.485 : U64 = CallByName Num.19 List.362 List.486; - jump List.480 List.359 List.483 List.361 List.485 List.363; +procedure List.90 (List.534, List.535, List.536, List.537, List.538): + joinpoint List.509 List.388 List.389 List.390 List.391 List.392: + let List.511 : Int1 = CallByName Num.22 List.391 List.392; + if List.511 then + let List.517 : {Str, Str} = CallByName List.66 List.388 List.391; + let List.512 : {List U8, U64} = CallByName List.137 List.389 List.517 List.390; + let List.515 : U64 = 1i64; + let List.514 : U64 = CallByName Num.19 List.391 List.515; + jump List.509 List.388 List.512 List.390 List.514 List.392; else - ret List.360; + ret List.389; in - jump List.480 List.505 List.506 List.507 List.508 List.509; + jump List.509 List.534 List.535 List.536 List.537 List.538; -procedure Num.123 (#Attr.2): - let Num.283 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.283; +procedure Num.125 (#Attr.2): + let Num.282 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.282; procedure Num.19 (#Attr.2, #Attr.3): - let Num.286 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.286; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.284 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.284; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.287 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.287; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.285 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + let Num.285 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; ret Num.285; +procedure Num.20 (#Attr.2, #Attr.3): + let Num.283 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.283; + +procedure Num.22 (#Attr.2, #Attr.3): + let Num.286 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.286; + +procedure Num.24 (#Attr.2, #Attr.3): + let Num.284 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.284; + procedure Str.12 (#Attr.2): - let Str.268 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.268; + let Str.282 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.282; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.260; + let Str.274 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.274; -procedure Str.9 (Str.73): - let Str.258 : U64 = 0i64; - let Str.259 : U64 = CallByName List.6 Str.73; - let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; - let Str.255 : Int1 = StructAtIndex 2 Str.74; - if Str.255 then - let Str.257 : Str = StructAtIndex 1 Str.74; - inc Str.257; - dec Str.74; - let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; - ret Str.256; +procedure Str.9 (Str.76): + let Str.272 : U64 = 0i64; + let Str.273 : U64 = CallByName List.6 Str.76; + let Str.77 : {U64, Str, Int1, U8} = CallByName Str.48 Str.76 Str.272 Str.273; + let Str.269 : Int1 = StructAtIndex 2 Str.77; + if Str.269 then + let Str.271 : Str = StructAtIndex 1 Str.77; + inc Str.271; + dec Str.77; + let Str.270 : [C {U64, U8}, C Str] = TagId(1) Str.271; + ret Str.270; else - let Str.253 : U8 = StructAtIndex 3 Str.74; - let Str.254 : U64 = StructAtIndex 0 Str.74; - dec Str.74; - let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; - let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; - ret Str.251; + let Str.267 : U8 = StructAtIndex 3 Str.77; + let Str.268 : U64 = StructAtIndex 0 Str.77; + dec Str.77; + let Str.266 : {U64, U8} = Struct {Str.268, Str.267}; + let Str.265 : [C {U64, U8}, C Str] = TagId(0) Str.266; + ret Str.265; procedure Test.0 (): let Test.12 : Str = "bar"; 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 be6b0abf1b..9b81c3f70e 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 @@ -25,11 +25,11 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.106; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.113 : List U8 = CallByName Json.113 Encode.94 Encode.96 Encode.102; + let Encode.113 : List U8 = CallByName Json.112 Encode.94 Encode.96 Encode.102; ret Encode.113; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.116 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; + let Encode.116 : List U8 = CallByName Json.96 Encode.94 Encode.96 Encode.102; ret Encode.116; procedure Encode.25 (Encode.100, Encode.101): @@ -39,188 +39,188 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.396 : {} = Struct {}; - ret Json.396; + let Json.394 : {} = Struct {}; + ret Json.394; -procedure Json.113 (Json.114, Json.399, Json.112): - let Json.432 : I32 = 123i64; - let Json.431 : U8 = CallByName Num.123 Json.432; - let Json.116 : List U8 = CallByName List.4 Json.114 Json.431; - let Json.430 : U64 = CallByName List.6 Json.112; - let Json.407 : {List U8, U64} = Struct {Json.116, Json.430}; - let Json.408 : {} = Struct {}; - let Json.406 : {List U8, U64} = CallByName List.18 Json.112 Json.407 Json.408; - dec Json.112; - let Json.118 : List U8 = StructAtIndex 0 Json.406; - inc Json.118; - dec Json.406; - let Json.405 : I32 = 125i64; - let Json.404 : U8 = CallByName Num.123 Json.405; - let Json.403 : List U8 = CallByName List.4 Json.118 Json.404; - ret Json.403; +procedure Json.112 (Json.113, Json.397, Json.111): + let Json.430 : I64 = 123i64; + let Json.429 : U8 = CallByName Num.125 Json.430; + let Json.115 : List U8 = CallByName List.4 Json.113 Json.429; + let Json.428 : U64 = CallByName List.6 Json.111; + let Json.405 : {List U8, U64} = Struct {Json.115, Json.428}; + let Json.406 : {} = Struct {}; + let Json.404 : {List U8, U64} = CallByName List.18 Json.111 Json.405 Json.406; + dec Json.111; + let Json.117 : List U8 = StructAtIndex 0 Json.404; + inc Json.117; + dec Json.404; + let Json.403 : I64 = 125i64; + let Json.402 : U8 = CallByName Num.125 Json.403; + let Json.401 : List U8 = CallByName List.4 Json.117 Json.402; + ret Json.401; -procedure Json.115 (Json.401, Json.402): - let Json.121 : Str = StructAtIndex 0 Json.402; +procedure Json.114 (Json.399, Json.400): + let Json.120 : Str = StructAtIndex 0 Json.400; + inc Json.120; + let Json.121 : Str = StructAtIndex 1 Json.400; inc Json.121; - let Json.122 : Str = StructAtIndex 1 Json.402; - inc Json.122; - dec Json.402; - let Json.119 : List U8 = StructAtIndex 0 Json.401; - inc Json.119; - let Json.120 : U64 = StructAtIndex 1 Json.401; - dec Json.401; - let Json.429 : I32 = 34i64; - let Json.428 : U8 = CallByName Num.123 Json.429; - let Json.426 : List U8 = CallByName List.4 Json.119 Json.428; - let Json.427 : List U8 = CallByName Str.12 Json.121; - let Json.423 : List U8 = CallByName List.8 Json.426 Json.427; - let Json.425 : I32 = 34i64; - let Json.424 : U8 = CallByName Num.123 Json.425; - let Json.420 : List U8 = CallByName List.4 Json.423 Json.424; - let Json.422 : I32 = 58i64; - let Json.421 : U8 = CallByName Num.123 Json.422; - let Json.418 : List U8 = CallByName List.4 Json.420 Json.421; - let Json.419 : {} = Struct {}; - let Json.123 : List U8 = CallByName Encode.23 Json.418 Json.122 Json.419; - joinpoint Json.413 Json.124: - let Json.411 : U64 = 1i64; - let Json.410 : U64 = CallByName Num.20 Json.120 Json.411; - let Json.409 : {List U8, U64} = Struct {Json.124, Json.410}; - ret Json.409; + dec Json.400; + let Json.118 : List U8 = StructAtIndex 0 Json.399; + inc Json.118; + let Json.119 : U64 = StructAtIndex 1 Json.399; + dec Json.399; + let Json.427 : I64 = 34i64; + let Json.426 : U8 = CallByName Num.125 Json.427; + let Json.424 : List U8 = CallByName List.4 Json.118 Json.426; + let Json.425 : List U8 = CallByName Str.12 Json.120; + let Json.421 : List U8 = CallByName List.8 Json.424 Json.425; + let Json.423 : I64 = 34i64; + let Json.422 : U8 = CallByName Num.125 Json.423; + let Json.418 : List U8 = CallByName List.4 Json.421 Json.422; + let Json.420 : I64 = 58i64; + let Json.419 : U8 = CallByName Num.125 Json.420; + let Json.416 : List U8 = CallByName List.4 Json.418 Json.419; + let Json.417 : {} = Struct {}; + let Json.122 : List U8 = CallByName Encode.23 Json.416 Json.121 Json.417; + joinpoint Json.411 Json.123: + let Json.409 : U64 = 1i64; + let Json.408 : U64 = CallByName Num.20 Json.119 Json.409; + let Json.407 : {List U8, U64} = Struct {Json.123, Json.408}; + ret Json.407; in - let Json.417 : U64 = 1i64; - let Json.414 : Int1 = CallByName Num.24 Json.120 Json.417; - if Json.414 then - let Json.416 : I32 = 44i64; - let Json.415 : U8 = CallByName Num.123 Json.416; - let Json.412 : List U8 = CallByName List.4 Json.123 Json.415; - jump Json.413 Json.412; + let Json.415 : U64 = 1i64; + let Json.412 : Int1 = CallByName Num.24 Json.119 Json.415; + if Json.412 then + let Json.414 : I64 = 44i64; + let Json.413 : U8 = CallByName Num.125 Json.414; + let Json.410 : List U8 = CallByName List.4 Json.122 Json.413; + jump Json.411 Json.410; else - jump Json.413 Json.123; + jump Json.411 Json.122; -procedure Json.18 (Json.96): - let Json.433 : Str = CallByName Encode.22 Json.96; - ret Json.433; +procedure Json.18 (Json.95): + let Json.431 : Str = CallByName Encode.22 Json.95; + ret Json.431; -procedure Json.20 (Json.112): - let Json.397 : List {Str, Str} = CallByName Encode.22 Json.112; - ret Json.397; +procedure Json.20 (Json.111): + let Json.395 : List {Str, Str} = CallByName Encode.22 Json.111; + ret Json.395; -procedure Json.97 (Json.98, Json.435, Json.96): - let Json.444 : I32 = 34i64; - let Json.443 : U8 = CallByName Num.123 Json.444; - let Json.441 : List U8 = CallByName List.4 Json.98 Json.443; - let Json.442 : List U8 = CallByName Str.12 Json.96; - let Json.438 : List U8 = CallByName List.8 Json.441 Json.442; - let Json.440 : I32 = 34i64; - let Json.439 : U8 = CallByName Num.123 Json.440; - let Json.437 : List U8 = CallByName List.4 Json.438 Json.439; - ret Json.437; +procedure Json.96 (Json.97, Json.433, Json.95): + let Json.442 : I64 = 34i64; + let Json.441 : U8 = CallByName Num.125 Json.442; + let Json.439 : List U8 = CallByName List.4 Json.97 Json.441; + let Json.440 : List U8 = CallByName Str.12 Json.95; + let Json.436 : List U8 = CallByName List.8 Json.439 Json.440; + let Json.438 : I64 = 34i64; + let Json.437 : U8 = CallByName Num.125 Json.438; + let Json.435 : List U8 = CallByName List.4 Json.436 Json.437; + ret Json.435; -procedure List.133 (List.134, List.135, List.132): - let List.426 : {List U8, U64} = CallByName Json.115 List.134 List.135; - ret List.426; +procedure List.137 (List.138, List.139, List.136): + let List.455 : {List U8, U64} = CallByName Json.114 List.138 List.139; + ret List.455; -procedure List.18 (List.130, List.131, List.132): - let List.408 : {List U8, U64} = CallByName List.75 List.130 List.131 List.132; - ret List.408; +procedure List.18 (List.134, List.135, List.136): + let List.437 : {List U8, U64} = CallByName List.89 List.134 List.135 List.136; + ret List.437; -procedure List.4 (List.101, List.102): - let List.407 : U64 = 1i64; - let List.406 : List U8 = CallByName List.70 List.101 List.407; - let List.405 : List U8 = CallByName List.71 List.406 List.102; - ret List.405; +procedure List.4 (List.105, List.106): + let List.436 : U64 = 1i64; + let List.435 : List U8 = CallByName List.70 List.105 List.436; + let List.434 : List U8 = CallByName List.71 List.435 List.106; + ret List.434; procedure List.6 (#Attr.2): - let List.380 : U64 = lowlevel ListLen #Attr.2; - ret List.380; + let List.409 : U64 = lowlevel ListLen #Attr.2; + ret List.409; procedure List.6 (#Attr.2): - let List.429 : U64 = lowlevel ListLen #Attr.2; - ret List.429; + let List.458 : U64 = lowlevel ListLen #Attr.2; + ret List.458; procedure List.66 (#Attr.2, #Attr.3): - let List.423 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.423; + let List.452 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.452; procedure List.70 (#Attr.2, #Attr.3): - let List.386 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.386; + let List.415 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.415; procedure List.71 (#Attr.2, #Attr.3): - let List.384 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.384; - -procedure List.75 (List.356, List.357, List.358): - let List.412 : U64 = 0i64; - let List.413 : U64 = CallByName List.6 List.356; - let List.411 : {List U8, U64} = CallByName List.86 List.356 List.357 List.358 List.412 List.413; - ret List.411; + let List.413 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.413; procedure List.8 (#Attr.2, #Attr.3): - let List.428 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.428; + let List.457 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.457; -procedure List.86 (List.439, List.440, List.441, List.442, List.443): - joinpoint List.414 List.359 List.360 List.361 List.362 List.363: - let List.416 : Int1 = CallByName Num.22 List.362 List.363; - if List.416 then - let List.422 : {Str, Str} = CallByName List.66 List.359 List.362; - let List.417 : {List U8, U64} = CallByName List.133 List.360 List.422 List.361; - let List.420 : U64 = 1i64; - let List.419 : U64 = CallByName Num.19 List.362 List.420; - jump List.414 List.359 List.417 List.361 List.419 List.363; +procedure List.89 (List.385, List.386, List.387): + let List.441 : U64 = 0i64; + let List.442 : U64 = CallByName List.6 List.385; + let List.440 : {List U8, U64} = CallByName List.90 List.385 List.386 List.387 List.441 List.442; + ret List.440; + +procedure List.90 (List.468, List.469, List.470, List.471, List.472): + joinpoint List.443 List.388 List.389 List.390 List.391 List.392: + let List.445 : Int1 = CallByName Num.22 List.391 List.392; + if List.445 then + let List.451 : {Str, Str} = CallByName List.66 List.388 List.391; + let List.446 : {List U8, U64} = CallByName List.137 List.389 List.451 List.390; + let List.449 : U64 = 1i64; + let List.448 : U64 = CallByName Num.19 List.391 List.449; + jump List.443 List.388 List.446 List.390 List.448 List.392; else - ret List.360; + ret List.389; in - jump List.414 List.439 List.440 List.441 List.442 List.443; + jump List.443 List.468 List.469 List.470 List.471 List.472; -procedure Num.123 (#Attr.2): - let Num.264 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.264; +procedure Num.125 (#Attr.2): + let Num.263 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.263; procedure Num.19 (#Attr.2, #Attr.3): - let Num.267 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.267; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.265 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.265; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.268 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.268; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.266 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + let Num.266 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; ret Num.266; +procedure Num.20 (#Attr.2, #Attr.3): + let Num.264 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.264; + +procedure Num.22 (#Attr.2, #Attr.3): + let Num.267 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.267; + +procedure Num.24 (#Attr.2, #Attr.3): + let Num.265 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.265; + procedure Str.12 (#Attr.2): - let Str.266 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.266; + let Str.280 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.280; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.260; + let Str.274 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.274; -procedure Str.9 (Str.73): - let Str.258 : U64 = 0i64; - let Str.259 : U64 = CallByName List.6 Str.73; - let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; - let Str.255 : Int1 = StructAtIndex 2 Str.74; - if Str.255 then - let Str.257 : Str = StructAtIndex 1 Str.74; - inc Str.257; - dec Str.74; - let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; - ret Str.256; +procedure Str.9 (Str.76): + let Str.272 : U64 = 0i64; + let Str.273 : U64 = CallByName List.6 Str.76; + let Str.77 : {U64, Str, Int1, U8} = CallByName Str.48 Str.76 Str.272 Str.273; + let Str.269 : Int1 = StructAtIndex 2 Str.77; + if Str.269 then + let Str.271 : Str = StructAtIndex 1 Str.77; + inc Str.271; + dec Str.77; + let Str.270 : [C {U64, U8}, C Str] = TagId(1) Str.271; + ret Str.270; else - let Str.253 : U8 = StructAtIndex 3 Str.74; - let Str.254 : U64 = StructAtIndex 0 Str.74; - dec Str.74; - let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; - let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; - ret Str.251; + let Str.267 : U8 = StructAtIndex 3 Str.77; + let Str.268 : U64 = StructAtIndex 0 Str.77; + dec Str.77; + let Str.266 : {U64, U8} = Struct {Str.268, Str.267}; + let Str.265 : [C {U64, U8}, C Str] = TagId(0) Str.266; + ret Str.265; procedure Test.0 (): let Test.11 : Str = "foo"; 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 c40b1c595e..faa8c35dcf 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 @@ -33,11 +33,11 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.106; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.113 : List U8 = CallByName Json.113 Encode.94 Encode.96 Encode.102; + let Encode.113 : List U8 = CallByName Json.112 Encode.94 Encode.96 Encode.102; ret Encode.113; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.117 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; + let Encode.117 : List U8 = CallByName Json.96 Encode.94 Encode.96 Encode.102; ret Encode.117; procedure Encode.25 (Encode.100, Encode.101): @@ -47,188 +47,188 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.396 : {} = Struct {}; - ret Json.396; + let Json.394 : {} = Struct {}; + ret Json.394; -procedure Json.113 (Json.114, Json.399, Json.112): - let Json.432 : I32 = 123i64; - let Json.431 : U8 = CallByName Num.123 Json.432; - let Json.116 : List U8 = CallByName List.4 Json.114 Json.431; - let Json.430 : U64 = CallByName List.6 Json.112; - let Json.407 : {List U8, U64} = Struct {Json.116, Json.430}; - let Json.408 : {} = Struct {}; - let Json.406 : {List U8, U64} = CallByName List.18 Json.112 Json.407 Json.408; - dec Json.112; - let Json.118 : List U8 = StructAtIndex 0 Json.406; - inc Json.118; - dec Json.406; - let Json.405 : I32 = 125i64; - let Json.404 : U8 = CallByName Num.123 Json.405; - let Json.403 : List U8 = CallByName List.4 Json.118 Json.404; - ret Json.403; +procedure Json.112 (Json.113, Json.397, Json.111): + let Json.430 : I64 = 123i64; + let Json.429 : U8 = CallByName Num.125 Json.430; + let Json.115 : List U8 = CallByName List.4 Json.113 Json.429; + let Json.428 : U64 = CallByName List.6 Json.111; + let Json.405 : {List U8, U64} = Struct {Json.115, Json.428}; + let Json.406 : {} = Struct {}; + let Json.404 : {List U8, U64} = CallByName List.18 Json.111 Json.405 Json.406; + dec Json.111; + let Json.117 : List U8 = StructAtIndex 0 Json.404; + inc Json.117; + dec Json.404; + let Json.403 : I64 = 125i64; + let Json.402 : U8 = CallByName Num.125 Json.403; + let Json.401 : List U8 = CallByName List.4 Json.117 Json.402; + ret Json.401; -procedure Json.115 (Json.401, Json.402): - let Json.121 : Str = StructAtIndex 0 Json.402; +procedure Json.114 (Json.399, Json.400): + let Json.120 : Str = StructAtIndex 0 Json.400; + inc Json.120; + let Json.121 : Str = StructAtIndex 1 Json.400; inc Json.121; - let Json.122 : Str = StructAtIndex 1 Json.402; - inc Json.122; - dec Json.402; - let Json.119 : List U8 = StructAtIndex 0 Json.401; - inc Json.119; - let Json.120 : U64 = StructAtIndex 1 Json.401; - dec Json.401; - let Json.429 : I32 = 34i64; - let Json.428 : U8 = CallByName Num.123 Json.429; - let Json.426 : List U8 = CallByName List.4 Json.119 Json.428; - let Json.427 : List U8 = CallByName Str.12 Json.121; - let Json.423 : List U8 = CallByName List.8 Json.426 Json.427; - let Json.425 : I32 = 34i64; - let Json.424 : U8 = CallByName Num.123 Json.425; - let Json.420 : List U8 = CallByName List.4 Json.423 Json.424; - let Json.422 : I32 = 58i64; - let Json.421 : U8 = CallByName Num.123 Json.422; - let Json.418 : List U8 = CallByName List.4 Json.420 Json.421; - let Json.419 : {} = Struct {}; - let Json.123 : List U8 = CallByName Encode.23 Json.418 Json.122 Json.419; - joinpoint Json.413 Json.124: - let Json.411 : U64 = 1i64; - let Json.410 : U64 = CallByName Num.20 Json.120 Json.411; - let Json.409 : {List U8, U64} = Struct {Json.124, Json.410}; - ret Json.409; + dec Json.400; + let Json.118 : List U8 = StructAtIndex 0 Json.399; + inc Json.118; + let Json.119 : U64 = StructAtIndex 1 Json.399; + dec Json.399; + let Json.427 : I64 = 34i64; + let Json.426 : U8 = CallByName Num.125 Json.427; + let Json.424 : List U8 = CallByName List.4 Json.118 Json.426; + let Json.425 : List U8 = CallByName Str.12 Json.120; + let Json.421 : List U8 = CallByName List.8 Json.424 Json.425; + let Json.423 : I64 = 34i64; + let Json.422 : U8 = CallByName Num.125 Json.423; + let Json.418 : List U8 = CallByName List.4 Json.421 Json.422; + let Json.420 : I64 = 58i64; + let Json.419 : U8 = CallByName Num.125 Json.420; + let Json.416 : List U8 = CallByName List.4 Json.418 Json.419; + let Json.417 : {} = Struct {}; + let Json.122 : List U8 = CallByName Encode.23 Json.416 Json.121 Json.417; + joinpoint Json.411 Json.123: + let Json.409 : U64 = 1i64; + let Json.408 : U64 = CallByName Num.20 Json.119 Json.409; + let Json.407 : {List U8, U64} = Struct {Json.123, Json.408}; + ret Json.407; in - let Json.417 : U64 = 1i64; - let Json.414 : Int1 = CallByName Num.24 Json.120 Json.417; - if Json.414 then - let Json.416 : I32 = 44i64; - let Json.415 : U8 = CallByName Num.123 Json.416; - let Json.412 : List U8 = CallByName List.4 Json.123 Json.415; - jump Json.413 Json.412; + let Json.415 : U64 = 1i64; + let Json.412 : Int1 = CallByName Num.24 Json.119 Json.415; + if Json.412 then + let Json.414 : I64 = 44i64; + let Json.413 : U8 = CallByName Num.125 Json.414; + let Json.410 : List U8 = CallByName List.4 Json.122 Json.413; + jump Json.411 Json.410; else - jump Json.413 Json.123; + jump Json.411 Json.122; -procedure Json.18 (Json.96): - let Json.445 : Str = CallByName Encode.22 Json.96; - ret Json.445; +procedure Json.18 (Json.95): + let Json.443 : Str = CallByName Encode.22 Json.95; + ret Json.443; -procedure Json.20 (Json.112): - let Json.397 : List {Str, Str} = CallByName Encode.22 Json.112; - ret Json.397; +procedure Json.20 (Json.111): + let Json.395 : List {Str, Str} = CallByName Encode.22 Json.111; + ret Json.395; -procedure Json.97 (Json.98, Json.435, Json.96): - let Json.444 : I32 = 34i64; - let Json.443 : U8 = CallByName Num.123 Json.444; - let Json.441 : List U8 = CallByName List.4 Json.98 Json.443; - let Json.442 : List U8 = CallByName Str.12 Json.96; - let Json.438 : List U8 = CallByName List.8 Json.441 Json.442; - let Json.440 : I32 = 34i64; - let Json.439 : U8 = CallByName Num.123 Json.440; - let Json.437 : List U8 = CallByName List.4 Json.438 Json.439; - ret Json.437; +procedure Json.96 (Json.97, Json.433, Json.95): + let Json.442 : I64 = 34i64; + let Json.441 : U8 = CallByName Num.125 Json.442; + let Json.439 : List U8 = CallByName List.4 Json.97 Json.441; + let Json.440 : List U8 = CallByName Str.12 Json.95; + let Json.436 : List U8 = CallByName List.8 Json.439 Json.440; + let Json.438 : I64 = 34i64; + let Json.437 : U8 = CallByName Num.125 Json.438; + let Json.435 : List U8 = CallByName List.4 Json.436 Json.437; + ret Json.435; -procedure List.133 (List.134, List.135, List.132): - let List.426 : {List U8, U64} = CallByName Json.115 List.134 List.135; - ret List.426; +procedure List.137 (List.138, List.139, List.136): + let List.455 : {List U8, U64} = CallByName Json.114 List.138 List.139; + ret List.455; -procedure List.18 (List.130, List.131, List.132): - let List.408 : {List U8, U64} = CallByName List.75 List.130 List.131 List.132; - ret List.408; +procedure List.18 (List.134, List.135, List.136): + let List.437 : {List U8, U64} = CallByName List.89 List.134 List.135 List.136; + ret List.437; -procedure List.4 (List.101, List.102): - let List.407 : U64 = 1i64; - let List.406 : List U8 = CallByName List.70 List.101 List.407; - let List.405 : List U8 = CallByName List.71 List.406 List.102; - ret List.405; +procedure List.4 (List.105, List.106): + let List.436 : U64 = 1i64; + let List.435 : List U8 = CallByName List.70 List.105 List.436; + let List.434 : List U8 = CallByName List.71 List.435 List.106; + ret List.434; procedure List.6 (#Attr.2): - let List.380 : U64 = lowlevel ListLen #Attr.2; - ret List.380; + let List.409 : U64 = lowlevel ListLen #Attr.2; + ret List.409; procedure List.6 (#Attr.2): - let List.429 : U64 = lowlevel ListLen #Attr.2; - ret List.429; + let List.458 : U64 = lowlevel ListLen #Attr.2; + ret List.458; procedure List.66 (#Attr.2, #Attr.3): - let List.423 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.423; + let List.452 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.452; procedure List.70 (#Attr.2, #Attr.3): - let List.386 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.386; + let List.415 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.415; procedure List.71 (#Attr.2, #Attr.3): - let List.384 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.384; - -procedure List.75 (List.356, List.357, List.358): - let List.412 : U64 = 0i64; - let List.413 : U64 = CallByName List.6 List.356; - let List.411 : {List U8, U64} = CallByName List.86 List.356 List.357 List.358 List.412 List.413; - ret List.411; + let List.413 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.413; procedure List.8 (#Attr.2, #Attr.3): - let List.428 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.428; + let List.457 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.457; -procedure List.86 (List.439, List.440, List.441, List.442, List.443): - joinpoint List.414 List.359 List.360 List.361 List.362 List.363: - let List.416 : Int1 = CallByName Num.22 List.362 List.363; - if List.416 then - let List.422 : {Str, Str} = CallByName List.66 List.359 List.362; - let List.417 : {List U8, U64} = CallByName List.133 List.360 List.422 List.361; - let List.420 : U64 = 1i64; - let List.419 : U64 = CallByName Num.19 List.362 List.420; - jump List.414 List.359 List.417 List.361 List.419 List.363; +procedure List.89 (List.385, List.386, List.387): + let List.441 : U64 = 0i64; + let List.442 : U64 = CallByName List.6 List.385; + let List.440 : {List U8, U64} = CallByName List.90 List.385 List.386 List.387 List.441 List.442; + ret List.440; + +procedure List.90 (List.468, List.469, List.470, List.471, List.472): + joinpoint List.443 List.388 List.389 List.390 List.391 List.392: + let List.445 : Int1 = CallByName Num.22 List.391 List.392; + if List.445 then + let List.451 : {Str, Str} = CallByName List.66 List.388 List.391; + let List.446 : {List U8, U64} = CallByName List.137 List.389 List.451 List.390; + let List.449 : U64 = 1i64; + let List.448 : U64 = CallByName Num.19 List.391 List.449; + jump List.443 List.388 List.446 List.390 List.448 List.392; else - ret List.360; + ret List.389; in - jump List.414 List.439 List.440 List.441 List.442 List.443; + jump List.443 List.468 List.469 List.470 List.471 List.472; -procedure Num.123 (#Attr.2): - let Num.264 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.264; +procedure Num.125 (#Attr.2): + let Num.263 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.263; procedure Num.19 (#Attr.2, #Attr.3): - let Num.267 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.267; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.265 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.265; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.268 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.268; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.266 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + let Num.266 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; ret Num.266; +procedure Num.20 (#Attr.2, #Attr.3): + let Num.264 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.264; + +procedure Num.22 (#Attr.2, #Attr.3): + let Num.267 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.267; + +procedure Num.24 (#Attr.2, #Attr.3): + let Num.265 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.265; + procedure Str.12 (#Attr.2): - let Str.266 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.266; + let Str.280 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.280; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.260; + let Str.274 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.274; -procedure Str.9 (Str.73): - let Str.258 : U64 = 0i64; - let Str.259 : U64 = CallByName List.6 Str.73; - let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; - let Str.255 : Int1 = StructAtIndex 2 Str.74; - if Str.255 then - let Str.257 : Str = StructAtIndex 1 Str.74; - inc Str.257; - dec Str.74; - let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; - ret Str.256; +procedure Str.9 (Str.76): + let Str.272 : U64 = 0i64; + let Str.273 : U64 = CallByName List.6 Str.76; + let Str.77 : {U64, Str, Int1, U8} = CallByName Str.48 Str.76 Str.272 Str.273; + let Str.269 : Int1 = StructAtIndex 2 Str.77; + if Str.269 then + let Str.271 : Str = StructAtIndex 1 Str.77; + inc Str.271; + dec Str.77; + let Str.270 : [C {U64, U8}, C Str] = TagId(1) Str.271; + ret Str.270; else - let Str.253 : U8 = StructAtIndex 3 Str.74; - let Str.254 : U64 = StructAtIndex 0 Str.74; - dec Str.74; - let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; - let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; - ret Str.251; + let Str.267 : U8 = StructAtIndex 3 Str.77; + let Str.268 : U64 = StructAtIndex 0 Str.77; + dec Str.77; + let Str.266 : {U64, U8} = Struct {Str.268, Str.267}; + let Str.265 : [C {U64, U8}, C Str] = TagId(0) Str.266; + ret Str.265; procedure Test.0 (): let Test.11 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/encode_derived_string.txt b/crates/compiler/test_mono/generated/encode_derived_string.txt index 445fb2415a..922ec7bc09 100644 --- a/crates/compiler/test_mono/generated/encode_derived_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_string.txt @@ -2,7 +2,7 @@ procedure Encode.22 (Encode.93): ret Encode.93; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.106 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; + let Encode.106 : List U8 = CallByName Json.96 Encode.94 Encode.96 Encode.102; ret Encode.106; procedure Encode.25 (Encode.100, Encode.101): @@ -12,76 +12,76 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.396 : {} = Struct {}; - ret Json.396; + let Json.394 : {} = Struct {}; + ret Json.394; -procedure Json.18 (Json.96): - let Json.397 : Str = CallByName Encode.22 Json.96; - ret Json.397; +procedure Json.18 (Json.95): + let Json.395 : Str = CallByName Encode.22 Json.95; + ret Json.395; -procedure Json.97 (Json.98, Json.399, Json.96): - let Json.408 : I32 = 34i64; - let Json.407 : U8 = CallByName Num.123 Json.408; - let Json.405 : List U8 = CallByName List.4 Json.98 Json.407; - let Json.406 : List U8 = CallByName Str.12 Json.96; - let Json.402 : List U8 = CallByName List.8 Json.405 Json.406; - let Json.404 : I32 = 34i64; - let Json.403 : U8 = CallByName Num.123 Json.404; - let Json.401 : List U8 = CallByName List.4 Json.402 Json.403; - ret Json.401; +procedure Json.96 (Json.97, Json.397, Json.95): + let Json.406 : I64 = 34i64; + let Json.405 : U8 = CallByName Num.125 Json.406; + let Json.403 : List U8 = CallByName List.4 Json.97 Json.405; + let Json.404 : List U8 = CallByName Str.12 Json.95; + let Json.400 : List U8 = CallByName List.8 Json.403 Json.404; + let Json.402 : I64 = 34i64; + let Json.401 : U8 = CallByName Num.125 Json.402; + let Json.399 : List U8 = CallByName List.4 Json.400 Json.401; + ret Json.399; -procedure List.4 (List.101, List.102): - let List.389 : U64 = 1i64; - let List.388 : List U8 = CallByName List.70 List.101 List.389; - let List.387 : List U8 = CallByName List.71 List.388 List.102; - ret List.387; +procedure List.4 (List.105, List.106): + let List.418 : U64 = 1i64; + let List.417 : List U8 = CallByName List.70 List.105 List.418; + let List.416 : List U8 = CallByName List.71 List.417 List.106; + ret List.416; procedure List.6 (#Attr.2): - let List.380 : U64 = lowlevel ListLen #Attr.2; - ret List.380; + let List.409 : U64 = lowlevel ListLen #Attr.2; + ret List.409; procedure List.70 (#Attr.2, #Attr.3): - let List.386 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.386; + let List.415 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.415; procedure List.71 (#Attr.2, #Attr.3): - let List.384 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.384; + let List.413 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.413; procedure List.8 (#Attr.2, #Attr.3): - let List.390 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.390; + let List.419 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.419; -procedure Num.123 (#Attr.2): - let Num.258 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.258; +procedure Num.125 (#Attr.2): + let Num.257 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.257; procedure Str.12 (#Attr.2): - let Str.265 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.265; + let Str.279 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.279; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.260; + let Str.274 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.274; -procedure Str.9 (Str.73): - let Str.258 : U64 = 0i64; - let Str.259 : U64 = CallByName List.6 Str.73; - let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; - let Str.255 : Int1 = StructAtIndex 2 Str.74; - if Str.255 then - let Str.257 : Str = StructAtIndex 1 Str.74; - inc Str.257; - dec Str.74; - let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; - ret Str.256; +procedure Str.9 (Str.76): + let Str.272 : U64 = 0i64; + let Str.273 : U64 = CallByName List.6 Str.76; + let Str.77 : {U64, Str, Int1, U8} = CallByName Str.48 Str.76 Str.272 Str.273; + let Str.269 : Int1 = StructAtIndex 2 Str.77; + if Str.269 then + let Str.271 : Str = StructAtIndex 1 Str.77; + inc Str.271; + dec Str.77; + let Str.270 : [C {U64, U8}, C Str] = TagId(1) Str.271; + ret Str.270; else - let Str.253 : U8 = StructAtIndex 3 Str.74; - let Str.254 : U64 = StructAtIndex 0 Str.74; - dec Str.74; - let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; - let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; - ret Str.251; + let Str.267 : U8 = StructAtIndex 3 Str.77; + let Str.268 : U64 = StructAtIndex 0 Str.77; + dec Str.77; + let Str.266 : {U64, U8} = Struct {Str.268, Str.267}; + let Str.265 : [C {U64, U8}, C Str] = TagId(0) Str.266; + ret Str.265; procedure Test.0 (): let Test.9 : Str = "abc"; 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 fe61a284f4..d5e22ddb0f 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 @@ -27,11 +27,11 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.106; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.113 : List U8 = CallByName Json.127 Encode.94 Encode.96 Encode.102; + let Encode.113 : List U8 = CallByName Json.126 Encode.94 Encode.96 Encode.102; ret Encode.113; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.116 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; + let Encode.116 : List U8 = CallByName Json.96 Encode.94 Encode.96 Encode.102; ret Encode.116; procedure Encode.25 (Encode.100, Encode.101): @@ -41,195 +41,195 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.396 : {} = Struct {}; - ret Json.396; + let Json.394 : {} = Struct {}; + ret Json.394; -procedure Json.127 (Json.128, Json.399, #Attr.12): - let Json.126 : List Str = StructAtIndex 1 #Attr.12; - inc Json.126; - let Json.125 : Str = StructAtIndex 0 #Attr.12; +procedure Json.126 (Json.127, Json.397, #Attr.12): + let Json.125 : List Str = StructAtIndex 1 #Attr.12; inc Json.125; + let Json.124 : Str = StructAtIndex 0 #Attr.12; + inc Json.124; dec #Attr.12; - let Json.437 : I32 = 123i64; - let Json.436 : U8 = CallByName Num.123 Json.437; - let Json.433 : List U8 = CallByName List.4 Json.128 Json.436; - let Json.435 : I32 = 34i64; - let Json.434 : U8 = CallByName Num.123 Json.435; - let Json.431 : List U8 = CallByName List.4 Json.433 Json.434; - let Json.432 : List U8 = CallByName Str.12 Json.125; - let Json.428 : List U8 = CallByName List.8 Json.431 Json.432; - let Json.430 : I32 = 34i64; - let Json.429 : U8 = CallByName Num.123 Json.430; - let Json.425 : List U8 = CallByName List.4 Json.428 Json.429; - let Json.427 : I32 = 58i64; - let Json.426 : U8 = CallByName Num.123 Json.427; - let Json.422 : List U8 = CallByName List.4 Json.425 Json.426; - let Json.424 : I32 = 91i64; - let Json.423 : U8 = CallByName Num.123 Json.424; - let Json.130 : List U8 = CallByName List.4 Json.422 Json.423; - let Json.421 : U64 = CallByName List.6 Json.126; - let Json.409 : {List U8, U64} = Struct {Json.130, Json.421}; - let Json.410 : {} = Struct {}; - let Json.408 : {List U8, U64} = CallByName List.18 Json.126 Json.409 Json.410; - dec Json.126; - let Json.132 : List U8 = StructAtIndex 0 Json.408; + let Json.435 : I64 = 123i64; + let Json.434 : U8 = CallByName Num.125 Json.435; + let Json.431 : List U8 = CallByName List.4 Json.127 Json.434; + let Json.433 : I64 = 34i64; + let Json.432 : U8 = CallByName Num.125 Json.433; + let Json.429 : List U8 = CallByName List.4 Json.431 Json.432; + let Json.430 : List U8 = CallByName Str.12 Json.124; + let Json.426 : List U8 = CallByName List.8 Json.429 Json.430; + let Json.428 : I64 = 34i64; + let Json.427 : U8 = CallByName Num.125 Json.428; + let Json.423 : List U8 = CallByName List.4 Json.426 Json.427; + let Json.425 : I64 = 58i64; + let Json.424 : U8 = CallByName Num.125 Json.425; + let Json.420 : List U8 = CallByName List.4 Json.423 Json.424; + let Json.422 : I64 = 91i64; + let Json.421 : U8 = CallByName Num.125 Json.422; + let Json.129 : List U8 = CallByName List.4 Json.420 Json.421; + let Json.419 : U64 = CallByName List.6 Json.125; + let Json.407 : {List U8, U64} = Struct {Json.129, Json.419}; + let Json.408 : {} = Struct {}; + let Json.406 : {List U8, U64} = CallByName List.18 Json.125 Json.407 Json.408; + dec Json.125; + let Json.131 : List U8 = StructAtIndex 0 Json.406; + inc Json.131; + dec Json.406; + let Json.405 : I64 = 93i64; + let Json.404 : U8 = CallByName Num.125 Json.405; + let Json.401 : List U8 = CallByName List.4 Json.131 Json.404; + let Json.403 : I64 = 125i64; + let Json.402 : U8 = CallByName Num.125 Json.403; + let Json.400 : List U8 = CallByName List.4 Json.401 Json.402; + ret Json.400; + +procedure Json.128 (Json.399, Json.134): + let Json.132 : List U8 = StructAtIndex 0 Json.399; inc Json.132; - dec Json.408; - let Json.407 : I32 = 93i64; - let Json.406 : U8 = CallByName Num.123 Json.407; - let Json.403 : List U8 = CallByName List.4 Json.132 Json.406; - let Json.405 : I32 = 125i64; - let Json.404 : U8 = CallByName Num.123 Json.405; - let Json.402 : List U8 = CallByName List.4 Json.403 Json.404; - ret Json.402; - -procedure Json.129 (Json.401, Json.135): - let Json.133 : List U8 = StructAtIndex 0 Json.401; - inc Json.133; - let Json.134 : U64 = StructAtIndex 1 Json.401; - dec Json.401; - let Json.420 : {} = Struct {}; - let Json.136 : List U8 = CallByName Encode.23 Json.133 Json.135 Json.420; - joinpoint Json.415 Json.137: - let Json.413 : U64 = 1i64; - let Json.412 : U64 = CallByName Num.20 Json.134 Json.413; - let Json.411 : {List U8, U64} = Struct {Json.137, Json.412}; - ret Json.411; + let Json.133 : U64 = StructAtIndex 1 Json.399; + dec Json.399; + let Json.418 : {} = Struct {}; + let Json.135 : List U8 = CallByName Encode.23 Json.132 Json.134 Json.418; + joinpoint Json.413 Json.136: + let Json.411 : U64 = 1i64; + let Json.410 : U64 = CallByName Num.20 Json.133 Json.411; + let Json.409 : {List U8, U64} = Struct {Json.136, Json.410}; + ret Json.409; in - let Json.419 : U64 = 1i64; - let Json.416 : Int1 = CallByName Num.24 Json.134 Json.419; - if Json.416 then - let Json.418 : I32 = 44i64; - let Json.417 : U8 = CallByName Num.123 Json.418; - let Json.414 : List U8 = CallByName List.4 Json.136 Json.417; - jump Json.415 Json.414; + let Json.417 : U64 = 1i64; + let Json.414 : Int1 = CallByName Num.24 Json.133 Json.417; + if Json.414 then + let Json.416 : I64 = 44i64; + let Json.415 : U8 = CallByName Num.125 Json.416; + let Json.412 : List U8 = CallByName List.4 Json.135 Json.415; + jump Json.413 Json.412; else - jump Json.415 Json.136; + jump Json.413 Json.135; -procedure Json.18 (Json.96): - let Json.438 : Str = CallByName Encode.22 Json.96; - ret Json.438; +procedure Json.18 (Json.95): + let Json.436 : Str = CallByName Encode.22 Json.95; + ret Json.436; -procedure Json.21 (Json.125, Json.126): - let Json.398 : {Str, List Str} = Struct {Json.125, Json.126}; - let Json.397 : {Str, List Str} = CallByName Encode.22 Json.398; - ret Json.397; +procedure Json.21 (Json.124, Json.125): + let Json.396 : {Str, List Str} = Struct {Json.124, Json.125}; + let Json.395 : {Str, List Str} = CallByName Encode.22 Json.396; + ret Json.395; -procedure Json.97 (Json.98, Json.440, Json.96): - let Json.449 : I32 = 34i64; - let Json.448 : U8 = CallByName Num.123 Json.449; - let Json.446 : List U8 = CallByName List.4 Json.98 Json.448; - let Json.447 : List U8 = CallByName Str.12 Json.96; - let Json.443 : List U8 = CallByName List.8 Json.446 Json.447; - let Json.445 : I32 = 34i64; - let Json.444 : U8 = CallByName Num.123 Json.445; - let Json.442 : List U8 = CallByName List.4 Json.443 Json.444; - ret Json.442; +procedure Json.96 (Json.97, Json.438, Json.95): + let Json.447 : I64 = 34i64; + let Json.446 : U8 = CallByName Num.125 Json.447; + let Json.444 : List U8 = CallByName List.4 Json.97 Json.446; + let Json.445 : List U8 = CallByName Str.12 Json.95; + let Json.441 : List U8 = CallByName List.8 Json.444 Json.445; + let Json.443 : I64 = 34i64; + let Json.442 : U8 = CallByName Num.125 Json.443; + let Json.440 : List U8 = CallByName List.4 Json.441 Json.442; + ret Json.440; -procedure List.133 (List.134, List.135, List.132): - let List.432 : {List U8, U64} = CallByName Json.129 List.134 List.135; - ret List.432; +procedure List.137 (List.138, List.139, List.136): + let List.461 : {List U8, U64} = CallByName Json.128 List.138 List.139; + ret List.461; -procedure List.18 (List.130, List.131, List.132): - let List.414 : {List U8, U64} = CallByName List.75 List.130 List.131 List.132; - ret List.414; +procedure List.18 (List.134, List.135, List.136): + let List.443 : {List U8, U64} = CallByName List.89 List.134 List.135 List.136; + ret List.443; -procedure List.4 (List.101, List.102): - let List.413 : U64 = 1i64; - let List.412 : List U8 = CallByName List.70 List.101 List.413; - let List.411 : List U8 = CallByName List.71 List.412 List.102; - ret List.411; +procedure List.4 (List.105, List.106): + let List.442 : U64 = 1i64; + let List.441 : List U8 = CallByName List.70 List.105 List.442; + let List.440 : List U8 = CallByName List.71 List.441 List.106; + ret List.440; procedure List.6 (#Attr.2): - let List.380 : U64 = lowlevel ListLen #Attr.2; - ret List.380; + let List.409 : U64 = lowlevel ListLen #Attr.2; + ret List.409; procedure List.6 (#Attr.2): - let List.433 : U64 = lowlevel ListLen #Attr.2; - ret List.433; + let List.462 : U64 = lowlevel ListLen #Attr.2; + ret List.462; procedure List.66 (#Attr.2, #Attr.3): - let List.429 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.429; + let List.458 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.458; procedure List.70 (#Attr.2, #Attr.3): - let List.386 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.386; + let List.415 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.415; procedure List.71 (#Attr.2, #Attr.3): - let List.384 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.384; - -procedure List.75 (List.356, List.357, List.358): - let List.418 : U64 = 0i64; - let List.419 : U64 = CallByName List.6 List.356; - let List.417 : {List U8, U64} = CallByName List.86 List.356 List.357 List.358 List.418 List.419; - ret List.417; + let List.413 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.413; procedure List.8 (#Attr.2, #Attr.3): - let List.435 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.435; + let List.464 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.464; -procedure List.86 (List.445, List.446, List.447, List.448, List.449): - joinpoint List.420 List.359 List.360 List.361 List.362 List.363: - let List.422 : Int1 = CallByName Num.22 List.362 List.363; - if List.422 then - let List.428 : Str = CallByName List.66 List.359 List.362; - let List.423 : {List U8, U64} = CallByName List.133 List.360 List.428 List.361; - let List.426 : U64 = 1i64; - let List.425 : U64 = CallByName Num.19 List.362 List.426; - jump List.420 List.359 List.423 List.361 List.425 List.363; +procedure List.89 (List.385, List.386, List.387): + let List.447 : U64 = 0i64; + let List.448 : U64 = CallByName List.6 List.385; + let List.446 : {List U8, U64} = CallByName List.90 List.385 List.386 List.387 List.447 List.448; + ret List.446; + +procedure List.90 (List.474, List.475, List.476, List.477, List.478): + joinpoint List.449 List.388 List.389 List.390 List.391 List.392: + let List.451 : Int1 = CallByName Num.22 List.391 List.392; + if List.451 then + let List.457 : Str = CallByName List.66 List.388 List.391; + let List.452 : {List U8, U64} = CallByName List.137 List.389 List.457 List.390; + let List.455 : U64 = 1i64; + let List.454 : U64 = CallByName Num.19 List.391 List.455; + jump List.449 List.388 List.452 List.390 List.454 List.392; else - ret List.360; + ret List.389; in - jump List.420 List.445 List.446 List.447 List.448 List.449; + jump List.449 List.474 List.475 List.476 List.477 List.478; -procedure Num.123 (#Attr.2): - let Num.266 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.266; +procedure Num.125 (#Attr.2): + let Num.265 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.265; procedure Num.19 (#Attr.2, #Attr.3): - let Num.269 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.269; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.267 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.267; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.270 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.270; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.268 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + let Num.268 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; ret Num.268; +procedure Num.20 (#Attr.2, #Attr.3): + let Num.266 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.266; + +procedure Num.22 (#Attr.2, #Attr.3): + let Num.269 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.269; + +procedure Num.24 (#Attr.2, #Attr.3): + let Num.267 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.267; + procedure Str.12 (#Attr.2): - let Str.266 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.266; + let Str.280 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.280; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.260; + let Str.274 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.274; -procedure Str.9 (Str.73): - let Str.258 : U64 = 0i64; - let Str.259 : U64 = CallByName List.6 Str.73; - let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; - let Str.255 : Int1 = StructAtIndex 2 Str.74; - if Str.255 then - let Str.257 : Str = StructAtIndex 1 Str.74; - inc Str.257; - dec Str.74; - let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; - ret Str.256; +procedure Str.9 (Str.76): + let Str.272 : U64 = 0i64; + let Str.273 : U64 = CallByName List.6 Str.76; + let Str.77 : {U64, Str, Int1, U8} = CallByName Str.48 Str.76 Str.272 Str.273; + let Str.269 : Int1 = StructAtIndex 2 Str.77; + if Str.269 then + let Str.271 : Str = StructAtIndex 1 Str.77; + inc Str.271; + dec Str.77; + let Str.270 : [C {U64, U8}, C Str] = TagId(1) Str.271; + ret Str.270; else - let Str.253 : U8 = StructAtIndex 3 Str.74; - let Str.254 : U64 = StructAtIndex 0 Str.74; - dec Str.74; - let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; - let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; - ret Str.251; + let Str.267 : U8 = StructAtIndex 3 Str.77; + let Str.268 : U64 = StructAtIndex 0 Str.77; + dec Str.77; + let Str.266 : {U64, U8} = Struct {Str.268, Str.267}; + let Str.265 : [C {U64, U8}, C Str] = TagId(0) Str.266; + ret Str.265; procedure Test.0 (): let Test.12 : Str = "foo"; 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 0fba32c529..39d9458331 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 @@ -33,11 +33,11 @@ procedure Encode.23 (Encode.94, Encode.102, Encode.96): ret Encode.106; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.113 : List U8 = CallByName Json.127 Encode.94 Encode.96 Encode.102; + let Encode.113 : List U8 = CallByName Json.126 Encode.94 Encode.96 Encode.102; ret Encode.113; procedure Encode.23 (Encode.94, Encode.102, Encode.96): - let Encode.117 : List U8 = CallByName Json.97 Encode.94 Encode.96 Encode.102; + let Encode.117 : List U8 = CallByName Json.96 Encode.94 Encode.96 Encode.102; ret Encode.117; procedure Encode.25 (Encode.100, Encode.101): @@ -47,195 +47,195 @@ procedure Encode.25 (Encode.100, Encode.101): ret Encode.103; procedure Json.1 (): - let Json.396 : {} = Struct {}; - ret Json.396; + let Json.394 : {} = Struct {}; + ret Json.394; -procedure Json.127 (Json.128, Json.399, #Attr.12): - let Json.126 : List Str = StructAtIndex 1 #Attr.12; - inc Json.126; - let Json.125 : Str = StructAtIndex 0 #Attr.12; +procedure Json.126 (Json.127, Json.397, #Attr.12): + let Json.125 : List Str = StructAtIndex 1 #Attr.12; inc Json.125; + let Json.124 : Str = StructAtIndex 0 #Attr.12; + inc Json.124; dec #Attr.12; - let Json.437 : I32 = 123i64; - let Json.436 : U8 = CallByName Num.123 Json.437; - let Json.433 : List U8 = CallByName List.4 Json.128 Json.436; - let Json.435 : I32 = 34i64; - let Json.434 : U8 = CallByName Num.123 Json.435; - let Json.431 : List U8 = CallByName List.4 Json.433 Json.434; - let Json.432 : List U8 = CallByName Str.12 Json.125; - let Json.428 : List U8 = CallByName List.8 Json.431 Json.432; - let Json.430 : I32 = 34i64; - let Json.429 : U8 = CallByName Num.123 Json.430; - let Json.425 : List U8 = CallByName List.4 Json.428 Json.429; - let Json.427 : I32 = 58i64; - let Json.426 : U8 = CallByName Num.123 Json.427; - let Json.422 : List U8 = CallByName List.4 Json.425 Json.426; - let Json.424 : I32 = 91i64; - let Json.423 : U8 = CallByName Num.123 Json.424; - let Json.130 : List U8 = CallByName List.4 Json.422 Json.423; - let Json.421 : U64 = CallByName List.6 Json.126; - let Json.409 : {List U8, U64} = Struct {Json.130, Json.421}; - let Json.410 : {} = Struct {}; - let Json.408 : {List U8, U64} = CallByName List.18 Json.126 Json.409 Json.410; - dec Json.126; - let Json.132 : List U8 = StructAtIndex 0 Json.408; + let Json.435 : I64 = 123i64; + let Json.434 : U8 = CallByName Num.125 Json.435; + let Json.431 : List U8 = CallByName List.4 Json.127 Json.434; + let Json.433 : I64 = 34i64; + let Json.432 : U8 = CallByName Num.125 Json.433; + let Json.429 : List U8 = CallByName List.4 Json.431 Json.432; + let Json.430 : List U8 = CallByName Str.12 Json.124; + let Json.426 : List U8 = CallByName List.8 Json.429 Json.430; + let Json.428 : I64 = 34i64; + let Json.427 : U8 = CallByName Num.125 Json.428; + let Json.423 : List U8 = CallByName List.4 Json.426 Json.427; + let Json.425 : I64 = 58i64; + let Json.424 : U8 = CallByName Num.125 Json.425; + let Json.420 : List U8 = CallByName List.4 Json.423 Json.424; + let Json.422 : I64 = 91i64; + let Json.421 : U8 = CallByName Num.125 Json.422; + let Json.129 : List U8 = CallByName List.4 Json.420 Json.421; + let Json.419 : U64 = CallByName List.6 Json.125; + let Json.407 : {List U8, U64} = Struct {Json.129, Json.419}; + let Json.408 : {} = Struct {}; + let Json.406 : {List U8, U64} = CallByName List.18 Json.125 Json.407 Json.408; + dec Json.125; + let Json.131 : List U8 = StructAtIndex 0 Json.406; + inc Json.131; + dec Json.406; + let Json.405 : I64 = 93i64; + let Json.404 : U8 = CallByName Num.125 Json.405; + let Json.401 : List U8 = CallByName List.4 Json.131 Json.404; + let Json.403 : I64 = 125i64; + let Json.402 : U8 = CallByName Num.125 Json.403; + let Json.400 : List U8 = CallByName List.4 Json.401 Json.402; + ret Json.400; + +procedure Json.128 (Json.399, Json.134): + let Json.132 : List U8 = StructAtIndex 0 Json.399; inc Json.132; - dec Json.408; - let Json.407 : I32 = 93i64; - let Json.406 : U8 = CallByName Num.123 Json.407; - let Json.403 : List U8 = CallByName List.4 Json.132 Json.406; - let Json.405 : I32 = 125i64; - let Json.404 : U8 = CallByName Num.123 Json.405; - let Json.402 : List U8 = CallByName List.4 Json.403 Json.404; - ret Json.402; - -procedure Json.129 (Json.401, Json.135): - let Json.133 : List U8 = StructAtIndex 0 Json.401; - inc Json.133; - let Json.134 : U64 = StructAtIndex 1 Json.401; - dec Json.401; - let Json.420 : {} = Struct {}; - let Json.136 : List U8 = CallByName Encode.23 Json.133 Json.135 Json.420; - joinpoint Json.415 Json.137: - let Json.413 : U64 = 1i64; - let Json.412 : U64 = CallByName Num.20 Json.134 Json.413; - let Json.411 : {List U8, U64} = Struct {Json.137, Json.412}; - ret Json.411; + let Json.133 : U64 = StructAtIndex 1 Json.399; + dec Json.399; + let Json.418 : {} = Struct {}; + let Json.135 : List U8 = CallByName Encode.23 Json.132 Json.134 Json.418; + joinpoint Json.413 Json.136: + let Json.411 : U64 = 1i64; + let Json.410 : U64 = CallByName Num.20 Json.133 Json.411; + let Json.409 : {List U8, U64} = Struct {Json.136, Json.410}; + ret Json.409; in - let Json.419 : U64 = 1i64; - let Json.416 : Int1 = CallByName Num.24 Json.134 Json.419; - if Json.416 then - let Json.418 : I32 = 44i64; - let Json.417 : U8 = CallByName Num.123 Json.418; - let Json.414 : List U8 = CallByName List.4 Json.136 Json.417; - jump Json.415 Json.414; + let Json.417 : U64 = 1i64; + let Json.414 : Int1 = CallByName Num.24 Json.133 Json.417; + if Json.414 then + let Json.416 : I64 = 44i64; + let Json.415 : U8 = CallByName Num.125 Json.416; + let Json.412 : List U8 = CallByName List.4 Json.135 Json.415; + jump Json.413 Json.412; else - jump Json.415 Json.136; + jump Json.413 Json.135; -procedure Json.18 (Json.96): - let Json.450 : Str = CallByName Encode.22 Json.96; - ret Json.450; +procedure Json.18 (Json.95): + let Json.448 : Str = CallByName Encode.22 Json.95; + ret Json.448; -procedure Json.21 (Json.125, Json.126): - let Json.398 : {Str, List Str} = Struct {Json.125, Json.126}; - let Json.397 : {Str, List Str} = CallByName Encode.22 Json.398; - ret Json.397; +procedure Json.21 (Json.124, Json.125): + let Json.396 : {Str, List Str} = Struct {Json.124, Json.125}; + let Json.395 : {Str, List Str} = CallByName Encode.22 Json.396; + ret Json.395; -procedure Json.97 (Json.98, Json.440, Json.96): - let Json.449 : I32 = 34i64; - let Json.448 : U8 = CallByName Num.123 Json.449; - let Json.446 : List U8 = CallByName List.4 Json.98 Json.448; - let Json.447 : List U8 = CallByName Str.12 Json.96; - let Json.443 : List U8 = CallByName List.8 Json.446 Json.447; - let Json.445 : I32 = 34i64; - let Json.444 : U8 = CallByName Num.123 Json.445; - let Json.442 : List U8 = CallByName List.4 Json.443 Json.444; - ret Json.442; +procedure Json.96 (Json.97, Json.438, Json.95): + let Json.447 : I64 = 34i64; + let Json.446 : U8 = CallByName Num.125 Json.447; + let Json.444 : List U8 = CallByName List.4 Json.97 Json.446; + let Json.445 : List U8 = CallByName Str.12 Json.95; + let Json.441 : List U8 = CallByName List.8 Json.444 Json.445; + let Json.443 : I64 = 34i64; + let Json.442 : U8 = CallByName Num.125 Json.443; + let Json.440 : List U8 = CallByName List.4 Json.441 Json.442; + ret Json.440; -procedure List.133 (List.134, List.135, List.132): - let List.432 : {List U8, U64} = CallByName Json.129 List.134 List.135; - ret List.432; +procedure List.137 (List.138, List.139, List.136): + let List.461 : {List U8, U64} = CallByName Json.128 List.138 List.139; + ret List.461; -procedure List.18 (List.130, List.131, List.132): - let List.414 : {List U8, U64} = CallByName List.75 List.130 List.131 List.132; - ret List.414; +procedure List.18 (List.134, List.135, List.136): + let List.443 : {List U8, U64} = CallByName List.89 List.134 List.135 List.136; + ret List.443; -procedure List.4 (List.101, List.102): - let List.413 : U64 = 1i64; - let List.412 : List U8 = CallByName List.70 List.101 List.413; - let List.411 : List U8 = CallByName List.71 List.412 List.102; - ret List.411; +procedure List.4 (List.105, List.106): + let List.442 : U64 = 1i64; + let List.441 : List U8 = CallByName List.70 List.105 List.442; + let List.440 : List U8 = CallByName List.71 List.441 List.106; + ret List.440; procedure List.6 (#Attr.2): - let List.380 : U64 = lowlevel ListLen #Attr.2; - ret List.380; + let List.409 : U64 = lowlevel ListLen #Attr.2; + ret List.409; procedure List.6 (#Attr.2): - let List.433 : U64 = lowlevel ListLen #Attr.2; - ret List.433; + let List.462 : U64 = lowlevel ListLen #Attr.2; + ret List.462; procedure List.66 (#Attr.2, #Attr.3): - let List.429 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.429; + let List.458 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.458; procedure List.70 (#Attr.2, #Attr.3): - let List.386 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.386; + let List.415 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.415; procedure List.71 (#Attr.2, #Attr.3): - let List.384 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.384; - -procedure List.75 (List.356, List.357, List.358): - let List.418 : U64 = 0i64; - let List.419 : U64 = CallByName List.6 List.356; - let List.417 : {List U8, U64} = CallByName List.86 List.356 List.357 List.358 List.418 List.419; - ret List.417; + let List.413 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.413; procedure List.8 (#Attr.2, #Attr.3): - let List.435 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.435; + let List.464 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.464; -procedure List.86 (List.445, List.446, List.447, List.448, List.449): - joinpoint List.420 List.359 List.360 List.361 List.362 List.363: - let List.422 : Int1 = CallByName Num.22 List.362 List.363; - if List.422 then - let List.428 : Str = CallByName List.66 List.359 List.362; - let List.423 : {List U8, U64} = CallByName List.133 List.360 List.428 List.361; - let List.426 : U64 = 1i64; - let List.425 : U64 = CallByName Num.19 List.362 List.426; - jump List.420 List.359 List.423 List.361 List.425 List.363; +procedure List.89 (List.385, List.386, List.387): + let List.447 : U64 = 0i64; + let List.448 : U64 = CallByName List.6 List.385; + let List.446 : {List U8, U64} = CallByName List.90 List.385 List.386 List.387 List.447 List.448; + ret List.446; + +procedure List.90 (List.474, List.475, List.476, List.477, List.478): + joinpoint List.449 List.388 List.389 List.390 List.391 List.392: + let List.451 : Int1 = CallByName Num.22 List.391 List.392; + if List.451 then + let List.457 : Str = CallByName List.66 List.388 List.391; + let List.452 : {List U8, U64} = CallByName List.137 List.389 List.457 List.390; + let List.455 : U64 = 1i64; + let List.454 : U64 = CallByName Num.19 List.391 List.455; + jump List.449 List.388 List.452 List.390 List.454 List.392; else - ret List.360; + ret List.389; in - jump List.420 List.445 List.446 List.447 List.448 List.449; + jump List.449 List.474 List.475 List.476 List.477 List.478; -procedure Num.123 (#Attr.2): - let Num.266 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.266; +procedure Num.125 (#Attr.2): + let Num.265 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.265; procedure Num.19 (#Attr.2, #Attr.3): - let Num.269 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.269; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.267 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.267; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.270 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.270; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.268 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + let Num.268 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; ret Num.268; +procedure Num.20 (#Attr.2, #Attr.3): + let Num.266 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.266; + +procedure Num.22 (#Attr.2, #Attr.3): + let Num.269 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.269; + +procedure Num.24 (#Attr.2, #Attr.3): + let Num.267 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.267; + procedure Str.12 (#Attr.2): - let Str.266 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.266; + let Str.280 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.280; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.260 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.260; + let Str.274 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.274; -procedure Str.9 (Str.73): - let Str.258 : U64 = 0i64; - let Str.259 : U64 = CallByName List.6 Str.73; - let Str.74 : {U64, Str, Int1, U8} = CallByName Str.48 Str.73 Str.258 Str.259; - let Str.255 : Int1 = StructAtIndex 2 Str.74; - if Str.255 then - let Str.257 : Str = StructAtIndex 1 Str.74; - inc Str.257; - dec Str.74; - let Str.256 : [C {U64, U8}, C Str] = TagId(1) Str.257; - ret Str.256; +procedure Str.9 (Str.76): + let Str.272 : U64 = 0i64; + let Str.273 : U64 = CallByName List.6 Str.76; + let Str.77 : {U64, Str, Int1, U8} = CallByName Str.48 Str.76 Str.272 Str.273; + let Str.269 : Int1 = StructAtIndex 2 Str.77; + if Str.269 then + let Str.271 : Str = StructAtIndex 1 Str.77; + inc Str.271; + dec Str.77; + let Str.270 : [C {U64, U8}, C Str] = TagId(1) Str.271; + ret Str.270; else - let Str.253 : U8 = StructAtIndex 3 Str.74; - let Str.254 : U64 = StructAtIndex 0 Str.74; - dec Str.74; - let Str.252 : {U64, U8} = Struct {Str.254, Str.253}; - let Str.251 : [C {U64, U8}, C Str] = TagId(0) Str.252; - ret Str.251; + let Str.267 : U8 = StructAtIndex 3 Str.77; + let Str.268 : U64 = StructAtIndex 0 Str.77; + dec Str.77; + let Str.266 : {U64, U8} = Struct {Str.268, Str.267}; + let Str.265 : [C {U64, U8}, C Str] = TagId(0) Str.266; + ret Str.265; procedure Test.0 (): let Test.13 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/factorial.txt b/crates/compiler/test_mono/generated/factorial.txt index 9aee646f72..b0319aa20a 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.258 : I64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.258; + let Num.257 : I64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.257; procedure Num.21 (#Attr.2, #Attr.3): - let Num.257 : I64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.256; procedure Test.1 (Test.15, Test.16): joinpoint Test.7 Test.2 Test.3: diff --git a/crates/compiler/test_mono/generated/guard_pattern_true.txt b/crates/compiler/test_mono/generated/guard_pattern_true.txt index f535579130..dfded1801e 100644 --- a/crates/compiler/test_mono/generated/guard_pattern_true.txt +++ b/crates/compiler/test_mono/generated/guard_pattern_true.txt @@ -1,6 +1,6 @@ procedure Bool.1 (): - let Bool.11 : Int1 = false; - ret Bool.11; + let Bool.23 : Int1 = false; + ret Bool.23; procedure Test.1 (Test.2): let Test.5 : I64 = 2i64; diff --git a/crates/compiler/test_mono/generated/if_guard_bind_variable_false.txt b/crates/compiler/test_mono/generated/if_guard_bind_variable_false.txt index 1565f25f88..b8a0dde808 100644 --- a/crates/compiler/test_mono/generated/if_guard_bind_variable_false.txt +++ b/crates/compiler/test_mono/generated/if_guard_bind_variable_false.txt @@ -1,6 +1,6 @@ -procedure Bool.7 (#Attr.2, #Attr.3): - let Bool.11 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.11; +procedure Bool.11 (#Attr.2, #Attr.3): + let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; + ret Bool.23; procedure Test.1 (Test.3): let Test.6 : I64 = 10i64; @@ -13,7 +13,7 @@ procedure Test.1 (Test.3): ret Test.11; in let Test.10 : I64 = 5i64; - let Test.9 : Int1 = CallByName Bool.7 Test.6 Test.10; + let Test.9 : Int1 = CallByName Bool.11 Test.6 Test.10; jump Test.8 Test.9; procedure Test.0 (): diff --git a/crates/compiler/test_mono/generated/if_multi_branch.txt b/crates/compiler/test_mono/generated/if_multi_branch.txt index 36dddc2fe9..3b9a81546f 100644 --- a/crates/compiler/test_mono/generated/if_multi_branch.txt +++ b/crates/compiler/test_mono/generated/if_multi_branch.txt @@ -1,10 +1,10 @@ procedure Bool.1 (): - let Bool.11 : Int1 = false; - ret Bool.11; + let Bool.23 : Int1 = false; + ret Bool.23; procedure Bool.2 (): - let Bool.12 : Int1 = true; - ret Bool.12; + let Bool.24 : Int1 = true; + ret Bool.24; procedure Test.0 (): let Test.4 : Int1 = CallByName Bool.2; diff --git a/crates/compiler/test_mono/generated/ir_int_add.txt b/crates/compiler/test_mono/generated/ir_int_add.txt index d8abd2d336..ca23069c99 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.380 : U64 = lowlevel ListLen #Attr.2; - ret List.380; + let List.409 : U64 = lowlevel ListLen #Attr.2; + ret List.409; procedure Num.19 (#Attr.2, #Attr.3): - let Num.259 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.259; + let Num.258 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.258; 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 2bbd4d95d2..2994403a5a 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; 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 69029d87c2..0ba65b4515 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.257 : I64 = lowlevel NumRound #Attr.2; - ret Num.257; + let Num.256 : I64 = lowlevel NumRound #Attr.2; + ret Num.256; procedure Test.0 (): let Test.2 : Float64 = 3.6f64; diff --git a/crates/compiler/test_mono/generated/ir_two_defs.txt b/crates/compiler/test_mono/generated/ir_two_defs.txt index f54ffd118b..aa2e631fbb 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; 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 6ab0065bc7..5bd2abf771 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 Bool.7 (#Attr.2, #Attr.3): - let Bool.11 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.11; +procedure Num.30 (#Attr.2): + let Num.263 : I64 = 0i64; + let Num.262 : Int1 = lowlevel Eq #Attr.2 Num.263; + ret Num.262; procedure Num.39 (#Attr.2, #Attr.3): - let Num.259 : I64 = lowlevel NumDivTruncUnchecked #Attr.2 #Attr.3; - ret Num.259; + let Num.258 : I64 = lowlevel NumDivTruncUnchecked #Attr.2 #Attr.3; + ret Num.258; -procedure Num.40 (Num.229, Num.230): - let Num.263 : I64 = 0i64; - let Num.260 : Int1 = CallByName Bool.7 Num.230 Num.263; - if Num.260 then - let Num.262 : {} = Struct {}; - let Num.261 : [C {}, C I64] = TagId(0) Num.262; - ret Num.261; +procedure Num.40 (Num.228, Num.229): + let Num.259 : Int1 = CallByName Num.30 Num.229; + if Num.259 then + let Num.261 : {} = Struct {}; + let Num.260 : [C {}, C I64] = TagId(0) Num.261; + ret Num.260; else - let Num.258 : I64 = CallByName Num.39 Num.229 Num.230; - let Num.257 : [C {}, C I64] = TagId(1) Num.258; - ret Num.257; + let Num.257 : I64 = CallByName Num.39 Num.228 Num.229; + let Num.256 : [C {}, C I64] = TagId(1) Num.257; + ret Num.256; 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 8ceef4e3e4..95413986b7 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; procedure Test.0 (): let Test.10 : I64 = 41i64; diff --git a/crates/compiler/test_mono/generated/is_nil.txt b/crates/compiler/test_mono/generated/is_nil.txt index aaea58f73a..e130f31ad5 100644 --- a/crates/compiler/test_mono/generated/is_nil.txt +++ b/crates/compiler/test_mono/generated/is_nil.txt @@ -1,10 +1,10 @@ procedure Bool.1 (): - let Bool.12 : Int1 = false; - ret Bool.12; + let Bool.24 : Int1 = false; + ret Bool.24; procedure Bool.2 (): - let Bool.11 : Int1 = true; - ret Bool.11; + let Bool.23 : Int1 = true; + ret Bool.23; procedure Test.2 (Test.4): let Test.11 : U8 = 1i64; 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 4dcb37efbc..132b5e6fa0 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 @@ -1,71 +1,71 @@ +procedure Bool.11 (#Attr.2, #Attr.3): + let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3; + ret Bool.24; + procedure Bool.2 (): - let Bool.11 : Int1 = true; - ret Bool.11; + let Bool.23 : Int1 = true; + ret Bool.23; -procedure Bool.7 (#Attr.2, #Attr.3): - let Bool.12 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.12; - -procedure List.2 (List.90, List.91): - let List.394 : U64 = CallByName List.6 List.90; - let List.390 : Int1 = CallByName Num.22 List.91 List.394; - if List.390 then - let List.392 : I64 = CallByName List.66 List.90 List.91; - let List.391 : [C {}, C I64] = TagId(1) List.392; - ret List.391; +procedure List.2 (List.94, List.95): + let List.423 : U64 = CallByName List.6 List.94; + let List.419 : Int1 = CallByName Num.22 List.95 List.423; + if List.419 then + let List.421 : I64 = CallByName List.66 List.94 List.95; + let List.420 : [C {}, C I64] = TagId(1) List.421; + ret List.420; else - let List.389 : {} = Struct {}; - let List.388 : [C {}, C I64] = TagId(0) List.389; - ret List.388; + let List.418 : {} = Struct {}; + let List.417 : [C {}, C I64] = TagId(0) List.418; + ret List.417; procedure List.6 (#Attr.2): - let List.395 : U64 = lowlevel ListLen #Attr.2; - ret List.395; + let List.424 : U64 = lowlevel ListLen #Attr.2; + ret List.424; procedure List.66 (#Attr.2, #Attr.3): - let List.393 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.393; + let List.422 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.422; -procedure List.9 (List.213): - let List.387 : U64 = 0i64; - let List.380 : [C {}, C I64] = CallByName List.2 List.213 List.387; - let List.384 : U8 = 1i64; - let List.385 : U8 = GetTagId List.380; - let List.386 : Int1 = lowlevel Eq List.384 List.385; - if List.386 then - let List.214 : I64 = UnionAtIndex (Id 1) (Index 0) List.380; - let List.381 : [C Int1, C I64] = TagId(1) List.214; - ret List.381; +procedure List.9 (List.242): + let List.416 : U64 = 0i64; + let List.409 : [C {}, C I64] = CallByName List.2 List.242 List.416; + let List.413 : U8 = 1i64; + let List.414 : U8 = GetTagId List.409; + let List.415 : Int1 = lowlevel Eq List.413 List.414; + if List.415 then + let List.243 : I64 = UnionAtIndex (Id 1) (Index 0) List.409; + let List.410 : [C Int1, C I64] = TagId(1) List.243; + ret List.410; else - let List.383 : Int1 = true; - let List.382 : [C Int1, C I64] = TagId(0) List.383; - ret List.382; + let List.412 : Int1 = true; + let List.411 : [C Int1, C I64] = TagId(0) List.412; + ret List.411; procedure Num.22 (#Attr.2, #Attr.3): - let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.256; -procedure Str.27 (Str.93): - let Str.251 : [C Int1, C I64] = CallByName Str.66 Str.93; - ret Str.251; +procedure Str.27 (Str.96): + let Str.265 : [C Int1, C I64] = CallByName Str.69 Str.96; + ret Str.265; procedure Str.47 (#Attr.2): - let Str.259 : {I64, U8} = lowlevel StrToNum #Attr.2; - ret Str.259; + let Str.273 : {I64, U8} = lowlevel StrToNum #Attr.2; + ret Str.273; -procedure Str.66 (Str.222): - let Str.223 : {I64, U8} = CallByName Str.47 Str.222; - let Str.257 : U8 = StructAtIndex 1 Str.223; - let Str.258 : U8 = 0i64; - let Str.254 : Int1 = CallByName Bool.7 Str.257 Str.258; - if Str.254 then - let Str.256 : I64 = StructAtIndex 0 Str.223; - let Str.255 : [C Int1, C I64] = TagId(1) Str.256; - ret Str.255; +procedure Str.69 (Str.231): + let Str.232 : {I64, U8} = CallByName Str.47 Str.231; + let Str.271 : U8 = StructAtIndex 1 Str.232; + let Str.272 : U8 = 0i64; + let Str.268 : Int1 = CallByName Bool.11 Str.271 Str.272; + if Str.268 then + let Str.270 : I64 = StructAtIndex 0 Str.232; + let Str.269 : [C Int1, C I64] = TagId(1) Str.270; + ret Str.269; else - let Str.253 : Int1 = false; - let Str.252 : [C Int1, C I64] = TagId(0) Str.253; - ret Str.252; + let Str.267 : Int1 = false; + let Str.266 : [C Int1, C I64] = TagId(0) Str.267; + ret Str.266; procedure Test.0 (): let Test.3 : Int1 = CallByName Bool.2; diff --git a/crates/compiler/test_mono/generated/issue_3669.txt b/crates/compiler/test_mono/generated/issue_3669.txt index 11d9485149..3f50a60607 100644 --- a/crates/compiler/test_mono/generated/issue_3669.txt +++ b/crates/compiler/test_mono/generated/issue_3669.txt @@ -1,6 +1,6 @@ -procedure Bool.7 (#Attr.2, #Attr.3): - let Bool.11 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.11; +procedure Bool.11 (#Attr.2, #Attr.3): + let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; + ret Bool.23; procedure Test.2 (Test.19): joinpoint Test.13 Test.7: @@ -21,6 +21,6 @@ procedure Test.0 (): let Test.10 : {} = CallByName Test.2 Test.12; dec Test.12; let Test.11 : {} = Struct {}; - let Test.8 : Int1 = CallByName Bool.7 Test.10 Test.11; + let Test.8 : Int1 = CallByName Bool.11 Test.10 Test.11; let Test.9 : Str = ""; ret Test.9; 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 b9c8c3a9f4..351d5255f1 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,11 +1,11 @@ +procedure Num.94 (#Attr.2): + let Num.256 : Str = lowlevel NumToStr #Attr.2; + ret Num.256; + procedure Num.94 (#Attr.2): let Num.257 : Str = lowlevel NumToStr #Attr.2; ret Num.257; -procedure Num.94 (#Attr.2): - let Num.258 : Str = lowlevel NumToStr #Attr.2; - ret Num.258; - procedure Test.1 (Test.4): let Test.16 : [C U8, C U64] = TagId(1) Test.4; ret Test.16; diff --git a/crates/compiler/test_mono/generated/list_append.txt b/crates/compiler/test_mono/generated/list_append.txt index 4ec9e800f3..224cea70dd 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.101, List.102): - let List.383 : U64 = 1i64; - let List.381 : List I64 = CallByName List.70 List.101 List.383; - let List.380 : List I64 = CallByName List.71 List.381 List.102; - ret List.380; +procedure List.4 (List.105, List.106): + let List.412 : U64 = 1i64; + let List.410 : List I64 = CallByName List.70 List.105 List.412; + let List.409 : List I64 = CallByName List.71 List.410 List.106; + ret List.409; procedure List.70 (#Attr.2, #Attr.3): - let List.384 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.384; + let List.413 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.413; procedure List.71 (#Attr.2, #Attr.3): - let List.382 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.382; + let List.411 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.411; 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 66396fabc0..2f02f8b4e4 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.101, List.102): - let List.383 : U64 = 1i64; - let List.381 : List I64 = CallByName List.70 List.101 List.383; - let List.380 : List I64 = CallByName List.71 List.381 List.102; - ret List.380; +procedure List.4 (List.105, List.106): + let List.412 : U64 = 1i64; + let List.410 : List I64 = CallByName List.70 List.105 List.412; + let List.409 : List I64 = CallByName List.71 List.410 List.106; + ret List.409; procedure List.70 (#Attr.2, #Attr.3): - let List.384 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.384; + let List.413 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.413; procedure List.71 (#Attr.2, #Attr.3): - let List.382 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.382; + let List.411 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.411; 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 d8f76d3ba2..638d364d74 100644 --- a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt +++ b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt @@ -1,35 +1,35 @@ -procedure List.3 (List.98, List.99, List.100): - let List.383 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; - let List.382 : List I64 = StructAtIndex 0 List.383; - inc List.382; - dec List.383; - ret List.382; +procedure List.3 (List.102, List.103, List.104): + let List.412 : {List I64, I64} = CallByName List.64 List.102 List.103 List.104; + let List.411 : List I64 = StructAtIndex 0 List.412; + inc List.411; + dec List.412; + ret List.411; procedure List.6 (#Attr.2): - let List.381 : U64 = lowlevel ListLen #Attr.2; - ret List.381; + let List.410 : U64 = lowlevel ListLen #Attr.2; + ret List.410; -procedure List.64 (List.95, List.96, List.97): - let List.388 : U64 = CallByName List.6 List.95; - let List.385 : Int1 = CallByName Num.22 List.96 List.388; - if List.385 then - let List.386 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; - ret List.386; +procedure List.64 (List.99, List.100, List.101): + let List.417 : U64 = CallByName List.6 List.99; + let List.414 : Int1 = CallByName Num.22 List.100 List.417; + if List.414 then + let List.415 : {List I64, I64} = CallByName List.67 List.99 List.100 List.101; + ret List.415; else - let List.384 : {List I64, I64} = Struct {List.95, List.97}; - ret List.384; + let List.413 : {List I64, I64} = Struct {List.99, List.101}; + ret List.413; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.387 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.387; + let List.416 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.416; procedure Num.19 (#Attr.2, #Attr.3): - let Num.257 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; procedure Num.22 (#Attr.2, #Attr.3): - let Num.258 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.258; + let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.257; 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 db3e811cb3..53734e6aa0 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.90, List.91): - let List.386 : U64 = CallByName List.6 List.90; - let List.382 : Int1 = CallByName Num.22 List.91 List.386; - if List.382 then - let List.384 : I64 = CallByName List.66 List.90 List.91; - let List.383 : [C {}, C I64] = TagId(1) List.384; - ret List.383; +procedure List.2 (List.94, List.95): + let List.415 : U64 = CallByName List.6 List.94; + let List.411 : Int1 = CallByName Num.22 List.95 List.415; + if List.411 then + let List.413 : I64 = CallByName List.66 List.94 List.95; + let List.412 : [C {}, C I64] = TagId(1) List.413; + ret List.412; else - let List.381 : {} = Struct {}; - let List.380 : [C {}, C I64] = TagId(0) List.381; - ret List.380; + let List.410 : {} = Struct {}; + let List.409 : [C {}, C I64] = TagId(0) List.410; + ret List.409; procedure List.6 (#Attr.2): - let List.387 : U64 = lowlevel ListLen #Attr.2; - ret List.387; + let List.416 : U64 = lowlevel ListLen #Attr.2; + ret List.416; procedure List.66 (#Attr.2, #Attr.3): - let List.385 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.385; + let List.414 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.414; procedure Num.22 (#Attr.2, #Attr.3): - let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.256; 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 75148df945..ba25fbc1f1 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.380 : U64 = lowlevel ListLen #Attr.2; - ret List.380; + let List.409 : U64 = lowlevel ListLen #Attr.2; + ret List.409; procedure List.6 (#Attr.2): - let List.381 : U64 = lowlevel ListLen #Attr.2; - ret List.381; + let List.410 : U64 = lowlevel ListLen #Attr.2; + ret List.410; procedure Num.19 (#Attr.2, #Attr.3): - let Num.257 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; 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 102f75b8cb..ca1cabd824 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt @@ -1,38 +1,38 @@ -procedure List.2 (List.90, List.91): - let List.386 : U64 = CallByName List.6 List.90; - let List.382 : Int1 = CallByName Num.22 List.91 List.386; - if List.382 then - let List.384 : Str = CallByName List.66 List.90 List.91; - let List.383 : [C {}, C Str] = TagId(1) List.384; - ret List.383; +procedure List.2 (List.94, List.95): + let List.415 : U64 = CallByName List.6 List.94; + let List.411 : Int1 = CallByName Num.22 List.95 List.415; + if List.411 then + let List.413 : Str = CallByName List.66 List.94 List.95; + let List.412 : [C {}, C Str] = TagId(1) List.413; + ret List.412; else - let List.381 : {} = Struct {}; - let List.380 : [C {}, C Str] = TagId(0) List.381; - ret List.380; + let List.410 : {} = Struct {}; + let List.409 : [C {}, C Str] = TagId(0) List.410; + ret List.409; procedure List.5 (#Attr.2, #Attr.3): - let List.388 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; - ret List.388; + let List.417 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; + ret List.417; procedure List.6 (#Attr.2): - let List.387 : U64 = lowlevel ListLen #Attr.2; - ret List.387; + let List.416 : U64 = lowlevel ListLen #Attr.2; + ret List.416; procedure List.66 (#Attr.2, #Attr.3): - let List.385 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.385; + let List.414 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.414; procedure Num.22 (#Attr.2, #Attr.3): - let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.256; procedure Str.16 (#Attr.2, #Attr.3): - let Str.251 : Str = lowlevel StrRepeat #Attr.2 #Attr.3; - ret Str.251; + let Str.265 : Str = lowlevel StrRepeat #Attr.2 #Attr.3; + ret Str.265; procedure Str.3 (#Attr.2, #Attr.3): - let Str.252 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.252; + let Str.266 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.266; 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 85c4902acb..dd79d46b04 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_owns.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_owns.txt @@ -1,36 +1,35 @@ -procedure List.2 (List.90, List.91): - let List.386 : U64 = CallByName List.6 List.90; - let List.382 : Int1 = CallByName Num.22 List.91 List.386; - if List.382 then - let List.384 : Str = CallByName List.66 List.90 List.91; - let List.383 : [C {}, C Str] = TagId(1) List.384; - ret List.383; +procedure List.2 (List.94, List.95): + let List.415 : U64 = CallByName List.6 List.94; + let List.411 : Int1 = CallByName Num.22 List.95 List.415; + if List.411 then + let List.413 : Str = CallByName List.66 List.94 List.95; + let List.412 : [C {}, C Str] = TagId(1) List.413; + ret List.412; else - let List.381 : {} = Struct {}; - let List.380 : [C {}, C Str] = TagId(0) List.381; - ret List.380; + let List.410 : {} = Struct {}; + let List.409 : [C {}, C Str] = TagId(0) List.410; + ret List.409; procedure List.5 (#Attr.2, #Attr.3): - inc #Attr.2; - let List.388 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; + let List.417 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; decref #Attr.2; - ret List.388; + ret List.417; procedure List.6 (#Attr.2): - let List.387 : U64 = lowlevel ListLen #Attr.2; - ret List.387; + let List.416 : U64 = lowlevel ListLen #Attr.2; + ret List.416; procedure List.66 (#Attr.2, #Attr.3): - let List.385 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.385; + let List.414 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.414; procedure Num.22 (#Attr.2, #Attr.3): - let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.256; procedure Str.3 (#Attr.2, #Attr.3): - let Str.252 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.252; + let Str.266 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.266; procedure Test.1 (): let Test.21 : Str = "lllllllllllllllllllllooooooooooong"; @@ -44,7 +43,6 @@ procedure Test.2 (): let Test.15 : List Str = CallByName Test.1; let Test.16 : {} = Struct {}; let Test.14 : List Str = CallByName List.5 Test.15 Test.16; - dec Test.15; ret Test.14; procedure Test.3 (Test.4): 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 97947c1243..4bdc8393cf 100644 --- a/crates/compiler/test_mono/generated/list_pass_to_function.txt +++ b/crates/compiler/test_mono/generated/list_pass_to_function.txt @@ -1,31 +1,31 @@ -procedure List.3 (List.98, List.99, List.100): - let List.381 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; - let List.380 : List I64 = StructAtIndex 0 List.381; - inc List.380; - dec List.381; - ret List.380; +procedure List.3 (List.102, List.103, List.104): + let List.410 : {List I64, I64} = CallByName List.64 List.102 List.103 List.104; + let List.409 : List I64 = StructAtIndex 0 List.410; + inc List.409; + dec List.410; + ret List.409; procedure List.6 (#Attr.2): - let List.387 : U64 = lowlevel ListLen #Attr.2; - ret List.387; + let List.416 : U64 = lowlevel ListLen #Attr.2; + ret List.416; -procedure List.64 (List.95, List.96, List.97): - let List.386 : U64 = CallByName List.6 List.95; - let List.383 : Int1 = CallByName Num.22 List.96 List.386; - if List.383 then - let List.384 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; - ret List.384; +procedure List.64 (List.99, List.100, List.101): + let List.415 : U64 = CallByName List.6 List.99; + let List.412 : Int1 = CallByName Num.22 List.100 List.415; + if List.412 then + let List.413 : {List I64, I64} = CallByName List.67 List.99 List.100 List.101; + ret List.413; else - let List.382 : {List I64, I64} = Struct {List.95, List.97}; - ret List.382; + let List.411 : {List I64, I64} = Struct {List.99, List.101}; + ret List.411; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.385 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.385; + let List.414 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.414; procedure Num.22 (#Attr.2, #Attr.3): - let Num.257 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.256; 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 e3bee9c60c..a375c93ae5 100644 --- a/crates/compiler/test_mono/generated/list_sort_asc.txt +++ b/crates/compiler/test_mono/generated/list_sort_asc.txt @@ -1,20 +1,20 @@ procedure List.28 (#Attr.2, #Attr.3): - let List.382 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; + let List.411 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; let #Derived_gen.0 : Int1 = lowlevel ListIsUnique #Attr.2; if #Derived_gen.0 then - ret List.382; + ret List.411; else decref #Attr.2; - ret List.382; + ret List.411; -procedure List.59 (List.208): - let List.381 : {} = Struct {}; - let List.380 : List I64 = CallByName List.28 List.208 List.381; - ret List.380; +procedure List.59 (List.237): + let List.410 : {} = Struct {}; + let List.409 : List I64 = CallByName List.28 List.237 List.410; + ret List.409; procedure Num.46 (#Attr.2, #Attr.3): - let Num.257 : U8 = lowlevel NumCompare #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : U8 = lowlevel NumCompare #Attr.2 #Attr.3; + ret Num.256; procedure Test.0 (): let Test.2 : List I64 = Array [4i64, 3i64, 2i64, 1i64]; diff --git a/crates/compiler/test_mono/generated/monomorphized_tag_with_aliased_args.txt b/crates/compiler/test_mono/generated/monomorphized_tag_with_aliased_args.txt index fe89b5144c..490a3c5643 100644 --- a/crates/compiler/test_mono/generated/monomorphized_tag_with_aliased_args.txt +++ b/crates/compiler/test_mono/generated/monomorphized_tag_with_aliased_args.txt @@ -1,6 +1,6 @@ procedure Bool.1 (): - let Bool.12 : Int1 = false; - ret Bool.12; + let Bool.24 : Int1 = false; + ret Bool.24; procedure Test.4 (Test.6): let Test.8 : U64 = 1i64; diff --git a/crates/compiler/test_mono/generated/nested_pattern_match.txt b/crates/compiler/test_mono/generated/nested_pattern_match.txt index e8e714e59e..4b2af8c406 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; 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 1925eaca63..e5c7df8fe3 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.257 : Float64 = lowlevel NumDivFrac #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : Float64 = lowlevel NumDivFrac #Attr.2 #Attr.3; + ret Num.256; procedure Test.0 (): let Test.2 : Float64 = 1f64; diff --git a/crates/compiler/test_mono/generated/optional_when.txt b/crates/compiler/test_mono/generated/optional_when.txt index 1da4dd989c..28667ba1d6 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.259 : I64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.259; + let Num.258 : I64 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.258; procedure Test.1 (Test.6): let Test.21 : Int1 = false; diff --git a/crates/compiler/test_mono/generated/quicksort_help.txt b/crates/compiler/test_mono/generated/quicksort_help.txt index 884a9adbad..b8a6ea2e5d 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; procedure Num.20 (#Attr.2, #Attr.3): - let Num.258 : I64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.258; + let Num.257 : I64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.257; procedure Num.22 (#Attr.2, #Attr.3): - let Num.259 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.259; + let Num.258 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.258; procedure Test.1 (Test.24, Test.25, Test.26): 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 ee01276f67..7714860bc7 100644 --- a/crates/compiler/test_mono/generated/quicksort_swap.txt +++ b/crates/compiler/test_mono/generated/quicksort_swap.txt @@ -1,47 +1,47 @@ -procedure List.2 (List.90, List.91): - let List.402 : U64 = CallByName List.6 List.90; - let List.399 : Int1 = CallByName Num.22 List.91 List.402; - if List.399 then - let List.401 : I64 = CallByName List.66 List.90 List.91; - let List.400 : [C {}, C I64] = TagId(1) List.401; - ret List.400; +procedure List.2 (List.94, List.95): + let List.431 : U64 = CallByName List.6 List.94; + let List.428 : Int1 = CallByName Num.22 List.95 List.431; + if List.428 then + let List.430 : I64 = CallByName List.66 List.94 List.95; + let List.429 : [C {}, C I64] = TagId(1) List.430; + ret List.429; else - let List.398 : {} = Struct {}; - let List.397 : [C {}, C I64] = TagId(0) List.398; - ret List.397; + let List.427 : {} = Struct {}; + let List.426 : [C {}, C I64] = TagId(0) List.427; + ret List.426; -procedure List.3 (List.98, List.99, List.100): - let List.389 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; - let List.388 : List I64 = StructAtIndex 0 List.389; - inc List.388; - dec List.389; - ret List.388; +procedure List.3 (List.102, List.103, List.104): + let List.418 : {List I64, I64} = CallByName List.64 List.102 List.103 List.104; + let List.417 : List I64 = StructAtIndex 0 List.418; + inc List.417; + dec List.418; + ret List.417; procedure List.6 (#Attr.2): - let List.387 : U64 = lowlevel ListLen #Attr.2; - ret List.387; + let List.416 : U64 = lowlevel ListLen #Attr.2; + ret List.416; -procedure List.64 (List.95, List.96, List.97): - let List.386 : U64 = CallByName List.6 List.95; - let List.383 : Int1 = CallByName Num.22 List.96 List.386; - if List.383 then - let List.384 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; - ret List.384; +procedure List.64 (List.99, List.100, List.101): + let List.415 : U64 = CallByName List.6 List.99; + let List.412 : Int1 = CallByName Num.22 List.100 List.415; + if List.412 then + let List.413 : {List I64, I64} = CallByName List.67 List.99 List.100 List.101; + ret List.413; else - let List.382 : {List I64, I64} = Struct {List.95, List.97}; - ret List.382; + let List.411 : {List I64, I64} = Struct {List.99, List.101}; + ret List.411; procedure List.66 (#Attr.2, #Attr.3): - let List.395 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.395; + let List.424 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.424; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.385 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.385; + let List.414 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.414; procedure Num.22 (#Attr.2, #Attr.3): - let Num.259 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.259; + let Num.258 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.258; procedure Test.1 (Test.2): let Test.28 : U64 = 0i64; 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 988b0cf432..2f7c2c8b22 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; 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 356f58f136..49267ae4b1 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; 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 2abaf868ba..21ebd109c8 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; 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 b70eba153b..c960fd1fb2 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; procedure Test.1 (Test.2): let Test.3 : I64 = 10i64; 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 1d0e02c71f..b969b12528 100644 --- a/crates/compiler/test_mono/generated/recursive_call_capturing_function.txt +++ b/crates/compiler/test_mono/generated/recursive_call_capturing_function.txt @@ -1,10 +1,10 @@ procedure Bool.2 (): - let Bool.11 : Int1 = true; - ret Bool.11; + let Bool.23 : Int1 = true; + ret Bool.23; procedure Num.19 (#Attr.2, #Attr.3): - let Num.257 : U32 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : U32 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; procedure Test.1 (Test.2): let Test.8 : U32 = 0i64; diff --git a/crates/compiler/test_mono/generated/rigids.txt b/crates/compiler/test_mono/generated/rigids.txt index 3026b305c0..71b3ba4340 100644 --- a/crates/compiler/test_mono/generated/rigids.txt +++ b/crates/compiler/test_mono/generated/rigids.txt @@ -1,47 +1,47 @@ -procedure List.2 (List.90, List.91): - let List.402 : U64 = CallByName List.6 List.90; - let List.399 : Int1 = CallByName Num.22 List.91 List.402; - if List.399 then - let List.401 : I64 = CallByName List.66 List.90 List.91; - let List.400 : [C {}, C I64] = TagId(1) List.401; - ret List.400; +procedure List.2 (List.94, List.95): + let List.431 : U64 = CallByName List.6 List.94; + let List.428 : Int1 = CallByName Num.22 List.95 List.431; + if List.428 then + let List.430 : I64 = CallByName List.66 List.94 List.95; + let List.429 : [C {}, C I64] = TagId(1) List.430; + ret List.429; else - let List.398 : {} = Struct {}; - let List.397 : [C {}, C I64] = TagId(0) List.398; - ret List.397; + let List.427 : {} = Struct {}; + let List.426 : [C {}, C I64] = TagId(0) List.427; + ret List.426; -procedure List.3 (List.98, List.99, List.100): - let List.389 : {List I64, I64} = CallByName List.64 List.98 List.99 List.100; - let List.388 : List I64 = StructAtIndex 0 List.389; - inc List.388; - dec List.389; - ret List.388; +procedure List.3 (List.102, List.103, List.104): + let List.418 : {List I64, I64} = CallByName List.64 List.102 List.103 List.104; + let List.417 : List I64 = StructAtIndex 0 List.418; + inc List.417; + dec List.418; + ret List.417; procedure List.6 (#Attr.2): - let List.387 : U64 = lowlevel ListLen #Attr.2; - ret List.387; + let List.416 : U64 = lowlevel ListLen #Attr.2; + ret List.416; -procedure List.64 (List.95, List.96, List.97): - let List.386 : U64 = CallByName List.6 List.95; - let List.383 : Int1 = CallByName Num.22 List.96 List.386; - if List.383 then - let List.384 : {List I64, I64} = CallByName List.67 List.95 List.96 List.97; - ret List.384; +procedure List.64 (List.99, List.100, List.101): + let List.415 : U64 = CallByName List.6 List.99; + let List.412 : Int1 = CallByName Num.22 List.100 List.415; + if List.412 then + let List.413 : {List I64, I64} = CallByName List.67 List.99 List.100 List.101; + ret List.413; else - let List.382 : {List I64, I64} = Struct {List.95, List.97}; - ret List.382; + let List.411 : {List I64, I64} = Struct {List.99, List.101}; + ret List.411; procedure List.66 (#Attr.2, #Attr.3): - let List.395 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.395; + let List.424 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.424; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.385 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.385; + let List.414 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.414; procedure Num.22 (#Attr.2, #Attr.3): - let Num.259 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.259; + let Num.258 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.258; 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/simple_if.txt b/crates/compiler/test_mono/generated/simple_if.txt index 0ffc888c09..42fbbf320f 100644 --- a/crates/compiler/test_mono/generated/simple_if.txt +++ b/crates/compiler/test_mono/generated/simple_if.txt @@ -1,6 +1,6 @@ procedure Bool.2 (): - let Bool.11 : Int1 = true; - ret Bool.11; + let Bool.23 : Int1 = true; + ret Bool.23; procedure Test.0 (): let Test.2 : Int1 = CallByName Bool.2; diff --git a/crates/compiler/test_mono/generated/specialize_closures.txt b/crates/compiler/test_mono/generated/specialize_closures.txt index 4dacbd022f..844180ae10 100644 --- a/crates/compiler/test_mono/generated/specialize_closures.txt +++ b/crates/compiler/test_mono/generated/specialize_closures.txt @@ -1,14 +1,14 @@ procedure Bool.2 (): - let Bool.12 : Int1 = true; - ret Bool.12; + let Bool.24 : Int1 = true; + ret Bool.24; procedure Num.19 (#Attr.2, #Attr.3): - let Num.258 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.258; + let Num.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.257; procedure Num.21 (#Attr.2, #Attr.3): - let Num.257 : I64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.256; 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 017db92ce7..cb54585dd7 100644 --- a/crates/compiler/test_mono/generated/specialize_lowlevel.txt +++ b/crates/compiler/test_mono/generated/specialize_lowlevel.txt @@ -1,14 +1,14 @@ procedure Bool.2 (): - let Bool.11 : Int1 = true; - ret Bool.11; + let Bool.23 : Int1 = true; + ret Bool.23; procedure Num.19 (#Attr.2, #Attr.3): - let Num.258 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.258; + let Num.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.257; procedure Num.21 (#Attr.2, #Attr.3): - let Num.257 : I64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.256; procedure Test.6 (Test.8, #Attr.12): let Test.4 : 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 996ca5866c..8d5dd76e08 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; procedure Num.20 (#Attr.2, #Attr.3): - let Num.258 : I64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.258; + let Num.257 : I64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.257; procedure Test.1 (Test.15, Test.16): joinpoint Test.7 Test.2 Test.3: diff --git a/crates/compiler/test_mono/generated/unreachable_void_constructor.txt b/crates/compiler/test_mono/generated/unreachable_void_constructor.txt index 16b7d9807e..017064eed0 100644 --- a/crates/compiler/test_mono/generated/unreachable_void_constructor.txt +++ b/crates/compiler/test_mono/generated/unreachable_void_constructor.txt @@ -1,6 +1,6 @@ procedure Bool.2 (): - let Bool.11 : Int1 = true; - ret Bool.11; + let Bool.23 : Int1 = true; + ret Bool.23; procedure Test.0 (): let Test.6 : Int1 = CallByName Bool.2; diff --git a/crates/compiler/test_mono/generated/when_nested_maybe.txt b/crates/compiler/test_mono/generated/when_nested_maybe.txt index e8e714e59e..4b2af8c406 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; 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 18381ca043..83aabd4e7f 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; 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 76a1f73339..14788ffbaf 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.257 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.257; + let Num.256 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; procedure Test.0 (): let Test.15 : I64 = 3i64; diff --git a/crates/compiler/test_mono/src/tests.rs b/crates/compiler/test_mono/src/tests.rs index 4436c815f7..c66e9d5ca1 100644 --- a/crates/compiler/test_mono/src/tests.rs +++ b/crates/compiler/test_mono/src/tests.rs @@ -143,7 +143,6 @@ fn compiles_to_ir(test_name: &str, src: &str) { verify_procedures(test_name, layout_interner, procedures, main_fn_symbol); } -#[cfg(debug_assertions)] fn verify_procedures<'a>( test_name: &str, interner: STLayoutInterner<'a>, @@ -174,7 +173,7 @@ fn verify_procedures<'a>( use std::process::Command; let is_tracked = Command::new("git") - .args(&["ls-files", "--error-unmatch", &path]) + .args(["ls-files", "--error-unmatch", &path]) .output() .unwrap(); @@ -186,7 +185,7 @@ fn verify_procedures<'a>( } let has_changes = Command::new("git") - .args(&["diff", "--color=always", &path]) + .args(["diff", "--color=always", &path]) .output() .unwrap(); @@ -201,19 +200,6 @@ fn verify_procedures<'a>( } } -// NOTE because the Show instance of module names is different in --release mode, -// these tests would all fail. In the future, when we do interesting optimizations, -// we'll likely want some tests for --release too. -#[cfg(not(debug_assertions))] -fn verify_procedures( - _expected: &str, - _interner: STLayoutInterner<'_>, - _procedures: MutMap<(Symbol, ProcLayout<'_>), Proc<'_>>, - _main_fn_symbol: Symbol, -) { - // Do nothing -} - #[mono_test] fn ir_int_literal() { r#" diff --git a/crates/compiler/types/src/pretty_print.rs b/crates/compiler/types/src/pretty_print.rs index 67ff778cd6..bfe2126d98 100644 --- a/crates/compiler/types/src/pretty_print.rs +++ b/crates/compiler/types/src/pretty_print.rs @@ -30,7 +30,7 @@ static EMPTY_TAG_UNION: &str = "[]"; /// List (List I64) /// /// Otherwise, parens are unnecessary. -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Parens { InFn, InTypeParam, diff --git a/crates/compiler/types/src/types.rs b/crates/compiler/types/src/types.rs index 50fbfb6af1..943ca81a98 100644 --- a/crates/compiler/types/src/types.rs +++ b/crates/compiler/types/src/types.rs @@ -8,7 +8,7 @@ use roc_error_macros::internal_error; use roc_module::called_via::CalledVia; use roc_module::ident::{ForeignSymbol, Ident, Lowercase, TagName}; use roc_module::low_level::LowLevel; -use roc_module::symbol::{Interns, ModuleId, Symbol}; +use roc_module::symbol::{Interns, Symbol}; use roc_region::all::{Loc, Region}; use std::fmt; use std::fmt::Write; @@ -2250,7 +2250,7 @@ pub enum Reason { }, } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum Category { Lookup(Symbol), CallResult(Option, CalledVia), @@ -2334,7 +2334,7 @@ impl AliasKind { } } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct AliasVar { pub name: Lowercase, pub var: Variable, @@ -2518,15 +2518,14 @@ impl ErrorType { } } -pub fn write_error_type(home: ModuleId, interns: &Interns, error_type: ErrorType) -> String { +pub fn write_error_type(interns: &Interns, error_type: ErrorType) -> String { let mut buf = String::new(); - write_error_type_help(home, interns, error_type, &mut buf, Parens::Unnecessary); + write_error_type_help(interns, error_type, &mut buf, Parens::Unnecessary); buf } fn write_error_type_help( - home: ModuleId, interns: &Interns, error_type: ErrorType, buf: &mut String, @@ -2550,7 +2549,7 @@ fn write_error_type_help( for arg in arguments { buf.push(' '); - write_error_type_help(home, interns, arg, buf, Parens::InTypeParam); + write_error_type_help(interns, arg, buf, Parens::InTypeParam); } if write_parens { @@ -2576,7 +2575,7 @@ fn write_error_type_help( buf.push('('); } buf.push_str("Num "); - write_error_type_help(home, interns, other, buf, Parens::InTypeParam); + write_error_type_help(interns, other, buf, Parens::InTypeParam); if write_parens { buf.push(')'); @@ -2594,7 +2593,7 @@ fn write_error_type_help( let mut it = arguments.into_iter().peekable(); while let Some(arg) = it.next() { - write_error_type_help(home, interns, arg, buf, Parens::InFn); + write_error_type_help(interns, arg, buf, Parens::InFn); if it.peek().is_some() { buf.push_str(", "); } @@ -2602,7 +2601,7 @@ fn write_error_type_help( buf.push_str(" -> "); - write_error_type_help(home, interns, *result, buf, Parens::InFn); + write_error_type_help(interns, *result, buf, Parens::InFn); if write_parens { buf.push(')'); @@ -2627,7 +2626,7 @@ fn write_error_type_help( } }; - write_error_type_help(home, interns, content, buf, Parens::Unnecessary); + write_error_type_help(interns, content, buf, Parens::Unnecessary); } buf.push('}'); diff --git a/crates/editor/src/editor/main.rs b/crates/editor/src/editor/main.rs index b345815db5..1095bcec47 100644 --- a/crates/editor/src/editor/main.rs +++ b/crates/editor/src/editor/main.rs @@ -507,7 +507,7 @@ fn read_main_roc_file(project_dir_path_opt: Option<&Path>) -> (PathBuf, String) if let Some(&roc_file_name) = roc_file_names.first() { let full_roc_file_path = project_dir_path.join(roc_file_name); - let file_as_str = std::fs::read_to_string(&Path::new(&full_roc_file_path)) + let file_as_str = std::fs::read_to_string(Path::new(&full_roc_file_path)) .unwrap_or_else(|err| panic!("In the provided project {:?}, I found the roc file {:?}, but I failed to read it: {}", &project_dir_path, full_roc_file_path, err)); (full_roc_file_path, file_as_str) diff --git a/crates/editor/src/graphics/lowlevel/buffer.rs b/crates/editor/src/graphics/lowlevel/buffer.rs index 76f26e0480..593309460e 100644 --- a/crates/editor/src/graphics/lowlevel/buffer.rs +++ b/crates/editor/src/graphics/lowlevel/buffer.rs @@ -42,7 +42,7 @@ impl QuadBufferBuilder { max_y: f32, color: [f32; 4], ) -> Self { - self.vertex_data.extend(&[ + self.vertex_data.extend([ Vertex { position: (min_x, min_y).into(), color, @@ -60,7 +60,7 @@ impl QuadBufferBuilder { color, }, ]); - self.index_data.extend(&[ + self.index_data.extend([ self.current_quad * 4, self.current_quad * 4 + 1, self.current_quad * 4 + 2, diff --git a/crates/highlight/src/highlight_parser.rs b/crates/highlight/src/highlight_parser.rs index f096cf7cec..ff1efc1e79 100644 --- a/crates/highlight/src/highlight_parser.rs +++ b/crates/highlight/src/highlight_parser.rs @@ -233,7 +233,7 @@ pub mod highlight_tests { node_to_string_w_children( *highlight_defs("a = 0", &mut mark_node_pool) .unwrap() - .get(0) + .first() .unwrap(), &mut str_buffer, &mark_node_pool, diff --git a/crates/linker/src/elf.rs b/crates/linker/src/elf.rs index 29ac545944..3b59d08bd0 100644 --- a/crates/linker/src/elf.rs +++ b/crates/linker/src/elf.rs @@ -1597,7 +1597,7 @@ mod tests { // we need to compile the app first let output = std::process::Command::new(&zig) .current_dir(dir) - .args(&[ + .args([ "build-obj", "app.zig", "-fPIC", @@ -1637,7 +1637,7 @@ mod tests { // now we can compile the host (it uses libapp.so, hence the order here) let output = std::process::Command::new(&zig) .current_dir(dir) - .args(&[ + .args([ "build-exe", "libapp.so", "host.zig", @@ -1672,7 +1672,7 @@ mod tests { std::fs::copy(&dir.join("preprocessedhost"), &dir.join("final")).unwrap(); surgery_elf( - &*roc_app, + &roc_app, &dir.join("metadata"), &dir.join("final"), false, diff --git a/crates/linker/src/generate_dylib/macho.rs b/crates/linker/src/generate_dylib/macho.rs index 4c80fb06eb..f1c6ba5342 100644 --- a/crates/linker/src/generate_dylib/macho.rs +++ b/crates/linker/src/generate_dylib/macho.rs @@ -47,7 +47,7 @@ pub fn create_dylib_macho( } std::fs::write( - &dummy_obj_file, + dummy_obj_file, out_object.write().expect("failed to build output object"), ) .expect("failed to write object to file"); @@ -67,7 +67,7 @@ pub fn create_dylib_macho( let output = Command::new("ld") .args(ld_prefix_args) - .args(&[ + .args([ ld_flag_soname, dummy_lib_file.file_name().unwrap().to_str().unwrap(), dummy_obj_file.to_str().unwrap(), diff --git a/crates/linker/src/lib.rs b/crates/linker/src/lib.rs index b51b9703dd..841432f9ee 100644 --- a/crates/linker/src/lib.rs +++ b/crates/linker/src/lib.rs @@ -231,7 +231,7 @@ fn generate_import_library(stub_lib_path: &Path, custom_names: &[String]) { // > https://github.com/messense/implib-rs let output = std::process::Command::new(&zig) .current_dir(stub_lib_path.parent().unwrap()) - .args(&[ + .args([ "dlltool", "-d", def_filename.to_str().unwrap(), diff --git a/crates/linker/src/metadata.rs b/crates/linker/src/metadata.rs index aa665988a0..9085ea15e1 100644 --- a/crates/linker/src/metadata.rs +++ b/crates/linker/src/metadata.rs @@ -8,13 +8,13 @@ use roc_collections::all::MutMap; use roc_error_macros::internal_error; use serde::{Deserialize, Serialize}; -#[derive(Serialize, Deserialize, PartialEq, Debug)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] pub enum VirtualOffset { Absolute, Relative(u64), } -#[derive(Serialize, Deserialize, PartialEq, Debug)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] pub struct SurgeryEntry { pub file_offset: u64, pub virtual_offset: VirtualOffset, @@ -25,7 +25,7 @@ pub struct SurgeryEntry { // I think a number of them can be combined to reduce string duplication. // Also I think a few of them aren't need. // For example, I think preprocessing can deal with all shifting and remove the need for added_byte_count. -#[derive(Default, Serialize, Deserialize, PartialEq, Debug)] +#[derive(Default, Serialize, Deserialize, PartialEq, Eq, Debug)] pub struct Metadata { pub app_functions: Vec, // offset followed by address. diff --git a/crates/linker/src/pe.rs b/crates/linker/src/pe.rs index 211d249bcd..8a0846d8a2 100644 --- a/crates/linker/src/pe.rs +++ b/crates/linker/src/pe.rs @@ -1617,7 +1617,7 @@ mod test { // we need to compile the app first let output = std::process::Command::new(&zig) .current_dir(dir) - .args(&[ + .args([ "build-obj", "app.zig", "-target", @@ -1642,7 +1642,7 @@ mod test { let file = std::fs::File::open(dir.join("app.obj")).unwrap(); let roc_app = unsafe { memmap2::Mmap::map(&file) }.unwrap(); - let roc_app_sections = AppSections::from_data(&*roc_app); + let roc_app_sections = AppSections::from_data(&roc_app); let symbols = roc_app_sections.roc_symbols; // make the dummy dylib based on the app object @@ -1653,7 +1653,7 @@ mod test { // now we can compile the host (it uses libapp.dll, hence the order here) let output = std::process::Command::new(&zig) .current_dir(dir) - .args(&[ + .args([ "build-exe", "libapp.dll", "host.zig", @@ -1689,7 +1689,7 @@ mod test { std::fs::copy(&dir.join("preprocessedhost"), &dir.join("app.exe")).unwrap(); - surgery_pe(&dir.join("app.exe"), &dir.join("metadata"), &*roc_app); + surgery_pe(&dir.join("app.exe"), &dir.join("metadata"), &roc_app); } #[allow(dead_code)] @@ -1731,7 +1731,7 @@ mod test { let output = std::process::Command::new("wine") .current_dir(dir) - .args(&["app.exe"]) + .args(["app.exe"]) .output() .unwrap(); @@ -1869,7 +1869,7 @@ mod test { let output = std::process::Command::new(&zig) .current_dir(dir) - .args(&[ + .args([ "build-exe", "host.zig", "-lc", diff --git a/crates/repl_eval/src/eval.rs b/crates/repl_eval/src/eval.rs index dc76afcd91..38554598da 100644 --- a/crates/repl_eval/src/eval.rs +++ b/crates/repl_eval/src/eval.rs @@ -345,13 +345,8 @@ fn jit_to_ast_help<'a, A: ReplApp<'a>>( let result = match layout { Layout::Builtin(Builtin::Bool) => Ok(app.call_function( main_fn_name, - |mem: &A::Memory, num: bool| { - bool_to_ast( - env, - mem, - num, - env.subs.get_content_without_compacting(raw_var), - ) + |_mem: &A::Memory, num: bool| { + bool_to_ast(env, num, env.subs.get_content_without_compacting(raw_var)) }, )), Layout::Builtin(Builtin::Int(int_width)) => { @@ -362,13 +357,8 @@ fn jit_to_ast_help<'a, A: ReplApp<'a>>( (Some(Alias(Symbol::NUM_UNSIGNED8, ..)), U8) => num_helper!(u8), (_, U8) => { // This is not a number, it's a tag union or something else - app.call_function(main_fn_name, |mem: &A::Memory, num: u8| { - byte_to_ast( - env, - mem, - num, - env.subs.get_content_without_compacting(raw_var), - ) + app.call_function(main_fn_name, |_mem: &A::Memory, num: u8| { + byte_to_ast(env, num, env.subs.get_content_without_compacting(raw_var)) }) } // The rest are numbers... for now @@ -582,7 +572,7 @@ fn addr_to_ast<'a, M: ReplAppMemory>( // num is always false at the moment. let num: bool = mem.deref_bool(addr); - bool_to_ast(env, mem, num, raw_content) + bool_to_ast(env, num, raw_content) } (_, Layout::Builtin(Builtin::Int(int_width))) => { use IntWidth::*; @@ -1141,12 +1131,7 @@ fn unpack_two_element_tag_union( (tag_name1, payload_vars1, tag_name2, payload_vars2) } -fn bool_to_ast<'a, M: ReplAppMemory>( - env: &Env<'a, '_>, - mem: &M, - value: bool, - content: &Content, -) -> Expr<'a> { +fn bool_to_ast<'a>(env: &Env<'a, '_>, value: bool, content: &Content) -> Expr<'a> { use Content::*; let arena = env.arena; @@ -1176,7 +1161,7 @@ fn bool_to_ast<'a, M: ReplAppMemory>( let content = env.subs.get_content_without_compacting(var); let loc_payload = &*arena.alloc(Loc { - value: bool_to_ast(env, mem, value, content), + value: bool_to_ast(env, value, content), region: Region::zero(), }); @@ -1225,7 +1210,7 @@ fn bool_to_ast<'a, M: ReplAppMemory>( Alias(_, _, var, _) => { let content = env.subs.get_content_without_compacting(*var); - bool_to_ast(env, mem, value, content) + bool_to_ast(env, value, content) } other => { unreachable!("Unexpected FlatType {:?} in bool_to_ast", other); @@ -1233,12 +1218,7 @@ fn bool_to_ast<'a, M: ReplAppMemory>( } } -fn byte_to_ast<'a, M: ReplAppMemory>( - env: &mut Env<'a, '_>, - mem: &M, - value: u8, - content: &Content, -) -> Expr<'a> { +fn byte_to_ast<'a>(env: &mut Env<'a, '_>, value: u8, content: &Content) -> Expr<'a> { use Content::*; let arena = env.arena; @@ -1268,7 +1248,7 @@ fn byte_to_ast<'a, M: ReplAppMemory>( let content = env.subs.get_content_without_compacting(var); let loc_payload = &*arena.alloc(Loc { - value: byte_to_ast(env, mem, value, content), + value: byte_to_ast(env, value, content), region: Region::zero(), }); @@ -1345,7 +1325,7 @@ fn byte_to_ast<'a, M: ReplAppMemory>( Alias(_, _, var, _) => { let content = env.subs.get_content_without_compacting(*var); - byte_to_ast(env, mem, value, content) + byte_to_ast(env, value, content) } other => { unreachable!("Unexpected FlatType {:?} in byte_to_ast", other); diff --git a/crates/repl_expect/src/run.rs b/crates/repl_expect/src/run.rs index 39044c45e6..af95645efb 100644 --- a/crates/repl_expect/src/run.rs +++ b/crates/repl_expect/src/run.rs @@ -239,7 +239,7 @@ fn run_expect_fx<'a, W: std::io::Write>( ) -> std::io::Result { use signal_hook::{consts::signal::SIGCHLD, consts::signal::SIGUSR1, iterator::Signals}; - let mut signals = Signals::new(&[SIGCHLD, SIGUSR1]).unwrap(); + let mut signals = Signals::new([SIGCHLD, SIGUSR1]).unwrap(); match unsafe { libc::fork() } { 0 => unsafe { diff --git a/crates/repl_wasm/build.rs b/crates/repl_wasm/build.rs index 93f869ef43..f7397754d7 100644 --- a/crates/repl_wasm/build.rs +++ b/crates/repl_wasm/build.rs @@ -20,7 +20,7 @@ fn main() { let platform_obj = build_wasm_platform(&out_dir, &source_path); let mut pre_linked_binary_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()); - pre_linked_binary_path.extend(&["pre_linked_binary"]); + pre_linked_binary_path.extend(["pre_linked_binary"]); pre_linked_binary_path.set_extension("o"); let output = Command::new(&zig_executable()) diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index 6f82759b09..997d714d84 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -4847,14 +4847,27 @@ mod test_reporting { "# ), @r###" - ── MISSING EXPRESSION ───────────────────── tmp/pattern_binds_keyword/Test.roc ─ + ── MISSING ARROW ────────────────────────── tmp/pattern_binds_keyword/Test.roc ─ - I am partway through parsing a `when` expression, but I got stuck here: + I am partway through parsing a `when` expression, but got stuck here: 5│ Just when -> - ^ + ^ - I was expecting to see an expression like 42 or "hello". + I was expecting to see an arrow next. + + Note: Sometimes I get confused by indentation, so try to make your `when` + look something like this: + + when List.first plants is + Ok n -> + n + + Err _ -> + 200 + + Notice the indentation. All patterns are aligned, and each branch is + indented a bit more than the corresponding pattern. That is important! "### ); diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index b433a05442..f0e99282c3 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; #[doc(hidden)] pub use pretty_assertions::assert_eq as _pretty_assert_eq; -#[derive(PartialEq)] +#[derive(PartialEq, Eq)] pub struct DebugAsDisplay(pub T); impl std::fmt::Debug for DebugAsDisplay { @@ -32,7 +32,7 @@ impl TmpDir { let path = std::path::Path::new(dir); // ensure_empty_dir will fail if the dir doesn't already exist std::fs::create_dir_all(path).unwrap(); - remove_dir_all::ensure_empty_dir(&path).unwrap(); + remove_dir_all::ensure_empty_dir(path).unwrap(); let mut pathbuf = std::path::PathBuf::new(); pathbuf.push(path); diff --git a/crates/vendor/morphic_lib/src/analyze.rs b/crates/vendor/morphic_lib/src/analyze.rs index 498a2c279b..44f58da4ad 100644 --- a/crates/vendor/morphic_lib/src/analyze.rs +++ b/crates/vendor/morphic_lib/src/analyze.rs @@ -1562,11 +1562,11 @@ impl Query { } hasher.update((self.arg_slots_touched.len() as u64).to_le_bytes()); for &arg_touched in &self.arg_slots_touched { - hasher.update(&[arg_touched as u8]); + hasher.update([arg_touched as u8]); } hasher.update((self.ret_slots_touched.len() as u64).to_le_bytes()); for &ret_touched in &self.ret_slots_touched { - hasher.update(&[ret_touched as u8]); + hasher.update([ret_touched as u8]); } api::FuncSpec(hasher.finalize().into()) } @@ -1775,7 +1775,7 @@ pub(crate) fn analyze(tc: TypeCache, program: &ir::Program) -> ProgramSolutions fn hash_func_id_trivial(func_id: FuncId) -> api::FuncSpec { use sha2::{Digest, Sha256}; let mut hasher = Sha256::new(); - hasher.update(&func_id.0.to_le_bytes()); + hasher.update(func_id.0.to_le_bytes()); api::FuncSpec(hasher.finalize().into()) } diff --git a/crates/vendor/morphic_lib/src/api.rs b/crates/vendor/morphic_lib/src/api.rs index b93180764c..70ec8efa19 100644 --- a/crates/vendor/morphic_lib/src/api.rs +++ b/crates/vendor/morphic_lib/src/api.rs @@ -1654,7 +1654,7 @@ pub fn solve_trivial(api_program: Program) -> Result { // solutions fn hash_bstr(hasher: &mut Sha256, bstr: &[u8]) { let header = (bstr.len() as u64).to_le_bytes(); - hasher.update(&header); + hasher.update(header); hasher.update(bstr); } diff --git a/examples/ruby-interop/README.md b/examples/ruby-interop/README.md index 6257894786..d95a2c9d0d 100644 --- a/examples/ruby-interop/README.md +++ b/examples/ruby-interop/README.md @@ -49,10 +49,9 @@ You can now try this out in Ruby's REPL (`irb`), like so: ```sh $ irb irb(main):001:0> require_relative 'demo' -Ruby just required Roc. Let's get READY TO ROC. => true -irb(main):002:0> RocStuff::hello 'Hello, World' -=> "Hello, World, OH YEAH!!! 🤘🤘" +irb(main):002:0> RocApp::call_roc 42 +=> "The number was 42, OH YEAH!!! 🤘🤘" ``` ## Rebuilding after Changes diff --git a/examples/ruby-interop/demo.c b/examples/ruby-interop/demo.c index f0572368f0..b5afb29419 100644 --- a/examples/ruby-interop/demo.c +++ b/examples/ruby-interop/demo.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -19,10 +20,7 @@ void roc_dealloc(void *ptr, unsigned int alignment) { free(ptr); } __attribute__((noreturn)) void roc_panic(void *ptr, unsigned int alignment) { - char *msg = (char *)ptr; - fprintf(stderr, - "Application crashed with message\n\n %s\n\nShutting down\n", msg); - exit(0); + rb_raise(rb_eException, "%s", (char *)ptr); } void *roc_memcpy(void *dest, const void *src, size_t n) @@ -32,42 +30,142 @@ void *roc_memcpy(void *dest, const void *src, size_t n) void *roc_memset(void *str, int c, size_t n) { return memset(str, c, n); } -struct RocStr +// Reference counting + +// If the refcount is set to this, that means the allocation is +// stored in readonly memory in the binary, and we must not +// attempt to increment or decrement it; if we do, we'll segfault! +const ssize_t REFCOUNT_READONLY = 0; +const ssize_t REFCOUNT_ONE = (ssize_t)PTRDIFF_MIN; +const size_t MASK = (size_t)PTRDIFF_MIN; + +// Increment reference count, given a pointer to the first element in a collection. +// We don't need to check for overflow because in order to overflow a usize worth of refcounts, +// you'd need to somehow have more pointers in memory than the OS's virtual address space can hold. +void incref(uint8_t* bytes, uint32_t alignment) { - char *bytes; + ssize_t *refcount_ptr = ((ssize_t *)bytes) - 1; + ssize_t refcount = *refcount_ptr; + + if (refcount != REFCOUNT_READONLY) { + *refcount_ptr = refcount + 1; + } +} + +// Decrement reference count, given a pointer to the first element in a collection. +// Then call roc_dealloc if nothing is referencing this collection anymore. +void decref(uint8_t* bytes, uint32_t alignment) +{ + if (bytes == NULL) { + return; + } + + size_t extra_bytes = (sizeof(size_t) >= (size_t)alignment) ? sizeof(size_t) : (size_t)alignment; + ssize_t *refcount_ptr = ((ssize_t *)bytes) - 1; + ssize_t refcount = *refcount_ptr; + + if (refcount != REFCOUNT_READONLY) { + *refcount_ptr = refcount - 1; + + if (refcount == REFCOUNT_ONE) { + void *original_allocation = (void *)(refcount_ptr - (extra_bytes - sizeof(size_t))); + + roc_dealloc(original_allocation, alignment); + } + } +} + +// RocBytes (List U8) + +struct RocBytes +{ + uint8_t *bytes; size_t len; size_t capacity; }; -struct RocStr init_rocstr(char *bytes, size_t len) +struct RocBytes init_rocbytes(uint8_t *bytes, size_t len) { - struct RocStr ret; - - if (len < sizeof(struct RocStr)) + if (len == 0) { - // This is a small string. TODO do small string things. - size_t refcount_size = sizeof(size_t); - char *new_content = (char *)roc_alloc(len + refcount_size, alignof(size_t)) - refcount_size; + struct RocBytes ret = { + .len = 0, + .bytes = NULL, + .capacity = MASK, + }; - roc_memcpy(new_content, bytes, len); - - ret.bytes = new_content; - ret.len = len; - ret.capacity = len; + return ret; } else { + struct RocBytes ret; size_t refcount_size = sizeof(size_t); - char *new_content = (char *)roc_alloc(len + refcount_size, alignof(size_t)) - refcount_size; + uint8_t *new_content = (uint8_t *)roc_alloc(len + refcount_size, alignof(size_t)) + refcount_size; - roc_memcpy(new_content, bytes, len); + memcpy(new_content, bytes, len); ret.bytes = new_content; ret.len = len; ret.capacity = len; - } - return ret; + return ret; + } +} + +// RocStr + +struct RocStr +{ + uint8_t *bytes; + size_t len; + size_t capacity; +}; + +struct RocStr init_rocstr(uint8_t *bytes, size_t len) +{ + if (len == 0) + { + struct RocStr ret = { + .len = 0, + .bytes = NULL, + .capacity = MASK, + }; + + return ret; + } + else if (len < sizeof(struct RocStr)) + { + // Start out with zeroed memory, so that + // if we end up comparing two small RocStr values + // for equality, we won't risk memory garbage resulting + // in two equal strings appearing unequal. + struct RocStr ret = { + .len = 0, + .bytes = NULL, + .capacity = MASK, + }; + + // Copy the bytes into the stack allocation + memcpy(&ret, bytes, len); + + // Record the string's length in the last byte of the stack allocation + ((uint8_t *)&ret)[sizeof(struct RocStr) - 1] = (uint8_t)len | 0b10000000; + + return ret; + } + else + { + // A large RocStr is the same as a List U8 (aka RocBytes) in memory. + struct RocBytes roc_bytes = init_rocbytes(bytes, len); + + struct RocStr ret = { + .len = roc_bytes.len, + .bytes = roc_bytes.bytes, + .capacity = roc_bytes.capacity, + }; + + return ret; + } } bool is_small_str(struct RocStr str) { return ((ssize_t)str.capacity) < 0; } @@ -76,9 +174,9 @@ bool is_small_str(struct RocStr str) { return ((ssize_t)str.capacity) < 0; } // account the small string optimization size_t roc_str_len(struct RocStr str) { - char *bytes = (char *)&str; - char last_byte = bytes[sizeof(str) - 1]; - char last_byte_xored = last_byte ^ 0b10000000; + uint8_t *bytes = (uint8_t *)&str; + uint8_t last_byte = bytes[sizeof(str) - 1]; + uint8_t last_byte_xored = last_byte ^ 0b10000000; size_t small_len = (size_t)(last_byte_xored); size_t big_len = str.len; @@ -95,45 +193,38 @@ size_t roc_str_len(struct RocStr str) } } -extern void roc__mainForHost_1_exposed_generic(struct RocStr *ret, struct RocStr *arg); +extern void roc__mainForHost_1_exposed_generic(struct RocBytes *ret, struct RocBytes *arg); -VALUE hello(VALUE self, VALUE rb_arg) +// Receive a value from Ruby, JSON serialized it and pass it to Roc as a List U8 +// (at which point the Roc platform will decode it and crash if it's invalid, +// which roc_panic will translate into a Ruby exception), then get some JSON back from Roc +// - also as a List U8 - and have Ruby JSON.parse it into a plain Ruby value to return. +VALUE call_roc(VALUE self, VALUE rb_arg) { - // Verify the argument is a Ruby string; raise a type error if not. - if (TYPE(rb_arg) != T_STRING) - { - rb_raise(rb_eTypeError, "`hello` only accepts strings."); - } + // This must be required before the to_json method will exist on String. + rb_require("json"); - struct RocStr arg = init_rocstr(RSTRING_PTR(rb_arg), RSTRING_LEN(rb_arg)); - struct RocStr ret; + // Turn the given Ruby value into a JSON string. + // TODO should we defensively encode it as UTF-8 first? + VALUE json_arg = rb_funcall(rb_arg, rb_intern("to_json"), 0); + struct RocBytes arg = init_rocbytes((uint8_t *)RSTRING_PTR(json_arg), RSTRING_LEN(json_arg)); + struct RocBytes ret; + + // Call the Roc function to populate `ret`'s bytes. roc__mainForHost_1_exposed_generic(&ret, &arg); - // Determine str_len and the str_bytes pointer, - // taking into account the small string optimization. - size_t str_len = roc_str_len(ret); - VALUE ruby_str; + // Create a rb_utf8_str from the heap-allocated JSON bytes the Roc function returned. + VALUE returned_json = rb_utf8_str_new((char *)ret.bytes, ret.len); - if (is_small_str(ret)) - { - ruby_str = rb_utf8_str_new((char *)&ret, str_len); - } - else - { - ruby_str = rb_utf8_str_new(ret.bytes, str_len); + // Now that we've created our Ruby JSON string, we're no longer referencing the RocBytes. + decref((void *)&ret, alignof(uint8_t *)); - // TODO decrement refcount and then only dealloc if that was the last reference - roc_dealloc(ret.bytes - sizeof(size_t), alignof(char *)); - } - - return ruby_str; + return rb_funcall(rb_define_module("JSON"), rb_intern("parse"), 1, returned_json); } void Init_demo() { - printf("Ruby just required Roc. Let's get READY TO ROC.\n"); - - VALUE roc_stuff = rb_define_module("RocStuff"); - rb_define_module_function(roc_stuff, "hello", &hello, 1); + VALUE roc_app = rb_define_module("RocApp"); + rb_define_module_function(roc_app, "call_roc", &call_roc, 1); } diff --git a/examples/ruby-interop/main.roc b/examples/ruby-interop/main.roc index f0ccd64238..9b9d316dca 100644 --- a/examples/ruby-interop/main.roc +++ b/examples/ruby-interop/main.roc @@ -1,11 +1,13 @@ app "libhello" packages { pf: "platform/main.roc" } imports [] - provides [makeItRoc] to pf + provides [main] to pf -makeItRoc : Str -> Str -makeItRoc = \str -> - if Str.isEmpty str then - "I need a string here!" +main : U64 -> Str +main = \num -> + if num == 0 then + "I need a positive number here!" else - "\(str), OH YEAH!!! 🤘🤘" + str = Num.toStr num + + "The number was \(str), OH YEAH!!! 🤘🤘" diff --git a/examples/ruby-interop/platform/main.roc b/examples/ruby-interop/platform/main.roc index 339ef9eb61..c26447e0d3 100644 --- a/examples/ruby-interop/platform/main.roc +++ b/examples/ruby-interop/platform/main.roc @@ -1,9 +1,12 @@ -platform "hello-world" - requires {} { makeItRoc : Str -> Str } +platform "ruby-interop" + requires {} { main : arg -> ret | arg has Decoding, ret has Encoding } exposes [] packages {} - imports [] + imports [Json] provides [mainForHost] -mainForHost : Str -> Str -mainForHost = \str -> makeItRoc str +mainForHost : List U8 -> List U8 +mainForHost = \json -> + when Decode.fromBytes json Json.fromUtf8 is + Ok arg -> Encode.toBytes (main arg) Json.toUtf8 + Err _ -> [] # TODO panic so that Ruby raises an exception