From f4551978ce8250dc3e963732e9cdec54902d10be Mon Sep 17 00:00:00 2001 From: JRI98 <38755101+JRI98@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:01:49 +0100 Subject: [PATCH 01/42] Handle multi pattern unbound list rest variables --- crates/compiler/can/src/pattern.rs | 9 ++++++-- crates/compiler/constrain/src/pattern.rs | 4 ++-- crates/compiler/load/tests/test_reporting.rs | 23 ++++++++++++++++++++ crates/compiler/mono/src/ir/pattern.rs | 4 +++- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/crates/compiler/can/src/pattern.rs b/crates/compiler/can/src/pattern.rs index a016356f37..dc3a7d7dfe 100644 --- a/crates/compiler/can/src/pattern.rs +++ b/crates/compiler/can/src/pattern.rs @@ -207,7 +207,7 @@ pub struct ListPatterns { /// [ .., A, B ] -> patterns = [A, B], rest = 0 /// [ A, .., B ] -> patterns = [A, B], rest = 1 /// [ A, B, .. ] -> patterns = [A, B], rest = 2 - pub opt_rest: Option<(usize, Option)>, + pub opt_rest: Option<(usize, Option>)>, } impl ListPatterns { @@ -793,7 +793,8 @@ pub fn canonicalize_pattern<'a>( pattern_as.identifier.value, ) { Ok(symbol) => { - rest_name = Some(symbol); + rest_name = + Some(Loc::at(pattern_as.identifier.region, symbol)); } Err(pattern) => { opt_erroneous = Some(pattern); @@ -997,6 +998,10 @@ impl<'a> BindingsFromPattern<'a> { | OpaqueNotInScope(..) => (), List { patterns, .. } => { stack.extend(patterns.patterns.iter().rev().map(Pattern)); + + if let Some((_, Some(rest_sym))) = &patterns.opt_rest { + return Some((rest_sym.value, rest_sym.region)); + } } } } diff --git a/crates/compiler/constrain/src/pattern.rs b/crates/compiler/constrain/src/pattern.rs index 3b3ce10a3d..c680206357 100644 --- a/crates/compiler/constrain/src/pattern.rs +++ b/crates/compiler/constrain/src/pattern.rs @@ -141,7 +141,7 @@ fn headers_from_annotation_help( constraints.push_type(types, typ) }; let typ = Loc::at(annotation.region, annotation_index); - headers.insert(rest, typ); + headers.insert(rest.value, typ); false } else { @@ -735,7 +735,7 @@ pub fn constrain_pattern( if let Some((_, Some(rest))) = opt_rest { state.headers.insert( - *rest, + rest.value, Loc { region, value: *constraints[expected].get_type_ref(), diff --git a/crates/compiler/load/tests/test_reporting.rs b/crates/compiler/load/tests/test_reporting.rs index 3510fe9e24..38f2788961 100644 --- a/crates/compiler/load/tests/test_reporting.rs +++ b/crates/compiler/load/tests/test_reporting.rs @@ -10501,6 +10501,29 @@ In roc, functions are always written as a lambda, like{} "### ); + test_report!( + issue_6825, + indoc!( + r#" + when [] is + [] | [_, .. as rest] if List.isEmpty rest -> [] + _ -> [] + "# + ), + @r###" + ── NAME NOT BOUND IN ALL PATTERNS in /code/proj/Main.roc ─────────────────────── + + `rest` is not bound in all patterns of this `when` branch + + 5│ [] | [_, .. as rest] if List.isEmpty rest -> [] + ^^^^ + + Identifiers introduced in a `when` branch must be bound in all patterns + of the branch. Otherwise, the program would crash when it tries to use + an identifier that wasn't bound! + "### + ); + test_report!( flip_flop_catch_all_branches_not_exhaustive, indoc!( diff --git a/crates/compiler/mono/src/ir/pattern.rs b/crates/compiler/mono/src/ir/pattern.rs index ed6787c96f..de0c96e495 100644 --- a/crates/compiler/mono/src/ir/pattern.rs +++ b/crates/compiler/mono/src/ir/pattern.rs @@ -1084,7 +1084,9 @@ fn from_can_pattern_help<'a>( list_layout, element_layout, elements: mono_patterns, - opt_rest: patterns.opt_rest, + opt_rest: patterns + .opt_rest + .map(|(i, name)| (i, name.map(|s| s.value))), }) } } From 4d0112ef2ac720f6d1a76b0830a887bdf5eb76a9 Mon Sep 17 00:00:00 2001 From: shua Date: Sun, 23 Jun 2024 16:19:30 +0200 Subject: [PATCH 02/42] resolve TODO: don't use vec --- crates/compiler/build/src/link.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index 347f713f41..845ed8e6ec 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -981,20 +981,14 @@ fn link_linux( LinkType::Executable => ( // Presumably this S stands for Static, since if we include Scrt1.o // in the linking for dynamic builds, linking fails. - vec![scrt1_path_str.to_string()], + [scrt1_path_str.as_ref()], output_path, ), LinkType::Dylib => { let mut output_path = output_path; output_path.set_extension("so"); - ( - // TODO: find a way to avoid using a vec! here - should theoretically be - // able to do this somehow using &[] but the borrow checker isn't having it. - // Also find a way to have these be string slices instead of Strings. - vec!["-shared".to_string()], - output_path, - ) + (["-shared"], output_path) } LinkType::None => internal_error!("link_linux should not be called with link type of none"), }; From 91c071713bf4db2fbd9e98342b164047489ac1f2 Mon Sep 17 00:00:00 2001 From: shua Date: Mon, 24 Jun 2024 16:53:32 +0200 Subject: [PATCH 03/42] appease clippy (only on mac silicon?) --- crates/compiler/build/src/link.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index 845ed8e6ec..620d1381fb 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -1019,7 +1019,7 @@ fn link_linux( &crti_path_str, &crtn_path_str, ]) - .args(&base_args) + .args(base_args) .args(["-dynamic-linker", ld_linux_path_str]) .args(input_paths) .args(extra_link_flags()) From 1f0303cf53c5a05a8ff20b08ac631d53e8959f0b Mon Sep 17 00:00:00 2001 From: Jackson Wambolt Date: Wed, 26 Jun 2024 03:35:02 +0000 Subject: [PATCH 04/42] Narrow use of unsafe in `roc_run_native` `roc_run_native_fast` is actually the only unsafe part of the function, so we probably don't need everything to be wrapped in an `unsafe` block. --- crates/cli/src/lib.rs | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 7ab9b4e577..7431c4880c 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -1099,28 +1099,26 @@ fn roc_run_native, S: AsRef>( ) -> std::io::Result { use bumpalo::collections::CollectIn; - unsafe { - let executable = roc_run_executable_file_path(binary_bytes)?; - let (argv_cstrings, envp_cstrings) = make_argv_envp(arena, &executable, args); + let executable = roc_run_executable_file_path(binary_bytes)?; + let (argv_cstrings, envp_cstrings) = make_argv_envp(arena, &executable, args); - let argv: bumpalo::collections::Vec<*const c_char> = argv_cstrings - .iter() - .map(|s| s.as_ptr()) - .chain([std::ptr::null()]) - .collect_in(arena); + let argv: bumpalo::collections::Vec<*const c_char> = argv_cstrings + .iter() + .map(|s| s.as_ptr()) + .chain([std::ptr::null()]) + .collect_in(arena); - let envp: bumpalo::collections::Vec<*const c_char> = envp_cstrings - .iter() - .map(|s| s.as_ptr()) - .chain([std::ptr::null()]) - .collect_in(arena); + let envp: bumpalo::collections::Vec<*const c_char> = envp_cstrings + .iter() + .map(|s| s.as_ptr()) + .chain([std::ptr::null()]) + .collect_in(arena); - match opt_level { - OptLevel::Development => roc_dev_native(arena, executable, argv, envp, expect_metadata), - OptLevel::Normal | OptLevel::Size | OptLevel::Optimize => { - roc_run_native_fast(executable, &argv, &envp); - } - } + match opt_level { + OptLevel::Development => roc_dev_native(arena, executable, argv, envp, expect_metadata), + OptLevel::Normal | OptLevel::Size | OptLevel::Optimize => unsafe { + roc_run_native_fast(executable, &argv, &envp); + }, } Ok(1) From 11c9b90551adfa0260ae004caf6caf65aae298f7 Mon Sep 17 00:00:00 2001 From: Jackson Wambolt Date: Wed, 26 Jun 2024 04:50:06 +0000 Subject: [PATCH 05/42] Get exit code correctly `status` isn't the exit code of the program - the actual exit code is shifted left by 8 bits. We can get that with a `WIFEXITED` check to make sure the exit code exists, followed by `WEXITSTATUS` to retrieve it. --- crates/cli/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 7431c4880c..e036eef36f 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -1244,7 +1244,13 @@ fn roc_dev_native( let options = 0; unsafe { libc::waitpid(pid, &mut status, options) }; - break status; + // if `WIFEXITED` returns false, `WEXITSTATUS` will just return junk + break if libc::WIFEXITED(status) { + libc::WEXITSTATUS(status) + } else { + // we don't have an exit code, so we probably shouldn't make one up + 0 + }; } ChildProcessMsg::Expect => { roc_repl_expect::run::render_expects_in_memory( From d0f8dbe85b35f7bb77b46447da84f88a733f46a0 Mon Sep 17 00:00:00 2001 From: Jackson Wambolt Date: Wed, 26 Jun 2024 04:54:51 +0000 Subject: [PATCH 06/42] Clean up `roc_dev_native` a bit `writer` is only used by the parent process, so we don't need the soon-to-be-forked child process to create it just to immediately get overwritten by `execve`. --- crates/cli/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index e036eef36f..486fd702e9 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -1205,14 +1205,11 @@ fn roc_dev_native( layout_interner, } = expect_metadata; - // let shm_name = let shm_name = format!("/roc_expect_buffer_{}", std::process::id()); let mut memory = ExpectMemory::create_or_reuse_mmap(&shm_name); let layout_interner = layout_interner.into_global(); - let mut writer = std::io::stdout(); - match unsafe { libc::fork() } { 0 => unsafe { // we are the child @@ -1253,6 +1250,7 @@ fn roc_dev_native( }; } ChildProcessMsg::Expect => { + let mut writer = std::io::stdout(); roc_repl_expect::run::render_expects_in_memory( &mut writer, arena, From cc7d3d3e1dfaeb79555e613acf13bad6e69aa4c8 Mon Sep 17 00:00:00 2001 From: Isak Date: Thu, 27 Jun 2024 13:34:09 -0400 Subject: [PATCH 07/42] fix: allow multiple newlines between signature and body --- crates/compiler/can/tests/test_can.rs | 12 +----- crates/compiler/parse/src/expr.rs | 60 ++++++++++++--------------- 2 files changed, 29 insertions(+), 43 deletions(-) diff --git a/crates/compiler/can/tests/test_can.rs b/crates/compiler/can/tests/test_can.rs index fa44b0e728..29d9ad73ba 100644 --- a/crates/compiler/can/tests/test_can.rs +++ b/crates/compiler/can/tests/test_can.rs @@ -379,11 +379,7 @@ mod test_can { let arena = Bump::new(); let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src); - assert_eq!(problems.len(), 2); - assert!(problems.iter().any(|problem| matches!( - problem, - Problem::RuntimeError(RuntimeError::Shadowing { .. }) - ))); + assert_eq!(problems.len(), 0); } #[test] @@ -400,11 +396,7 @@ mod test_can { let arena = Bump::new(); let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src); - assert_eq!(problems.len(), 2); - assert!(problems.iter().any(|problem| matches!( - problem, - Problem::RuntimeError(RuntimeError::Shadowing { .. }) - ))); + assert_eq!(problems.len(), 0); } #[test] diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 272346ca04..19292e5ad2 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -1366,18 +1366,22 @@ fn parse_defs_end<'a>( ); } Either::Second(value_def) => { - // If we got a ValueDef::Body, check if a type annotation preceded it. - // If so, we may need to combine them into an AnnotatedBody. - let joined = match value_def { - ValueDef::Body(loc_pattern, loc_def_expr) - if spaces_before_current.len() <= 1 => - { + let joined_def = match value_def { + // If we got a ValueDef::Body, check if a type annotation preceded it. + // If so, we may need to combine them into an AnnotatedBody. + ValueDef::Body(loc_pattern, loc_def_expr) => { let region = Region::span_across(&loc_pattern.region, &loc_def_expr.region); + let signature_must_match_value = spaces_before_current.len() <= 1; + let value_name = &loc_pattern.value; + match defs.last() { - Some(Err(ValueDef::Annotation(ann_pattern, ann_type))) => { - let (value_def, region) = join_ann_to_body!( + Some(Err(ValueDef::Annotation(ann_pattern, ann_type))) + if signature_must_match_value + || ann_pattern.value.equivalent(value_name) => + { + Some(join_ann_to_body!( arena, loc_pattern, loc_def_expr, @@ -1385,21 +1389,19 @@ fn parse_defs_end<'a>( ann_type, spaces_before_current, region - ); - - defs.replace_with_value_def( - defs.tags.len() - 1, - value_def, - region, - ); - - true + )) } Some(Ok(TypeDef::Alias { header, ann: ann_type, - })) => { - let (value_def, region) = join_alias_to_body!( + })) if signature_must_match_value + || header + .vars + .first() + .map(|var| var.value.equivalent(value_name)) + .unwrap_or(false) => + { + Some(join_alias_to_body!( arena, loc_pattern, loc_def_expr, @@ -1407,24 +1409,16 @@ fn parse_defs_end<'a>( ann_type, spaces_before_current, region - ); - - defs.replace_with_value_def( - defs.tags.len() - 1, - value_def, - region, - ); - - true + )) } - _ => false, + _ => None, } } - _ => false, + _ => None, }; - - if !joined { - // the previous and current def can't be joined up + if let Some((joined_def, region)) = joined_def { + defs.replace_with_value_def(defs.tags.len() - 1, joined_def, region); + } else { defs.push_value_def( value_def, region, From eb98dd7bdeb6bd4d6b89ddf7b4ca67aa31b4a838 Mon Sep 17 00:00:00 2001 From: Isak Date: Thu, 27 Jun 2024 13:38:30 -0400 Subject: [PATCH 08/42] move comment --- crates/compiler/parse/src/expr.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 19292e5ad2..e5cb4fd60e 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -1366,9 +1366,9 @@ fn parse_defs_end<'a>( ); } Either::Second(value_def) => { + // If we got a ValueDef::Body, check if a type annotation preceded it. + // If so, we may need to combine them into an AnnotatedBody. let joined_def = match value_def { - // If we got a ValueDef::Body, check if a type annotation preceded it. - // If so, we may need to combine them into an AnnotatedBody. ValueDef::Body(loc_pattern, loc_def_expr) => { let region = Region::span_across(&loc_pattern.region, &loc_def_expr.region); From ee84b613605c10be71587331d029c2ddcfcb40b8 Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Thu, 13 Jun 2024 19:10:32 +1000 Subject: [PATCH 09/42] update preprocess host API --- crates/cli/src/lib.rs | 30 ++++++++++---- crates/cli/src/main.rs | 58 +++++++++++++++++++--------- crates/compiler/build/src/program.rs | 5 ++- crates/linker/src/lib.rs | 29 +++++++------- crates/linker/src/macho.rs | 2 +- 5 files changed, 79 insertions(+), 45 deletions(-) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 7ab9b4e577..4871bfba30 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -79,6 +79,9 @@ pub const GLUE_DIR: &str = "GLUE_DIR"; pub const GLUE_SPEC: &str = "GLUE_SPEC"; pub const DIRECTORY_OR_FILES: &str = "DIRECTORY_OR_FILES"; pub const ARGS_FOR_APP: &str = "ARGS_FOR_APP"; +pub const FLAG_PP_HOST: &str = "host"; +pub const FLAG_PP_PLATFORM: &str = "platform"; +pub const FLAG_PP_DYLIB: &str = "lib"; const VERSION: &str = include_str!("../../../version.txt"); const DEFAULT_GENERATED_DOCS_DIR: &str = "generated-docs"; @@ -400,18 +403,29 @@ pub fn build_app() -> Command { .subcommand(Command::new(CMD_PREPROCESS_HOST) .about("Runs the surgical linker preprocessor to generate `.rh` and `.rm` files.") .arg( - Arg::new(ROC_FILE) - .help("The .roc file for an app using the platform") + Arg::new(FLAG_PP_HOST) + .help("Path to the host executable where the app was linked dynamically") .value_parser(value_parser!(PathBuf)) .required(true) ) .arg( - Arg::new(FLAG_TARGET) - .long(FLAG_TARGET) - .help("Choose a different target") - .default_value(Into::<&'static str>::into(Target::default())) - .value_parser(build_target_values_parser) - .required(false), + Arg::new(FLAG_PP_PLATFORM) + .help("Path to the platform/main.roc file") + .value_parser(value_parser!(PathBuf)) + .required(true) + ) + .arg( + Arg::new(FLAG_PP_DYLIB) + .help("Path to a stubbed app dynamic library (e.g. roc build --lib app.roc)") + .value_parser(value_parser!(PathBuf)) + .required(true) + ) + .arg( + Arg::new(FLAG_VERBOSE) + .long(FLAG_VERBOSE) + .help("Print detailed information while pre-processing host") + .action(ArgAction::SetTrue) + .required(false) ) ) .arg(flag_optimize) diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 7aceca7121..f5cb5e0f77 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -6,8 +6,8 @@ use roc_cli::{ build_app, format_files, format_src, test, BuildConfig, FormatMode, CMD_BUILD, CMD_CHECK, CMD_DEV, CMD_DOCS, CMD_FORMAT, CMD_GEN_STUB_LIB, CMD_GLUE, CMD_PREPROCESS_HOST, CMD_REPL, CMD_RUN, CMD_TEST, CMD_VERSION, DIRECTORY_OR_FILES, FLAG_CHECK, FLAG_DEV, FLAG_LIB, FLAG_MAIN, - FLAG_NO_LINK, FLAG_OUTPUT, FLAG_STDIN, FLAG_STDOUT, FLAG_TARGET, FLAG_TIME, GLUE_DIR, - GLUE_SPEC, ROC_FILE, + FLAG_NO_LINK, FLAG_OUTPUT, FLAG_PP_DYLIB, FLAG_PP_HOST, FLAG_PP_PLATFORM, FLAG_STDIN, + FLAG_STDOUT, FLAG_TARGET, FLAG_TIME, GLUE_DIR, GLUE_SPEC, ROC_FILE, }; use roc_docs::generate_docs_html; use roc_error_macros::user_error; @@ -136,31 +136,53 @@ fn main() -> io::Result<()> { Ok(0) } Some((CMD_PREPROCESS_HOST, matches)) => { - let input_path = matches.get_one::(ROC_FILE).unwrap(); + let preprocess_host_err = + { |msg: String| user_error!("\n\n ERROR PRE-PROCESSING HOST: {}\n\n", msg) }; + + let host_path = matches.get_one::(FLAG_PP_HOST).unwrap(); + if !host_path.is_file() { + preprocess_host_err(format!( + "Expected to find the host executable file at {}", + &host_path.display() + )); + } + + let platform_path = matches.get_one::(FLAG_PP_PLATFORM).unwrap(); + if !platform_path.is_file() { + preprocess_host_err(format!( + "Expected to find the platform/main.roc file at {}", + &platform_path.display() + )); + } + + let dylib_path = matches.get_one::(FLAG_PP_DYLIB).unwrap(); + if !dylib_path.is_file() { + preprocess_host_err(format!( + "Expected to find the app stub dynamic library file at {}", + dylib_path.display() + )); + } let target = matches .get_one::(FLAG_TARGET) .and_then(|s| Target::from_str(s).ok()) .unwrap_or_default(); - let function_kind = FunctionKind::LambdaSet; - let (platform_path, stub_lib, stub_dll_symbols) = roc_linker::generate_stub_lib( - input_path, - RocCacheDir::Persistent(cache::roc_cache_dir().as_path()), - target, - function_kind, - ); + let verbose_and_time = matches.get_one::(roc_cli::FLAG_VERBOSE).unwrap(); + + #[cfg(target_os = "windows")] + { + internal_error!("TODO populate stub_dll_symbols for Windows"); + } - // TODO: pipeline the executable location through here. - // Currently it is essentally hardcoded as platform_path/dynhost. roc_linker::preprocess_host( target, - &platform_path.with_file_name("main.roc"), - // The target triple string must be derived from the triple to convert from the generic - // `system` target to the exact specific target. - &platform_path.with_file_name(format!("{}.rh", target)), - &stub_lib, - &stub_dll_symbols, + host_path, + platform_path, + dylib_path, + *verbose_and_time, + *verbose_and_time, ); + Ok(0) } Some((CMD_BUILD, matches)) => { diff --git a/crates/compiler/build/src/program.rs b/crates/compiler/build/src/program.rs index 1c3a77f028..286ffdee7e 100644 --- a/crates/compiler/build/src/program.rs +++ b/crates/compiler/build/src/program.rs @@ -1181,10 +1181,11 @@ fn build_and_preprocess_host_lowlevel( roc_linker::preprocess_host( target, - platform_main_roc, preprocessed_host_path, + platform_main_roc, &stub_lib, - stub_dll_symbols, + false, + false, ) } diff --git a/crates/linker/src/lib.rs b/crates/linker/src/lib.rs index 17c905aaa8..783bba0443 100644 --- a/crates/linker/src/lib.rs +++ b/crates/linker/src/lib.rs @@ -365,27 +365,24 @@ fn stub_lib_is_up_to_date(target: Target, stub_lib_path: &Path, custom_names: &[ pub fn preprocess_host( target: Target, - platform_main_roc: &Path, - preprocessed_path: &Path, - shared_lib: &Path, - stub_dll_symbols: &[String], + host_path: &Path, + platform_path: &Path, + dylib_path: &Path, + verbose: bool, + time: bool, ) { - let metadata_path = platform_main_roc.with_file_name(metadata_file_name(target)); - let host_exe_path = if target.operating_system() == OperatingSystem::Windows { - platform_main_roc.with_file_name("dynhost.exe") - } else { - platform_main_roc.with_file_name("dynhost") - }; + let preprocessed_path = platform_path.with_file_name(format!("{}.rh", target)); + let metadata_path = platform_path.with_file_name(metadata_file_name(target)); preprocess( target, - &host_exe_path, + host_path, &metadata_path, - preprocessed_path, - shared_lib, - stub_dll_symbols, - false, - false, + preprocessed_path.as_path(), + dylib_path, + &[], + verbose, + time, ) } diff --git a/crates/linker/src/macho.rs b/crates/linker/src/macho.rs index 2ce2dbced3..05d1bb3987 100644 --- a/crates/linker/src/macho.rs +++ b/crates/linker/src/macho.rs @@ -1088,7 +1088,7 @@ fn gen_macho_le( } } - offset += dbg!(cmd_size); + offset += cmd_size; } // cmd_loc should be where the last offset ended From 20a5bd668ac4e71d39bce447807c59a6cec0117f Mon Sep 17 00:00:00 2001 From: Joscha Seelig <45944324+jdsee@users.noreply.github.com> Date: Wed, 8 May 2024 10:38:34 +0200 Subject: [PATCH 10/42] Document LSP configuration via nvim-lspconfig Signed-off-by: Joscha Seelig <45944324+jdsee@users.noreply.github.com> --- crates/language_server/README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/language_server/README.md b/crates/language_server/README.md index 8041dcb6f6..dbb588fd7f 100644 --- a/crates/language_server/README.md +++ b/crates/language_server/README.md @@ -42,7 +42,7 @@ The roc_language_server binary is included with the [nightly releases](https://g Follow the [building from source](https://github.com/roc-lang/roc/blob/main/BUILDING_FROM_SOURCE.md) instructions for roc. Then run: -``` +```bash # do `nix develop` first if you're using nix! cargo build --bin roc_language_server --release ``` @@ -61,7 +61,7 @@ Please follow your editor's language server implementation's documentation to se Add the following to your coc JSON configuration file: -``` +```json { "languageserver": { "roc": { @@ -74,6 +74,18 @@ Add the following to your coc JSON configuration file: If you're using coc.nvim and want to use the configuration above, be sure to also instruct your vim that `*.roc` files have roc filetype. +#### [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) + +Add the follwoing to your lspconfig setup: + +```lua +local lspconfig = require('lspconfig') +lspconfig.roc_ls.setup() +``` + +Make sure that the roc binary is on your `PATH`. +Further instructions on how to setup nvim-lspconfig can be found in their [docs](https://github.com/neovim/nvim-lspconfig?tab=readme-ov-file#quickstart). + ## Debug If you want to debug the server, use [debug_server.sh](./debug_server.sh) From 7e3d5752b90208e86a960fa7cafbcafc99d77fdb Mon Sep 17 00:00:00 2001 From: Joscha Seelig <45944324+jdsee@users.noreply.github.com> Date: Thu, 9 May 2024 08:58:52 +0200 Subject: [PATCH 11/42] Fix typo Signed-off-by: Joscha Seelig <45944324+jdsee@users.noreply.github.com> --- crates/language_server/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/language_server/README.md b/crates/language_server/README.md index dbb588fd7f..a336f02f5d 100644 --- a/crates/language_server/README.md +++ b/crates/language_server/README.md @@ -76,7 +76,7 @@ If you're using coc.nvim and want to use the configuration above, be sure to als #### [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) -Add the follwoing to your lspconfig setup: +Add the following to your lspconfig setup: ```lua local lspconfig = require('lspconfig') From b92d0ef3155d889c931d0c89a4d6c0e55a0298ff Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Fri, 28 Jun 2024 15:25:07 +1000 Subject: [PATCH 12/42] fix host_dest in preprocessed_host --- crates/compiler/build/src/program.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/compiler/build/src/program.rs b/crates/compiler/build/src/program.rs index 286ffdee7e..ed33850294 100644 --- a/crates/compiler/build/src/program.rs +++ b/crates/compiler/build/src/program.rs @@ -1169,7 +1169,7 @@ fn build_and_preprocess_host_lowlevel( opt_level: OptLevel, target: Target, platform_main_roc: &Path, - preprocessed_host_path: &Path, + _preprocessed_host_path: &Path, stub_dll_symbols: &[String], ) { let stub_lib = @@ -1177,11 +1177,11 @@ fn build_and_preprocess_host_lowlevel( debug_assert!(stub_lib.exists()); - rebuild_host(opt_level, target, platform_main_roc, Some(&stub_lib)); + let host_dest = rebuild_host(opt_level, target, platform_main_roc, Some(&stub_lib)); roc_linker::preprocess_host( target, - preprocessed_host_path, + host_dest.as_path(), platform_main_roc, &stub_lib, false, From aa17d17c6006184a5c61e41f16a88aa2c88df204 Mon Sep 17 00:00:00 2001 From: Kiryl Dziamura Date: Fri, 28 Jun 2024 12:54:10 +0200 Subject: [PATCH 13/42] handle bang in dbg arg --- crates/compiler/can/src/suffixed.rs | 122 +++++++++++++++++++--------- 1 file changed, 82 insertions(+), 40 deletions(-) diff --git a/crates/compiler/can/src/suffixed.rs b/crates/compiler/can/src/suffixed.rs index bcc44a6278..eabd726967 100644 --- a/crates/compiler/can/src/suffixed.rs +++ b/crates/compiler/can/src/suffixed.rs @@ -129,46 +129,7 @@ pub fn unwrap_suffixed_expression<'a>( internal_error!("BinOps should have been desugared in desugar_expr"); } - Expr::LowLevelDbg(dbg_src, arg, rest) => { - if is_expr_suffixed(&arg.value) { - // we cannot unwrap a suffixed expression within dbg - // e.g. dbg (foo! "bar") - return Err(EUnwrapped::Malformed); - } - - match unwrap_suffixed_expression(arena, rest, maybe_def_pat) { - Ok(unwrapped_expr) => { - let new_dbg = arena.alloc(Loc::at( - loc_expr.region, - LowLevelDbg(dbg_src, arg, unwrapped_expr), - )); - return Ok(new_dbg); - } - Err(EUnwrapped::UnwrappedDefExpr(unwrapped_expr)) => { - let new_dbg = arena.alloc(Loc::at( - loc_expr.region, - LowLevelDbg(dbg_src, arg, unwrapped_expr), - )); - Err(EUnwrapped::UnwrappedDefExpr(new_dbg)) - } - Err(EUnwrapped::UnwrappedSubExpr { - sub_arg: unwrapped_expr, - sub_pat, - sub_new, - }) => { - let new_dbg = arena.alloc(Loc::at( - loc_expr.region, - LowLevelDbg(dbg_src, arg, unwrapped_expr), - )); - Err(EUnwrapped::UnwrappedSubExpr { - sub_arg: new_dbg, - sub_pat, - sub_new, - }) - } - Err(EUnwrapped::Malformed) => Err(EUnwrapped::Malformed), - } - } + Expr::LowLevelDbg(..) => unwrap_low_level_dbg(arena, loc_expr, maybe_def_pat), Expr::Expect(condition, continuation) => { if is_expr_suffixed(&condition.value) { @@ -767,6 +728,87 @@ pub fn unwrap_suffixed_expression_defs_help<'a>( } } +fn unwrap_low_level_dbg<'a>( + arena: &'a Bump, + loc_expr: &'a Loc>, + maybe_def_pat: Option<&'a Loc>>, +) -> Result<&'a Loc>, EUnwrapped<'a>> { + match loc_expr.value { + LowLevelDbg(dbg_src, arg, rest) => { + if is_expr_suffixed(&arg.value) { + return match unwrap_suffixed_expression(arena, arg, maybe_def_pat) { + Ok(unwrapped_expr) => { + let new_dbg = arena.alloc(Loc::at( + loc_expr.region, + LowLevelDbg(dbg_src, unwrapped_expr, rest), + )); + + unwrap_low_level_dbg(arena, new_dbg, maybe_def_pat) + } + Err(EUnwrapped::UnwrappedSubExpr { + sub_arg, + sub_pat, + sub_new, + }) => { + let new_dbg = arena.alloc(Loc::at( + loc_expr.region, + LowLevelDbg(dbg_src, sub_new, rest), + )); + + unwrap_suffixed_expression( + arena, + apply_task_await(arena, new_dbg.region, sub_arg, sub_pat, new_dbg), + maybe_def_pat, + ) + } + Err(EUnwrapped::UnwrappedDefExpr(..)) => { + internal_error!( + "unreachable, arg of LowLevelDbg should generate UnwrappedSubExpr instead" + ); + } + Err(EUnwrapped::Malformed) => Err(EUnwrapped::Malformed), + }; + } + + match unwrap_suffixed_expression(arena, rest, maybe_def_pat) { + Ok(unwrapped_expr) => { + let new_dbg = arena.alloc(Loc::at( + loc_expr.region, + LowLevelDbg(dbg_src, arg, unwrapped_expr), + )); + Ok(&*new_dbg) + } + Err(EUnwrapped::UnwrappedDefExpr(unwrapped_expr)) => { + let new_dbg = arena.alloc(Loc::at( + loc_expr.region, + LowLevelDbg(dbg_src, arg, unwrapped_expr), + )); + Err(EUnwrapped::UnwrappedDefExpr(new_dbg)) + } + Err(EUnwrapped::UnwrappedSubExpr { + sub_arg: unwrapped_expr, + sub_pat, + sub_new, + }) => { + let new_dbg = arena.alloc(Loc::at( + loc_expr.region, + LowLevelDbg(dbg_src, arg, unwrapped_expr), + )); + Err(EUnwrapped::UnwrappedSubExpr { + sub_arg: new_dbg, + sub_pat, + sub_new, + }) + } + Err(EUnwrapped::Malformed) => Err(EUnwrapped::Malformed), + } + } + _ => internal_error!( + "unreachable, expected a LowLevelDbg node to be passed into unwrap_low_level_dbg" + ), + } +} + /// Helper for `Task.await (loc_arg) \loc_pat -> loc_new` pub fn apply_task_await<'a>( arena: &'a Bump, From 9c133f72d8da23c70e6e8a546a16a1a4ec1df6ed Mon Sep 17 00:00:00 2001 From: Kiryl Dziamura Date: Fri, 28 Jun 2024 12:54:26 +0200 Subject: [PATCH 14/42] test bang in dbg arg --- crates/compiler/can/tests/test_suffixed.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/compiler/can/tests/test_suffixed.rs b/crates/compiler/can/tests/test_suffixed.rs index 636786a937..5f833335e3 100644 --- a/crates/compiler/can/tests/test_suffixed.rs +++ b/crates/compiler/can/tests/test_suffixed.rs @@ -900,6 +900,19 @@ mod suffixed_tests { r#"Defs { tags: [Index(2147483648)], regions: [@0-266], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @0-266 When(@28-29 Var { module_name: "", ident: "x" }, [WhenBranch { patterns: [@53-54 Tag("A")], value: @82-214 Defs(Defs { tags: [Index(2147483649)], regions: [@86-88], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@82-83 Identifier { ident: "y" }, @86-88 Num("42")), Body(@82-83 Identifier { ident: "y" }, @86-88 Num("42"))] }, @114-214 If([(@117-118 Var { module_name: "", ident: "a" }, @152-154 Var { module_name: "", ident: "b" })], @212-214 Var { module_name: "", ident: "c" })), guard: None }, WhenBranch { patterns: [@235-236 Tag("B")], value: @264-266 Var { module_name: "", ident: "d" }, guard: None }]))] }"#, ); } + + #[test] + fn dbg_stmt_arg() { + run_test( + r#" + main = + dbg a! + + b + "#, + r##"Defs { tags: [Index(2147483648)], regions: [@0-48], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @0-48 Apply(@0-48 Var { module_name: "Task", ident: "await" }, [@27-29 Var { module_name: "", ident: "a" }, @0-48 Closure([@27-29 Identifier { ident: "#!a0" }], @0-48 LowLevelDbg(("test.roc:3", " "), @27-29 Apply(@27-29 Var { module_name: "Inspect", ident: "toStr" }, [@27-29 Var { module_name: "", ident: "#!a0" }], Space), @47-48 Var { module_name: "", ident: "b" }))], BangSuffix))] }"##, + ) + } } #[cfg(test)] From 1ac9e588a8b6866156a521d94d28e2367bf53980 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 28 Jun 2024 14:07:11 +0200 Subject: [PATCH 15/42] Update CONTRIBUTING.md - applied UX best practices - added debugging tips Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- CONTRIBUTING.md | 56 +++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d794d504bf..e98a9deaef 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,20 +2,20 @@ ## Code of Conduct -We are committed to providing a friendly, safe and welcoming environment for all. Make sure to take a look at the [Code of Conduct](CODE_OF_CONDUCT.md)! +We are committed to providing a friendly, safe and welcoming environment for all. See our [Code of Conduct](CODE_OF_CONDUCT.md) for details. ## How to contribute All contributions are appreciated! Typo fixes, bug fixes, feature requests, -bug reports are all helpful for the project. +bug reports... -If you are looking for a good place to start, consider reaching out on the `#contributing` channel on [Roc Zulip][roc-zulip]. -Before making your first pull request, definitely talk to an existing contributor on [Roc Zulip][roc-zulip] first about what you plan to do! This can not only avoid duplicated effort, it can also avoid making a whole PR only to discover it won't be accepted because the change doesn't fit with the goals of the language's design or implementation. +For a good place to start, consider reaching out on the `#contributing` channel on [our zulip group chat][roc-zulip]. +Before making your first pull request, talk to an existing contributor on [zulip][roc-zulip] about what you plan to do! This can avoid duplicated effort or a rejection because the change doesn't fit with the goals of the language. If you are interested in larger, implementation- or research-heavy projects related to Roc, check out [Roc Project Ideas][project-ideas] and reach out to us -on Zulip! These projects may be suitable for academic theses, independent -research, or even just valuable projects to learn from and improve Roc with. +on [zulip][roc-zulip]! These projects may be suitable for academic theses, internships, +independent research, or just valuable projects to learn from and improve Roc with. ## Building from Source @@ -33,29 +33,35 @@ cargo clippy --workspace --tests -- --deny warnings Execute `cargo fmt --all` to fix the formatting. -## Generating Docs - -If you make changes to [Roc's Standard Library](https://www.roc-lang.org/builtins/Str), you can add comments to the code following [the CommonMark Spec](https://spec.commonmark.org/current/) to further explain your intentions. You can view these changes locally with: - -```sh -cargo run docs crates/compiler/builtins/roc/main.roc -``` - -This command will generate the documentation in the [`generated-docs`](generated-docs) directory. - ## Contribution Tips - If you've never made a pull request on github before, [this](https://www.freecodecamp.org/news/how-to-make-your-first-pull-request-on-github-3/) will be a good place to start. -- Create an issue if the purpose of a struct/field/type/function/... is not immediately clear from its name or nearby comments. - You can find good first issues [here][good-first-issues]. Once you have gained some experience you can take a look at the [intermediate issues](https://github.com/roc-lang/roc/issues?q=is%3Aopen+is%3Aissue+label%3A%22intermediate+issue%22). -- [Fork](https://github.com/roc-lang/roc/fork) the repo so that you can apply your changes first on your own copy of the roc repo. -- It's a good idea to open a draft pull request as you begin working on something. This way, others can see that you're working on it, which avoids duplicate effort, and others can give feedback sooner rather than later if they notice a problem in the direction things are going. Click the button "ready for review" when it's ready. +- It's a good idea to open a draft pull request as you begin working on something. This way, others can see that you're working on it, which avoids duplicate effort, and others can give important feedback sooner rather than later. Click the button "ready for review" when it's ready. +- The [compiler's README](https://github.com/roc-lang/roc/tree/main/crates/compiler) contains important info. +- The AI chat in the [cursor editor](https://www.cursor.com/) can also help you find your way in the codebase. + +
+:beetle: Debugging Tips + +- At the bottom of [.cargo/config.toml](https://github.com/roc-lang/roc/blob/main/.cargo/config.toml) we have useful debug flags that activate certain debug prints. +- For Roc code; minimize the code that produces the issue. +- For segmentation faults: + + In general we recommend using linux to investigate, it has better tools for this. + + Use `roc build myApp.roc --linker=legacy` followed by `valgrind ./myApp`. + + Use gdb to step through the code, [this gdb script](https://roc.zulipchat.com/#narrow/stream/395097-compiler-development/topic/gdb.20script/near/424422545) can be helpful. + + Inspect the generated LLVM IR (`roc build myApp.roc --emit-llvm-ir`) between Roc code that encounters the segfault and code that doesn't. + + +
### Commit signing -All your commits need to be signed [to prevent impersonation](https://dev.to/martiliones/how-i-got-linus-torvalds-in-my-contributors-on-github-3k4g). Check out [our guide for commit signing](devtools/signing.md). +All your commits need to be signed [to prevent impersonation](https://dev.to/martiliones/how-i-got-linus-torvalds-in-my-contributors-on-github-3k4g). +Check out [our guide for commit signing](devtools/signing.md). -#### Commit signing on NixOS +
+⚠️ Tip for NixOS users On NixOS pinentry can cause problems, the following setup works well for those with a KDE desktop. From `/etc/nixos/configuration.nix`: ``` @@ -65,8 +71,10 @@ programs.gnupg.agent = { enableSSHSupport = true; }; ``` +
-### Forgot to sign commits? +
+Forgot to sign commits? You can view your commits on github, those without the "Verified" badge still need to be signed. If any of those is a merge commit, follow [these steps](https://stackoverflow.com/a/9958215/4200103) instead of the ones below. @@ -88,9 +96,11 @@ In case you have multiple commits, you can sign them in two ways: If you already pushed unsigned commits, you may have to do a force push with `git push origin -f `. +
+ ## Can we do better? -Feel free to open an issue if you think this document can be improved or is unclear in any way. +Feel free to open an issue if you think this document can be improved! [roc-zulip]: https://roc.zulipchat.com [good-first-issues]: https://github.com/roc-lang/roc/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 From 2bc78e80f5dbaba31881ba2b1792a3a2430aecbc Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 28 Jun 2024 14:10:41 +0200 Subject: [PATCH 16/42] link to CONTRIBUTING.md Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 287131b515..fc9cd4c256 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ - [**faq**: frequently asked questions](https://github.com/roc-lang/roc/blob/main/www/content/faq.md) - [**group chat**](https://roc.zulipchat.com) for help, questions and discussions -If you'd like to contribute, check out [good first issues](https://github.com/roc-lang/roc/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22). Don't hesitate to ask for help on our [group chat](https://roc.zulipchat.com), we're friendly! +If you'd like to contribute, [get started here](CONTRIBUTING.md). Don't hesitate to ask for help on our [group chat](https://roc.zulipchat.com), we're friendly! ## Sponsors From 0aa2cefa06df0c3bb86872f33e615207952d7c20 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 28 Jun 2024 14:33:12 +0200 Subject: [PATCH 17/42] more useful links Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e98a9deaef..a544936213 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,9 @@ We are committed to providing a friendly, safe and welcoming environment for all All contributions are appreciated! Typo fixes, bug fixes, feature requests, bug reports... -For a good place to start, consider reaching out on the `#contributing` channel on [our zulip group chat][roc-zulip]. +For ideas, proposals and feature request, [click here](https://www.roc-lang.org/community#ideas), for all other contributions, read on. + +For a good place to start, check out [good first issues](https://github.com/roc-lang/roc/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) or reach out on the `#contributing` channel on [our zulip group chat][roc-zulip]. Before making your first pull request, talk to an existing contributor on [zulip][roc-zulip] about what you plan to do! This can avoid duplicated effort or a rejection because the change doesn't fit with the goals of the language. If you are interested in larger, implementation- or research-heavy projects From 101621bd5a693852c0952e67b602c2216bce94b5 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sat, 29 Jun 2024 20:52:21 -0400 Subject: [PATCH 18/42] Make error_macros be no_std --- crates/error_macros/src/lib.rs | 113 +++++++++++++++++++++++++++++---- 1 file changed, 101 insertions(+), 12 deletions(-) diff --git a/crates/error_macros/src/lib.rs b/crates/error_macros/src/lib.rs index c36f880991..8d2ed3ea81 100644 --- a/crates/error_macros/src/lib.rs +++ b/crates/error_macros/src/lib.rs @@ -1,4 +1,96 @@ //! Provides macros for consistent reporting of errors in Roc's rust code. +#![no_std] + +#[cfg(unix)] +extern "C" { + fn write(fd: i32, buf: *const u8, count: usize) -> isize; + fn exit(status: i32) -> !; +} + +#[cfg(unix)] +const STDERR_FD: i32 = 2; + +#[cfg(windows)] +extern "C" { + pub fn GetStdHandle(nStdHandle: i32) -> *mut core::ffi::c_void; + pub fn WriteFile( + hFile: *mut core::ffi::c_void, + lpBuffer: *const u8, + nNumberOfBytesToWrite: u32, + lpNumberOfBytesWritten: *mut u32, + lpOverlapped: *mut core::ffi::c_void, + ) -> i32; + pub fn ExitProcess(exit_code: u32) -> !; +} + +#[cfg(windows)] +const STD_ERROR_HANDLE: i32 = -12; + +/// Print each of the given strings to stderr (if it's available; on wasm, nothing will +/// be printed) and then immediately exit the program with an error. +/// On wasm, this will trap, and on UNIX or Windows it will exit with a code of 1. +#[cfg(any(unix, windows, wasm32))] +pub fn error_and_exit<'a>(strings: impl IntoIterator>) -> ! { + #[cfg(unix)] + unsafe { + // Write each of the arguments to stderr + for string in strings { + let string = string.into(); + + if !string.is_empty() { + let _ = write(STDERR_FD, string.as_ptr(), string.len()); + } + } + + // Write a newline at the end to make sure stderr gets flushed. + const NEWLINE: &'static str = "\n"; + + let _ = write(STDERR_FD, NEWLINE.as_ptr(), NEWLINE.len()); + + exit(1) + } + + #[cfg(windows)] + unsafe { + let handle = GetStdHandle(STD_ERROR_HANDLE); + let mut written = 0; + + for string in strings { + let string = string.into(); + + if !string.is_empty() { + let _ = WriteFile( + handle, + string.as_ptr(), + string.len() as u32, + &mut written, + core::ptr::null_mut(), + ); + } + } + + // Write a newline at the end to make sure stderr gets flushed. + const NEWLINE: &'static str = "\n"; + + let _ = WriteFile( + handle, + NEWLINE.as_ptr(), + NEWLINE.len() as u32, + &mut written, + core::ptr::null_mut(), + ); + + ExitProcess(1) + } + + #[cfg(wasm32)] + { + // We have no way to write to any stderr equivalent in wasm, + // so just trap to end the program immediately. + core::arch::wasm32::unreachable() + } +} + /// `internal_error!` should be used whenever a compiler invariant is broken. /// It is a wrapper around panic that tells the user to file a bug. /// This should only be used in cases where there would be a compiler bug and the user can't fix it. @@ -7,13 +99,11 @@ #[macro_export] macro_rules! internal_error { ($($arg:tt)*) => ({ - eprintln!("An internal compiler expectation was broken."); - eprintln!("This is definitely a compiler bug."); - // TODO: update this to the new bug template. - eprintln!("Please file an issue here: https://github.com/roc-lang/roc/issues/new/choose"); - #[allow(clippy::panic)] { - panic!($($arg)*); - } + $crate::error_and_exit([ + // TODO: update this to the new bug template. + "An internal compiler expectation was broken.\nThis is definitely a compiler bug.\nPlease file an issue here: " + $(,$arg)* + ]) }) } @@ -23,11 +113,10 @@ macro_rules! internal_error { #[macro_export] macro_rules! user_error { ($($arg:tt)*) => ({ - eprintln!("We ran into an issue while compiling your code."); - eprintln!("Sadly, we don't have a pretty error message for this case yet."); - eprintln!("If you can't figure out the problem from the context below, please reach out at: https://roc.zulipchat.com/"); - eprintln!($($arg)*); - std::process::exit(1); + $crate::error_and_exit([ + "We ran into an issue while compiling your code.\nSadly, we don't have a pretty error message for this case yet.\nIf you can't figure out the problem from the context below, please reach out at \n" + $(,$arg)* + ]) }) } From 99eb5bfe1ef3eca31242b9807b0f4be3b271d8bb Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sat, 29 Jun 2024 21:05:57 -0400 Subject: [PATCH 19/42] Support formatting strings in error macros --- crates/compiler/gen_wasm/src/code_builder.rs | 1 - crates/error_macros/src/lib.rs | 123 +++++++++++-------- 2 files changed, 75 insertions(+), 49 deletions(-) diff --git a/crates/compiler/gen_wasm/src/code_builder.rs b/crates/compiler/gen_wasm/src/code_builder.rs index ecec4ad2b0..7b917734d2 100644 --- a/crates/compiler/gen_wasm/src/code_builder.rs +++ b/crates/compiler/gen_wasm/src/code_builder.rs @@ -1,7 +1,6 @@ use bitvec::vec::BitVec; use bumpalo::collections::vec::Vec; use bumpalo::Bump; -use core::panic; use roc_wasm_module::linking::IndexRelocType; use roc_error_macros::internal_error; diff --git a/crates/error_macros/src/lib.rs b/crates/error_macros/src/lib.rs index 8d2ed3ea81..39c76864e1 100644 --- a/crates/error_macros/src/lib.rs +++ b/crates/error_macros/src/lib.rs @@ -1,6 +1,8 @@ //! Provides macros for consistent reporting of errors in Roc's rust code. #![no_std] +use core::fmt; + #[cfg(unix)] extern "C" { fn write(fd: i32, buf: *const u8, count: usize) -> isize; @@ -30,56 +32,54 @@ const STD_ERROR_HANDLE: i32 = -12; /// be printed) and then immediately exit the program with an error. /// On wasm, this will trap, and on UNIX or Windows it will exit with a code of 1. #[cfg(any(unix, windows, wasm32))] -pub fn error_and_exit<'a>(strings: impl IntoIterator>) -> ! { - #[cfg(unix)] - unsafe { - // Write each of the arguments to stderr - for string in strings { - let string = string.into(); +pub fn error_and_exit(args: fmt::Arguments) -> ! { + use fmt::Write; - if !string.is_empty() { - let _ = write(STDERR_FD, string.as_ptr(), string.len()); + struct StderrWriter; + + impl Write for StderrWriter { + #[cfg(unix)] + fn write_str(&mut self, s: &str) -> fmt::Result { + unsafe { + let _ = write(STDERR_FD, s.as_ptr(), s.len()); } + Ok(()) } - // Write a newline at the end to make sure stderr gets flushed. - const NEWLINE: &'static str = "\n"; + #[cfg(windows)] + fn write_str(&mut self, s: &str) -> fmt::Result { + unsafe { + let handle = GetStdHandle(STD_ERROR_HANDLE); + let mut written = 0; + let _ = WriteFile( + handle, + s.as_ptr(), + s.len() as u32, + &mut written, + core::ptr::null_mut(), + ); + } + Ok(()) + } - let _ = write(STDERR_FD, NEWLINE.as_ptr(), NEWLINE.len()); + #[cfg(wasm32)] + fn write_str(&mut self, _s: &str) -> fmt::Result { + Ok(()) + } + } + let _ = fmt::write(&mut StderrWriter, args); + + // Write a newline at the end to make sure stderr gets flushed. + let _ = StderrWriter.write_str("\n"); + + #[cfg(unix)] + unsafe { exit(1) } #[cfg(windows)] unsafe { - let handle = GetStdHandle(STD_ERROR_HANDLE); - let mut written = 0; - - for string in strings { - let string = string.into(); - - if !string.is_empty() { - let _ = WriteFile( - handle, - string.as_ptr(), - string.len() as u32, - &mut written, - core::ptr::null_mut(), - ); - } - } - - // Write a newline at the end to make sure stderr gets flushed. - const NEWLINE: &'static str = "\n"; - - let _ = WriteFile( - handle, - NEWLINE.as_ptr(), - NEWLINE.len() as u32, - &mut written, - core::ptr::null_mut(), - ); - ExitProcess(1) } @@ -98,12 +98,25 @@ pub fn error_and_exit<'a>(strings: impl IntoIterator>) /// If there is a user error, please use roc_reporting to print a nice error message. #[macro_export] macro_rules! internal_error { + () => ({ + $crate::error_and_exit(format_args!( + concat!( + "An internal compiler expectation was broken.\n", + "This is definitely a compiler bug.\n", + "Please file an issue here: " + ) + )) + }); ($($arg:tt)*) => ({ - $crate::error_and_exit([ - // TODO: update this to the new bug template. - "An internal compiler expectation was broken.\nThis is definitely a compiler bug.\nPlease file an issue here: " - $(,$arg)* - ]) + $crate::error_and_exit(format_args!( + concat!( + "An internal compiler expectation was broken.\n", + "This is definitely a compiler bug.\n", + "Please file an issue here: \n", + "{}" + ), + format_args!($($arg)*) + )) }) } @@ -112,11 +125,25 @@ macro_rules! internal_error { /// All cases of `user_error!` should eventually be replaced with pretty error printing using roc_reporting. #[macro_export] macro_rules! user_error { + () => ({ + $crate::error_and_exit(format_args!( + concat!( + "We ran into an issue while compiling your code.\n", + "Sadly, we don't have a pretty error message for this case yet.\n", + "If you can't figure out the problem from the context below, please reach out at \n", + ) + )) + }); ($($arg:tt)*) => ({ - $crate::error_and_exit([ - "We ran into an issue while compiling your code.\nSadly, we don't have a pretty error message for this case yet.\nIf you can't figure out the problem from the context below, please reach out at \n" - $(,$arg)* - ]) + $crate::error_and_exit(format_args!( + concat!( + "We ran into an issue while compiling your code.\n", + "Sadly, we don't have a pretty error message for this case yet.\n", + "If you can't figure out the problem from the context below, please reach out at \n", + "{}" + ), + format_args!($($arg)*) + )) }) } From 863c97330d069f1161fc3e21ae05be51904f7e2d Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sat, 29 Jun 2024 21:15:23 -0400 Subject: [PATCH 20/42] Use constants for error message strings --- crates/error_macros/src/lib.rs | 44 ++++++++++++++-------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/crates/error_macros/src/lib.rs b/crates/error_macros/src/lib.rs index 39c76864e1..844e3f388d 100644 --- a/crates/error_macros/src/lib.rs +++ b/crates/error_macros/src/lib.rs @@ -91,6 +91,12 @@ pub fn error_and_exit(args: fmt::Arguments) -> ! { } } +pub const INTERNAL_ERROR_MESSAGE: &'static str = concat!( + "An internal compiler expectation was broken.\n", + "This is definitely a compiler bug.\n", + "Please file an issue here: \n", +); + /// `internal_error!` should be used whenever a compiler invariant is broken. /// It is a wrapper around panic that tells the user to file a bug. /// This should only be used in cases where there would be a compiler bug and the user can't fix it. @@ -99,49 +105,35 @@ pub fn error_and_exit(args: fmt::Arguments) -> ! { #[macro_export] macro_rules! internal_error { () => ({ - $crate::error_and_exit(format_args!( - concat!( - "An internal compiler expectation was broken.\n", - "This is definitely a compiler bug.\n", - "Please file an issue here: " - ) - )) + $crate::error_and_exit(format_args!("{}", $crate::INTERNAL_ERROR_MESSAGE)) }); ($($arg:tt)*) => ({ $crate::error_and_exit(format_args!( - concat!( - "An internal compiler expectation was broken.\n", - "This is definitely a compiler bug.\n", - "Please file an issue here: \n", - "{}" - ), + "{}{}", + $crate::INTERNAL_ERROR_MESSAGE, format_args!($($arg)*) )) }) } +pub const USER_ERROR_MESSAGE: &'static str = concat!( + "We ran into an issue while compiling your code.\n", + "Sadly, we don't have a pretty error message for this case yet.\n", + "If you can't figure out the problem from the context below, please reach out at \n", +); + /// `user_error!` should only ever be used temporarily. /// It is a way to document locations where we do not yet have nice error reporting. /// All cases of `user_error!` should eventually be replaced with pretty error printing using roc_reporting. #[macro_export] macro_rules! user_error { () => ({ - $crate::error_and_exit(format_args!( - concat!( - "We ran into an issue while compiling your code.\n", - "Sadly, we don't have a pretty error message for this case yet.\n", - "If you can't figure out the problem from the context below, please reach out at \n", - ) - )) + $crate::error_and_exit(format_args!("{}", $crate::USER_ERROR_MESSAGE)) }); ($($arg:tt)*) => ({ $crate::error_and_exit(format_args!( - concat!( - "We ran into an issue while compiling your code.\n", - "Sadly, we don't have a pretty error message for this case yet.\n", - "If you can't figure out the problem from the context below, please reach out at \n", - "{}" - ), + "{}{}", + $crate::USER_ERROR_MESSAGE, format_args!($($arg)*) )) }) From 28be4e5ee2b9f2e735ced2153f88dba118058a8c Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sat, 29 Jun 2024 21:17:42 -0400 Subject: [PATCH 21/42] Make some things non-pub that don't need to be pub --- crates/error_macros/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/error_macros/src/lib.rs b/crates/error_macros/src/lib.rs index 844e3f388d..93500daabf 100644 --- a/crates/error_macros/src/lib.rs +++ b/crates/error_macros/src/lib.rs @@ -14,15 +14,15 @@ const STDERR_FD: i32 = 2; #[cfg(windows)] extern "C" { - pub fn GetStdHandle(nStdHandle: i32) -> *mut core::ffi::c_void; - pub fn WriteFile( + fn GetStdHandle(nStdHandle: i32) -> *mut core::ffi::c_void; + fn WriteFile( hFile: *mut core::ffi::c_void, lpBuffer: *const u8, nNumberOfBytesToWrite: u32, lpNumberOfBytesWritten: *mut u32, lpOverlapped: *mut core::ffi::c_void, ) -> i32; - pub fn ExitProcess(exit_code: u32) -> !; + fn ExitProcess(exit_code: u32) -> !; } #[cfg(windows)] From 2253e849d49d52d24c10e18e947ea0821668ea5e Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sat, 29 Jun 2024 23:20:44 -0400 Subject: [PATCH 22/42] clippy --- crates/error_macros/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/error_macros/src/lib.rs b/crates/error_macros/src/lib.rs index 93500daabf..f5f84056b2 100644 --- a/crates/error_macros/src/lib.rs +++ b/crates/error_macros/src/lib.rs @@ -91,7 +91,7 @@ pub fn error_and_exit(args: fmt::Arguments) -> ! { } } -pub const INTERNAL_ERROR_MESSAGE: &'static str = concat!( +pub const INTERNAL_ERROR_MESSAGE: &str = concat!( "An internal compiler expectation was broken.\n", "This is definitely a compiler bug.\n", "Please file an issue here: \n", @@ -116,7 +116,7 @@ macro_rules! internal_error { }) } -pub const USER_ERROR_MESSAGE: &'static str = concat!( +pub const USER_ERROR_MESSAGE: &str = concat!( "We ran into an issue while compiling your code.\n", "Sadly, we don't have a pretty error message for this case yet.\n", "If you can't figure out the problem from the context below, please reach out at \n", From 6102e38f33cc419987a15c598b16c9f3cd14434b Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 30 Jun 2024 00:22:04 -0400 Subject: [PATCH 23/42] Use target_arch if targeting wasm (so wasi works) --- crates/error_macros/src/lib.rs | 7 +- crates/heap_alloc/src/allocation.rs | 323 ++++++++++++++++++++++++++++ 2 files changed, 327 insertions(+), 3 deletions(-) create mode 100644 crates/heap_alloc/src/allocation.rs diff --git a/crates/error_macros/src/lib.rs b/crates/error_macros/src/lib.rs index f5f84056b2..df68562292 100644 --- a/crates/error_macros/src/lib.rs +++ b/crates/error_macros/src/lib.rs @@ -1,6 +1,7 @@ //! Provides macros for consistent reporting of errors in Roc's rust code. #![no_std] +#[cfg(any(unix, windows, target_arch = "wasm32"))] use core::fmt; #[cfg(unix)] @@ -31,7 +32,7 @@ const STD_ERROR_HANDLE: i32 = -12; /// Print each of the given strings to stderr (if it's available; on wasm, nothing will /// be printed) and then immediately exit the program with an error. /// On wasm, this will trap, and on UNIX or Windows it will exit with a code of 1. -#[cfg(any(unix, windows, wasm32))] +#[cfg(any(unix, windows, target_arch = "wasm32"))] pub fn error_and_exit(args: fmt::Arguments) -> ! { use fmt::Write; @@ -62,7 +63,7 @@ pub fn error_and_exit(args: fmt::Arguments) -> ! { Ok(()) } - #[cfg(wasm32)] + #[cfg(target_arch = "wasm32")] fn write_str(&mut self, _s: &str) -> fmt::Result { Ok(()) } @@ -83,7 +84,7 @@ pub fn error_and_exit(args: fmt::Arguments) -> ! { ExitProcess(1) } - #[cfg(wasm32)] + #[cfg(target_arch = "wasm32")] { // We have no way to write to any stderr equivalent in wasm, // so just trap to end the program immediately. diff --git a/crates/heap_alloc/src/allocation.rs b/crates/heap_alloc/src/allocation.rs new file mode 100644 index 0000000000..4afa929d6c --- /dev/null +++ b/crates/heap_alloc/src/allocation.rs @@ -0,0 +1,323 @@ +/// OS-level virtual memory allocation and deallocation functions, for use in the `arena` module. +/// The goal here is to avoid managing free lists and instead to directly ask the OS for memory. +/// In long-running compiler processes (e.g. watch mode, editor integrations, repl), this can +/// prevent memory usage from slowly growing over time because we're actually goving memory +/// back to the OS when we're done with it. +/// +/// Since we should only use these to allocate memory for an entire module at a time, this should +/// result in 1 total syscall per module, which should be fine in terms of performance. +/// +/// As of this writing, wasm uses the wee_alloc crate to emulate virtual memory by managing a free +/// list behind the scenes, since wasm only supports growing the heap and that's it. Although +/// wasm doesn't have a watch mode, it does have long-running processes in the form of the repl +/// and also potentially in the future a playground. +use core::{alloc::Layout, fmt, ptr::NonNull}; + +#[derive(Debug)] +pub struct Allocation { + pages: NonNull, + layout: Layout, + len: usize, +} + +#[derive(Clone, Copy)] +#[repr(transparent)] +struct Page { + _bytes: [u8; PAGE_SIZE], +} + +impl fmt::Debug for Page { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("Page") + } +} + +// All allocations will be rounded up to this number of bytes. +// +// https://devblogs.microsoft.com/oldnewthing/20210510-00/?p=105200 +// 16KiB should be accepted by all Windows systems +#[cfg(any(windows, unix))] +const PAGE_SIZE: usize = 16384; + +// All allocations will be rounded up to this number of bytes. +// +// In wasm, "each page is sized 64KiB" according to +// https://developer.mozilla.org/en-US/docs/webassembly/reference/memory/size +#[cfg(target_arch = "wasm32")] +const PAGE_SIZE: usize = 65536; + +/// We use wee_alloc for allocations on wasm because wasm natively supports only growing the heap, +/// not releasing anything. Releasing has to be built in userspace, which wee_alloc provides. +#[cfg(target_arch = "wasm32")] +static WEE_ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; + +#[derive(Debug, PartialEq, Eq)] +pub enum AllocFailed { + OsAllocFailed, + InvalidLayout, +} + +impl Allocation { + /// This may round the requested number of bytes up to the nearest page size, + /// depending on target OS. + pub fn alloc_virtual(layout: Layout) -> Result { + // Round up to nearest OS page size or the requested alignment, + // whichevever is bigger. Pad the size to fit this alignment. + let layout = match layout.align_to(layout.align().max(PAGE_SIZE)) { + Ok(layout) => layout.pad_to_align(), + Err(_) => { + return Err(AllocFailed::InvalidLayout); + } + }; + + let non_null = { + #[cfg(unix)] + { + use core::{ffi::c_void, ptr}; + + extern "C" { + fn mmap( + addr: *mut c_void, + length: usize, + prot: i32, + flags: i32, + fd: i32, + offset: i64, + ) -> *mut c_void; + } + + const MAP_FAILED: *mut c_void = -1isize as *mut c_void; + const PROT_READ: i32 = 1; + const PROT_WRITE: i32 = 2; + const MAP_PRIVATE: i32 = 0x0002; + + #[cfg(target_os = "macos")] + const MAP_ANONYMOUS: i32 = 0x1000; + + #[cfg(target_os = "linux")] + const MAP_ANONYMOUS: i32 = 0x0020; + + // Safety: We rounded up `size` to the correct multiple already. + let answer = unsafe { + mmap( + ptr::null_mut(), + layout.size(), + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, + -1, + 0, + ) + }; + + match NonNull::new(answer) { + Some(non_null) if answer != MAP_FAILED => non_null, + _ => { + return Err(AllocFailed::OsAllocFailed); + } + } + } + + #[cfg(windows)] + { + use core::{ffi::c_void, ptr}; + + extern "system" { + fn VirtualAlloc( + lpAddress: *mut c_void, + dwSize: usize, + flAllocationType: u32, + flProtect: u32, + ) -> *mut c_void; + } + + const MEM_COMMIT: u32 = 0x1000; + const MEM_RESERVE: u32 = 0x2000;; + const PAGE_READWRITE: u32 = 0x04; + + // Safety: We rounded up `size` to the correct multiple already. + let ptr = unsafe { + VirtualAlloc( + ptr::null_mut(), + layout.size(), + MEM_COMMIT | MEM_RESERVE, + PAGE_READWRITE, + ) + }; + + match NonNull::new(ptr) { + Some(non_null) => non_null, + None => { + return Err(AllocFailed::OsAllocFailed); + } + } + } + + #[cfg(target_arch = "wasm32")] + { + let ptr = unsafe { WEE_ALLOC.alloc(layout) }; + + // We should never return a size smaller than what was requested! + debug_assert!(size >= layout.size()); + + match NonNull::new(ptr) { + Some(non_null) => non_null, + None => { + return Err(AllocFailed::OsAllocFailed); + } + } + } + }; + + Ok(Self { + pages: non_null.cast(), + len: 0, + layout, + }) + } + + pub fn bytes_remaining(&self) -> usize { + self.layout.size().saturating_sub(self.len) + } + + /// Reallocate in-place if possible; otherwise, create a new allocation + /// and copy over the contents of the old one. If the new size would + /// exceed isize::MAX, it instead becomes isize::MAX. + pub fn grow(&mut self, additional_bytes_desired: usize) { + let layout = self.layout; + let new_size = layout.size().saturating_add(additional_bytes_desired); + let layout = Layout::from_size_align(new_size, layout.align()) + // Although the alignment is already valid, this can theoretically fail + // in the very specific case where the new size, when rounded to the nearest + // multiple of alignment, exceeds isize::MAX. In the extremely unlikely + // event where that happens, decline to grow and go back to the old layout. + .unwrap_or(layout) + .pad_to_align(); + + let todo = todo!(); // TODO try to grow the allocation in-place. Replace self's pointer. + } + + pub fn slice_mut(&mut self, layout: Layout) -> &mut [u8] { + // We won't return a slice that's bigger than the number of + // allocated bytes we have left! + let available_len = self.bytes_remaining(); + let desired_len = available_len.min(layout.size()); + let desired_align = self.layout.align().max(layout.align()); + + // Figure out how much padding we need to achieve the desired alignment + let ptr = self.pages.as_ptr() as *mut u8; + let padding_needed = ptr.align_offset(desired_align); + + // Figure out what the actual length of the slice will be, + // taking into account necessary padding and how mny bytes are left. + let actual_len = desired_len + .saturating_add(padding_needed) + .min(available_len); + + // Advance the pointer past the padding. + let ptr = unsafe { ptr.add(padding_needed) }; + + // After adding the padding, the pointer should now be aligned correctly! + debug_assert_eq!(ptr as usize % desired_align, 0); + + // Record the new length + self.len += actual_len; + + unsafe { core::slice::from_raw_parts_mut(ptr, actual_len) } + } +} + +impl Drop for Allocation { + fn drop(&mut self) { + let ptr = self.pages.as_ptr(); + let layout = self.layout; + let size = layout.size(); + + #[cfg(unix)] + { + use core::ffi::c_void; + + extern "C" { + fn munmap(addr: *mut c_void, length: usize) -> i32; + } + + // If deallocation fails, panic in debug builds so we can try to diagnose it + // (and so that it will fail tests), but silently continue in release builds + // because a memory leak is generally a better user experience than a crash. + let _answer = unsafe { munmap(ptr as *mut c_void, size) }; + + #[cfg(debug_assertions)] + { + if _answer < 0 { + panic!("Tried to deallocate address {:?} but it failed!", ptr); + } + } + } + + #[cfg(windows)] + { + use core::ffi::c_void; + + extern "system" { + fn VirtualFree(lpAddress: *mut c_void, dwSize: usize, dwFreeType: u32) -> i32; + } + + const MEM_RELEASE: u32 = 0x8000; + + // When calling VirtualAlloc with MEM_RELEASE, the second argument must be 0. + // https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualfree#parameters + let _answer = unsafe { VirtualFree(ptr as *mut c_void, 0, MEM_RELEASE) }; + + #[cfg(debug_assertions)] + { + if _answer == 0 { + panic!("Tried to deallocate address {:?} but it failed!", ptr); + } + } + } + + #[cfg(target_arch = "wasm32")] + { + let _ptr = unsafe { WEE_ALLOC.dealloc(layout) }; + + // If deallocation fails, panic in debug builds so we can try to diagnose it + // (and so that it will fail tests), but silently continue in release builds + // because a memory leak is generally a better user experience than a crash. + #[cfg(debug_assertions)] + { + if _ptr.is_null() { + panic!("Tried to deallocate address {:?} but it failed!", ptr); + } + } + } + } +} + +#[test] +fn verify_page_size() { + let os_page_size = unsafe { + #[cfg(unix)] + { + extern "C" { + fn getpagesize() -> i32; + } + + getpagesize() as usize + } + + #[cfg(windows)] + { + // https://devblogs.microsoft.com/oldnewthing/20210510-00/?p=105200 + // 16KiB should be accepted by all Windows systems + 16384 + } + + #[cfg(target_arch = "wasm32")] + { + // In wasm, "each page is sized 64KiB" according to + // https://developer.mozilla.org/en-US/docs/webassembly/reference/memory/size + 65536 + } + }; + + assert_eq!(os_page_size, PAGE_SIZE); +} From 39144a198d7786564636a2c00b0d409070c3b557 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 30 Jun 2024 06:47:54 -0400 Subject: [PATCH 24/42] Make error_and_exit inline(never) and cold --- crates/error_macros/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/error_macros/src/lib.rs b/crates/error_macros/src/lib.rs index df68562292..d1a3b3015a 100644 --- a/crates/error_macros/src/lib.rs +++ b/crates/error_macros/src/lib.rs @@ -32,6 +32,8 @@ const STD_ERROR_HANDLE: i32 = -12; /// Print each of the given strings to stderr (if it's available; on wasm, nothing will /// be printed) and then immediately exit the program with an error. /// On wasm, this will trap, and on UNIX or Windows it will exit with a code of 1. +#[inline(never)] +#[cold] #[cfg(any(unix, windows, target_arch = "wasm32"))] pub fn error_and_exit(args: fmt::Arguments) -> ! { use fmt::Write; From f0f8d76055be9d0a38a9d0abe93648adbf36c3ba Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 30 Jun 2024 08:16:53 -0400 Subject: [PATCH 25/42] Remove heap_alloc for now --- crates/heap_alloc/src/allocation.rs | 323 ---------------------------- 1 file changed, 323 deletions(-) delete mode 100644 crates/heap_alloc/src/allocation.rs diff --git a/crates/heap_alloc/src/allocation.rs b/crates/heap_alloc/src/allocation.rs deleted file mode 100644 index 4afa929d6c..0000000000 --- a/crates/heap_alloc/src/allocation.rs +++ /dev/null @@ -1,323 +0,0 @@ -/// OS-level virtual memory allocation and deallocation functions, for use in the `arena` module. -/// The goal here is to avoid managing free lists and instead to directly ask the OS for memory. -/// In long-running compiler processes (e.g. watch mode, editor integrations, repl), this can -/// prevent memory usage from slowly growing over time because we're actually goving memory -/// back to the OS when we're done with it. -/// -/// Since we should only use these to allocate memory for an entire module at a time, this should -/// result in 1 total syscall per module, which should be fine in terms of performance. -/// -/// As of this writing, wasm uses the wee_alloc crate to emulate virtual memory by managing a free -/// list behind the scenes, since wasm only supports growing the heap and that's it. Although -/// wasm doesn't have a watch mode, it does have long-running processes in the form of the repl -/// and also potentially in the future a playground. -use core::{alloc::Layout, fmt, ptr::NonNull}; - -#[derive(Debug)] -pub struct Allocation { - pages: NonNull, - layout: Layout, - len: usize, -} - -#[derive(Clone, Copy)] -#[repr(transparent)] -struct Page { - _bytes: [u8; PAGE_SIZE], -} - -impl fmt::Debug for Page { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("Page") - } -} - -// All allocations will be rounded up to this number of bytes. -// -// https://devblogs.microsoft.com/oldnewthing/20210510-00/?p=105200 -// 16KiB should be accepted by all Windows systems -#[cfg(any(windows, unix))] -const PAGE_SIZE: usize = 16384; - -// All allocations will be rounded up to this number of bytes. -// -// In wasm, "each page is sized 64KiB" according to -// https://developer.mozilla.org/en-US/docs/webassembly/reference/memory/size -#[cfg(target_arch = "wasm32")] -const PAGE_SIZE: usize = 65536; - -/// We use wee_alloc for allocations on wasm because wasm natively supports only growing the heap, -/// not releasing anything. Releasing has to be built in userspace, which wee_alloc provides. -#[cfg(target_arch = "wasm32")] -static WEE_ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; - -#[derive(Debug, PartialEq, Eq)] -pub enum AllocFailed { - OsAllocFailed, - InvalidLayout, -} - -impl Allocation { - /// This may round the requested number of bytes up to the nearest page size, - /// depending on target OS. - pub fn alloc_virtual(layout: Layout) -> Result { - // Round up to nearest OS page size or the requested alignment, - // whichevever is bigger. Pad the size to fit this alignment. - let layout = match layout.align_to(layout.align().max(PAGE_SIZE)) { - Ok(layout) => layout.pad_to_align(), - Err(_) => { - return Err(AllocFailed::InvalidLayout); - } - }; - - let non_null = { - #[cfg(unix)] - { - use core::{ffi::c_void, ptr}; - - extern "C" { - fn mmap( - addr: *mut c_void, - length: usize, - prot: i32, - flags: i32, - fd: i32, - offset: i64, - ) -> *mut c_void; - } - - const MAP_FAILED: *mut c_void = -1isize as *mut c_void; - const PROT_READ: i32 = 1; - const PROT_WRITE: i32 = 2; - const MAP_PRIVATE: i32 = 0x0002; - - #[cfg(target_os = "macos")] - const MAP_ANONYMOUS: i32 = 0x1000; - - #[cfg(target_os = "linux")] - const MAP_ANONYMOUS: i32 = 0x0020; - - // Safety: We rounded up `size` to the correct multiple already. - let answer = unsafe { - mmap( - ptr::null_mut(), - layout.size(), - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, - -1, - 0, - ) - }; - - match NonNull::new(answer) { - Some(non_null) if answer != MAP_FAILED => non_null, - _ => { - return Err(AllocFailed::OsAllocFailed); - } - } - } - - #[cfg(windows)] - { - use core::{ffi::c_void, ptr}; - - extern "system" { - fn VirtualAlloc( - lpAddress: *mut c_void, - dwSize: usize, - flAllocationType: u32, - flProtect: u32, - ) -> *mut c_void; - } - - const MEM_COMMIT: u32 = 0x1000; - const MEM_RESERVE: u32 = 0x2000;; - const PAGE_READWRITE: u32 = 0x04; - - // Safety: We rounded up `size` to the correct multiple already. - let ptr = unsafe { - VirtualAlloc( - ptr::null_mut(), - layout.size(), - MEM_COMMIT | MEM_RESERVE, - PAGE_READWRITE, - ) - }; - - match NonNull::new(ptr) { - Some(non_null) => non_null, - None => { - return Err(AllocFailed::OsAllocFailed); - } - } - } - - #[cfg(target_arch = "wasm32")] - { - let ptr = unsafe { WEE_ALLOC.alloc(layout) }; - - // We should never return a size smaller than what was requested! - debug_assert!(size >= layout.size()); - - match NonNull::new(ptr) { - Some(non_null) => non_null, - None => { - return Err(AllocFailed::OsAllocFailed); - } - } - } - }; - - Ok(Self { - pages: non_null.cast(), - len: 0, - layout, - }) - } - - pub fn bytes_remaining(&self) -> usize { - self.layout.size().saturating_sub(self.len) - } - - /// Reallocate in-place if possible; otherwise, create a new allocation - /// and copy over the contents of the old one. If the new size would - /// exceed isize::MAX, it instead becomes isize::MAX. - pub fn grow(&mut self, additional_bytes_desired: usize) { - let layout = self.layout; - let new_size = layout.size().saturating_add(additional_bytes_desired); - let layout = Layout::from_size_align(new_size, layout.align()) - // Although the alignment is already valid, this can theoretically fail - // in the very specific case where the new size, when rounded to the nearest - // multiple of alignment, exceeds isize::MAX. In the extremely unlikely - // event where that happens, decline to grow and go back to the old layout. - .unwrap_or(layout) - .pad_to_align(); - - let todo = todo!(); // TODO try to grow the allocation in-place. Replace self's pointer. - } - - pub fn slice_mut(&mut self, layout: Layout) -> &mut [u8] { - // We won't return a slice that's bigger than the number of - // allocated bytes we have left! - let available_len = self.bytes_remaining(); - let desired_len = available_len.min(layout.size()); - let desired_align = self.layout.align().max(layout.align()); - - // Figure out how much padding we need to achieve the desired alignment - let ptr = self.pages.as_ptr() as *mut u8; - let padding_needed = ptr.align_offset(desired_align); - - // Figure out what the actual length of the slice will be, - // taking into account necessary padding and how mny bytes are left. - let actual_len = desired_len - .saturating_add(padding_needed) - .min(available_len); - - // Advance the pointer past the padding. - let ptr = unsafe { ptr.add(padding_needed) }; - - // After adding the padding, the pointer should now be aligned correctly! - debug_assert_eq!(ptr as usize % desired_align, 0); - - // Record the new length - self.len += actual_len; - - unsafe { core::slice::from_raw_parts_mut(ptr, actual_len) } - } -} - -impl Drop for Allocation { - fn drop(&mut self) { - let ptr = self.pages.as_ptr(); - let layout = self.layout; - let size = layout.size(); - - #[cfg(unix)] - { - use core::ffi::c_void; - - extern "C" { - fn munmap(addr: *mut c_void, length: usize) -> i32; - } - - // If deallocation fails, panic in debug builds so we can try to diagnose it - // (and so that it will fail tests), but silently continue in release builds - // because a memory leak is generally a better user experience than a crash. - let _answer = unsafe { munmap(ptr as *mut c_void, size) }; - - #[cfg(debug_assertions)] - { - if _answer < 0 { - panic!("Tried to deallocate address {:?} but it failed!", ptr); - } - } - } - - #[cfg(windows)] - { - use core::ffi::c_void; - - extern "system" { - fn VirtualFree(lpAddress: *mut c_void, dwSize: usize, dwFreeType: u32) -> i32; - } - - const MEM_RELEASE: u32 = 0x8000; - - // When calling VirtualAlloc with MEM_RELEASE, the second argument must be 0. - // https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualfree#parameters - let _answer = unsafe { VirtualFree(ptr as *mut c_void, 0, MEM_RELEASE) }; - - #[cfg(debug_assertions)] - { - if _answer == 0 { - panic!("Tried to deallocate address {:?} but it failed!", ptr); - } - } - } - - #[cfg(target_arch = "wasm32")] - { - let _ptr = unsafe { WEE_ALLOC.dealloc(layout) }; - - // If deallocation fails, panic in debug builds so we can try to diagnose it - // (and so that it will fail tests), but silently continue in release builds - // because a memory leak is generally a better user experience than a crash. - #[cfg(debug_assertions)] - { - if _ptr.is_null() { - panic!("Tried to deallocate address {:?} but it failed!", ptr); - } - } - } - } -} - -#[test] -fn verify_page_size() { - let os_page_size = unsafe { - #[cfg(unix)] - { - extern "C" { - fn getpagesize() -> i32; - } - - getpagesize() as usize - } - - #[cfg(windows)] - { - // https://devblogs.microsoft.com/oldnewthing/20210510-00/?p=105200 - // 16KiB should be accepted by all Windows systems - 16384 - } - - #[cfg(target_arch = "wasm32")] - { - // In wasm, "each page is sized 64KiB" according to - // https://developer.mozilla.org/en-US/docs/webassembly/reference/memory/size - 65536 - } - }; - - assert_eq!(os_page_size, PAGE_SIZE); -} From 1caebcff56fa98583a12685c85ff1a316e4d9d43 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 30 Jun 2024 08:18:49 -0400 Subject: [PATCH 26/42] Update some error macro docs --- crates/error_macros/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/error_macros/src/lib.rs b/crates/error_macros/src/lib.rs index d1a3b3015a..0e6c8168bf 100644 --- a/crates/error_macros/src/lib.rs +++ b/crates/error_macros/src/lib.rs @@ -101,7 +101,8 @@ pub const INTERNAL_ERROR_MESSAGE: &str = concat!( ); /// `internal_error!` should be used whenever a compiler invariant is broken. -/// It is a wrapper around panic that tells the user to file a bug. +/// It tells the user to file a bug and then exits the program with a nonzero exit code. +/// (On wasm it doesn't tell the user anything, since we don't necessarily have a way to print.) /// This should only be used in cases where there would be a compiler bug and the user can't fix it. /// If there is simply an unimplemented feature, please use `unimplemented!` /// If there is a user error, please use roc_reporting to print a nice error message. From e421ef61bebbba67059067e11f3347f42700ecec Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 30 Jun 2024 08:19:37 -0400 Subject: [PATCH 27/42] Use internal_error over panic --- crates/error_macros/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/error_macros/src/lib.rs b/crates/error_macros/src/lib.rs index 0e6c8168bf..4a9f938403 100644 --- a/crates/error_macros/src/lib.rs +++ b/crates/error_macros/src/lib.rs @@ -204,13 +204,13 @@ macro_rules! assert_copyable { #[macro_export] macro_rules! _incomplete_project { ($project_name:literal, $tracking_issue_no:literal) => { - panic!( + $crate::internal_error!( "[{}] not yet implemented. Tracking issue: https://github.com/roc-lang/roc/issues/{}", $project_name, $tracking_issue_no, ) }; ($project_name:literal, $tracking_issue_no:literal, $($arg:tt)+) => { - panic!( + $crate::internal_error!( "[{}] not yet implemented. Tracking issue: https://github.com/roc-lang/roc/issues/{}.\nAdditional information: {}", $project_name, $tracking_issue_no, format_args!($($arg)+), From 720ed2a457ee643ff484290dd5ab27d83db40197 Mon Sep 17 00:00:00 2001 From: Ryan Barth Date: Sun, 30 Jun 2024 22:56:14 -0700 Subject: [PATCH 28/42] fix: calculate windows dll symbols from prebuilt shared library --- crates/cli/src/main.rs | 5 ----- crates/linker/src/elf.rs | 23 ++--------------------- crates/linker/src/lib.rs | 5 ++--- crates/linker/src/pe.rs | 35 +++++++++++++++++++---------------- crates/linker/src/util.rs | 23 +++++++++++++++++++++++ 5 files changed, 46 insertions(+), 45 deletions(-) create mode 100644 crates/linker/src/util.rs diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index f5cb5e0f77..69b8060e18 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -169,11 +169,6 @@ fn main() -> io::Result<()> { let verbose_and_time = matches.get_one::(roc_cli::FLAG_VERBOSE).unwrap(); - #[cfg(target_os = "windows")] - { - internal_error!("TODO populate stub_dll_symbols for Windows"); - } - roc_linker::preprocess_host( target, host_path, diff --git a/crates/linker/src/elf.rs b/crates/linker/src/elf.rs index 6250186675..1519f080e8 100644 --- a/crates/linker/src/elf.rs +++ b/crates/linker/src/elf.rs @@ -15,9 +15,10 @@ use std::{ io::{BufReader, BufWriter}, mem, path::Path, - time::{Duration, Instant}, + time::Instant, }; +use crate::util::{is_roc_definition, is_roc_undefined, report_timing}; use crate::{ align_by_constraint, align_to_offset_by_constraint, load_struct_inplace, load_struct_inplace_mut, load_structs_inplace_mut, open_mmap, open_mmap_mut, @@ -103,26 +104,6 @@ impl Metadata { } } -fn report_timing(label: &str, duration: Duration) { - println!("\t{:9.3} ms {}", duration.as_secs_f64() * 1000.0, label,); -} - -fn is_roc_symbol(sym: &object::Symbol) -> bool { - if let Ok(name) = sym.name() { - name.trim_start_matches('_').starts_with("roc_") - } else { - false - } -} - -fn is_roc_definition(sym: &object::Symbol) -> bool { - sym.is_definition() && is_roc_symbol(sym) -} - -fn is_roc_undefined(sym: &object::Symbol) -> bool { - sym.is_undefined() && is_roc_symbol(sym) -} - fn collect_roc_definitions<'a>(object: &object::File<'a, &'a [u8]>) -> MutMap { let mut vaddresses = MutMap::default(); diff --git a/crates/linker/src/lib.rs b/crates/linker/src/lib.rs index 783bba0443..5f968c6cf2 100644 --- a/crates/linker/src/lib.rs +++ b/crates/linker/src/lib.rs @@ -19,6 +19,7 @@ use std::path::{Path, PathBuf}; mod elf; mod macho; mod pe; +mod util; mod generate_dylib; @@ -380,7 +381,6 @@ pub fn preprocess_host( &metadata_path, preprocessed_path.as_path(), dylib_path, - &[], verbose, time, ) @@ -394,7 +394,6 @@ fn preprocess( metadata_path: &Path, preprocessed_path: &Path, shared_lib: &Path, - stub_dll_symbols: &[String], verbose: bool, time: bool, ) { @@ -430,7 +429,7 @@ fn preprocess( host_exe_path, metadata_path, preprocessed_path, - stub_dll_symbols, + shared_lib, verbose, time, ) diff --git a/crates/linker/src/pe.rs b/crates/linker/src/pe.rs index fb3176fc85..c9d7cf300b 100644 --- a/crates/linker/src/pe.rs +++ b/crates/linker/src/pe.rs @@ -11,7 +11,7 @@ use object::{ ImageSectionHeader, ImageThunkData64, }, read::pe::ImportTable, - LittleEndian as LE, Object, RelocationTarget, SectionIndex, + LittleEndian as LE, Object, ObjectSection, ObjectSymbol, RelocationTarget, SectionIndex, }; use serde::{Deserialize, Serialize}; @@ -19,8 +19,10 @@ use roc_collections::{MutMap, VecMap}; use roc_error_macros::internal_error; use crate::{ - generate_dylib::APP_DLL, load_struct_inplace, load_struct_inplace_mut, - load_structs_inplace_mut, open_mmap, open_mmap_mut, + generate_dylib::APP_DLL, + load_struct_inplace, load_struct_inplace_mut, load_structs_inplace_mut, open_mmap, + open_mmap_mut, + util::is_roc_definition, }; /// The metadata stores information about/from the host .exe because @@ -95,8 +97,6 @@ impl PeMetadata { } fn from_preprocessed_host(preprocessed_data: &[u8], new_sections: &[[u8; 8]]) -> Self { - use object::ObjectSection; - let dynhost_obj = object::read::pe::PeFile64::parse(preprocessed_data) .unwrap_or_else(|err| internal_error!("Failed to parse executable file: {}", err)); @@ -183,17 +183,26 @@ pub(crate) fn preprocess_windows( host_exe_filename: &Path, metadata_filename: &Path, preprocessed_filename: &Path, - dummy_dll_symbols: &[String], + shared_lib: &Path, _verbose: bool, _time: bool, ) -> object::read::Result<()> { - let data = open_mmap(host_exe_filename); + let exec_data = open_mmap(host_exe_filename); + let shared_lib_data = &*open_mmap(shared_lib); + let shared_lib_obj = match object::File::parse(shared_lib_data) { + Ok(obj) => obj, + Err(e) => internal_error!("Failed to parse shared library file: {e}"), + }; + let dummy_dll_symbols = shared_lib_obj + .dynamic_symbols() + .filter(is_roc_definition) + .count(); let new_sections = [*b".text\0\0\0", *b".rdata\0\0"]; let mut preprocessed = Preprocessor::preprocess( preprocessed_filename, - &data, - dummy_dll_symbols.len(), + &exec_data, + dummy_dll_symbols, &new_sections, ); @@ -1164,8 +1173,6 @@ fn process_internal_relocations( impl<'a> AppSections<'a> { fn from_data(data: &'a [u8]) -> Self { - use object::ObjectSection; - let file = object::File::parse(data).unwrap(); let mut sections = Vec::new(); @@ -1193,8 +1200,6 @@ impl<'a> AppSections<'a> { for (offset_in_section, relocation) in section.relocations() { match relocation.target() { RelocationTarget::Symbol(symbol_index) => { - use object::ObjectSymbol; - let symbol = file.symbol_by_index(symbol_index); let address = symbol.as_ref().map(|s| s.address()).unwrap_or_default(); @@ -1252,8 +1257,6 @@ impl<'a> AppSections<'a> { let mut other_symbols = Vec::new(); for symbol in file.symbols() { - use object::ObjectSymbol; - if symbol.name_bytes().unwrap_or_default().starts_with(b"roc") { if let object::SymbolSection::Section(index) = symbol.section() { let (kind, offset_in_host_section) = section_starts[&index]; @@ -1801,7 +1804,7 @@ mod test { &dir.join("host.exe"), &dir.join("metadata"), &preprocessed_host_filename, - &names, + &dir.join("libapp.dll"), false, false, ) diff --git a/crates/linker/src/util.rs b/crates/linker/src/util.rs new file mode 100644 index 0000000000..993853ecd8 --- /dev/null +++ b/crates/linker/src/util.rs @@ -0,0 +1,23 @@ +use std::time::Duration; + +use object::ObjectSymbol; + +pub(crate) fn report_timing(label: &str, duration: Duration) { + println!("\t{:9.3} ms {}", duration.as_secs_f64() * 1000.0, label,); +} + +fn is_roc_symbol(sym: &object::Symbol) -> bool { + if let Ok(name) = sym.name() { + name.trim_start_matches('_').starts_with("roc_") + } else { + false + } +} + +pub(crate) fn is_roc_definition(sym: &object::Symbol) -> bool { + sym.is_definition() && is_roc_symbol(sym) +} + +pub(crate) fn is_roc_undefined(sym: &object::Symbol) -> bool { + sym.is_undefined() && is_roc_symbol(sym) +} From 3fe2a4cd13260063b0bb71bce9fe8844e1fcf524 Mon Sep 17 00:00:00 2001 From: Ryan Barth Date: Sun, 30 Jun 2024 23:01:32 -0700 Subject: [PATCH 29/42] refactor: remove duplicate symbol functions from macho module --- crates/linker/src/macho.rs | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/crates/linker/src/macho.rs b/crates/linker/src/macho.rs index 05d1bb3987..0c80d7f2e5 100644 --- a/crates/linker/src/macho.rs +++ b/crates/linker/src/macho.rs @@ -15,7 +15,7 @@ use std::{ io::{BufReader, BufWriter}, mem, path::Path, - time::{Duration, Instant}, + time::Instant, }; use crate::{ @@ -23,6 +23,7 @@ use crate::{ load_struct_inplace_mut, load_structs_inplace, load_structs_inplace_mut, open_mmap, open_mmap_mut, }; +use crate::util::{report_timing, is_roc_undefined, is_roc_definition}; const MIN_SECTION_ALIGNMENT: usize = 0x40; @@ -104,26 +105,6 @@ impl Metadata { } } -fn report_timing(label: &str, duration: Duration) { - println!("\t{:9.3} ms {}", duration.as_secs_f64() * 1000.0, label,); -} - -fn is_roc_symbol(sym: &object::Symbol) -> bool { - if let Ok(name) = sym.name() { - name.trim_start_matches('_').starts_with("roc_") - } else { - false - } -} - -fn is_roc_definition(sym: &object::Symbol) -> bool { - sym.is_definition() && is_roc_symbol(sym) -} - -fn is_roc_undefined(sym: &object::Symbol) -> bool { - sym.is_undefined() && is_roc_symbol(sym) -} - fn collect_roc_definitions<'a>(object: &object::File<'a, &'a [u8]>) -> MutMap { let mut vaddresses = MutMap::default(); From 43f970f813d4d44da7f0e49f56f21d93ae605cdd Mon Sep 17 00:00:00 2001 From: Ryan Barth Date: Sun, 30 Jun 2024 23:17:20 -0700 Subject: [PATCH 30/42] fix: count all symbols to err on the side of over allocating --- crates/linker/src/pe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/linker/src/pe.rs b/crates/linker/src/pe.rs index c9d7cf300b..091e628dc5 100644 --- a/crates/linker/src/pe.rs +++ b/crates/linker/src/pe.rs @@ -194,7 +194,7 @@ pub(crate) fn preprocess_windows( Err(e) => internal_error!("Failed to parse shared library file: {e}"), }; let dummy_dll_symbols = shared_lib_obj - .dynamic_symbols() + .symbols() .filter(is_roc_definition) .count(); From 05ab0183805907c3042e9f946a08b793ea75c038 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 1 Jul 2024 07:48:11 -0400 Subject: [PATCH 31/42] Add Eric Andresen to sponsors --- README.md | 1 + www/content/index.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index fc9cd4c256..ad23a9e287 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ If you would like your company to become a corporate sponsor of Roc's developmen We'd also like to express our gratitude to our generous [individual sponsors](https://github.com/sponsors/roc-lang/)! A special thanks to those sponsoring $25/month or more: +- Eric Andresen - [Jackson Lucky](https://github.com/jluckyiv) - [Agus Zubiaga](https://github.com/agu-z) - [Angelo Ceccato](https://github.com/AngeloChecked) diff --git a/www/content/index.md b/www/content/index.md index 23fe83e72c..02c5bfb782 100644 --- a/www/content/index.md +++ b/www/content/index.md @@ -148,6 +148,7 @@ If you would like your organization to become an official sponsor of Roc's devel We'd also like to express our gratitude to our generous [individual sponsors](https://github.com/sponsors/roc-lang/)! A special thanks to those sponsoring $25/month or more:
    +
  • Eric Andresen
  • Jackson Lucky
  • Agus Zubiaga
  • Angelo Ceccato
  • From de9ed734c51e4965ee0208015d3ffd34897cf092 Mon Sep 17 00:00:00 2001 From: Kiryl Dziamura Date: Fri, 28 Jun 2024 20:54:28 +0200 Subject: [PATCH 32/42] remove EmptyDefsFinal --- crates/compiler/can/src/desugar.rs | 22 --- crates/compiler/can/src/expr.rs | 6 +- crates/compiler/fmt/src/expr.rs | 7 - crates/compiler/fmt/src/spaces.rs | 1 - crates/compiler/parse/src/ast.rs | 87 +++++------- crates/compiler/parse/src/expr.rs | 129 ++---------------- crates/language_server/src/analysis/tokens.rs | 1 - 7 files changed, 49 insertions(+), 204 deletions(-) diff --git a/crates/compiler/can/src/desugar.rs b/crates/compiler/can/src/desugar.rs index 950a33ac2b..f72c91cabd 100644 --- a/crates/compiler/can/src/desugar.rs +++ b/crates/compiler/can/src/desugar.rs @@ -755,28 +755,6 @@ pub fn desugar_expr<'a>( }) } - // Replace an empty final def with a `Task.ok {}` - EmptyDefsFinal => { - let mut apply_args: Vec<&'a Loc>> = Vec::new_in(arena); - apply_args - .push(arena.alloc(Loc::at(loc_expr.region, Expr::Record(Collection::empty())))); - - arena.alloc(Loc::at( - loc_expr.region, - Expr::Apply( - arena.alloc(Loc::at( - loc_expr.region, - Expr::Var { - module_name: ModuleName::TASK, - ident: "ok", - }, - )), - arena.alloc(apply_args), - CalledVia::BangSuffix, - ), - )) - } - // note this only exists after desugaring LowLevelDbg(_, _, _) => loc_expr, } diff --git a/crates/compiler/can/src/expr.rs b/crates/compiler/can/src/expr.rs index 23f3f6b2e4..70e8f4dec3 100644 --- a/crates/compiler/can/src/expr.rs +++ b/crates/compiler/can/src/expr.rs @@ -621,9 +621,6 @@ pub fn canonicalize_expr<'a>( use Expr::*; let (expr, output) = match expr { - &ast::Expr::EmptyDefsFinal => { - internal_error!("EmptyDefsFinal should have been desugared") - } &ast::Expr::Num(str) => { let answer = num_expr_from_result(var_store, finish_parsing_num(str), region, env); @@ -2392,8 +2389,7 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool { | ast::Expr::Backpassing(_, _, _) | ast::Expr::SpaceBefore(_, _) | ast::Expr::Str(StrLiteral::Block(_)) - | ast::Expr::SpaceAfter(_, _) - | ast::Expr::EmptyDefsFinal => false, + | ast::Expr::SpaceAfter(_, _) => false, // These can contain subexpressions, so we need to recursively check those ast::Expr::Str(StrLiteral::Line(segments)) => { segments.iter().all(|segment| match segment { diff --git a/crates/compiler/fmt/src/expr.rs b/crates/compiler/fmt/src/expr.rs index 4fc4912ccc..c8d746c68f 100644 --- a/crates/compiler/fmt/src/expr.rs +++ b/crates/compiler/fmt/src/expr.rs @@ -45,7 +45,6 @@ impl<'a> Formattable for Expr<'a> { | MalformedClosure | Tag(_) | OpaqueRef(_) - | EmptyDefsFinal | Crash => false, RecordAccess(inner, _) | TupleAccess(inner, _) | TaskAwaitBang(inner) => { @@ -420,9 +419,6 @@ impl<'a> Formattable for Expr<'a> { indent, ); } - EmptyDefsFinal => { - // no need to print anything - } _ => { buf.ensure_ends_with_newline(); buf.indent(indent); @@ -439,9 +435,6 @@ impl<'a> Formattable for Expr<'a> { buf.push(')'); } } - EmptyDefsFinal => { - // no need to print anything - } Expect(condition, continuation) => { fmt_expect(buf, condition, continuation, self.is_multiline(), indent); } diff --git a/crates/compiler/fmt/src/spaces.rs b/crates/compiler/fmt/src/spaces.rs index df6a0436a2..774d06fa5c 100644 --- a/crates/compiler/fmt/src/spaces.rs +++ b/crates/compiler/fmt/src/spaces.rs @@ -768,7 +768,6 @@ impl<'a> RemoveSpaces<'a> for StrSegment<'a> { impl<'a> RemoveSpaces<'a> for Expr<'a> { fn remove_spaces(&self, arena: &'a Bump) -> Self { match *self { - Expr::EmptyDefsFinal => Expr::EmptyDefsFinal, Expr::Float(a) => Expr::Float(a), Expr::Num(a) => Expr::Num(a), Expr::NonBase10Int { diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index 3a9ab2d97c..c4673de62a 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -462,10 +462,6 @@ pub enum Expr<'a> { /// Multiple defs in a row Defs(&'a Defs<'a>, &'a Loc>), - /// Used in place of an expression when the final expression is empty - /// This may happen if the final expression is actually a suffixed statement - EmptyDefsFinal, - Backpassing(&'a [Loc>], &'a Loc>, &'a Loc>), Expect(&'a Loc>, &'a Loc>), Dbg(&'a Loc>, &'a Loc>), @@ -613,7 +609,6 @@ pub fn is_expr_suffixed(expr: &Expr) -> bool { Expr::Crash => false, Expr::Tag(_) => false, Expr::OpaqueRef(_) => false, - Expr::EmptyDefsFinal => false, Expr::Backpassing(_, _, _) => false, // TODO: we might want to check this? Expr::Expect(a, b) | Expr::Dbg(a, b) => { is_expr_suffixed(&a.value) || is_expr_suffixed(&b.value) @@ -975,8 +970,7 @@ impl<'a, 'b> RecursiveValueDefIter<'a, 'b> { | MalformedIdent(_, _) | MalformedClosure | PrecedenceConflict(_) - | MalformedSuffixed(_) - | EmptyDefsFinal => { /* terminal */ } + | MalformedSuffixed(_) => { /* terminal */ } } } } @@ -1183,51 +1177,43 @@ impl<'a> Defs<'a> { }) } - // We could have a type annotation as the last tag, - // this helper ensures we refer to the last value_def - // and that we remove the correct tag - pub fn last_value_suffixed(&self) -> Option<(Self, &'a Loc>)> { - let value_indexes = - self.tags - .clone() - .into_iter() - .enumerate() - .filter_map(|(tag_index, tag)| match tag.split() { - Ok(_) => None, - Err(value_index) => Some((tag_index, value_index.index())), - }); + pub fn last_value_suffixed(&mut self) -> Option<&'a Loc>> { + let last_value_suffix = self + .tags + .iter() + .enumerate() + .rev() + .find_map(|(tag_index, tag)| match tag.split() { + Ok(_) => None, + Err(value_index) => match self.value_defs[value_index.index()] { + ValueDef::Body( + Loc { + value: Pattern::RecordDestructure(collection), + .. + }, + loc_expr, + ) if collection.is_empty() && is_expr_suffixed(&loc_expr.value) => { + Some((tag_index, loc_expr)) + } + ValueDef::Stmt(loc_expr) if is_expr_suffixed(&loc_expr.value) => { + Some((tag_index, loc_expr)) + } + _ => None, + }, + }); - if let Some((tag_index, value_index)) = value_indexes.last() { - match self.value_defs[value_index] { - ValueDef::Body( - Loc { - value: Pattern::RecordDestructure(collection), - .. - }, - loc_expr, - ) if collection.is_empty() && is_expr_suffixed(&loc_expr.value) => { - let mut new_defs = self.clone(); - new_defs.remove_value_def(tag_index); - - return Some((new_defs, loc_expr)); - } - ValueDef::Stmt(loc_expr) if is_expr_suffixed(&loc_expr.value) => { - let mut new_defs = self.clone(); - new_defs.remove_value_def(tag_index); - - return Some((new_defs, loc_expr)); - } - _ => {} - } + if let Some((tag_index, loc_expr)) = last_value_suffix { + self.remove_tag(tag_index); + Some(loc_expr) + } else { + None } - - None } - pub fn remove_value_def(&mut self, index: usize) { + pub fn remove_tag(&mut self, tag_index: usize) { match self .tags - .get(index) + .get(tag_index) .expect("got an invalid index for Defs") .split() { @@ -1260,10 +1246,10 @@ impl<'a> Defs<'a> { } } } - self.tags.remove(index); - self.regions.remove(index); - self.space_after.remove(index); - self.space_before.remove(index); + self.tags.remove(tag_index); + self.regions.remove(tag_index); + self.space_after.remove(tag_index); + self.space_before.remove(tag_index); } /// NOTE assumes the def itself is pushed already! @@ -2394,7 +2380,6 @@ impl<'a> Malformed for Expr<'a> { Tag(_) | OpaqueRef(_) | SingleQuote(_) | // This is just a &str - not a bunch of segments - EmptyDefsFinal | Crash => false, Str(inner) => inner.is_malformed(), diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index e5cb4fd60e..4c5d7ab078 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -372,31 +372,14 @@ fn expr_operator_chain<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a end, }; - match parse_expr_end( + parse_expr_end( new_min_indent, options, expr_state, arena, state, initial_state, - ) { - Err(err) => Err(err), - Ok((progress, expr, new_state)) => { - // We need to check if we have just parsed a suffixed statement, - // if so, this is a defs node. - if is_expr_suffixed(&expr) { - let def_region = Region::new(end, new_state.pos()); - let value_def = ValueDef::Stmt(arena.alloc(Loc::at(def_region, expr))); - - let mut defs = Defs::default(); - defs.push_value_def(value_def, def_region, &[], &[]); - - return parse_defs_expr(options, min_indent, defs, arena, new_state); - } else { - Ok((progress, expr, new_state)) - } - } - } + ) } } }) @@ -1151,69 +1134,6 @@ pub fn parse_single_def_assignment<'a>( parse_def_expr.parse(arena, initial_state, min_indent)?; let region = Region::span_across(&def_loc_pattern.region, &first_loc_expr.region); - - // If the expression is actually a suffixed statement, then we need to continue - // to parse the rest of the expression - if crate::ast::is_expr_suffixed(&first_loc_expr.value) { - let mut defs = Defs::default(); - // Take the suffixed value and make it a e.g. Body(`{}=`, Apply(Var(...))) - // we will keep the pattern `def_loc_pattern` for the new Defs - defs.push_value_def( - ValueDef::Stmt(arena.alloc(first_loc_expr)), - Region::span_across(&def_loc_pattern.region, &first_loc_expr.region), - spaces_before_current, - &[], - ); - - // Try to parse the rest of the expression as multiple defs, which may contain sub-assignments - match parse_defs_expr( - options, - min_indent, - defs.clone(), - arena, - state_after_first_expression.clone(), - ) { - Ok((progress_after_rest_of_def, expr, state_after_rest_of_def)) => { - let final_loc_expr = arena.alloc(Loc::at(region, expr)); - - let value_def = ValueDef::Body(arena.alloc(def_loc_pattern), final_loc_expr); - - return Ok(( - progress_after_rest_of_def, - Some(SingleDef { - type_or_value: Either::Second(value_def), - region, - spaces_before: spaces_before_current, - spaces_after: &[], - }), - state_after_rest_of_def, - )); - } - Err(_) => { - // Unable to parse more defs, continue and return the first parsed expression as a stement - let empty_return = - arena.alloc(Loc::at(first_loc_expr.region, Expr::EmptyDefsFinal)); - let value_def = ValueDef::Body( - arena.alloc(def_loc_pattern), - arena.alloc(Loc::at( - first_loc_expr.region, - Expr::Defs(arena.alloc(defs), empty_return), - )), - ); - return Ok(( - progress_after_first, - Some(SingleDef { - type_or_value: Either::Second(value_def), - region, - spaces_before: spaces_before_current, - spaces_after: &[], - }), - state_after_first_expression, - )); - } - } - } - let value_def = ValueDef::Body(arena.alloc(def_loc_pattern), arena.alloc(first_loc_expr)); Ok(( @@ -1458,7 +1378,7 @@ fn parse_defs_expr<'a>( ) -> ParseResult<'a, Expr<'a>, EExpr<'a>> { match parse_defs_end(options, min_indent, defs, arena, state) { Err(bad) => Err(bad), - Ok((_, def_state, state)) => { + Ok((_, mut def_state, state)) => { // this is no def, because there is no `=` or `:`; parse as an expr let parse_final_expr = space0_before_e(expr_start(options), EExpr::IndentEnd); @@ -1467,41 +1387,17 @@ fn parse_defs_expr<'a>( // If the last def was a suffixed statement, assume this was // intentional by the application author instead of giving // an error. - if let Some((new_defs, loc_ret)) = def_state.last_value_suffixed() { - // note we check the tags here and not value_defs, as there may be redundant defs in Defs - - let mut local_defs = new_defs.clone(); - - let last_stmt = ValueDef::Stmt(loc_ret); - local_defs.push_value_def(last_stmt, loc_ret.region, &[], &[]); - - //check the length of the defs we would return, if we only have one - // we can just return the expression - // note we use tags here, as we may have redundant defs in Defs - if local_defs - .tags - .iter() - .filter(|tag| tag.split().is_err()) - .count() - == 1 - { - return Ok((MadeProgress, loc_ret.value, state)); - } - - return Ok(( + match def_state.last_value_suffixed() { + Some(loc_ret) => Ok(( MadeProgress, - Expr::Defs( - arena.alloc(local_defs), - arena.alloc(Loc::at_zero(Expr::EmptyDefsFinal)), - ), + Expr::Defs(arena.alloc(def_state), arena.alloc(loc_ret)), state, - )); + )), + _ => Err(( + MadeProgress, + EExpr::DefMissingFinalExpr2(arena.alloc(fail), state.pos()), + )), } - - Err(( - MadeProgress, - EExpr::DefMissingFinalExpr2(arena.alloc(fail), state.pos()), - )) } Ok((_, loc_ret, state)) => Ok(( MadeProgress, @@ -2408,8 +2304,7 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result unreachable!(), + | Expr::RecordBuilder(..) => unreachable!(), Expr::Record(fields) => { let patterns = fields.map_items_result(arena, |loc_assigned_field| { diff --git a/crates/language_server/src/analysis/tokens.rs b/crates/language_server/src/analysis/tokens.rs index edc3e679da..869817080b 100644 --- a/crates/language_server/src/analysis/tokens.rs +++ b/crates/language_server/src/analysis/tokens.rs @@ -732,7 +732,6 @@ impl IterTokens for Loc> { Expr::MalformedIdent(_, _) | Expr::MalformedClosure | Expr::PrecedenceConflict(_) - | Expr::EmptyDefsFinal | Expr::MalformedSuffixed(_) => { bumpvec![in arena;] } From c4b63aa80aa66bbc1fccc6cc72c2f330a9650ee1 Mon Sep 17 00:00:00 2001 From: Kiryl Dziamura Date: Mon, 1 Jul 2024 19:44:32 +0200 Subject: [PATCH 33/42] simplify defs parsing --- crates/compiler/parse/src/ast.rs | 23 ++++-- crates/compiler/parse/src/expr.rs | 128 ++++++++++++++++++++++-------- 2 files changed, 113 insertions(+), 38 deletions(-) diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index c4673de62a..a3371688b0 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -532,6 +532,19 @@ pub fn split_loc_exprs_around<'a>( (before, after) } +/// Checks if the bang suffix is applied only at the top level of expression +pub fn is_top_level_suffixed(expr: &Expr) -> bool { + // TODO: should we check BinOps with pizza where the last expression is TaskAwaitBang? + match expr { + Expr::TaskAwaitBang(..) => true, + Expr::Apply(a, _, _) => is_top_level_suffixed(&a.value), + Expr::SpaceBefore(a, _) => is_top_level_suffixed(a), + Expr::SpaceAfter(a, _) => is_top_level_suffixed(a), + _ => false, + } +} + +/// Check if the bang suffix is applied recursevely in expression pub fn is_expr_suffixed(expr: &Expr) -> bool { match expr { // expression without arguments, `read!` @@ -1177,7 +1190,7 @@ impl<'a> Defs<'a> { }) } - pub fn last_value_suffixed(&mut self) -> Option<&'a Loc>> { + pub fn pop_last_value(&mut self) -> Option<&'a Loc>> { let last_value_suffix = self .tags .iter() @@ -1192,12 +1205,8 @@ impl<'a> Defs<'a> { .. }, loc_expr, - ) if collection.is_empty() && is_expr_suffixed(&loc_expr.value) => { - Some((tag_index, loc_expr)) - } - ValueDef::Stmt(loc_expr) if is_expr_suffixed(&loc_expr.value) => { - Some((tag_index, loc_expr)) - } + ) if collection.is_empty() => Some((tag_index, loc_expr)), + ValueDef::Stmt(loc_expr) => Some((tag_index, loc_expr)), _ => None, }, }); diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 4c5d7ab078..f02dfe79be 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -1,9 +1,9 @@ use crate::ast::{ - is_expr_suffixed, AssignedField, Collection, CommentOrNewline, Defs, Expr, ExtractSpaces, - Implements, ImplementsAbilities, ImportAlias, ImportAsKeyword, ImportExposingKeyword, - ImportedModuleName, IngestedFileAnnotation, IngestedFileImport, ModuleImport, - ModuleImportParams, Pattern, RecordBuilderField, Spaceable, Spaced, Spaces, TypeAnnotation, - TypeDef, TypeHeader, ValueDef, + is_expr_suffixed, is_top_level_suffixed, AssignedField, Collection, CommentOrNewline, Defs, + Expr, ExtractSpaces, Implements, ImplementsAbilities, ImportAlias, ImportAsKeyword, + ImportExposingKeyword, ImportedModuleName, IngestedFileAnnotation, IngestedFileImport, + ModuleImport, ModuleImportParams, Pattern, RecordBuilderField, Spaceable, Spaced, Spaces, + TypeAnnotation, TypeDef, TypeHeader, ValueDef, }; use crate::blankspace::{ space0_after_e, space0_around_e_no_after_indent_check, space0_around_ee, space0_before_e, @@ -372,14 +372,31 @@ fn expr_operator_chain<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a end, }; - parse_expr_end( + match parse_expr_end( new_min_indent, options, expr_state, arena, state, initial_state, - ) + ) { + Err(err) => Err(err), + Ok((progress, expr, new_state)) => { + // We need to check if we have just parsed a suffixed statement, + // if so, this is a defs node. + if is_top_level_suffixed(&expr) { + let def_region = Region::new(end, new_state.pos()); + let value_def = ValueDef::Stmt(arena.alloc(Loc::at(def_region, expr))); + + let mut defs = Defs::default(); + defs.push_value_def(value_def, def_region, &[], &[]); + + return parse_defs_expr(options, min_indent, defs, arena, new_state); + } else { + Ok((progress, expr, new_state)) + } + } + } } } }) @@ -1134,18 +1151,60 @@ pub fn parse_single_def_assignment<'a>( parse_def_expr.parse(arena, initial_state, min_indent)?; let region = Region::span_across(&def_loc_pattern.region, &first_loc_expr.region); - let value_def = ValueDef::Body(arena.alloc(def_loc_pattern), arena.alloc(first_loc_expr)); - Ok(( - progress_after_first, - Some(SingleDef { - type_or_value: Either::Second(value_def), + // If the expression is actually a suffixed statement, then we need to continue + // to parse the rest of the expression + if is_top_level_suffixed(&first_loc_expr.value) { + let mut defs = Defs::default(); + // Take the suffixed value and make it a e.g. Body(`{}=`, Apply(Var(...))) + // we will keep the pattern `def_loc_pattern` for the new Defs + defs.push_value_def( + ValueDef::Stmt(arena.alloc(first_loc_expr)), region, - spaces_before: spaces_before_current, - spaces_after: &[], - }), - state_after_first_expression, - )) + spaces_before_current, + &[], + ); + + // Try to parse the rest of the expression as multiple defs, which may contain sub-assignments + match parse_defs_expr( + options, + min_indent, + defs, + arena, + state_after_first_expression, + ) { + Ok((progress_after_rest_of_def, expr, state_after_rest_of_def)) => { + let final_loc_expr = arena.alloc(Loc::at(region, expr)); + + let value_def = ValueDef::Body(arena.alloc(def_loc_pattern), final_loc_expr); + + Ok(( + progress_after_rest_of_def, + Some(SingleDef { + type_or_value: Either::Second(value_def), + region, + spaces_before: spaces_before_current, + spaces_after: &[], + }), + state_after_rest_of_def, + )) + } + Err((progress, err)) => Err((progress, err)), + } + } else { + let value_def = ValueDef::Body(arena.alloc(def_loc_pattern), arena.alloc(first_loc_expr)); + + Ok(( + progress_after_first, + Some(SingleDef { + type_or_value: Either::Second(value_def), + region, + spaces_before: spaces_before_current, + spaces_after: &[], + }), + state_after_first_expression, + )) + } } /// e.g. Things that can be on their own line in a def, e.g. `expect`, `expect-fx`, or `dbg` @@ -1378,22 +1437,29 @@ fn parse_defs_expr<'a>( ) -> ParseResult<'a, Expr<'a>, EExpr<'a>> { match parse_defs_end(options, min_indent, defs, arena, state) { Err(bad) => Err(bad), - Ok((_, mut def_state, state)) => { + Ok((_, def_state, state)) => { // this is no def, because there is no `=` or `:`; parse as an expr - let parse_final_expr = space0_before_e(expr_start(options), EExpr::IndentEnd); - - match parse_final_expr.parse(arena, state.clone(), min_indent) { + match space0_before_e(expr_start(options), EExpr::IndentEnd).parse( + arena, + state.clone(), + min_indent, + ) { Err((_, fail)) => { - // If the last def was a suffixed statement, assume this was - // intentional by the application author instead of giving - // an error. - match def_state.last_value_suffixed() { - Some(loc_ret) => Ok(( - MadeProgress, - Expr::Defs(arena.alloc(def_state), arena.alloc(loc_ret)), - state, - )), - _ => Err(( + let mut def_state = def_state; + match def_state.pop_last_value() { + Some(loc_ret) => { + // If the poped value was the only item in defs - just return it as an expression + if def_state.is_empty() { + Ok((MadeProgress, loc_ret.value, state)) + } else { + Ok(( + MadeProgress, + Expr::Defs(arena.alloc(def_state), arena.alloc(loc_ret)), + state, + )) + } + } + None => Err(( MadeProgress, EExpr::DefMissingFinalExpr2(arena.alloc(fail), state.pos()), )), From 1008b94259512231befb4a93cd893a92de93c7a6 Mon Sep 17 00:00:00 2001 From: Kiryl Dziamura Date: Mon, 1 Jul 2024 19:46:59 +0200 Subject: [PATCH 34/42] fix returned expression desugaring --- crates/compiler/can/src/suffixed.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/compiler/can/src/suffixed.rs b/crates/compiler/can/src/suffixed.rs index eabd726967..77f8727df0 100644 --- a/crates/compiler/can/src/suffixed.rs +++ b/crates/compiler/can/src/suffixed.rs @@ -619,7 +619,8 @@ pub fn unwrap_suffixed_expression_defs_help<'a>( let after_empty = split_defs.after.is_empty(); if before_empty && after_empty { // NIL before, NIL after -> SINGLE DEF - let next_expr = match unwrap_suffixed_expression(arena,loc_ret,maybe_def_pat) { + // We pass None as a def pattern here because it's desugaring of the ret expression + let next_expr = match unwrap_suffixed_expression(arena,loc_ret, None) { Ok(next_expr) => next_expr, Err(EUnwrapped::UnwrappedSubExpr { sub_arg, sub_pat, sub_new }) => { // We need to apply Task.ok here as the defs final expression was unwrapped @@ -649,7 +650,8 @@ pub fn unwrap_suffixed_expression_defs_help<'a>( return unwrap_suffixed_expression(arena, apply_task_await(arena,def_expr.region,unwrapped_expr,def_pattern,next_expr), maybe_def_pat); } else if after_empty { // SOME before, NIL after -> LAST DEF - match unwrap_suffixed_expression(arena,loc_ret,maybe_def_pat){ + // We pass None as a def pattern here because it's desugaring of the ret expression + match unwrap_suffixed_expression(arena,loc_ret,None){ Ok(new_loc_ret) => { let applied_task_await = apply_task_await(arena, loc_expr.region, unwrapped_expr, def_pattern, new_loc_ret); let new_defs = arena.alloc(Loc::at(loc_expr.region,Defs(arena.alloc(split_defs.before), applied_task_await))); From 632938997205764ee2bba5fff8c88f3edc1538fe Mon Sep 17 00:00:00 2001 From: Kiryl Dziamura Date: Mon, 1 Jul 2024 19:47:49 +0200 Subject: [PATCH 35/42] add tests --- crates/compiler/can/tests/test_suffixed.rs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/crates/compiler/can/tests/test_suffixed.rs b/crates/compiler/can/tests/test_suffixed.rs index 5f833335e3..1cc744a08c 100644 --- a/crates/compiler/can/tests/test_suffixed.rs +++ b/crates/compiler/can/tests/test_suffixed.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate indoc; + #[cfg(test)] mod suffixed_tests { @@ -913,6 +916,35 @@ mod suffixed_tests { r##"Defs { tags: [Index(2147483648)], regions: [@0-48], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @0-48 Apply(@0-48 Var { module_name: "Task", ident: "await" }, [@27-29 Var { module_name: "", ident: "a" }, @0-48 Closure([@27-29 Identifier { ident: "#!a0" }], @0-48 LowLevelDbg(("test.roc:3", " "), @27-29 Apply(@27-29 Var { module_name: "Inspect", ident: "toStr" }, [@27-29 Var { module_name: "", ident: "#!a0" }], Space), @47-48 Var { module_name: "", ident: "b" }))], BangSuffix))] }"##, ) } + + #[test] + fn last_stmt_not_top_level_suffixed() { + run_test( + r#" + main = + x = 42 + a b! + "#, + r##"Defs { tags: [Index(2147483648)], regions: [@0-50], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @23-50 Defs(Defs { tags: [Index(2147483650)], regions: [@27-29], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@23-24 Identifier { ident: "x" }, @27-29 Num("42")), Body(@23-24 Identifier { ident: "x" }, @27-29 Num("42")), Body(@23-24 Identifier { ident: "x" }, @27-29 Num("42"))] }, @23-50 Apply(@23-50 Var { module_name: "Task", ident: "await" }, [@48-49 Var { module_name: "", ident: "b" }, @23-50 Closure([@48-49 Identifier { ident: "#!a0" }], @46-50 Apply(@46-47 Var { module_name: "", ident: "a" }, [@48-49 Var { module_name: "", ident: "#!a0" }], Space))], BangSuffix)))] }"##, + ); + } + + #[test] + fn nested_defs() { + run_test( + indoc!( + r##" + main = + x = + a = b! + c! a + + x + "##, + ), + r##"Defs { tags: [Index(2147483648)], regions: [@0-49], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @11-49 Defs(Defs { tags: [Index(2147483649)], regions: [@23-42], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@11-12 Identifier { ident: "x" }, @23-42 Defs(Defs { tags: [Index(2147483648)], regions: [@23-29], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@23-24 Identifier { ident: "a" }, @27-29 TaskAwaitBang(Var { module_name: "", ident: "b" }))] }, @38-42 Apply(@38-39 TaskAwaitBang(Var { module_name: "", ident: "c" }), [@41-42 Var { module_name: "", ident: "a" }], Space))), Body(@11-12 Identifier { ident: "x" }, @27-29 Apply(@27-29 Var { module_name: "Task", ident: "await" }, [@27-29 Var { module_name: "", ident: "b" }, @27-29 Closure([@23-24 Identifier { ident: "a" }], @38-42 Apply(@38-42 Var { module_name: "", ident: "c" }, [@41-42 Var { module_name: "", ident: "a" }], Space))], BangSuffix))] }, @48-49 Var { module_name: "", ident: "x" }))] }"##, + ); + } } #[cfg(test)] From 819cfd6035962711ce717a60cf3bd752986efe89 Mon Sep 17 00:00:00 2001 From: Kiryl Dziamura Date: Mon, 1 Jul 2024 19:48:00 +0200 Subject: [PATCH 36/42] fix test snapshots --- crates/compiler/can/tests/test_suffixed.rs | 22 ++++---- ...xed_multiple_defs.moduledefs.formatted.roc | 1 + ...ffixed_multiple_defs.moduledefs.result-ast | 51 ++++++++----------- .../suffixed_optional_last.full.result-ast | 2 +- 4 files changed, 35 insertions(+), 41 deletions(-) diff --git a/crates/compiler/can/tests/test_suffixed.rs b/crates/compiler/can/tests/test_suffixed.rs index 1cc744a08c..526d2c7172 100644 --- a/crates/compiler/can/tests/test_suffixed.rs +++ b/crates/compiler/can/tests/test_suffixed.rs @@ -378,7 +378,7 @@ mod suffixed_tests { x = foo! msg bar x "#, - r#"Defs { tags: [Index(2147483648)], regions: [@0-88], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @0-88 Defs(Defs { tags: [Index(2147483649)], regions: [@30-37], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@24-27 Identifier { ident: "msg" }, @30-37 Str(PlainLine("hello"))), Body(@24-27 Identifier { ident: "msg" }, @30-37 Str(PlainLine("hello")))] }, @0-88 Apply(@0-88 Var { module_name: "Task", ident: "await" }, [@54-66 Apply(@54-66 Var { module_name: "", ident: "foo" }, [@63-66 Var { module_name: "", ident: "msg" }], Space), @0-88 Closure([@54-55 Identifier { ident: "x" }], @83-88 Apply(@83-86 Var { module_name: "", ident: "bar" }, [@87-88 Var { module_name: "", ident: "x" }], Space))], BangSuffix)))] }"#, + r#"Defs { tags: [Index(2147483648)], regions: [@0-88], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @24-88 Defs(Defs { tags: [Index(2147483649)], regions: [@30-37], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@24-27 Identifier { ident: "msg" }, @30-37 Str(PlainLine("hello"))), Body(@24-27 Identifier { ident: "msg" }, @30-37 Str(PlainLine("hello")))] }, @24-88 Apply(@24-88 Var { module_name: "Task", ident: "await" }, [@54-66 Apply(@54-66 Var { module_name: "", ident: "foo" }, [@63-66 Var { module_name: "", ident: "msg" }], Space), @24-88 Closure([@54-55 Identifier { ident: "x" }], @83-88 Apply(@83-86 Var { module_name: "", ident: "bar" }, [@87-88 Var { module_name: "", ident: "x" }], Space))], BangSuffix)))] }"#, ); } @@ -419,7 +419,7 @@ mod suffixed_tests { x "foo" "#, - r#"Defs { tags: [Index(2147483648)], regions: [@0-187], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @0-187 Defs(Defs { tags: [Index(2147483650)], regions: [@60-162], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Annotation(@24-25 Identifier { ident: "x" }, @28-43 Function([@28-31 Apply("", "Str", [])], @35-43 Apply("", "Task", [@40-41 Inferred, @42-43 Inferred]))), AnnotatedBody { ann_pattern: @24-25 Identifier { ident: "x" }, ann_type: @28-43 Function([@28-31 Apply("", "Str", [])], @35-43 Apply("", "Task", [@40-41 Inferred, @42-43 Inferred])), comment: None, body_pattern: @60-61 Identifier { ident: "x" }, body_expr: @60-162 Closure([@65-68 Identifier { ident: "msg" }], @93-162 Defs(Defs { tags: [Index(2147483649)], regions: [@93-140], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Annotation(@93-94 Identifier { ident: "y" }, @97-106 Apply("", "Task", [@102-104 Record { fields: [], ext: None }, @105-106 Inferred])), AnnotatedBody { ann_pattern: @93-94 Identifier { ident: "y" }, ann_type: @97-106 Apply("", "Task", [@102-104 Record { fields: [], ext: None }, @105-106 Inferred]), comment: None, body_pattern: @127-128 Identifier { ident: "y" }, body_expr: @127-140 Apply(@131-135 TaskAwaitBang(Var { module_name: "", ident: "line" }), [@137-140 Var { module_name: "", ident: "msg" }], Space) }] }, @161-162 Var { module_name: "", ident: "y" })) }, AnnotatedBody { ann_pattern: @24-25 Identifier { ident: "x" }, ann_type: @28-43 Function([@28-31 Apply("", "Str", [])], @35-43 Apply("", "Task", [@40-41 Inferred, @42-43 Inferred])), comment: None, body_pattern: @60-61 Identifier { ident: "x" }, body_expr: @60-162 Closure([@65-68 Identifier { ident: "msg" }], @127-140 Apply(@127-140 Var { module_name: "Task", ident: "await" }, [@127-140 Apply(@127-140 Var { module_name: "", ident: "line" }, [@137-140 Var { module_name: "", ident: "msg" }], Space), @127-140 Closure([@127-128 Identifier { ident: "y" }], @161-162 Var { module_name: "", ident: "y" })], BangSuffix)) }] }, @180-187 Apply(@180-181 Var { module_name: "", ident: "x" }, [@182-187 Str(PlainLine("foo"))], Space)))] }"#, + r#"Defs { tags: [Index(2147483648)], regions: [@0-187], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @24-187 Defs(Defs { tags: [Index(2147483650)], regions: [@64-162], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Annotation(@24-25 Identifier { ident: "x" }, @28-43 Function([@28-31 Apply("", "Str", [])], @35-43 Apply("", "Task", [@40-41 Inferred, @42-43 Inferred]))), AnnotatedBody { ann_pattern: @24-25 Identifier { ident: "x" }, ann_type: @28-43 Function([@28-31 Apply("", "Str", [])], @35-43 Apply("", "Task", [@40-41 Inferred, @42-43 Inferred])), comment: None, body_pattern: @60-61 Identifier { ident: "x" }, body_expr: @64-162 Closure([@65-68 Identifier { ident: "msg" }], @93-162 Defs(Defs { tags: [Index(2147483649)], regions: [@93-140], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Annotation(@93-94 Identifier { ident: "y" }, @97-106 Apply("", "Task", [@102-104 Record { fields: [], ext: None }, @105-106 Inferred])), AnnotatedBody { ann_pattern: @93-94 Identifier { ident: "y" }, ann_type: @97-106 Apply("", "Task", [@102-104 Record { fields: [], ext: None }, @105-106 Inferred]), comment: None, body_pattern: @127-128 Identifier { ident: "y" }, body_expr: @127-140 Apply(@131-135 TaskAwaitBang(Var { module_name: "", ident: "line" }), [@137-140 Var { module_name: "", ident: "msg" }], Space) }] }, @161-162 Var { module_name: "", ident: "y" })) }, AnnotatedBody { ann_pattern: @24-25 Identifier { ident: "x" }, ann_type: @28-43 Function([@28-31 Apply("", "Str", [])], @35-43 Apply("", "Task", [@40-41 Inferred, @42-43 Inferred])), comment: None, body_pattern: @60-61 Identifier { ident: "x" }, body_expr: @64-162 Closure([@65-68 Identifier { ident: "msg" }], @127-140 Apply(@127-140 Var { module_name: "Task", ident: "await" }, [@127-140 Apply(@127-140 Var { module_name: "", ident: "line" }, [@137-140 Var { module_name: "", ident: "msg" }], Space), @127-140 Closure([@127-128 Identifier { ident: "y" }], @161-162 Var { module_name: "", ident: "y" })], BangSuffix)) }] }, @180-187 Apply(@180-181 Var { module_name: "", ident: "x" }, [@182-187 Str(PlainLine("foo"))], Space)))] }"#, ); } @@ -613,7 +613,7 @@ mod suffixed_tests { else line "fail" "#, - r##"Defs { tags: [Index(2147483648)], regions: [@0-286], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @0-286 Defs(Defs { tags: [Index(2147483650), Index(2147483651)], regions: [@32-49, @76-94], space_before: [Slice(start = 0, length = 0), Slice(start = 0, length = 1)], space_after: [Slice(start = 0, length = 0), Slice(start = 1, length = 0)], spaces: [Newline], type_defs: [], value_defs: [Body(@23-29 Identifier { ident: "isTrue" }, @32-49 Apply(@32-39 Var { module_name: "Task", ident: "ok" }, [@40-49 Var { module_name: "Bool", ident: "true" }], Space)), Body(@66-73 Identifier { ident: "isFalse" }, @76-94 Apply(@76-83 Var { module_name: "Task", ident: "ok" }, [@84-94 Var { module_name: "Bool", ident: "false" }], Space)), Body(@23-29 Identifier { ident: "isTrue" }, @32-49 Apply(@32-39 Var { module_name: "Task", ident: "ok" }, [@40-49 Var { module_name: "Bool", ident: "true" }], Space)), Body(@66-73 Identifier { ident: "isFalse" }, @76-94 Apply(@76-83 Var { module_name: "Task", ident: "ok" }, [@84-94 Var { module_name: "Bool", ident: "false" }], Space))] }, @115-123 Apply(@115-123 Var { module_name: "Task", ident: "await" }, [@115-123 Var { module_name: "", ident: "isFalse" }, @115-123 Closure([@115-123 Identifier { ident: "#!a0" }], @112-286 If([(@115-123 Var { module_name: "", ident: "#!a0" }, @149-160 Apply(@149-153 Var { module_name: "", ident: "line" }, [@154-160 Str(PlainLine("fail"))], Space))], @185-192 Apply(@185-192 Var { module_name: "Task", ident: "await" }, [@185-192 Var { module_name: "", ident: "isTrue" }, @185-192 Closure([@185-192 Identifier { ident: "#!a1" }], @112-286 If([(@185-192 Var { module_name: "", ident: "#!a1" }, @219-233 Apply(@219-223 Var { module_name: "", ident: "line" }, [@224-233 Str(PlainLine("success"))], Space))], @275-286 Apply(@275-279 Var { module_name: "", ident: "line" }, [@280-286 Str(PlainLine("fail"))], Space)))], BangSuffix)))], BangSuffix)))] }"##, + r##"Defs { tags: [Index(2147483648)], regions: [@0-286], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @23-286 Defs(Defs { tags: [Index(2147483650), Index(2147483651)], regions: [@32-49, @76-94], space_before: [Slice(start = 0, length = 0), Slice(start = 0, length = 1)], space_after: [Slice(start = 0, length = 0), Slice(start = 1, length = 0)], spaces: [Newline], type_defs: [], value_defs: [Body(@23-29 Identifier { ident: "isTrue" }, @32-49 Apply(@32-39 Var { module_name: "Task", ident: "ok" }, [@40-49 Var { module_name: "Bool", ident: "true" }], Space)), Body(@66-73 Identifier { ident: "isFalse" }, @76-94 Apply(@76-83 Var { module_name: "Task", ident: "ok" }, [@84-94 Var { module_name: "Bool", ident: "false" }], Space)), Body(@23-29 Identifier { ident: "isTrue" }, @32-49 Apply(@32-39 Var { module_name: "Task", ident: "ok" }, [@40-49 Var { module_name: "Bool", ident: "true" }], Space)), Body(@66-73 Identifier { ident: "isFalse" }, @76-94 Apply(@76-83 Var { module_name: "Task", ident: "ok" }, [@84-94 Var { module_name: "Bool", ident: "false" }], Space))] }, @115-123 Apply(@115-123 Var { module_name: "Task", ident: "await" }, [@115-123 Var { module_name: "", ident: "isFalse" }, @115-123 Closure([@115-123 Identifier { ident: "#!a0" }], @112-286 If([(@115-123 Var { module_name: "", ident: "#!a0" }, @149-160 Apply(@149-153 Var { module_name: "", ident: "line" }, [@154-160 Str(PlainLine("fail"))], Space))], @185-192 Apply(@185-192 Var { module_name: "Task", ident: "await" }, [@185-192 Var { module_name: "", ident: "isTrue" }, @185-192 Closure([@185-192 Identifier { ident: "#!a1" }], @112-286 If([(@185-192 Var { module_name: "", ident: "#!a1" }, @219-233 Apply(@219-223 Var { module_name: "", ident: "line" }, [@224-233 Str(PlainLine("success"))], Space))], @275-286 Apply(@275-279 Var { module_name: "", ident: "line" }, [@280-286 Str(PlainLine("fail"))], Space)))], BangSuffix)))], BangSuffix)))] }"##, ); } @@ -653,7 +653,7 @@ mod suffixed_tests { msg "#, - r##"Defs { tags: [Index(2147483648)], regions: [@0-466], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @0-466 Defs(Defs { tags: [Index(2147483652), Index(2147483653), Index(2147483654)], regions: [@32-49, @77-92, @143-445], space_before: [Slice(start = 0, length = 0), Slice(start = 0, length = 1), Slice(start = 1, length = 1)], space_after: [Slice(start = 0, length = 0), Slice(start = 1, length = 0), Slice(start = 2, length = 0)], spaces: [Newline, Newline], type_defs: [], value_defs: [Body(@23-29 Identifier { ident: "isTrue" }, @32-49 Apply(@32-39 Var { module_name: "Task", ident: "ok" }, [@40-49 Var { module_name: "Bool", ident: "true" }], Space)), Body(@66-74 Identifier { ident: "isFalsey" }, @77-92 Closure([@78-79 Identifier { ident: "x" }], @83-92 Apply(@83-90 Var { module_name: "Task", ident: "ok" }, [@91-92 Var { module_name: "", ident: "x" }], Space))), Annotation(@109-112 Identifier { ident: "msg" }, @115-126 Apply("", "Task", [@120-122 Record { fields: [], ext: None }, @123-126 Apply("", "I32", [])])), AnnotatedBody { ann_pattern: @109-112 Identifier { ident: "msg" }, ann_type: @115-126 Apply("", "Task", [@120-122 Record { fields: [], ext: None }, @123-126 Apply("", "I32", [])]), comment: None, body_pattern: @143-146 Identifier { ident: "msg" }, body_expr: @143-445 If([(@173-183 Apply(@173-174 Var { module_name: "Bool", ident: "not" }, [@175-182 ParensAround(TaskAwaitBang(Var { module_name: "", ident: "isTrue" }))], UnaryOp(Not)), @213-256 Defs(Defs { tags: [Index(2147483648)], regions: [@218-225], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@218-225 RecordDestructure([]), @218-225 Apply(@213-217 TaskAwaitBang(Var { module_name: "", ident: "line" }), [@219-225 Str(PlainLine("fail"))], Space))] }, @251-256 Apply(@251-254 Var { module_name: "", ident: "err" }, [@255-256 Num("1")], Space))), (@285-307 ParensAround(Apply(@286-294 TaskAwaitBang(Var { module_name: "", ident: "isFalsey" }), [@296-306 Var { module_name: "Bool", ident: "false" }], Space)), @338-380 Defs(Defs { tags: [Index(2147483648)], regions: [@343-350], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@343-350 RecordDestructure([]), @343-350 Apply(@338-342 TaskAwaitBang(Var { module_name: "", ident: "line" }), [@344-350 Str(PlainLine("nope"))], Space))] }, @375-380 Apply(@375-377 Var { module_name: "", ident: "ok" }, [@378-380 Record([])], Space)))], @430-445 Apply(@430-434 TaskAwaitBang(Var { module_name: "", ident: "line" }), [@436-445 Str(PlainLine("success"))], Space)) }, Body(@23-29 Identifier { ident: "isTrue" }, @32-49 Apply(@32-39 Var { module_name: "Task", ident: "ok" }, [@40-49 Var { module_name: "Bool", ident: "true" }], Space)), Body(@66-74 Identifier { ident: "isFalsey" }, @77-92 Closure([@78-79 Identifier { ident: "x" }], @83-92 Apply(@83-90 Var { module_name: "Task", ident: "ok" }, [@91-92 Var { module_name: "", ident: "x" }], Space))), AnnotatedBody { ann_pattern: @109-112 Identifier { ident: "msg" }, ann_type: @115-126 Apply("", "Task", [@120-122 Record { fields: [], ext: None }, @123-126 Apply("", "I32", [])]), comment: None, body_pattern: @143-146 Identifier { ident: "msg" }, body_expr: Apply(Var { module_name: "Task", ident: "await" }, [Var { module_name: "", ident: "isTrue" }, Closure([Identifier { ident: "#!a0" }], @143-445 If([(@173-183 Apply(@173-174 Var { module_name: "Bool", ident: "not" }, [@175-182 ParensAround(Var { module_name: "", ident: "#!a0" })], UnaryOp(Not)), @218-225 Apply(@218-225 Var { module_name: "Task", ident: "await" }, [@218-225 Apply(@218-225 Var { module_name: "", ident: "line" }, [@219-225 Str(PlainLine("fail"))], Space), @218-225 Closure([@218-225 RecordDestructure([])], @251-256 Apply(@251-254 Var { module_name: "", ident: "err" }, [@255-256 Num("1")], Space))], BangSuffix))], Apply(Var { module_name: "Task", ident: "await" }, [Apply(Var { module_name: "", ident: "isFalsey" }, [@296-306 Var { module_name: "Bool", ident: "false" }], Space), Closure([Identifier { ident: "#!a1" }], @143-445 If([(@285-307 ParensAround(Var { module_name: "", ident: "#!a1" }), @343-350 Apply(@343-350 Var { module_name: "Task", ident: "await" }, [@343-350 Apply(@343-350 Var { module_name: "", ident: "line" }, [@344-350 Str(PlainLine("nope"))], Space), @343-350 Closure([@343-350 RecordDestructure([])], @375-380 Apply(@375-377 Var { module_name: "", ident: "ok" }, [@378-380 Record([])], Space))], BangSuffix))], @430-445 Apply(@430-445 Var { module_name: "", ident: "line" }, [@436-445 Str(PlainLine("success"))], Space)))], BangSuffix)))], BangSuffix) }] }, @463-466 Var { module_name: "", ident: "msg" }))] }"##, + r##"Defs { tags: [Index(2147483648)], regions: [@0-466], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @23-466 Defs(Defs { tags: [Index(2147483652), Index(2147483653), Index(2147483654)], regions: [@32-49, @77-92, @170-445], space_before: [Slice(start = 0, length = 0), Slice(start = 0, length = 1), Slice(start = 1, length = 1)], space_after: [Slice(start = 0, length = 0), Slice(start = 1, length = 0), Slice(start = 2, length = 0)], spaces: [Newline, Newline], type_defs: [], value_defs: [Body(@23-29 Identifier { ident: "isTrue" }, @32-49 Apply(@32-39 Var { module_name: "Task", ident: "ok" }, [@40-49 Var { module_name: "Bool", ident: "true" }], Space)), Body(@66-74 Identifier { ident: "isFalsey" }, @77-92 Closure([@78-79 Identifier { ident: "x" }], @83-92 Apply(@83-90 Var { module_name: "Task", ident: "ok" }, [@91-92 Var { module_name: "", ident: "x" }], Space))), Annotation(@109-112 Identifier { ident: "msg" }, @115-126 Apply("", "Task", [@120-122 Record { fields: [], ext: None }, @123-126 Apply("", "I32", [])])), AnnotatedBody { ann_pattern: @109-112 Identifier { ident: "msg" }, ann_type: @115-126 Apply("", "Task", [@120-122 Record { fields: [], ext: None }, @123-126 Apply("", "I32", [])]), comment: None, body_pattern: @143-146 Identifier { ident: "msg" }, body_expr: @170-445 If([(@173-183 Apply(@173-174 Var { module_name: "Bool", ident: "not" }, [@175-182 ParensAround(TaskAwaitBang(Var { module_name: "", ident: "isTrue" }))], UnaryOp(Not)), @213-256 Defs(Defs { tags: [Index(2147483648)], regions: [@218-225], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@218-225 RecordDestructure([]), @218-225 Apply(@213-217 TaskAwaitBang(Var { module_name: "", ident: "line" }), [@219-225 Str(PlainLine("fail"))], Space))] }, @251-256 Apply(@251-254 Var { module_name: "", ident: "err" }, [@255-256 Num("1")], Space))), (@285-307 ParensAround(Apply(@286-294 TaskAwaitBang(Var { module_name: "", ident: "isFalsey" }), [@296-306 Var { module_name: "Bool", ident: "false" }], Space)), @338-380 Defs(Defs { tags: [Index(2147483648)], regions: [@343-350], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@343-350 RecordDestructure([]), @343-350 Apply(@338-342 TaskAwaitBang(Var { module_name: "", ident: "line" }), [@344-350 Str(PlainLine("nope"))], Space))] }, @375-380 Apply(@375-377 Var { module_name: "", ident: "ok" }, [@378-380 Record([])], Space)))], @430-445 Apply(@430-434 TaskAwaitBang(Var { module_name: "", ident: "line" }), [@436-445 Str(PlainLine("success"))], Space)) }, Body(@23-29 Identifier { ident: "isTrue" }, @32-49 Apply(@32-39 Var { module_name: "Task", ident: "ok" }, [@40-49 Var { module_name: "Bool", ident: "true" }], Space)), Body(@66-74 Identifier { ident: "isFalsey" }, @77-92 Closure([@78-79 Identifier { ident: "x" }], @83-92 Apply(@83-90 Var { module_name: "Task", ident: "ok" }, [@91-92 Var { module_name: "", ident: "x" }], Space))), AnnotatedBody { ann_pattern: @109-112 Identifier { ident: "msg" }, ann_type: @115-126 Apply("", "Task", [@120-122 Record { fields: [], ext: None }, @123-126 Apply("", "I32", [])]), comment: None, body_pattern: @143-146 Identifier { ident: "msg" }, body_expr: Apply(Var { module_name: "Task", ident: "await" }, [Var { module_name: "", ident: "isTrue" }, Closure([Identifier { ident: "#!a0" }], @170-445 If([(@173-183 Apply(@173-174 Var { module_name: "Bool", ident: "not" }, [@175-182 ParensAround(Var { module_name: "", ident: "#!a0" })], UnaryOp(Not)), @218-225 Apply(@218-225 Var { module_name: "Task", ident: "await" }, [@218-225 Apply(@218-225 Var { module_name: "", ident: "line" }, [@219-225 Str(PlainLine("fail"))], Space), @218-225 Closure([@218-225 RecordDestructure([])], @251-256 Apply(@251-254 Var { module_name: "", ident: "err" }, [@255-256 Num("1")], Space))], BangSuffix))], Apply(Var { module_name: "Task", ident: "await" }, [Apply(Var { module_name: "", ident: "isFalsey" }, [@296-306 Var { module_name: "Bool", ident: "false" }], Space), Closure([Identifier { ident: "#!a1" }], @170-445 If([(@285-307 ParensAround(Var { module_name: "", ident: "#!a1" }), @343-350 Apply(@343-350 Var { module_name: "Task", ident: "await" }, [@343-350 Apply(@343-350 Var { module_name: "", ident: "line" }, [@344-350 Str(PlainLine("nope"))], Space), @343-350 Closure([@343-350 RecordDestructure([])], @375-380 Apply(@375-377 Var { module_name: "", ident: "ok" }, [@378-380 Record([])], Space))], BangSuffix))], @430-445 Apply(@430-445 Var { module_name: "", ident: "line" }, [@436-445 Str(PlainLine("success"))], Space)))], BangSuffix)))], BangSuffix) }] }, @463-466 Var { module_name: "", ident: "msg" }))] }"##, ); } @@ -684,7 +684,7 @@ mod suffixed_tests { CMD.new "cp" |> mapErr! ERR "#, - r#"Defs { tags: [Index(2147483648)], regions: [@0-103], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "copy" }, @0-103 Closure([@8-9 Identifier { ident: "a" }, @10-11 Identifier { ident: "b" }], @36-42 Apply(@36-42 Var { module_name: "Task", ident: "await" }, [@36-42 Apply(@36-42 Var { module_name: "", ident: "line" }, [@37-42 Str(PlainLine("FOO"))], Space), @36-42 Closure([@36-42 RecordDestructure([])], @60-103 Apply(@60-103 Var { module_name: "", ident: "mapErr" }, [@60-72 Apply(@60-67 Var { module_name: "CMD", ident: "new" }, [@68-72 Str(PlainLine("cp"))], Space), @100-103 Tag("ERR")], BinOp(Pizza)))], BangSuffix)))] }"#, + r#"Defs { tags: [Index(2147483648)], regions: [@0-103], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "copy" }, @7-103 Closure([@8-9 Identifier { ident: "a" }, @10-11 Identifier { ident: "b" }], @36-42 Apply(@36-42 Var { module_name: "Task", ident: "await" }, [@36-42 Apply(@36-42 Var { module_name: "", ident: "line" }, [@37-42 Str(PlainLine("FOO"))], Space), @36-42 Closure([@36-42 RecordDestructure([])], @60-103 Apply(@60-103 Var { module_name: "", ident: "mapErr" }, [@60-72 Apply(@60-67 Var { module_name: "CMD", ident: "new" }, [@68-72 Str(PlainLine("cp"))], Space), @100-103 Tag("ERR")], BinOp(Pizza)))], BangSuffix)))] }"#, ); } @@ -712,7 +712,7 @@ mod suffixed_tests { [] -> "empty" _ -> "non-empty" "#, - r##"Defs { tags: [Index(2147483648)], regions: [@0-111], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "list" }, @0-111 Apply(@0-111 Var { module_name: "Task", ident: "await" }, [@29-37 Var { module_name: "", ident: "getList" }, @0-111 Closure([@29-37 Identifier { ident: "#!a0" }], @0-111 When(@29-37 Var { module_name: "", ident: "#!a0" }, [WhenBranch { patterns: [@61-63 List([])], value: @67-74 Str(PlainLine("empty")), guard: None }, WhenBranch { patterns: [@95-96 Underscore("")], value: @100-111 Str(PlainLine("non-empty")), guard: None }]))], BangSuffix))] }"##, + r##"Defs { tags: [Index(2147483648)], regions: [@0-111], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "list" }, @24-111 Apply(@24-111 Var { module_name: "Task", ident: "await" }, [@29-37 Var { module_name: "", ident: "getList" }, @24-111 Closure([@29-37 Identifier { ident: "#!a0" }], @24-111 When(@29-37 Var { module_name: "", ident: "#!a0" }, [WhenBranch { patterns: [@61-63 List([])], value: @67-74 Str(PlainLine("empty")), guard: None }, WhenBranch { patterns: [@95-96 Underscore("")], value: @100-111 Str(PlainLine("non-empty")), guard: None }]))], BangSuffix))] }"##, ); } @@ -757,7 +757,7 @@ mod suffixed_tests { _ -> ok {} "#, - r##"Defs { tags: [Index(2147483648)], regions: [@0-195], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "list" }, @0-195 Apply(@0-195 Var { module_name: "Task", ident: "await" }, [@29-37 Var { module_name: "", ident: "getList" }, @0-195 Closure([@29-37 Identifier { ident: "#!a0" }], @0-195 When(@29-37 Var { module_name: "", ident: "#!a0" }, [WhenBranch { patterns: [@61-63 List([])], value: @97-103 Apply(@97-103 Var { module_name: "Task", ident: "await" }, [@97-103 Apply(@97-103 Var { module_name: "", ident: "line" }, [@98-103 Str(PlainLine("foo"))], Space), @97-103 Closure([@97-103 RecordDestructure([])], @128-139 Apply(@128-139 Var { module_name: "", ident: "line" }, [@134-139 Str(PlainLine("bar"))], Space))], BangSuffix), guard: None }, WhenBranch { patterns: [@160-161 Underscore("")], value: @190-195 Apply(@190-192 Var { module_name: "", ident: "ok" }, [@193-195 Record([])], Space), guard: None }]))], BangSuffix))] }"##, + r##"Defs { tags: [Index(2147483648)], regions: [@0-195], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "list" }, @24-195 Apply(@24-195 Var { module_name: "Task", ident: "await" }, [@29-37 Var { module_name: "", ident: "getList" }, @24-195 Closure([@29-37 Identifier { ident: "#!a1" }], @24-195 When(@29-37 Var { module_name: "", ident: "#!a1" }, [WhenBranch { patterns: [@61-63 List([])], value: @97-103 Apply(@97-103 Var { module_name: "Task", ident: "await" }, [@97-103 Apply(@97-103 Var { module_name: "", ident: "line" }, [@98-103 Str(PlainLine("foo"))], Space), @97-103 Closure([@97-103 RecordDestructure([])], @128-139 Apply(@128-139 Var { module_name: "", ident: "line" }, [@134-139 Str(PlainLine("bar"))], Space))], BangSuffix), guard: None }, WhenBranch { patterns: [@160-161 Underscore("")], value: @190-195 Apply(@190-192 Var { module_name: "", ident: "ok" }, [@193-195 Record([])], Space), guard: None }]))], BangSuffix))] }"##, ); } @@ -865,7 +865,7 @@ mod suffixed_tests { expect 1 == 2 x! "#, - r#"Defs { tags: [Index(2147483648)], regions: [@0-55], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @0-55 Expect(@30-36 Apply(@32-34 Var { module_name: "Bool", ident: "isEq" }, [@30-31 Num("1"), @35-36 Num("2")], BinOp(Equals)), @53-55 Var { module_name: "", ident: "x" }))] }"#, + r#"Defs { tags: [Index(2147483648)], regions: [@0-55], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @23-55 Expect(@30-36 Apply(@32-34 Var { module_name: "Bool", ident: "isEq" }, [@30-31 Num("1"), @35-36 Num("2")], BinOp(Equals)), @53-55 Var { module_name: "", ident: "x" }))] }"#, ); } @@ -880,7 +880,7 @@ mod suffixed_tests { 1 -> c! "#, - r#"Defs { tags: [Index(2147483648)], regions: [@0-159], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @0-159 When(@28-29 Var { module_name: "", ident: "a" }, [WhenBranch { patterns: [@53-54 NumLiteral("0")], value: @82-159 When(@87-88 Var { module_name: "", ident: "b" }, [WhenBranch { patterns: [@120-121 NumLiteral("1")], value: @157-159 Var { module_name: "", ident: "c" }, guard: None }]), guard: None }]))] }"#, + r#"Defs { tags: [Index(2147483648)], regions: [@0-159], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @23-159 When(@28-29 Var { module_name: "", ident: "a" }, [WhenBranch { patterns: [@53-54 NumLiteral("0")], value: @82-159 When(@87-88 Var { module_name: "", ident: "b" }, [WhenBranch { patterns: [@120-121 NumLiteral("1")], value: @157-159 Var { module_name: "", ident: "c" }, guard: None }]), guard: None }]))] }"#, ); } @@ -900,7 +900,7 @@ mod suffixed_tests { B -> d! "#, - r#"Defs { tags: [Index(2147483648)], regions: [@0-266], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @0-266 When(@28-29 Var { module_name: "", ident: "x" }, [WhenBranch { patterns: [@53-54 Tag("A")], value: @82-214 Defs(Defs { tags: [Index(2147483649)], regions: [@86-88], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@82-83 Identifier { ident: "y" }, @86-88 Num("42")), Body(@82-83 Identifier { ident: "y" }, @86-88 Num("42"))] }, @114-214 If([(@117-118 Var { module_name: "", ident: "a" }, @152-154 Var { module_name: "", ident: "b" })], @212-214 Var { module_name: "", ident: "c" })), guard: None }, WhenBranch { patterns: [@235-236 Tag("B")], value: @264-266 Var { module_name: "", ident: "d" }, guard: None }]))] }"#, + r#"Defs { tags: [Index(2147483648)], regions: [@0-266], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @23-266 When(@28-29 Var { module_name: "", ident: "x" }, [WhenBranch { patterns: [@53-54 Tag("A")], value: @82-214 Defs(Defs { tags: [Index(2147483649)], regions: [@86-88], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@82-83 Identifier { ident: "y" }, @86-88 Num("42")), Body(@82-83 Identifier { ident: "y" }, @86-88 Num("42"))] }, @114-214 If([(@117-118 Var { module_name: "", ident: "a" }, @152-154 Var { module_name: "", ident: "b" })], @212-214 Var { module_name: "", ident: "c" })), guard: None }, WhenBranch { patterns: [@235-236 Tag("B")], value: @264-266 Var { module_name: "", ident: "d" }, guard: None }]))] }"#, ); } @@ -913,7 +913,7 @@ mod suffixed_tests { b "#, - r##"Defs { tags: [Index(2147483648)], regions: [@0-48], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @0-48 Apply(@0-48 Var { module_name: "Task", ident: "await" }, [@27-29 Var { module_name: "", ident: "a" }, @0-48 Closure([@27-29 Identifier { ident: "#!a0" }], @0-48 LowLevelDbg(("test.roc:3", " "), @27-29 Apply(@27-29 Var { module_name: "Inspect", ident: "toStr" }, [@27-29 Var { module_name: "", ident: "#!a0" }], Space), @47-48 Var { module_name: "", ident: "b" }))], BangSuffix))] }"##, + r##"Defs { tags: [Index(2147483648)], regions: [@0-48], space_before: [Slice(start = 0, length = 0)], space_after: [Slice(start = 0, length = 0)], spaces: [], type_defs: [], value_defs: [Body(@0-4 Identifier { ident: "main" }, @23-48 Apply(@23-48 Var { module_name: "Task", ident: "await" }, [@27-29 Var { module_name: "", ident: "a" }, @23-48 Closure([@27-29 Identifier { ident: "#!a0" }], @23-48 LowLevelDbg(("test.roc:3", " "), @27-29 Apply(@27-29 Var { module_name: "Inspect", ident: "toStr" }, [@27-29 Var { module_name: "", ident: "#!a0" }], Space), @47-48 Var { module_name: "", ident: "b" }))], BangSuffix))] }"##, ) } diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_multiple_defs.moduledefs.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_multiple_defs.moduledefs.formatted.roc index 02f8af5c5b..3365e68d38 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_multiple_defs.moduledefs.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_multiple_defs.moduledefs.formatted.roc @@ -1,4 +1,5 @@ main = a! "Bar" x = B.b! "Foo" + c! x diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_multiple_defs.moduledefs.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_multiple_defs.moduledefs.result-ast index 8bf74738c2..5d86567e66 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_multiple_defs.moduledefs.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_multiple_defs.moduledefs.result-ast @@ -18,28 +18,24 @@ Defs { @0-4 Identifier { ident: "main", }, - @0-49 SpaceBefore( + @12-49 SpaceBefore( Defs( Defs { tags: [ Index(2147483648), Index(2147483649), - Index(2147483650), ], regions: [ @14-21, @26-39, - @45-49, ], space_before: [ Slice(start = 0, length = 0), Slice(start = 0, length = 1), - Slice(start = 1, length = 0), ], space_after: [ Slice(start = 0, length = 0), Slice(start = 1, length = 0), - Slice(start = 1, length = 0), ], spaces: [ Newline, @@ -85,32 +81,29 @@ Defs { Space, ), ), - Stmt( - @45-49 SpaceBefore( - Apply( - @45-46 TaskAwaitBang( - Var { - module_name: "", - ident: "c", - }, - ), - [ - @48-49 Var { - module_name: "", - ident: "x", - }, - ], - Space, - ), - [ - Newline, - Newline, - ], - ), - ), ], }, - EmptyDefsFinal, + @45-49 SpaceBefore( + Apply( + @45-46 TaskAwaitBang( + Var { + module_name: "", + ident: "c", + }, + ), + [ + @48-49 Var { + module_name: "", + ident: "x", + }, + ], + Space, + ), + [ + Newline, + Newline, + ], + ), ), [ Newline, diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_optional_last.full.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_optional_last.full.result-ast index d2807f1b20..21d5d8e515 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_optional_last.full.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/suffixed_optional_last.full.result-ast @@ -64,7 +64,7 @@ Full { @88-92 Identifier { ident: "main", }, - @88-202 SpaceBefore( + @100-202 SpaceBefore( BinOps( [ ( From 0faa1d5f20fe40c3f773546ce9dc6b883245c6c8 Mon Sep 17 00:00:00 2001 From: shua Date: Fri, 28 Jun 2024 15:20:29 +0200 Subject: [PATCH 37/42] test_gen: replace stdlib Json with inline implementation Towards the goal of removing Json from stdlib, this change replaces usage of TotallyNotJson in test_gen/gen_abilities with a simple usable inline implementation of Encoder/DecoderFormatting. Similarly, the use of TotallyNotJson in test_reporting is not necessary at all and is replaced with a Decoder that wouldn't actually work, but which does compile. --- Cargo.lock | 1 + crates/compiler/load/tests/test_reporting.rs | 48 +- crates/compiler/test_gen/Cargo.toml | 1 + crates/compiler/test_gen/src/gen_abilities.rs | 554 ++++++++++-------- .../uitest/tests/solve/stdlib_encode_json.txt | 18 - .../tests/solve/stdlib_encode_something.txt | 66 +++ crates/test_utils/src/TagLenEncoderFmt.roc | 261 +++++++++ crates/test_utils/src/lib.rs | 8 + 8 files changed, 679 insertions(+), 278 deletions(-) delete mode 100644 crates/compiler/uitest/tests/solve/stdlib_encode_json.txt create mode 100644 crates/compiler/uitest/tests/solve/stdlib_encode_something.txt create mode 100644 crates/test_utils/src/TagLenEncoderFmt.roc diff --git a/Cargo.lock b/Cargo.lock index 1877687dd5..3dc8cff8dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3846,6 +3846,7 @@ dependencies = [ "roc_solve", "roc_std", "roc_target", + "roc_test_utils", "roc_types", "roc_unify", "roc_wasm_interp", diff --git a/crates/compiler/load/tests/test_reporting.rs b/crates/compiler/load/tests/test_reporting.rs index 38f2788961..781f48eba4 100644 --- a/crates/compiler/load/tests/test_reporting.rs +++ b/crates/compiler/load/tests/test_reporting.rs @@ -11401,10 +11401,50 @@ In roc, functions are always written as a lambda, like{} r#" app "test" imports [] provides [main] to "./platform" - import TotallyNotJson + ErrDecoder := {} implements [DecoderFormatting { + u8: decodeU8, + u16: decodeU16, + u32: decodeU32, + u64: decodeU64, + u128: decodeU128, + i8: decodeI8, + i16: decodeI16, + i32: decodeI32, + i64: decodeI64, + i128: decodeI128, + f32: decodeF32, + f64: decodeF64, + dec: decodeDec, + bool: decodeBool, + string: decodeString, + list: decodeList, + record: decodeRecord, + tuple: decodeTuple, + }] + decodeU8 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeU16 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeU32 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeU64 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeU128 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeI8 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeI16 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeI32 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeI64 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeI128 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeF32 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeF64 = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeDec = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeBool = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeString = Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeList : Decoder elem (ErrDecoder) -> Decoder (List elem) (ErrDecoder) + decodeList = \_ -> Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeRecord : state, (state, Str -> [Keep (Decoder state (ErrDecoder)), Skip]), (state, (ErrDecoder) -> Result val DecodeError) -> Decoder val (ErrDecoder) + decodeRecord =\_, _, _ -> Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} + decodeTuple : state, (state, U64 -> [Next (Decoder state (ErrDecoder)), TooLong]), (state -> Result val DecodeError) -> Decoder val (ErrDecoder) + decodeTuple = \_, _, _ -> Decode.custom \rest, @ErrDecoder {} -> {result: Err TooShort, rest} main = - decoded = Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes TotallyNotJson.json + decoded = Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes (@ErrDecoder {}) when decoded is Ok rcd -> rcd.first rcd.second _ -> "something went wrong" @@ -11415,8 +11455,8 @@ In roc, functions are always written as a lambda, like{} This expression has a type that does not implement the abilities it's expected to: - 8│ Ok rcd -> rcd.first rcd.second - ^^^^^^^^^ + 48│ Ok rcd -> rcd.first rcd.second + ^^^^^^^^^ I can't generate an implementation of the `Decoding` ability for diff --git a/crates/compiler/test_gen/Cargo.toml b/crates/compiler/test_gen/Cargo.toml index cc323c814b..d2262ec59c 100644 --- a/crates/compiler/test_gen/Cargo.toml +++ b/crates/compiler/test_gen/Cargo.toml @@ -45,6 +45,7 @@ roc_reporting = { path = "../../reporting" } roc_solve = { path = "../solve" } roc_std = { path = "../../roc_std" } roc_target = { path = "../roc_target" } +roc_test_utils = { path = "../../test_utils"} roc_types = { path = "../types" } roc_unify = { path = "../unify" } roc_wasm_interp = { path = "../../wasm_interp" } diff --git a/crates/compiler/test_gen/src/gen_abilities.rs b/crates/compiler/test_gen/src/gen_abilities.rs index bf89a75d15..d8829ae0ad 100644 --- a/crates/compiler/test_gen/src/gen_abilities.rs +++ b/crates/compiler/test_gen/src/gen_abilities.rs @@ -5,13 +5,15 @@ use crate::helpers::llvm::assert_evals_to; use crate::helpers::wasm::assert_evals_to; #[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))] -use indoc::indoc; +use indoc::{formatdoc, indoc}; #[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))] use roc_std::RocList; #[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))] use roc_std::RocStr; +use roc_test_utils::TAG_LEN_ENCODER_FMT; + #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn hash_specialization() { @@ -352,26 +354,26 @@ fn decode() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_use_stdlib() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" - HelloWorld := {} implements [Encoding {toEncoder}] - toEncoder = \@HelloWorld {} -> + {TAG_LEN_ENCODER_FMT} + + HelloWorld := {{}} implements [Encoding {{toEncoder}}] + toEncoder = \@HelloWorld {{}} -> Encode.custom \bytes, fmt -> bytes |> Encode.appendWith (Encode.string "Hello, World!\n") fmt main = - result = Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes (@HelloWorld {{}}) tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from("\"Hello, World!\\n\""), + RocStr::from("s14 Hello, World!\n "), RocStr ) } @@ -380,23 +382,23 @@ fn encode_use_stdlib() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_use_stdlib_without_wrapping_custom() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" - HelloWorld := {} implements [Encoding {toEncoder}] - toEncoder = \@HelloWorld {} -> Encode.string "Hello, World!\n" + {TAG_LEN_ENCODER_FMT} + + HelloWorld := {{}} implements [Encoding {{toEncoder}}] + toEncoder = \@HelloWorld {{}} -> Encode.string "Hello, World!\n" main = - result = Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes (@HelloWorld {{}}) tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from("\"Hello, World!\\n\""), + RocStr::from("s14 Hello, World!\n "), RocStr ) } @@ -406,22 +408,22 @@ fn encode_use_stdlib_without_wrapping_custom() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derive_to_encoder_for_opaque() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" - HelloWorld := { a: Str } implements [Encoding] + {TAG_LEN_ENCODER_FMT} + + HelloWorld := {{ a: Str }} implements [Encoding] main = - result = Str.fromUtf8 (Encode.toBytes (@HelloWorld { a: "Hello, World!" }) TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes (@HelloWorld {{ a: "Hello, World!" }}) tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"{"a":"Hello, World!"}"#), + RocStr::from("r1 s1 a s13 Hello, World! "), RocStr ) } @@ -430,31 +432,33 @@ fn encode_derive_to_encoder_for_opaque() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn to_encoder_encode_custom_has_capture() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" - HelloWorld := Str implements [Encoding {toEncoder}] + {TAG_LEN_ENCODER_FMT} + + HelloWorld := Str implements [Encoding {{toEncoder}}] toEncoder = \@HelloWorld s1 -> Encode.custom \bytes, fmt -> bytes |> Encode.appendWith (Encode.string s1) fmt main = - result = Str.fromUtf8 (Encode.toBytes (@HelloWorld "Hello, World!\n") TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes (@HelloWorld "Hello, World!\n") tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from("\"Hello, World!\\n\""), + RocStr::from("s14 Hello, World!\n "), RocStr ) } mod encode_immediate { + use super::TAG_LEN_ENCODER_FMT; + #[cfg(feature = "gen-llvm")] use crate::helpers::llvm::assert_evals_to; @@ -462,7 +466,7 @@ mod encode_immediate { use crate::helpers::wasm::assert_evals_to; #[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))] - use indoc::indoc; + use indoc::formatdoc; #[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))] use roc_std::RocStr; @@ -471,17 +475,19 @@ mod encode_immediate { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn string() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.fromUtf8 (Encode.toBytes "foo" TotallyNotJson.json) is + when Str.fromUtf8 (Encode.toBytes "foo" tagLenFmt) is Ok s -> s _ -> "" "# ), - RocStr::from("\"foo\""), + RocStr::from("s3 foo "), RocStr ) } @@ -490,17 +496,19 @@ mod encode_immediate { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn ranged_number() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.fromUtf8 (Encode.toBytes [1, 2, 3] TotallyNotJson.json) is + when Str.fromUtf8 (Encode.toBytes [1, 2, 3] tagLenFmt) is Ok s -> s _ -> "" "# ), - RocStr::from(r"[1,2,3]"), + RocStr::from("l3 n1 n2 n3 "), RocStr ) } @@ -509,17 +517,19 @@ mod encode_immediate { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn bool() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.fromUtf8 (Encode.toBytes Bool.false TotallyNotJson.json) is + when Str.fromUtf8 (Encode.toBytes Bool.false tagLenFmt) is Ok s -> s _ -> "" "# ), - RocStr::from(r"false"), + RocStr::from(r"n0 "), RocStr ) } @@ -530,17 +540,18 @@ mod encode_immediate { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn $typ() { assert_evals_to!( - &format!(indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.fromUtf8 (Encode.toBytes {}{} TotallyNotJson.json) is + when Str.fromUtf8 (Encode.toBytes {}{} tagLenFmt) is Ok s -> s _ -> "" - "# - ), $num, stringify!($typ)), - RocStr::from(format!(r"{}", $num).as_str()), + "#, $num, stringify!($typ)), + RocStr::from(format!(r"n{} ", $num).as_str()), RocStr ) } @@ -569,20 +580,20 @@ mod encode_immediate { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_record_one_field_string() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - result = Str.fromUtf8 (Encode.toBytes {a: "foo"} TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes {{a: "foo"}} tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"{"a":"foo"}"#), + RocStr::from("r1 s1 a s3 foo "), RocStr ) } @@ -592,21 +603,21 @@ fn encode_derived_record_one_field_string() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_record_two_fields_strings() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - rcd = {a: "foo", b: "bar"} - result = Str.fromUtf8 (Encode.toBytes rcd TotallyNotJson.json) + rcd = {{a: "foo", b: "bar"}} + result = Str.fromUtf8 (Encode.toBytes rcd tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"{"a":"foo","b":"bar"}"#), + RocStr::from("r2 s1 a s3 foo s1 b s3 bar "), RocStr ) } @@ -616,22 +627,22 @@ fn encode_derived_record_two_fields_strings() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_nested_record_string() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - rcd = {a: {b: "bar"}} - encoded = Encode.toBytes rcd TotallyNotJson.json + rcd = {{a: {{b: "bar"}}}} + encoded = Encode.toBytes rcd tagLenFmt result = Str.fromUtf8 encoded when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"{"a":{"b":"bar"}}"#), + RocStr::from("r1 s1 a r1 s1 b s3 bar "), RocStr ) } @@ -640,21 +651,21 @@ fn encode_derived_nested_record_string() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_tag_one_payload_string() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = x = A "foo" - result = Str.fromUtf8 (Encode.toBytes x TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes x tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"{"A":["foo"]}"#), + RocStr::from("l2 s1 A s3 foo "), RocStr ) } @@ -663,21 +674,21 @@ fn encode_derived_tag_one_payload_string() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_tag_two_payloads_string() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = x = A "foo" "bar" - result = Str.fromUtf8 (Encode.toBytes x TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes x tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"{"A":["foo","bar"]}"#), + RocStr::from("l3 s1 A s3 foo s3 bar "), RocStr ) } @@ -686,22 +697,22 @@ fn encode_derived_tag_two_payloads_string() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_nested_tag_string() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = x = A (B "foo" "bar") - encoded = Encode.toBytes x TotallyNotJson.json + encoded = Encode.toBytes x tagLenFmt result = Str.fromUtf8 encoded when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"{"A":[{"B":["foo","bar"]}]}"#), + RocStr::from("l2 s1 A l3 s1 B s3 foo s3 bar "), RocStr ) } @@ -711,22 +722,22 @@ fn encode_derived_nested_tag_string() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_nested_record_tag_record() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - x = {a: (B ({c: "foo"}))} - encoded = Encode.toBytes x TotallyNotJson.json + x = {{a: (B ({{c: "foo"}}))}} + encoded = Encode.toBytes x tagLenFmt result = Str.fromUtf8 encoded when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"{"a":{"B":[{"c":"foo"}]}}"#), + RocStr::from("r1 s1 a l2 s1 B r1 s1 c s3 foo "), RocStr ) } @@ -735,22 +746,22 @@ fn encode_derived_nested_record_tag_record() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_list_string() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = lst = ["foo", "bar", "baz"] - encoded = Encode.toBytes lst TotallyNotJson.json + encoded = Encode.toBytes lst tagLenFmt result = Str.fromUtf8 encoded when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"["foo","bar","baz"]"#), + RocStr::from("l3 s3 foo s3 bar s3 baz "), RocStr ) } @@ -760,22 +771,22 @@ fn encode_derived_list_string() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_list_of_records() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - lst = [{a: "foo"}, {a: "bar"}, {a: "baz"}] - encoded = Encode.toBytes lst TotallyNotJson.json + lst = [{{a: "foo"}}, {{a: "bar"}}, {{a: "baz"}}] + encoded = Encode.toBytes lst tagLenFmt result = Str.fromUtf8 encoded when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"[{"a":"foo"},{"a":"bar"},{"a":"baz"}]"#), + RocStr::from("l3 r1 s1 a s3 foo r1 s1 a s3 bar r1 s1 a s3 baz "), RocStr ) } @@ -784,22 +795,22 @@ fn encode_derived_list_of_records() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_list_of_lists_of_strings() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = lst = [["a", "b"], ["c", "d", "e"], ["f"]] - encoded = Encode.toBytes lst TotallyNotJson.json + encoded = Encode.toBytes lst tagLenFmt result = Str.fromUtf8 encoded when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"[["a","b"],["c","d","e"],["f"]]"#), + RocStr::from("l3 l2 s1 a s1 b l3 s1 c s1 d s1 e l1 s1 f "), RocStr ) } @@ -809,24 +820,24 @@ fn encode_derived_list_of_lists_of_strings() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_record_with_many_types() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = fresh : [Fresh Str, Rotten Str] fresh = Fresh "tomatoes" - rcd = {actors: ["Idris Elba", "Mila Kunis"], year: 2004u16, rating: {average: 7u8, min: 1u8, max: 10u8, sentiment: fresh}} - result = Str.fromUtf8 (Encode.toBytes rcd TotallyNotJson.json) + rcd = {{actors: ["Idris Elba", "Mila Kunis"], year: 2004u16, rating: {{average: 7u8, min: 1u8, max: 10u8, sentiment: fresh}}}} + result = Str.fromUtf8 (Encode.toBytes rcd tagLenFmt) when result is Ok s -> s _ -> "" "# ), RocStr::from( - r#"{"actors":["Idris Elba","Mila Kunis"],"rating":{"average":7,"max":10,"min":1,"sentiment":{"Fresh":["tomatoes"]}},"year":2004}"# + "r3 s6 actors l2 s10 Idris Elba s10 Mila Kunis s6 rating r4 s7 average n7 s3 max n10 s3 min n1 s9 sentiment l2 s5 Fresh s8 tomatoes s4 year n2004 " ), RocStr ) @@ -836,21 +847,21 @@ fn encode_derived_record_with_many_types() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_tuple_two_fields() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = tup = ("foo", 10u8) - result = Str.fromUtf8 (Encode.toBytes tup TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes tup tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"["foo",10]"#), + RocStr::from("l2 s3 foo n10 "), RocStr ) } @@ -859,21 +870,21 @@ fn encode_derived_tuple_two_fields() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_tuple_of_tuples() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = tup = ( ("foo", 10u8), (23u8, "bar", 15u8) ) - result = Str.fromUtf8 (Encode.toBytes tup TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes tup tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"[["foo",10],[23,"bar",15]]"#), + RocStr::from("l2 l2 s3 foo n10 l3 n23 s3 bar n15 "), RocStr ) } @@ -883,24 +894,24 @@ fn encode_derived_tuple_of_tuples() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_generic_record_with_different_field_types() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" - Q a b := {a: a, b: b} implements [Encoding] + {TAG_LEN_ENCODER_FMT} - q = @Q {a: 10u32, b: "fieldb"} + Q a b := {{a: a, b: b}} implements [Encoding] + + q = @Q {{a: 10u32, b: "fieldb"}} main = - result = Str.fromUtf8 (Encode.toBytes q TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes q tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"{"a":10,"b":"fieldb"}"#), + RocStr::from("r2 s1 a n10 s1 b s6 fieldb "), RocStr ) } @@ -909,11 +920,11 @@ fn encode_derived_generic_record_with_different_field_types() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn encode_derived_generic_tag_with_different_field_types() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} Q a b := [A a, B b] implements [Encoding] @@ -921,13 +932,13 @@ fn encode_derived_generic_tag_with_different_field_types() { q = @Q (B 67) main = - result = Str.fromUtf8 (Encode.toBytes q TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes q tagLenFmt) when result is Ok s -> s _ -> "" "# ), - RocStr::from(r#"{"B":[67]}"#), + RocStr::from("l2 s1 B n67 "), RocStr ) } @@ -937,21 +948,21 @@ fn encode_derived_generic_tag_with_different_field_types() { fn specialize_unique_newtype_records() { crate::helpers::with_larger_debug_stack(|| { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" - main = - when Str.fromUtf8 (Encode.toBytes {a: Bool.true} TotallyNotJson.json) is - Ok s -> when Str.fromUtf8 (Encode.toBytes {b: Bool.true} TotallyNotJson.json) is - Ok t -> "$(s)$(t)" + {TAG_LEN_ENCODER_FMT} + + main = + when Str.fromUtf8 (Encode.toBytes {{a: Bool.true}} tagLenFmt) is + Ok s -> when Str.fromUtf8 (Encode.toBytes {{b: Bool.true}} tagLenFmt) is + Ok t -> "$(s)$(t)" + _ -> "" _ -> "" - _ -> "" - "# + "# ), - RocStr::from(r#"{"a":true}{"b":true}"#), + RocStr::from("r1 s1 a n1 r1 s1 b n1 "), RocStr ) }); @@ -961,24 +972,24 @@ fn specialize_unique_newtype_records() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn decode_use_stdlib() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" - MyNum := U8 implements [Decoding {decoder: myDecoder}] + {TAG_LEN_ENCODER_FMT} + + MyNum := U8 implements [Decoding {{decoder: myDecoder}}] myDecoder = Decode.custom \bytes, fmt -> when Decode.decodeWith bytes Decode.u8 fmt is - {result, rest} -> + {{result, rest}} -> when result is - Ok n -> {result: Ok (@MyNum n), rest} - Err e -> {result: Err e, rest} + Ok n -> {{result: Ok (@MyNum n), rest}} + Err e -> {{result: Err e, rest}} main = - when Decode.fromBytes [49, 53] TotallyNotJson.json is + when Decode.fromBytes [110, 49, 53, 32] tagLenFmt is Ok (@MyNum n) -> n _ -> 101 "# @@ -995,17 +1006,17 @@ fn decode_use_stdlib() { ))] fn decode_derive_decoder_for_opaque() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" - HelloWorld := { a: Str } implements [Decoding] + {TAG_LEN_ENCODER_FMT} + + HelloWorld := {{ a: Str }} implements [Decoding] main = - when Str.toUtf8 """{"a":"Hello, World!"}""" |> Decode.fromBytes TotallyNotJson.json is - Ok (@HelloWorld {a}) -> a + when Str.toUtf8 "r1 s1 a s13 Hello, World! " |> Decode.fromBytes tagLenFmt is + Ok (@HelloWorld {{a}}) -> a _ -> "FAIL" "# ), @@ -1013,29 +1024,26 @@ fn decode_derive_decoder_for_opaque() { RocStr ) } - #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -fn decode_use_stdlib_json_list() { +fn decode_use_stdlib_custom_list() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" - MyNumList := List U8 implements [Decoding {decoder: myDecoder}] + {TAG_LEN_ENCODER_FMT} + MyNumList := List U8 implements [Decoding {{decoder: myDecoder}}] myDecoder = Decode.custom \bytes, fmt -> when Decode.decodeWith bytes (Decode.list Decode.u8) fmt is - {result, rest} -> + {{result, rest}} -> when result is - Ok lst -> {result: Ok (@MyNumList lst), rest} - Err e -> {result: Err e, rest} - + Ok lst -> {{result: Ok (@MyNumList lst), rest}} + Err e -> {{result: Err e, rest}} main = - when Str.toUtf8 "[1,2,3]" |> Decode.fromBytes TotallyNotJson.json is + when Str.toUtf8 "l3 n1 n2 n3 " |> Decode.fromBytes tagLenFmt is Ok (@MyNumList lst) -> lst _ -> [] "# @@ -1046,6 +1054,8 @@ fn decode_use_stdlib_json_list() { } mod decode_immediate { + use super::TAG_LEN_ENCODER_FMT; + #[cfg(feature = "gen-llvm")] use crate::helpers::llvm::assert_evals_to; @@ -1053,7 +1063,7 @@ mod decode_immediate { use crate::helpers::wasm::assert_evals_to; #[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))] - use indoc::indoc; + use indoc::formatdoc; #[cfg(all(test, feature = "gen-llvm"))] use roc_std::{RocStr, I128, U128}; @@ -1063,12 +1073,14 @@ mod decode_immediate { fn string() { crate::helpers::with_larger_debug_stack(|| { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.toUtf8 "\"foo\"" |> Decode.fromBytes TotallyNotJson.json is + when Str.toUtf8 "s3 foo " |> Decode.fromBytes tagLenFmt is Ok s -> s _ -> "" "# @@ -1083,15 +1095,17 @@ mod decode_immediate { #[cfg(feature = "gen-llvm")] fn ranged_number() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - input = Str.toUtf8 "[1,2,3]" + input = Str.toUtf8 "l3 n1 n2 n3 " expected = [1,2,3] - actual = Decode.fromBytes input TotallyNotJson.json |> Result.withDefault [] + actual = Decode.fromBytes input tagLenFmt |> Result.withDefault [] actual == expected "# @@ -1105,12 +1119,14 @@ mod decode_immediate { #[cfg(feature = "gen-llvm")] fn bool() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.toUtf8 "false" |> Decode.fromBytes TotallyNotJson.json is + when Str.toUtf8 "n0 " |> Decode.fromBytes tagLenFmt is Ok s -> s _ -> Bool.true "# @@ -1126,16 +1142,18 @@ mod decode_immediate { #[cfg(feature = "gen-llvm")] fn $typ() { assert_evals_to!( - &format!(indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Num.toStr {}{} |> Str.toUtf8 |> Decode.fromBytes TotallyNotJson.json is + when Str.toUtf8 "n{} " |> Decode.fromBytes tagLenFmt is Ok n -> n _ -> 101{} - "# - ), $num, stringify!($typ), stringify!($typ)), + "#, + $num, stringify!($typ)), $num, $expected_type ) @@ -1164,12 +1182,14 @@ mod decode_immediate { use roc_std::RocDec; assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Num.toStr 17.23dec |> Str.toUtf8 |> Decode.fromBytes TotallyNotJson.json is + when Str.toUtf8 "n17.23 " |> Decode.fromBytes tagLenFmt is Ok n -> n _ -> 101dec "# @@ -1185,12 +1205,14 @@ mod decode_immediate { fn decode_list_of_strings() { crate::helpers::with_larger_debug_stack(|| { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.toUtf8 "[\"a\",\"b\",\"c\"]" |> Decode.fromBytes TotallyNotJson.json is + when Str.toUtf8 "l3 s1 a s1 b s1 c " |> Decode.fromBytes tagLenFmt is Ok l -> Str.joinWith l "," _ -> "" "# @@ -1206,12 +1228,14 @@ fn decode_list_of_strings() { fn encode_then_decode_list_of_strings() { crate::helpers::with_larger_debug_stack(|| { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Encode.toBytes ["a", "b", "c"] TotallyNotJson.json |> Decode.fromBytes TotallyNotJson.json is + when Encode.toBytes ["a", "b", "c"] tagLenFmt |> Decode.fromBytes tagLenFmt is Ok l -> Str.joinWith l "," _ -> "something went wrong" "# @@ -1224,17 +1248,18 @@ fn encode_then_decode_list_of_strings() { #[test] #[cfg(feature = "gen-llvm")] -#[ignore = "#3696: Currently hits some weird panic in borrow checking, not sure if it's directly related to abilities."] fn encode_then_decode_list_of_lists_of_strings() { crate::helpers::with_larger_debug_stack(|| { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Encode.toBytes [["a", "b"], ["c", "d", "e"], ["f"]] TotallyNotJson.json |> Decode.fromBytes TotallyNotJson.json is - Ok list -> (List.map list \inner -> Str.joinWith inner ",") |> Str.joinWith l ";" + when Encode.toBytes [["a", "b"], ["c", "d", "e"], ["f"]] tagLenFmt |> Decode.fromBytes tagLenFmt is + Ok list -> (List.map list \inner -> Str.joinWith inner ",") |> Str.joinWith ";" _ -> "something went wrong" "# ), @@ -1251,13 +1276,15 @@ fn encode_then_decode_list_of_lists_of_strings() { ))] fn decode_record_two_fields() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes TotallyNotJson.json is - Ok {first: "ab", second: "cd"} -> "abcd" + when Str.toUtf8 "r2 s6 second s2 cd s5 first s2 ab " |> Decode.fromBytes tagLenFmt is + Ok {{first: "ab", second: "cd"}} -> "abcd" _ -> "something went wrong" "# ), @@ -1273,13 +1300,15 @@ fn decode_record_two_fields() { ))] fn decode_record_two_fields_string_and_int() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.toUtf8 "{\"first\":\"ab\",\"second\":10}" |> Decode.fromBytes TotallyNotJson.json is - Ok {first: "ab", second: 10u8} -> "ab10" + when Str.toUtf8 "r2 s5 first s2 ab s6 second n10 " |> Decode.fromBytes tagLenFmt is + Ok {{first: "ab", second: 10u8}} -> "ab10" _ -> "something went wrong" "# ), @@ -1295,13 +1324,15 @@ fn decode_record_two_fields_string_and_int() { ))] fn decode_record_two_fields_string_and_string_infer() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes TotallyNotJson.json is - Ok {first, second} -> Str.concat first second + when Str.toUtf8 "r2 s5 first s2 ab s6 second s2 cd " |> Decode.fromBytes tagLenFmt is + Ok {{first, second}} -> Str.concat first second _ -> "something went wrong" "# ), @@ -1317,12 +1348,14 @@ fn decode_record_two_fields_string_and_string_infer() { ))] fn decode_record_two_fields_string_and_string_infer_local_var() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - decoded = Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes TotallyNotJson.json + decoded = Str.toUtf8 "r2 s5 first s2 ab s6 second s2 cd " |> Decode.fromBytes tagLenFmt when decoded is Ok rcd -> Str.concat rcd.first rcd.second _ -> "something went wrong" @@ -1340,14 +1373,16 @@ fn decode_record_two_fields_string_and_string_infer_local_var() { ))] fn decode_record_two_fields_string_and_string_infer_local_var_destructured() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - decoded = Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes TotallyNotJson.json + decoded = Str.toUtf8 "r2 s5 first s2 ab s6 second s2 cd " |> Decode.fromBytes tagLenFmt when decoded is - Ok {first, second} -> Str.concat first second + Ok {{first, second}} -> Str.concat first second _ -> "something went wrong" "# ), @@ -1358,16 +1393,17 @@ fn decode_record_two_fields_string_and_string_infer_local_var_destructured() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[ignore = "json parsing impl must be fixed first"] fn decode_empty_record() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.toUtf8 "{}" |> Decode.fromBytes TotallyNotJson.json is - Ok {} -> "empty" + when Str.toUtf8 "r0 " |> Decode.fromBytes tagLenFmt is + Ok {{}} -> "empty" _ -> "something went wrong" "# ), @@ -1384,13 +1420,15 @@ fn decode_empty_record() { ))] fn decode_record_of_record() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.toUtf8 "{\"outer\":{\"inner\":\"a\"},\"other\":{\"one\":\"b\",\"two\":10}}" |> Decode.fromBytes TotallyNotJson.json is - Ok {outer: {inner: "a"}, other: {one: "b", two: 10u8}} -> "ab10" + when Str.toUtf8 "r2 s5 other r2 s3 one s1 b s3 two n10 s5 outer r1 s5 inner s1 a " |> Decode.fromBytes tagLenFmt is + Ok {{outer: {{inner: "a"}}, other: {{one: "b", two: 10u8}}}} -> "ab10" _ -> "something went wrong" "# ), @@ -1406,12 +1444,14 @@ fn decode_record_of_record() { ))] fn decode_tuple_two_elements() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.toUtf8 "[\"ab\",10]" |> Decode.fromBytes TotallyNotJson.json is + when Str.toUtf8 "l2 s2 ab n10 " |> Decode.fromBytes tagLenFmt is Ok ("ab", 10u8) -> "abcd" _ -> "something went wrong" "# @@ -1428,12 +1468,14 @@ fn decode_tuple_two_elements() { ))] fn decode_tuple_of_tuples() { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} main = - when Str.toUtf8 "[[\"ab\",10],[\"cd\",25]]" |> Decode.fromBytes TotallyNotJson.json is + when Str.toUtf8 "l2 l2 s2 ab n10 l2 s2 cd n25 " |> Decode.fromBytes tagLenFmt is Ok ( ("ab", 10u8), ("cd", 25u8) ) -> "abcd" _ -> "something went wrong" "# @@ -2147,20 +2189,20 @@ mod eq { fn issue_4772_weakened_monomorphic_destructure() { crate::helpers::with_larger_debug_stack(|| { assert_evals_to!( - indoc!( + &formatdoc!( r#" - app "test" - imports [TotallyNotJson] - provides [main] to "./platform" + app "test" provides [main] to "./platform" + + {TAG_LEN_ENCODER_FMT} getNumber = - { result, rest } = Decode.fromBytesPartial (Str.toUtf8 "\"1234\"") TotallyNotJson.json + {{ result, rest }} = Decode.fromBytesPartial (Str.toUtf8 "s4 1234 ") tagLenFmt when result is Ok val -> when Str.toI64 val is Ok number -> - Ok {val : number, input : rest} + Ok {{ val : number, input : rest }} Err InvalidNumStr -> Err (ParsingFailure "not a number") diff --git a/crates/compiler/uitest/tests/solve/stdlib_encode_json.txt b/crates/compiler/uitest/tests/solve/stdlib_encode_json.txt deleted file mode 100644 index c799d0bc99..0000000000 --- a/crates/compiler/uitest/tests/solve/stdlib_encode_json.txt +++ /dev/null @@ -1,18 +0,0 @@ -app "test" - imports [TotallyNotJson] - provides [main] to "./platform" - -HelloWorld := {} implements [Encoding {toEncoder}] - -toEncoder = \@HelloWorld {} -> - Encode.custom \bytes, fmt -> - bytes - |> Encode.appendWith (Encode.string "Hello, World!\n") fmt - -f = - when Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) TotallyNotJson.json) is - Ok s -> s - _ -> "" - -main = f -# ^ Str diff --git a/crates/compiler/uitest/tests/solve/stdlib_encode_something.txt b/crates/compiler/uitest/tests/solve/stdlib_encode_something.txt new file mode 100644 index 0000000000..14632e2c21 --- /dev/null +++ b/crates/compiler/uitest/tests/solve/stdlib_encode_something.txt @@ -0,0 +1,66 @@ +app "test" + imports [] + provides [main] to "./platform" + +OnlyStrEncoder := {} implements [Encode.EncoderFormatting { + u8: encodeU8, + u16: encodeU16, + u32: encodeU32, + u64: encodeU64, + u128: encodeU128, + i8: encodeI8, + i16: encodeI16, + i32: encodeI32, + i64: encodeI64, + i128: encodeI128, + f32: encodeF32, + f64: encodeF64, + dec: encodeDec, + bool: encodeBool, + string: encodeString, + list: encodeList, + record: encodeRecord, + tuple: encodeTuple, + tag: encodeTag, +}] + +encodeNothing = Encode.custom \bytes, @OnlyStrEncoder {} -> bytes +encodeU8 = \_n -> encodeNothing +encodeU16 = \_n -> encodeNothing +encodeU32 = \_n -> encodeNothing +encodeU64 = \_n -> encodeNothing +encodeU128 = \_n -> encodeNothing +encodeI8 = \_n -> encodeNothing +encodeI16 = \_n -> encodeNothing +encodeI32 = \_n -> encodeNothing +encodeI64 = \_n -> encodeNothing +encodeI128 = \_n -> encodeNothing +encodeF32 = \_n -> encodeNothing +encodeF64 = \_n -> encodeNothing +encodeDec = \_n -> encodeNothing +encodeBool = \_b -> encodeNothing +encodeString = \str -> Encode.custom \bytes, @OnlyStrEncoder {} -> List.concat bytes (Str.toUtf8 str) +encodeList : List elem, (elem -> Encoder OnlyStrEncoder) -> Encoder OnlyStrEncoder +encodeList = \_lst, _encodeElem -> encodeNothing +encodeRecord : List {key: Str, value: Encoder OnlyStrEncoder} -> Encoder OnlyStrEncoder +encodeRecord = \_fields -> encodeNothing +encodeTuple : List (Encoder OnlyStrEncoder) -> Encoder OnlyStrEncoder +encodeTuple = \_elems -> encodeNothing +encodeTag : Str, List (Encoder OnlyStrEncoder) -> Encoder OnlyStrEncoder +encodeTag = \_name, _payload -> encodeNothing + + +HelloWorld := {} implements [Encoding {toEncoder}] + +toEncoder = \@HelloWorld {} -> + Encode.custom \bytes, fmt -> + bytes + |> Encode.appendWith (Encode.string "Hello, World!\n") fmt + +f = + when Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) (@OnlyStrEncoder {})) is + Ok s -> s + _ -> "" + +main = f +# ^ Str diff --git a/crates/test_utils/src/TagLenEncoderFmt.roc b/crates/test_utils/src/TagLenEncoderFmt.roc new file mode 100644 index 0000000000..a86595fa1d --- /dev/null +++ b/crates/test_utils/src/TagLenEncoderFmt.roc @@ -0,0 +1,261 @@ +# a simple encoder/decoder format +# +# HACK: since this file is inlined into test code, it can't be a proper module +# +# the original author found it useful to leave this header here as a comment, to +# make it easy to switch back and forth between editing it as a proper roc module +# (so things like language server and `roc test` work), and inlining it into test +# code. +# +# module [ +# TagLenFmt, +# tagLenFmt, +# ] + +TagLenFmt := {} + implements [ + EncoderFormatting { + u8: encodeU8, + u16: encodeU16, + u32: encodeU32, + u64: encodeU64, + u128: encodeU128, + i8: encodeI8, + i16: encodeI16, + i32: encodeI32, + i64: encodeI64, + i128: encodeI128, + f32: encodeF32, + f64: encodeF64, + dec: encodeDec, + bool: encodeBool, + string: encodeString, + list: encodeList, + record: encodeRecord, + tuple: encodeTuple, + tag: encodeTag, + }, + DecoderFormatting { + u8: decodeU8, + u16: decodeU16, + u32: decodeU32, + u64: decodeU64, + u128: decodeU128, + i8: decodeI8, + i16: decodeI16, + i32: decodeI32, + i64: decodeI64, + i128: decodeI128, + f32: decodeF32, + f64: decodeF64, + dec: decodeDec, + bool: decodeBool, + string: decodeString, + list: decodeList, + record: decodeRecord, + tuple: decodeTuple, + }, + ] + +tagLenFmt = @TagLenFmt {} + +# ENCODE + +appendPreLen = \bytes, pre, len -> + List.append bytes (Num.toU8 pre) + |> List.concat (Num.toStr len |> Str.toUtf8) + |> List.append ' ' +encodeNum = \n -> Encode.custom \bytes, @TagLenFmt {} -> appendPreLen bytes 'n' n + +encodeU8 = encodeNum +encodeU16 = encodeNum +encodeU32 = encodeNum +encodeU64 = encodeNum +encodeU128 = encodeNum +encodeI8 = encodeNum +encodeI16 = encodeNum +encodeI32 = encodeNum +encodeI64 = encodeNum +encodeI128 = encodeNum +encodeF32 = encodeNum +encodeF64 = encodeNum +encodeDec = encodeNum +encodeBool = \b -> encodeU8 (if b then 1 else 0) + +expect + actual = Encode.toBytes 1 tagLenFmt + actual == (Str.toUtf8 "n1 ") +expect + actual = Encode.toBytes 1.3dec tagLenFmt + actual == (Str.toUtf8 "n1.3 ") +expect + actual = Encode.toBytes Bool.true tagLenFmt + actual == (Str.toUtf8 "n1 ") + +encodeString = \str -> Encode.custom \bytes, @TagLenFmt {} -> + appendPreLen bytes 's' (Str.countUtf8Bytes str) + |> List.concat (Str.toUtf8 str) + |> List.append ' ' + +expect + actual = Encode.toBytes "hey" tagLenFmt + actual == (Str.toUtf8 "s3 hey ") + +encodeList = \lst, encodeElem -> Encode.custom \bytes, @TagLenFmt {} -> + bytesPre = appendPreLen bytes 'l' (List.len lst) + List.walk lst bytesPre \buf, elem -> + Encode.appendWith buf (encodeElem elem) (@TagLenFmt {}) + +expect + actual = Encode.toBytes [1, 2, 3] tagLenFmt + actual == (Str.toUtf8 "l3 n1 n2 n3 ") + +encodeRecord = \fields -> Encode.custom \bytes, @TagLenFmt {} -> + bytesPre = + appendPreLen bytes 'r' (List.len fields) + List.walk fields bytesPre \buf, { key, value } -> + Encode.appendWith buf (encodeString key) (@TagLenFmt {}) + |> Encode.appendWith value (@TagLenFmt {}) + +expect + actual = Encode.toBytes { foo: "foo", bar: Bool.true } tagLenFmt + actual == Str.toUtf8 "r2 s3 bar n1 s3 foo s3 foo " + +encodeTuple = \elems -> encodeList elems (\e -> e) +encodeTag = \name, payload -> encodeTuple (List.prepend payload (encodeString name)) + +expect + actual = Encode.toBytes (1, "foo", {}) tagLenFmt + actual == (Str.toUtf8 "l3 n1 s3 foo r0 ") + +# DECODE + +splitAtSpace = \bytes -> + when List.splitFirst bytes ' ' is + Ok { before, after } -> { taken: before, rest: after } + Err _ -> { taken: [], rest: bytes } + +decodeNumPre = \bytes, pre, toNum -> + when List.split bytes 1 is + { before: [b], others } if b == pre -> + { taken, rest } = splitAtSpace others + str = taken |> Str.fromUtf8 |> Result.mapErr \_ -> TooShort + result = Result.try str \s -> (toNum s |> Result.mapErr \_ -> TooShort) + when result is + Ok _ -> { result, rest } + Err _ -> { result, rest: others } + + _ -> { result: Err TooShort, rest: bytes } + +decodeNum = \toNum -> Decode.custom \bytes, @TagLenFmt {} -> decodeNumPre bytes 'n' toNum + +decodeU8 = decodeNum Str.toU8 +decodeU16 = decodeNum Str.toU16 +decodeU32 = decodeNum Str.toU32 +decodeU64 = decodeNum Str.toU64 +decodeU128 = decodeNum Str.toU128 +decodeI8 = decodeNum Str.toI8 +decodeI16 = decodeNum Str.toI16 +decodeI32 = decodeNum Str.toI32 +decodeI64 = decodeNum Str.toI64 +decodeI128 = decodeNum Str.toI128 +decodeF32 = decodeNum Str.toF32 +decodeF64 = decodeNum Str.toF64 +decodeDec = decodeNum Str.toDec +decodeBool = Decode.custom \bytes, @TagLenFmt {} -> + { result: numResult, rest } = Decode.decodeWith bytes decodeU8 (@TagLenFmt {}) + when numResult is + Ok 1 -> { result: Ok Bool.true, rest } + Ok 0 -> { result: Ok Bool.false, rest } + _ -> { result: Err TooShort, rest: bytes } + +expect + actual = Decode.fromBytes (Str.toUtf8 "n1 ") tagLenFmt + actual == Ok (Num.toU8 1) +expect + actual = Decode.fromBytes (Str.toUtf8 "n1 ") tagLenFmt + actual == Ok Bool.true + +decodeLenPre = \bytes, pre -> decodeNumPre bytes pre Str.toU64 + +decodeTry = \{ result, rest }, map -> + when result is + Ok a -> map a rest + Err e -> { result: Err e, rest } + +decodeString = Decode.custom \bytes, @TagLenFmt {} -> + decodeLenPre bytes 's' + |> decodeTry \len, lenRest -> + { before, others } = List.split lenRest len + result = Str.fromUtf8 before |> Result.mapErr \_ -> TooShort + when List.split others 1 is + { before: [' '], others: rest } -> { result, rest } + _ -> { result: Err TooShort, rest: others } + +expect + actual = Decode.fromBytes (Str.toUtf8 "s3 foo ") tagLenFmt + actual == Ok "foo" + +repeatDecode : U8, List U8, state, (state -> Decode.Decoder state TagLenFmt) -> DecodeResult state +repeatDecode = \pre, bytes, state, stepState -> + run = \end, bs -> + List.range { start: At 0, end: Before end } + |> List.walk { result: Ok state, rest: bs } \res, _i -> + decodeTry res \s, rest -> + Decode.decodeWith rest (stepState s) (@TagLenFmt {}) + + decodeLenPre bytes pre |> decodeTry run + +decodeList = \elemDecoder -> Decode.custom \bytes, @TagLenFmt {} -> + step = \lst -> Decode.custom \sbytes, @TagLenFmt {} -> + Decode.decodeWith sbytes elemDecoder (@TagLenFmt {}) + |> Decode.mapResult \elem -> List.append lst elem + repeatDecode 'l' bytes [] step + +expect + actual = Decode.fromBytes (Str.toUtf8 "l3 n1 n2 n3 ") tagLenFmt + actual == Ok [1, 2, 3] + +decodeRecord = \initState, stepField, finalizer -> Decode.custom \bytes, @TagLenFmt {} -> + flattenFieldRes = \next, rest -> + when next is + Keep valueDecoder -> { result: Ok valueDecoder, rest } + Skip -> { result: Err TooShort, rest } + + step = \state -> Decode.custom \sbytes, @TagLenFmt {} -> + Decode.decodeWith sbytes decodeString (@TagLenFmt {}) + |> decodeTry \key, bs -> + flattenFieldRes (stepField state key) bs + |> decodeTry \valueDecoder, bs -> + Decode.decodeWith bs valueDecoder (@TagLenFmt {}) + + repeatDecode 'r' bytes initState step + |> decodeTry \state, rest -> { result: finalizer state (@TagLenFmt {}), rest } + +expect + actual = Decode.fromBytes (Str.toUtf8 "r2 s3 bar n1 s3 foo s3 foo ") tagLenFmt + actual == Ok ({ foo: "foo", bar: Bool.true }) + +decodeTuple = \initialState, stepElem, finalizer -> Decode.custom \bytes, @TagLenFmt {} -> + flattenFieldRes = \next, rest -> + when next is + Next dec -> { result: Ok dec, rest } + TooLong -> { result: Err TooShort, rest } + step = \{ state, i } -> Decode.custom \sbytes, @TagLenFmt {} -> + flattenFieldRes (stepElem state i) sbytes + |> decodeTry \dec, rest -> Decode.decodeWith rest dec (@TagLenFmt {}) + |> Decode.mapResult \s -> { state: s, i: i + 1 } + + repeatDecode 'l' bytes { state: initialState, i: 0 } step + |> decodeTry \s, rest -> { result: finalizer s.state, rest } + +expect + actual = Decode.fromBytes (Str.toUtf8 "l3 n1 s3 abc l1 n0 ") tagLenFmt + actual == Ok (1, "abc", [Bool.false]) + +expect + input = { foo: (1, "abc", [Bool.false, Bool.true]), bar: { baz: 0.32 } } + encoded = Encode.toBytes input tagLenFmt + decoded = Decode.fromBytes encoded tagLenFmt + decoded == Ok input + diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 85683f14c8..5540b7cf60 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -18,3 +18,11 @@ macro_rules! assert_multiline_str_eq { $crate::_pretty_assert_eq!($crate::DebugAsDisplay($a), $crate::DebugAsDisplay($b)) }; } + +/// a very simple implementation of En/DecoderFormatting to be embedded in roc source under test +/// +/// - numbers and bools are encoded as 'n' ' ' +/// - strings are encoded as 's' ' ' ' ' +/// - records are encoded as 'r' ' ' []* +/// - lists and tuples are encoded as 'l' ' ' []* +pub const TAG_LEN_ENCODER_FMT: &str = include_str!("TagLenEncoderFmt.roc"); From 67f555feea4caec63335df0cbc486acd2ede370e Mon Sep 17 00:00:00 2001 From: shua Date: Fri, 28 Jun 2024 15:27:05 +0200 Subject: [PATCH 38/42] test_mono, uitest: rm stdlib Json dependency use the same tag len fmt introduced in test_gen/gen_abilities tests --- Cargo.lock | 1 + crates/compiler/test_mono/Cargo.toml | 1 + .../encode_derived_nested_record_string.txt | 656 +++---------- ...encode_derived_record_one_field_string.txt | 521 +++-------- ...ncode_derived_record_two_field_strings.txt | 527 +++-------- .../generated/encode_derived_string.txt | 380 ++------ .../encode_derived_tag_one_field_string.txt | 517 +++-------- ...encode_derived_tag_two_payloads_string.txt | 521 +++-------- .../test_mono/generated/issue_4749.txt | 834 +---------------- ..._4772_weakened_monomorphic_destructure.txt | 864 ++---------------- ...not_duplicate_identical_concrete_types.txt | 567 +++--------- ...types_without_unification_of_unifiable.txt | 458 +++++----- crates/compiler/test_mono/src/tests.rs | 171 +++- 13 files changed, 1230 insertions(+), 4788 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3dc8cff8dd..da1fbdbf13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3871,6 +3871,7 @@ dependencies = [ "roc_packaging", "roc_reporting", "roc_target", + "roc_test_utils", "roc_tracing", "test_mono_macros", ] diff --git a/crates/compiler/test_mono/Cargo.toml b/crates/compiler/test_mono/Cargo.toml index 05de03ab18..07802ccab9 100644 --- a/crates/compiler/test_mono/Cargo.toml +++ b/crates/compiler/test_mono/Cargo.toml @@ -21,6 +21,7 @@ roc_mono = { path = "../mono" } roc_packaging = { path = "../../packaging" } roc_reporting = { path = "../../reporting" } roc_target = { path = "../roc_target" } +roc_test_utils = { path = "../../test_utils" } roc_tracing = { path = "../../tracing" } test_mono_macros = { path = "../test_mono_macros" } 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 d5c06b0321..5741a7127b 100644 --- a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt @@ -7,7 +7,7 @@ procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1): let #Derived_gen.8 : Str = CallByName #Derived.5 #Derived.1; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8}; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6]; - let #Derived_gen.4 : List {Str, Str} = CallByName TotallyNotJson.29 #Derived_gen.5; + let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5; let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4; ret #Derived_gen.3; @@ -17,17 +17,13 @@ procedure #Derived.5 (#Derived.6): procedure #Derived.7 (#Derived.8, #Derived.9, #Derived.6): let #Derived_gen.17 : Str = "b"; - let #Derived_gen.18 : Str = CallByName TotallyNotJson.25 #Derived.6; + let #Derived_gen.18 : Str = CallByName Test.19 #Derived.6; let #Derived_gen.16 : {Str, Str} = Struct {#Derived_gen.17, #Derived_gen.18}; let #Derived_gen.15 : List {Str, Str} = Array [#Derived_gen.16]; - let #Derived_gen.14 : List {Str, Str} = CallByName TotallyNotJson.29 #Derived_gen.15; + let #Derived_gen.14 : List {Str, Str} = CallByName Test.21 #Derived_gen.15; let #Derived_gen.13 : List U8 = CallByName Encode.24 #Derived.8 #Derived_gen.14 #Derived.9; ret #Derived_gen.13; -procedure Bool.11 (#Attr.2, #Attr.3): - let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.24; - procedure Encode.23 (Encode.98): ret Encode.98; @@ -48,20 +44,20 @@ procedure Encode.24 (Encode.99, Encode.107, Encode.101): ret Encode.111; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName TotallyNotJson.202 Encode.99 Encode.101 Encode.107; + let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107; ret Encode.113; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.115 : List U8 = CallByName #Derived.7 Encode.99 Encode.101 Encode.107; - ret Encode.115; + let Encode.116 : List U8 = CallByName #Derived.7 Encode.99 Encode.101 Encode.107; + ret Encode.116; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.117 : List U8 = CallByName TotallyNotJson.202 Encode.99 Encode.101 Encode.107; - ret Encode.117; + let Encode.119 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107; + ret Encode.119; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.120 : List U8 = CallByName TotallyNotJson.150 Encode.99 Encode.101 Encode.107; - ret Encode.120; + let Encode.124 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; + ret Encode.124; procedure Encode.26 (Encode.105, Encode.106): let Encode.109 : List U8 = Array []; @@ -69,229 +65,107 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.104 (List.488, List.489, List.490): - let List.687 : U64 = 0i64; - let List.688 : U64 = CallByName List.6 List.488; - let List.686 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.488 List.489 List.490 List.687 List.688; - ret List.686; +procedure List.18 (List.160, List.161, List.162): + let List.575 : U64 = 0i64; + let List.576 : U64 = CallByName List.6 List.160; + let List.574 : List U8 = CallByName List.92 List.160 List.161 List.162 List.575 List.576; + ret List.574; procedure List.18 (List.160, List.161, List.162): - let List.595 : U64 = 0i64; - let List.596 : U64 = CallByName List.6 List.160; - let List.594 : {List U8, U64} = CallByName List.92 List.160 List.161 List.162 List.595 List.596; - ret List.594; - -procedure List.18 (List.160, List.161, List.162): - let List.630 : U64 = 0i64; - let List.631 : U64 = CallByName List.6 List.160; - let List.629 : {List U8, U64} = CallByName List.92 List.160 List.161 List.162 List.630 List.631; - ret List.629; - -procedure List.18 (List.160, List.161, List.162): - let List.642 : U64 = 0i64; - let List.643 : U64 = CallByName List.6 List.160; - let List.641 : List U8 = CallByName List.92 List.160 List.161 List.162 List.642 List.643; - ret List.641; - -procedure List.26 (List.201, List.202, List.203): - let List.680 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.104 List.201 List.202 List.203; - let List.683 : U8 = 1i64; - let List.684 : U8 = GetTagId List.680; - let List.685 : Int1 = lowlevel Eq List.683 List.684; - if List.685 then - let List.204 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.680; - ret List.204; - else - let List.205 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.680; - ret List.205; + let List.601 : U64 = 0i64; + let List.602 : U64 = CallByName List.6 List.160; + let List.600 : List U8 = CallByName List.92 List.160 List.161 List.162 List.601 List.602; + ret List.600; procedure List.4 (List.124, List.125): - let List.628 : U64 = 1i64; - let List.627 : List U8 = CallByName List.70 List.124 List.628; - let List.626 : List U8 = CallByName List.71 List.627 List.125; - ret List.626; - -procedure List.49 (List.420, List.421): - let List.671 : U64 = StructAtIndex 1 List.421; - let List.672 : U64 = StructAtIndex 0 List.421; - let List.670 : List U8 = CallByName List.72 List.420 List.671 List.672; - ret List.670; - -procedure List.52 (List.435, List.436): - let List.437 : U64 = CallByName List.6 List.435; - joinpoint List.678 List.438: - let List.676 : U64 = 0i64; - let List.675 : {U64, U64} = Struct {List.438, List.676}; - inc List.435; - let List.439 : List U8 = CallByName List.49 List.435 List.675; - let List.674 : U64 = CallByName Num.75 List.437 List.438; - let List.669 : {U64, U64} = Struct {List.674, List.438}; - let List.440 : List U8 = CallByName List.49 List.435 List.669; - let List.668 : {List U8, List U8} = Struct {List.439, List.440}; - ret List.668; - in - let List.679 : Int1 = CallByName Num.24 List.437 List.436; - if List.679 then - jump List.678 List.436; - else - jump List.678 List.437; + let List.622 : U64 = 1i64; + let List.621 : List U8 = CallByName List.70 List.124 List.622; + let List.620 : List U8 = CallByName List.71 List.621 List.125; + ret List.620; procedure List.6 (#Attr.2): - let List.608 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.608; + let List.599 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.599; procedure List.6 (#Attr.2): - let List.663 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.663; - -procedure List.6 (#Attr.2): - let List.665 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.665; + let List.625 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.625; procedure List.66 (#Attr.2, #Attr.3): - let List.604 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.604; + let List.584 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.584; procedure List.66 (#Attr.2, #Attr.3): - let List.639 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.639; - -procedure List.66 (#Attr.2, #Attr.3): - let List.651 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.651; - -procedure List.68 (#Attr.2): - let List.667 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.667; + let List.610 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.610; procedure List.70 (#Attr.2, #Attr.3): - let List.613 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.613; + let List.616 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.616; procedure List.71 (#Attr.2, #Attr.3): - let List.611 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.611; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.673 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.673; + let List.614 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.614; procedure List.8 (#Attr.2, #Attr.3): - let List.662 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.662; + let List.624 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.624; -procedure List.80 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): - joinpoint List.689 List.491 List.492 List.493 List.494 List.495: - let List.691 : Int1 = CallByName Num.22 List.494 List.495; - if List.691 then - let List.700 : U8 = CallByName List.66 List.491 List.494; - let List.692 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.157 List.492 List.700; - let List.697 : U8 = 1i64; - let List.698 : U8 = GetTagId List.692; - let List.699 : Int1 = lowlevel Eq List.697 List.698; - if List.699 then - let List.496 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.692; - let List.695 : U64 = 1i64; - let List.694 : U64 = CallByName Num.51 List.494 List.695; - jump List.689 List.491 List.496 List.493 List.694 List.495; - else - dec List.491; - let List.497 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.692; - let List.696 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.497; - ret List.696; - else - dec List.491; - let List.690 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.492; - ret List.690; - in - jump List.689 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; - -procedure List.92 (#Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34, #Derived_gen.35): - joinpoint List.597 List.163 List.164 List.165 List.166 List.167: - let List.599 : Int1 = CallByName Num.22 List.166 List.167; - if List.599 then - let List.603 : {Str, Str} = CallByName List.66 List.163 List.166; - inc List.603; - let List.168 : {List U8, U64} = CallByName TotallyNotJson.204 List.164 List.603; - let List.602 : U64 = 1i64; - let List.601 : U64 = CallByName Num.51 List.166 List.602; - jump List.597 List.163 List.168 List.165 List.601 List.167; +procedure List.92 (#Derived_gen.32, #Derived_gen.33, #Derived_gen.34, #Derived_gen.35, #Derived_gen.36): + joinpoint List.603 List.163 List.164 List.165 List.166 List.167: + let List.605 : Int1 = CallByName Num.22 List.166 List.167; + if List.605 then + let List.609 : {Str, Str} = CallByName List.66 List.163 List.166; + inc List.609; + let List.168 : List U8 = CallByName Test.70 List.164 List.609; + let List.608 : U64 = 1i64; + let List.607 : U64 = CallByName Num.51 List.166 List.608; + jump List.603 List.163 List.168 List.165 List.607 List.167; else dec List.163; ret List.164; in - jump List.597 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35; + jump List.603 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35 #Derived_gen.36; -procedure List.92 (#Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40): - joinpoint List.632 List.163 List.164 List.165 List.166 List.167: - let List.634 : Int1 = CallByName Num.22 List.166 List.167; - if List.634 then - let List.638 : {Str, Str} = CallByName List.66 List.163 List.166; - inc List.638; - let List.168 : {List U8, U64} = CallByName TotallyNotJson.204 List.164 List.638; - let List.637 : U64 = 1i64; - let List.636 : U64 = CallByName Num.51 List.166 List.637; - jump List.632 List.163 List.168 List.165 List.636 List.167; +procedure List.92 (#Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40, #Derived_gen.41): + joinpoint List.577 List.163 List.164 List.165 List.166 List.167: + let List.579 : Int1 = CallByName Num.22 List.166 List.167; + if List.579 then + let List.583 : {Str, Str} = CallByName List.66 List.163 List.166; + inc List.583; + let List.168 : List U8 = CallByName Test.70 List.164 List.583; + let List.582 : U64 = 1i64; + let List.581 : U64 = CallByName Num.51 List.166 List.582; + jump List.577 List.163 List.168 List.165 List.581 List.167; else dec List.163; ret List.164; in - jump List.632 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40; - -procedure List.92 (#Derived_gen.47, #Derived_gen.48, #Derived_gen.49, #Derived_gen.50, #Derived_gen.51): - joinpoint List.644 List.163 List.164 List.165 List.166 List.167: - let List.646 : Int1 = CallByName Num.22 List.166 List.167; - if List.646 then - let List.650 : U8 = CallByName List.66 List.163 List.166; - let List.168 : List U8 = CallByName TotallyNotJson.183 List.164 List.650; - let List.649 : U64 = 1i64; - let List.648 : U64 = CallByName Num.51 List.166 List.649; - jump List.644 List.163 List.168 List.165 List.648 List.167; - else - dec List.163; - ret List.164; - in - jump List.644 #Derived_gen.47 #Derived_gen.48 #Derived_gen.49 #Derived_gen.50 #Derived_gen.51; + jump List.577 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41; procedure Num.127 (#Attr.2): - let Num.295 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.295; - -procedure Num.137 (#Attr.2, #Attr.3): - let Num.301 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; - ret Num.301; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.300 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.300; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.297 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.297; - -procedure Num.21 (#Attr.2, #Attr.3): - let Num.302 : U64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.302; + let Num.284 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.284; procedure Num.22 (#Attr.2, #Attr.3): - let Num.308 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.308; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.310 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.310; + let Num.286 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.286; procedure Num.51 (#Attr.2, #Attr.3): - let Num.305 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.305; + let Num.285 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.285; -procedure Num.75 (#Attr.2, #Attr.3): - let Num.309 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.309; +procedure Num.96 (#Attr.2): + let Num.283 : Str = lowlevel NumToStr #Attr.2; + ret Num.283; procedure Str.12 (#Attr.2): - let Str.242 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.242; + let Str.244 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.244; + +procedure Str.36 (#Attr.2): + let Str.245 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.245; procedure Str.43 (#Attr.2): let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; @@ -307,324 +181,96 @@ procedure Str.9 (Str.67): else let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.55 : Str = StructAtIndex 1 Str.68; - dec #Derived_gen.55; + let #Derived_gen.45 : Str = StructAtIndex 1 Str.68; + dec #Derived_gen.45; let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; ret Str.232; -procedure TotallyNotJson.150 (TotallyNotJson.151, TotallyNotJson.1060, TotallyNotJson.149): - let TotallyNotJson.1063 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.149; - let TotallyNotJson.1062 : List U8 = CallByName List.8 TotallyNotJson.151 TotallyNotJson.1063; - ret TotallyNotJson.1062; +procedure Test.19 (Test.55): + let Test.324 : Str = CallByName Encode.23 Test.55; + ret Test.324; -procedure TotallyNotJson.157 (TotallyNotJson.1111, TotallyNotJson.160): - let TotallyNotJson.158 : U64 = StructAtIndex 0 TotallyNotJson.1111; - let TotallyNotJson.159 : Int1 = StructAtIndex 1 TotallyNotJson.1111; - switch TotallyNotJson.160: - case 34: - let TotallyNotJson.1114 : Int1 = false; - let TotallyNotJson.1113 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1114}; - let TotallyNotJson.1112 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1113; - ret TotallyNotJson.1112; - - case 92: - let TotallyNotJson.1117 : Int1 = false; - let TotallyNotJson.1116 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1117}; - let TotallyNotJson.1115 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1116; - ret TotallyNotJson.1115; - - case 47: - let TotallyNotJson.1120 : Int1 = false; - let TotallyNotJson.1119 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1120}; - let TotallyNotJson.1118 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1119; - ret TotallyNotJson.1118; - - case 8: - let TotallyNotJson.1123 : Int1 = false; - let TotallyNotJson.1122 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1123}; - let TotallyNotJson.1121 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1122; - ret TotallyNotJson.1121; - - case 12: - let TotallyNotJson.1126 : Int1 = false; - let TotallyNotJson.1125 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1126}; - let TotallyNotJson.1124 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1125; - ret TotallyNotJson.1124; - - case 10: - let TotallyNotJson.1129 : Int1 = false; - let TotallyNotJson.1128 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1129}; - let TotallyNotJson.1127 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1128; - ret TotallyNotJson.1127; - - case 13: - let TotallyNotJson.1132 : Int1 = false; - let TotallyNotJson.1131 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1132}; - let TotallyNotJson.1130 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1131; - ret TotallyNotJson.1130; - - case 9: - let TotallyNotJson.1135 : Int1 = false; - let TotallyNotJson.1134 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1135}; - let TotallyNotJson.1133 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1134; - ret TotallyNotJson.1133; - - default: - let TotallyNotJson.1139 : U64 = 1i64; - let TotallyNotJson.1138 : U64 = CallByName Num.19 TotallyNotJson.158 TotallyNotJson.1139; - let TotallyNotJson.1137 : {U64, Int1} = Struct {TotallyNotJson.1138, TotallyNotJson.159}; - let TotallyNotJson.1136 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) TotallyNotJson.1137; - ret TotallyNotJson.1136; - +procedure Test.2 (): + let Test.257 : {} = Struct {}; + ret Test.257; -procedure TotallyNotJson.183 (TotallyNotJson.184, TotallyNotJson.185): - let TotallyNotJson.1082 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.185; - let TotallyNotJson.1081 : List U8 = CallByName List.8 TotallyNotJson.184 TotallyNotJson.1082; - ret TotallyNotJson.1081; +procedure Test.21 (Test.66): + let Test.260 : List {Str, Str} = CallByName Encode.23 Test.66; + ret Test.260; -procedure TotallyNotJson.202 (TotallyNotJson.203, TotallyNotJson.976, TotallyNotJson.201): - let TotallyNotJson.1016 : I64 = 123i64; - let TotallyNotJson.1015 : U8 = CallByName Num.127 TotallyNotJson.1016; - let TotallyNotJson.205 : List U8 = CallByName List.4 TotallyNotJson.203 TotallyNotJson.1015; - let TotallyNotJson.1014 : U64 = CallByName List.6 TotallyNotJson.201; - let TotallyNotJson.984 : {List U8, U64} = Struct {TotallyNotJson.205, TotallyNotJson.1014}; - let TotallyNotJson.985 : {} = Struct {}; - let TotallyNotJson.983 : {List U8, U64} = CallByName List.18 TotallyNotJson.201 TotallyNotJson.984 TotallyNotJson.985; - let TotallyNotJson.207 : List U8 = StructAtIndex 0 TotallyNotJson.983; - let TotallyNotJson.982 : I64 = 125i64; - let TotallyNotJson.981 : U8 = CallByName Num.127 TotallyNotJson.982; - let TotallyNotJson.980 : List U8 = CallByName List.4 TotallyNotJson.207 TotallyNotJson.981; - ret TotallyNotJson.980; +procedure Test.21 (Test.66): + let Test.292 : List {Str, Str} = CallByName Encode.23 Test.66; + ret Test.292; -procedure TotallyNotJson.202 (TotallyNotJson.203, TotallyNotJson.976, TotallyNotJson.201): - let TotallyNotJson.1057 : I64 = 123i64; - let TotallyNotJson.1056 : U8 = CallByName Num.127 TotallyNotJson.1057; - let TotallyNotJson.205 : List U8 = CallByName List.4 TotallyNotJson.203 TotallyNotJson.1056; - let TotallyNotJson.1055 : U64 = CallByName List.6 TotallyNotJson.201; - let TotallyNotJson.1025 : {List U8, U64} = Struct {TotallyNotJson.205, TotallyNotJson.1055}; - let TotallyNotJson.1026 : {} = Struct {}; - let TotallyNotJson.1024 : {List U8, U64} = CallByName List.18 TotallyNotJson.201 TotallyNotJson.1025 TotallyNotJson.1026; - let TotallyNotJson.207 : List U8 = StructAtIndex 0 TotallyNotJson.1024; - let TotallyNotJson.1023 : I64 = 125i64; - let TotallyNotJson.1022 : U8 = CallByName Num.127 TotallyNotJson.1023; - let TotallyNotJson.1021 : List U8 = CallByName List.4 TotallyNotJson.207 TotallyNotJson.1022; - ret TotallyNotJson.1021; +procedure Test.3 (Test.48, Test.49, Test.50): + let Test.321 : U8 = CallByName Num.127 Test.49; + let Test.318 : List U8 = CallByName List.4 Test.48 Test.321; + let Test.320 : Str = CallByName Num.96 Test.50; + let Test.319 : List U8 = CallByName Str.12 Test.320; + let Test.316 : List U8 = CallByName List.8 Test.318 Test.319; + let Test.317 : U8 = 32i64; + let Test.315 : List U8 = CallByName List.4 Test.316 Test.317; + ret Test.315; -procedure TotallyNotJson.204 (TotallyNotJson.978, TotallyNotJson.979): - let TotallyNotJson.210 : Str = StructAtIndex 0 TotallyNotJson.979; - let TotallyNotJson.211 : Str = StructAtIndex 1 TotallyNotJson.979; - let TotallyNotJson.208 : List U8 = StructAtIndex 0 TotallyNotJson.978; - let TotallyNotJson.209 : U64 = StructAtIndex 1 TotallyNotJson.978; - let TotallyNotJson.1011 : List U8 = Array []; - let TotallyNotJson.1012 : {} = CallByName TotallyNotJson.8; - let TotallyNotJson.212 : List U8 = CallByName Encode.24 TotallyNotJson.1011 TotallyNotJson.211 TotallyNotJson.1012; - let TotallyNotJson.1010 : List U8 = Array []; - let TotallyNotJson.1006 : Int1 = CallByName Bool.11 TotallyNotJson.212 TotallyNotJson.1010; - dec TotallyNotJson.1010; - if TotallyNotJson.1006 then - dec TotallyNotJson.210; - dec TotallyNotJson.212; - let TotallyNotJson.1009 : U64 = 1i64; - let TotallyNotJson.1008 : U64 = CallByName Num.20 TotallyNotJson.209 TotallyNotJson.1009; - let TotallyNotJson.1007 : {List U8, U64} = Struct {TotallyNotJson.208, TotallyNotJson.1008}; - ret TotallyNotJson.1007; - else - let TotallyNotJson.1005 : I64 = 34i64; - let TotallyNotJson.1004 : U8 = CallByName Num.127 TotallyNotJson.1005; - let TotallyNotJson.1002 : List U8 = CallByName List.4 TotallyNotJson.208 TotallyNotJson.1004; - let TotallyNotJson.1003 : List U8 = CallByName Str.12 TotallyNotJson.210; - let TotallyNotJson.999 : List U8 = CallByName List.8 TotallyNotJson.1002 TotallyNotJson.1003; - let TotallyNotJson.1001 : I64 = 34i64; - let TotallyNotJson.1000 : U8 = CallByName Num.127 TotallyNotJson.1001; - let TotallyNotJson.996 : List U8 = CallByName List.4 TotallyNotJson.999 TotallyNotJson.1000; - let TotallyNotJson.998 : I64 = 58i64; - let TotallyNotJson.997 : U8 = CallByName Num.127 TotallyNotJson.998; - let TotallyNotJson.995 : List U8 = CallByName List.4 TotallyNotJson.996 TotallyNotJson.997; - let TotallyNotJson.214 : List U8 = CallByName List.8 TotallyNotJson.995 TotallyNotJson.212; - joinpoint TotallyNotJson.990 TotallyNotJson.215: - let TotallyNotJson.988 : U64 = 1i64; - let TotallyNotJson.987 : U64 = CallByName Num.20 TotallyNotJson.209 TotallyNotJson.988; - let TotallyNotJson.986 : {List U8, U64} = Struct {TotallyNotJson.215, TotallyNotJson.987}; - ret TotallyNotJson.986; - in - let TotallyNotJson.994 : U64 = 1i64; - let TotallyNotJson.991 : Int1 = CallByName Num.24 TotallyNotJson.209 TotallyNotJson.994; - if TotallyNotJson.991 then - let TotallyNotJson.993 : I64 = 44i64; - let TotallyNotJson.992 : U8 = CallByName Num.127 TotallyNotJson.993; - let TotallyNotJson.989 : List U8 = CallByName List.4 TotallyNotJson.214 TotallyNotJson.992; - jump TotallyNotJson.990 TotallyNotJson.989; - else - jump TotallyNotJson.990 TotallyNotJson.214; +procedure Test.56 (Test.57, Test.274, Test.55): + let Test.313 : I64 = 115i64; + let Test.314 : U64 = CallByName Str.36 Test.55; + let Test.311 : List U8 = CallByName Test.3 Test.57 Test.313 Test.314; + let Test.312 : List U8 = CallByName Str.12 Test.55; + let Test.309 : List U8 = CallByName List.8 Test.311 Test.312; + let Test.310 : U8 = 32i64; + let Test.308 : List U8 = CallByName List.4 Test.309 Test.310; + ret Test.308; -procedure TotallyNotJson.204 (TotallyNotJson.978, TotallyNotJson.979): - let TotallyNotJson.210 : Str = StructAtIndex 0 TotallyNotJson.979; - let TotallyNotJson.211 : Str = StructAtIndex 1 TotallyNotJson.979; - let TotallyNotJson.208 : List U8 = StructAtIndex 0 TotallyNotJson.978; - let TotallyNotJson.209 : U64 = StructAtIndex 1 TotallyNotJson.978; - let TotallyNotJson.1052 : List U8 = Array []; - let TotallyNotJson.1053 : {} = CallByName TotallyNotJson.8; - let TotallyNotJson.212 : List U8 = CallByName Encode.24 TotallyNotJson.1052 TotallyNotJson.211 TotallyNotJson.1053; - let TotallyNotJson.1051 : List U8 = Array []; - let TotallyNotJson.1047 : Int1 = CallByName Bool.11 TotallyNotJson.212 TotallyNotJson.1051; - dec TotallyNotJson.1051; - if TotallyNotJson.1047 then - dec TotallyNotJson.210; - dec TotallyNotJson.212; - let TotallyNotJson.1050 : U64 = 1i64; - let TotallyNotJson.1049 : U64 = CallByName Num.20 TotallyNotJson.209 TotallyNotJson.1050; - let TotallyNotJson.1048 : {List U8, U64} = Struct {TotallyNotJson.208, TotallyNotJson.1049}; - ret TotallyNotJson.1048; - else - let TotallyNotJson.1046 : I64 = 34i64; - let TotallyNotJson.1045 : U8 = CallByName Num.127 TotallyNotJson.1046; - let TotallyNotJson.1043 : List U8 = CallByName List.4 TotallyNotJson.208 TotallyNotJson.1045; - let TotallyNotJson.1044 : List U8 = CallByName Str.12 TotallyNotJson.210; - let TotallyNotJson.1040 : List U8 = CallByName List.8 TotallyNotJson.1043 TotallyNotJson.1044; - let TotallyNotJson.1042 : I64 = 34i64; - let TotallyNotJson.1041 : U8 = CallByName Num.127 TotallyNotJson.1042; - let TotallyNotJson.1037 : List U8 = CallByName List.4 TotallyNotJson.1040 TotallyNotJson.1041; - let TotallyNotJson.1039 : I64 = 58i64; - let TotallyNotJson.1038 : U8 = CallByName Num.127 TotallyNotJson.1039; - let TotallyNotJson.1036 : List U8 = CallByName List.4 TotallyNotJson.1037 TotallyNotJson.1038; - let TotallyNotJson.214 : List U8 = CallByName List.8 TotallyNotJson.1036 TotallyNotJson.212; - joinpoint TotallyNotJson.1031 TotallyNotJson.215: - let TotallyNotJson.1029 : U64 = 1i64; - let TotallyNotJson.1028 : U64 = CallByName Num.20 TotallyNotJson.209 TotallyNotJson.1029; - let TotallyNotJson.1027 : {List U8, U64} = Struct {TotallyNotJson.215, TotallyNotJson.1028}; - ret TotallyNotJson.1027; - in - let TotallyNotJson.1035 : U64 = 1i64; - let TotallyNotJson.1032 : Int1 = CallByName Num.24 TotallyNotJson.209 TotallyNotJson.1035; - if TotallyNotJson.1032 then - let TotallyNotJson.1034 : I64 = 44i64; - let TotallyNotJson.1033 : U8 = CallByName Num.127 TotallyNotJson.1034; - let TotallyNotJson.1030 : List U8 = CallByName List.4 TotallyNotJson.214 TotallyNotJson.1033; - jump TotallyNotJson.1031 TotallyNotJson.1030; - else - jump TotallyNotJson.1031 TotallyNotJson.214; +procedure Test.67 (Test.68, Test.262, Test.66): + let Test.290 : I64 = 114i64; + let Test.291 : U64 = CallByName List.6 Test.66; + let Test.69 : List U8 = CallByName Test.3 Test.68 Test.290 Test.291; + let Test.265 : {} = Struct {}; + let Test.264 : List U8 = CallByName List.18 Test.66 Test.69 Test.265; + ret Test.264; -procedure TotallyNotJson.25 (TotallyNotJson.149): - let TotallyNotJson.1058 : Str = CallByName Encode.23 TotallyNotJson.149; - ret TotallyNotJson.1058; +procedure Test.67 (Test.68, Test.262, Test.66): + let Test.322 : I64 = 114i64; + let Test.323 : U64 = CallByName List.6 Test.66; + let Test.69 : List U8 = CallByName Test.3 Test.68 Test.322 Test.323; + let Test.297 : {} = Struct {}; + let Test.296 : List U8 = CallByName List.18 Test.66 Test.69 Test.297; + ret Test.296; -procedure TotallyNotJson.26 (TotallyNotJson.152): - let TotallyNotJson.153 : List U8 = CallByName Str.12 TotallyNotJson.152; - let TotallyNotJson.1140 : U64 = 0i64; - let TotallyNotJson.1141 : Int1 = true; - let TotallyNotJson.154 : {U64, Int1} = Struct {TotallyNotJson.1140, TotallyNotJson.1141}; - let TotallyNotJson.1110 : {} = Struct {}; - inc TotallyNotJson.153; - let TotallyNotJson.155 : {U64, Int1} = CallByName List.26 TotallyNotJson.153 TotallyNotJson.154 TotallyNotJson.1110; - let TotallyNotJson.1064 : Int1 = StructAtIndex 1 TotallyNotJson.155; - let TotallyNotJson.1108 : Int1 = true; - let TotallyNotJson.1109 : Int1 = lowlevel Eq TotallyNotJson.1108 TotallyNotJson.1064; - if TotallyNotJson.1109 then - let TotallyNotJson.1074 : U64 = CallByName List.6 TotallyNotJson.153; - let TotallyNotJson.1075 : U64 = 2i64; - let TotallyNotJson.1073 : U64 = CallByName Num.19 TotallyNotJson.1074 TotallyNotJson.1075; - let TotallyNotJson.1070 : List U8 = CallByName List.68 TotallyNotJson.1073; - let TotallyNotJson.1072 : U8 = 34i64; - let TotallyNotJson.1071 : List U8 = Array [TotallyNotJson.1072]; - let TotallyNotJson.1069 : List U8 = CallByName List.8 TotallyNotJson.1070 TotallyNotJson.1071; - let TotallyNotJson.1066 : List U8 = CallByName List.8 TotallyNotJson.1069 TotallyNotJson.153; - let TotallyNotJson.1068 : U8 = 34i64; - let TotallyNotJson.1067 : List U8 = Array [TotallyNotJson.1068]; - let TotallyNotJson.1065 : List U8 = CallByName List.8 TotallyNotJson.1066 TotallyNotJson.1067; - ret TotallyNotJson.1065; - else - inc TotallyNotJson.153; - let TotallyNotJson.1107 : U64 = StructAtIndex 0 TotallyNotJson.155; - let TotallyNotJson.1106 : {List U8, List U8} = CallByName List.52 TotallyNotJson.153 TotallyNotJson.1107; - let TotallyNotJson.179 : List U8 = StructAtIndex 0 TotallyNotJson.1106; - let TotallyNotJson.181 : List U8 = StructAtIndex 1 TotallyNotJson.1106; - let TotallyNotJson.1104 : U64 = CallByName List.6 TotallyNotJson.153; - dec TotallyNotJson.153; - let TotallyNotJson.1105 : U64 = 120i64; - let TotallyNotJson.1102 : U64 = CallByName Num.21 TotallyNotJson.1104 TotallyNotJson.1105; - let TotallyNotJson.1103 : U64 = 100i64; - let TotallyNotJson.1101 : U64 = CallByName Num.137 TotallyNotJson.1102 TotallyNotJson.1103; - let TotallyNotJson.1098 : List U8 = CallByName List.68 TotallyNotJson.1101; - let TotallyNotJson.1100 : U8 = 34i64; - let TotallyNotJson.1099 : List U8 = Array [TotallyNotJson.1100]; - let TotallyNotJson.1097 : List U8 = CallByName List.8 TotallyNotJson.1098 TotallyNotJson.1099; - let TotallyNotJson.182 : List U8 = CallByName List.8 TotallyNotJson.1097 TotallyNotJson.179; - let TotallyNotJson.1080 : {} = Struct {}; - let TotallyNotJson.1077 : List U8 = CallByName List.18 TotallyNotJson.181 TotallyNotJson.182 TotallyNotJson.1080; - let TotallyNotJson.1079 : U8 = 34i64; - let TotallyNotJson.1078 : List U8 = Array [TotallyNotJson.1079]; - let TotallyNotJson.1076 : List U8 = CallByName List.8 TotallyNotJson.1077 TotallyNotJson.1078; - ret TotallyNotJson.1076; +procedure Test.70 (Test.71, Test.266): + let Test.72 : Str = StructAtIndex 0 Test.266; + let Test.73 : Str = StructAtIndex 1 Test.266; + let Test.270 : Str = CallByName Test.19 Test.72; + let Test.271 : {} = Struct {}; + let Test.268 : List U8 = CallByName Encode.24 Test.71 Test.270 Test.271; + let Test.269 : {} = Struct {}; + let Test.267 : List U8 = CallByName Encode.24 Test.268 Test.73 Test.269; + ret Test.267; -procedure TotallyNotJson.27 (TotallyNotJson.186): - switch TotallyNotJson.186: - case 34: - let TotallyNotJson.1083 : List U8 = Array [92i64, 34i64]; - ret TotallyNotJson.1083; - - case 92: - let TotallyNotJson.1084 : List U8 = Array [92i64, 92i64]; - ret TotallyNotJson.1084; - - case 47: - let TotallyNotJson.1085 : List U8 = Array [92i64, 47i64]; - ret TotallyNotJson.1085; - - case 8: - let TotallyNotJson.1087 : U8 = 98i64; - let TotallyNotJson.1086 : List U8 = Array [92i64, TotallyNotJson.1087]; - ret TotallyNotJson.1086; - - case 12: - let TotallyNotJson.1089 : U8 = 102i64; - let TotallyNotJson.1088 : List U8 = Array [92i64, TotallyNotJson.1089]; - ret TotallyNotJson.1088; - - case 10: - let TotallyNotJson.1091 : U8 = 110i64; - let TotallyNotJson.1090 : List U8 = Array [92i64, TotallyNotJson.1091]; - ret TotallyNotJson.1090; - - case 13: - let TotallyNotJson.1093 : U8 = 114i64; - let TotallyNotJson.1092 : List U8 = Array [92i64, TotallyNotJson.1093]; - ret TotallyNotJson.1092; - - case 9: - let TotallyNotJson.1095 : U8 = 114i64; - let TotallyNotJson.1094 : List U8 = Array [92i64, TotallyNotJson.1095]; - ret TotallyNotJson.1094; - - default: - let TotallyNotJson.1096 : List U8 = Array [TotallyNotJson.186]; - ret TotallyNotJson.1096; - - -procedure TotallyNotJson.29 (TotallyNotJson.201): - let TotallyNotJson.1017 : List {Str, Str} = CallByName Encode.23 TotallyNotJson.201; - ret TotallyNotJson.1017; - -procedure TotallyNotJson.29 (TotallyNotJson.201): - let TotallyNotJson.974 : List {Str, Str} = CallByName Encode.23 TotallyNotJson.201; - ret TotallyNotJson.974; - -procedure TotallyNotJson.8 (): - let TotallyNotJson.1054 : {} = Struct {}; - ret TotallyNotJson.1054; +procedure Test.70 (Test.71, Test.266): + let Test.72 : Str = StructAtIndex 0 Test.266; + let Test.73 : Str = StructAtIndex 1 Test.266; + let Test.302 : Str = CallByName Test.19 Test.72; + let Test.303 : {} = Struct {}; + let Test.300 : List U8 = CallByName Encode.24 Test.71 Test.302 Test.303; + let Test.301 : {} = Struct {}; + let Test.299 : List U8 = CallByName Encode.24 Test.300 Test.73 Test.301; + ret Test.299; procedure Test.0 (): - let Test.12 : Str = "bar"; - let Test.10 : {} = CallByName TotallyNotJson.8; - let Test.8 : List U8 = CallByName Encode.26 Test.12 Test.10; - let Test.1 : [C {U64, U8}, C Str] = CallByName Str.9 Test.8; - let Test.5 : U8 = 1i64; - let Test.6 : U8 = GetTagId Test.1; - let Test.7 : Int1 = lowlevel Eq Test.5 Test.6; - if Test.7 then - let Test.2 : Str = UnionAtIndex (Id 1) (Index 0) Test.1; - ret Test.2; + let Test.259 : Str = "bar"; + let Test.256 : {} = CallByName Test.2; + let Test.254 : List U8 = CallByName Encode.26 Test.259 Test.256; + let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; + let Test.251 : U8 = 1i64; + let Test.252 : U8 = GetTagId Test.209; + let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; + if Test.253 then + let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; + ret Test.210; else - dec Test.1; - let Test.4 : Str = ""; - ret Test.4; + dec Test.209; + let Test.250 : Str = ""; + ret Test.250; 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 e1052bcce0..4fef47e28f 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt @@ -4,17 +4,13 @@ procedure #Derived.0 (#Derived.1): procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1): let #Derived_gen.7 : Str = "a"; - let #Derived_gen.8 : Str = CallByName TotallyNotJson.25 #Derived.1; + let #Derived_gen.8 : Str = CallByName Test.19 #Derived.1; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.7, #Derived_gen.8}; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6]; - let #Derived_gen.4 : List {Str, Str} = CallByName TotallyNotJson.29 #Derived_gen.5; + let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5; let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4; ret #Derived_gen.3; -procedure Bool.11 (#Attr.2, #Attr.3): - let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.23; - procedure Encode.23 (Encode.98): ret Encode.98; @@ -29,12 +25,12 @@ procedure Encode.24 (Encode.99, Encode.107, Encode.101): ret Encode.111; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName TotallyNotJson.202 Encode.99 Encode.101 Encode.107; + let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107; ret Encode.113; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.116 : List U8 = CallByName TotallyNotJson.150 Encode.99 Encode.101 Encode.107; - ret Encode.116; + let Encode.118 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; + ret Encode.118; procedure Encode.26 (Encode.105, Encode.106): let Encode.109 : List U8 = Array []; @@ -42,200 +38,78 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.104 (List.488, List.489, List.490): - let List.652 : U64 = 0i64; - let List.653 : U64 = CallByName List.6 List.488; - let List.651 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.488 List.489 List.490 List.652 List.653; - ret List.651; - procedure List.18 (List.160, List.161, List.162): - let List.595 : U64 = 0i64; - let List.596 : U64 = CallByName List.6 List.160; - let List.594 : {List U8, U64} = CallByName List.92 List.160 List.161 List.162 List.595 List.596; - ret List.594; - -procedure List.18 (List.160, List.161, List.162): - let List.607 : U64 = 0i64; - let List.608 : U64 = CallByName List.6 List.160; - let List.606 : List U8 = CallByName List.92 List.160 List.161 List.162 List.607 List.608; - ret List.606; - -procedure List.26 (List.201, List.202, List.203): - let List.645 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.104 List.201 List.202 List.203; - let List.648 : U8 = 1i64; - let List.649 : U8 = GetTagId List.645; - let List.650 : Int1 = lowlevel Eq List.648 List.649; - if List.650 then - let List.204 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.645; - ret List.204; - else - let List.205 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.645; - ret List.205; + let List.575 : U64 = 0i64; + let List.576 : U64 = CallByName List.6 List.160; + let List.574 : List U8 = CallByName List.92 List.160 List.161 List.162 List.575 List.576; + ret List.574; procedure List.4 (List.124, List.125): - let List.593 : U64 = 1i64; - let List.592 : List U8 = CallByName List.70 List.124 List.593; - let List.591 : List U8 = CallByName List.71 List.592 List.125; - ret List.591; - -procedure List.49 (List.420, List.421): - let List.636 : U64 = StructAtIndex 1 List.421; - let List.637 : U64 = StructAtIndex 0 List.421; - let List.635 : List U8 = CallByName List.72 List.420 List.636 List.637; - ret List.635; - -procedure List.52 (List.435, List.436): - let List.437 : U64 = CallByName List.6 List.435; - joinpoint List.643 List.438: - let List.641 : U64 = 0i64; - let List.640 : {U64, U64} = Struct {List.438, List.641}; - inc List.435; - let List.439 : List U8 = CallByName List.49 List.435 List.640; - let List.639 : U64 = CallByName Num.75 List.437 List.438; - let List.634 : {U64, U64} = Struct {List.639, List.438}; - let List.440 : List U8 = CallByName List.49 List.435 List.634; - let List.633 : {List U8, List U8} = Struct {List.439, List.440}; - ret List.633; - in - let List.644 : Int1 = CallByName Num.24 List.437 List.436; - if List.644 then - jump List.643 List.436; - else - jump List.643 List.437; + let List.596 : U64 = 1i64; + let List.595 : List U8 = CallByName List.70 List.124 List.596; + let List.594 : List U8 = CallByName List.71 List.595 List.125; + ret List.594; procedure List.6 (#Attr.2): - let List.628 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.628; - -procedure List.6 (#Attr.2): - let List.630 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.630; + let List.599 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.599; procedure List.66 (#Attr.2, #Attr.3): - let List.604 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.604; - -procedure List.66 (#Attr.2, #Attr.3): - let List.616 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.616; - -procedure List.68 (#Attr.2): - let List.632 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.632; + let List.584 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.584; procedure List.70 (#Attr.2, #Attr.3): - let List.578 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.578; + let List.590 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.590; procedure List.71 (#Attr.2, #Attr.3): - let List.576 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.576; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.638 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.638; + let List.588 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.588; procedure List.8 (#Attr.2, #Attr.3): - let List.627 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.627; + let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.598; -procedure List.80 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): - joinpoint List.654 List.491 List.492 List.493 List.494 List.495: - let List.656 : Int1 = CallByName Num.22 List.494 List.495; - if List.656 then - let List.665 : U8 = CallByName List.66 List.491 List.494; - let List.657 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.157 List.492 List.665; - let List.662 : U8 = 1i64; - let List.663 : U8 = GetTagId List.657; - let List.664 : Int1 = lowlevel Eq List.662 List.663; - if List.664 then - let List.496 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.657; - let List.660 : U64 = 1i64; - let List.659 : U64 = CallByName Num.51 List.494 List.660; - jump List.654 List.491 List.496 List.493 List.659 List.495; - else - dec List.491; - let List.497 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.657; - let List.661 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.497; - ret List.661; - else - dec List.491; - let List.655 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.492; - ret List.655; - in - jump List.654 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; - -procedure List.92 (#Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27, #Derived_gen.28): - joinpoint List.597 List.163 List.164 List.165 List.166 List.167: - let List.599 : Int1 = CallByName Num.22 List.166 List.167; - if List.599 then - let List.603 : {Str, Str} = CallByName List.66 List.163 List.166; - inc List.603; - let List.168 : {List U8, U64} = CallByName TotallyNotJson.204 List.164 List.603; - let List.602 : U64 = 1i64; - let List.601 : U64 = CallByName Num.51 List.166 List.602; - jump List.597 List.163 List.168 List.165 List.601 List.167; +procedure List.92 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): + joinpoint List.577 List.163 List.164 List.165 List.166 List.167: + let List.579 : Int1 = CallByName Num.22 List.166 List.167; + if List.579 then + let List.583 : {Str, Str} = CallByName List.66 List.163 List.166; + inc List.583; + let List.168 : List U8 = CallByName Test.70 List.164 List.583; + let List.582 : U64 = 1i64; + let List.581 : U64 = CallByName Num.51 List.166 List.582; + jump List.577 List.163 List.168 List.165 List.581 List.167; else dec List.163; ret List.164; in - jump List.597 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28; - -procedure List.92 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): - joinpoint List.609 List.163 List.164 List.165 List.166 List.167: - let List.611 : Int1 = CallByName Num.22 List.166 List.167; - if List.611 then - let List.615 : U8 = CallByName List.66 List.163 List.166; - let List.168 : List U8 = CallByName TotallyNotJson.183 List.164 List.615; - let List.614 : U64 = 1i64; - let List.613 : U64 = CallByName Num.51 List.166 List.614; - jump List.609 List.163 List.168 List.165 List.613 List.167; - else - dec List.163; - ret List.164; - in - jump List.609 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; + jump List.577 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; procedure Num.127 (#Attr.2): - let Num.284 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.284; - -procedure Num.137 (#Attr.2, #Attr.3): - let Num.290 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; - ret Num.290; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.289 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.289; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.286 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.286; - -procedure Num.21 (#Attr.2, #Attr.3): - let Num.291 : U64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.291; + let Num.280 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.280; procedure Num.22 (#Attr.2, #Attr.3): - let Num.297 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.297; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.299 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.299; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.294 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.294; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; -procedure Num.75 (#Attr.2, #Attr.3): - let Num.298 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.298; +procedure Num.96 (#Attr.2): + let Num.279 : Str = lowlevel NumToStr #Attr.2; + ret Num.279; procedure Str.12 (#Attr.2): let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; ret Str.241; +procedure Str.36 (#Attr.2): + let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.242; + procedure Str.43 (#Attr.2): let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; ret Str.239; @@ -250,259 +124,74 @@ procedure Str.9 (Str.67): else let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.34 : Str = StructAtIndex 1 Str.68; - dec #Derived_gen.34; + let #Derived_gen.24 : Str = StructAtIndex 1 Str.68; + dec #Derived_gen.24; let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; ret Str.232; -procedure TotallyNotJson.150 (TotallyNotJson.151, TotallyNotJson.1019, TotallyNotJson.149): - let TotallyNotJson.1022 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.149; - let TotallyNotJson.1021 : List U8 = CallByName List.8 TotallyNotJson.151 TotallyNotJson.1022; - ret TotallyNotJson.1021; +procedure Test.19 (Test.55): + let Test.291 : Str = CallByName Encode.23 Test.55; + ret Test.291; -procedure TotallyNotJson.157 (TotallyNotJson.1070, TotallyNotJson.160): - let TotallyNotJson.158 : U64 = StructAtIndex 0 TotallyNotJson.1070; - let TotallyNotJson.159 : Int1 = StructAtIndex 1 TotallyNotJson.1070; - switch TotallyNotJson.160: - case 34: - let TotallyNotJson.1073 : Int1 = false; - let TotallyNotJson.1072 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1073}; - let TotallyNotJson.1071 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1072; - ret TotallyNotJson.1071; - - case 92: - let TotallyNotJson.1076 : Int1 = false; - let TotallyNotJson.1075 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1076}; - let TotallyNotJson.1074 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1075; - ret TotallyNotJson.1074; - - case 47: - let TotallyNotJson.1079 : Int1 = false; - let TotallyNotJson.1078 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1079}; - let TotallyNotJson.1077 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1078; - ret TotallyNotJson.1077; - - case 8: - let TotallyNotJson.1082 : Int1 = false; - let TotallyNotJson.1081 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1082}; - let TotallyNotJson.1080 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1081; - ret TotallyNotJson.1080; - - case 12: - let TotallyNotJson.1085 : Int1 = false; - let TotallyNotJson.1084 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1085}; - let TotallyNotJson.1083 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1084; - ret TotallyNotJson.1083; - - case 10: - let TotallyNotJson.1088 : Int1 = false; - let TotallyNotJson.1087 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1088}; - let TotallyNotJson.1086 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1087; - ret TotallyNotJson.1086; - - case 13: - let TotallyNotJson.1091 : Int1 = false; - let TotallyNotJson.1090 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1091}; - let TotallyNotJson.1089 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1090; - ret TotallyNotJson.1089; - - case 9: - let TotallyNotJson.1094 : Int1 = false; - let TotallyNotJson.1093 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1094}; - let TotallyNotJson.1092 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1093; - ret TotallyNotJson.1092; - - default: - let TotallyNotJson.1098 : U64 = 1i64; - let TotallyNotJson.1097 : U64 = CallByName Num.19 TotallyNotJson.158 TotallyNotJson.1098; - let TotallyNotJson.1096 : {U64, Int1} = Struct {TotallyNotJson.1097, TotallyNotJson.159}; - let TotallyNotJson.1095 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) TotallyNotJson.1096; - ret TotallyNotJson.1095; - +procedure Test.2 (): + let Test.257 : {} = Struct {}; + ret Test.257; -procedure TotallyNotJson.183 (TotallyNotJson.184, TotallyNotJson.185): - let TotallyNotJson.1041 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.185; - let TotallyNotJson.1040 : List U8 = CallByName List.8 TotallyNotJson.184 TotallyNotJson.1041; - ret TotallyNotJson.1040; +procedure Test.21 (Test.66): + let Test.259 : List {Str, Str} = CallByName Encode.23 Test.66; + ret Test.259; -procedure TotallyNotJson.202 (TotallyNotJson.203, TotallyNotJson.976, TotallyNotJson.201): - let TotallyNotJson.1016 : I64 = 123i64; - let TotallyNotJson.1015 : U8 = CallByName Num.127 TotallyNotJson.1016; - let TotallyNotJson.205 : List U8 = CallByName List.4 TotallyNotJson.203 TotallyNotJson.1015; - let TotallyNotJson.1014 : U64 = CallByName List.6 TotallyNotJson.201; - let TotallyNotJson.984 : {List U8, U64} = Struct {TotallyNotJson.205, TotallyNotJson.1014}; - let TotallyNotJson.985 : {} = Struct {}; - let TotallyNotJson.983 : {List U8, U64} = CallByName List.18 TotallyNotJson.201 TotallyNotJson.984 TotallyNotJson.985; - let TotallyNotJson.207 : List U8 = StructAtIndex 0 TotallyNotJson.983; - let TotallyNotJson.982 : I64 = 125i64; - let TotallyNotJson.981 : U8 = CallByName Num.127 TotallyNotJson.982; - let TotallyNotJson.980 : List U8 = CallByName List.4 TotallyNotJson.207 TotallyNotJson.981; - ret TotallyNotJson.980; +procedure Test.3 (Test.48, Test.49, Test.50): + let Test.288 : U8 = CallByName Num.127 Test.49; + let Test.285 : List U8 = CallByName List.4 Test.48 Test.288; + let Test.287 : Str = CallByName Num.96 Test.50; + let Test.286 : List U8 = CallByName Str.12 Test.287; + let Test.283 : List U8 = CallByName List.8 Test.285 Test.286; + let Test.284 : U8 = 32i64; + let Test.282 : List U8 = CallByName List.4 Test.283 Test.284; + ret Test.282; -procedure TotallyNotJson.204 (TotallyNotJson.978, TotallyNotJson.979): - let TotallyNotJson.210 : Str = StructAtIndex 0 TotallyNotJson.979; - let TotallyNotJson.211 : Str = StructAtIndex 1 TotallyNotJson.979; - let TotallyNotJson.208 : List U8 = StructAtIndex 0 TotallyNotJson.978; - let TotallyNotJson.209 : U64 = StructAtIndex 1 TotallyNotJson.978; - let TotallyNotJson.1011 : List U8 = Array []; - let TotallyNotJson.1012 : {} = CallByName TotallyNotJson.8; - let TotallyNotJson.212 : List U8 = CallByName Encode.24 TotallyNotJson.1011 TotallyNotJson.211 TotallyNotJson.1012; - let TotallyNotJson.1010 : List U8 = Array []; - let TotallyNotJson.1006 : Int1 = CallByName Bool.11 TotallyNotJson.212 TotallyNotJson.1010; - dec TotallyNotJson.1010; - if TotallyNotJson.1006 then - dec TotallyNotJson.210; - dec TotallyNotJson.212; - let TotallyNotJson.1009 : U64 = 1i64; - let TotallyNotJson.1008 : U64 = CallByName Num.20 TotallyNotJson.209 TotallyNotJson.1009; - let TotallyNotJson.1007 : {List U8, U64} = Struct {TotallyNotJson.208, TotallyNotJson.1008}; - ret TotallyNotJson.1007; - else - let TotallyNotJson.1005 : I64 = 34i64; - let TotallyNotJson.1004 : U8 = CallByName Num.127 TotallyNotJson.1005; - let TotallyNotJson.1002 : List U8 = CallByName List.4 TotallyNotJson.208 TotallyNotJson.1004; - let TotallyNotJson.1003 : List U8 = CallByName Str.12 TotallyNotJson.210; - let TotallyNotJson.999 : List U8 = CallByName List.8 TotallyNotJson.1002 TotallyNotJson.1003; - let TotallyNotJson.1001 : I64 = 34i64; - let TotallyNotJson.1000 : U8 = CallByName Num.127 TotallyNotJson.1001; - let TotallyNotJson.996 : List U8 = CallByName List.4 TotallyNotJson.999 TotallyNotJson.1000; - let TotallyNotJson.998 : I64 = 58i64; - let TotallyNotJson.997 : U8 = CallByName Num.127 TotallyNotJson.998; - let TotallyNotJson.995 : List U8 = CallByName List.4 TotallyNotJson.996 TotallyNotJson.997; - let TotallyNotJson.214 : List U8 = CallByName List.8 TotallyNotJson.995 TotallyNotJson.212; - joinpoint TotallyNotJson.990 TotallyNotJson.215: - let TotallyNotJson.988 : U64 = 1i64; - let TotallyNotJson.987 : U64 = CallByName Num.20 TotallyNotJson.209 TotallyNotJson.988; - let TotallyNotJson.986 : {List U8, U64} = Struct {TotallyNotJson.215, TotallyNotJson.987}; - ret TotallyNotJson.986; - in - let TotallyNotJson.994 : U64 = 1i64; - let TotallyNotJson.991 : Int1 = CallByName Num.24 TotallyNotJson.209 TotallyNotJson.994; - if TotallyNotJson.991 then - let TotallyNotJson.993 : I64 = 44i64; - let TotallyNotJson.992 : U8 = CallByName Num.127 TotallyNotJson.993; - let TotallyNotJson.989 : List U8 = CallByName List.4 TotallyNotJson.214 TotallyNotJson.992; - jump TotallyNotJson.990 TotallyNotJson.989; - else - jump TotallyNotJson.990 TotallyNotJson.214; +procedure Test.56 (Test.57, Test.273, Test.55): + let Test.280 : I64 = 115i64; + let Test.281 : U64 = CallByName Str.36 Test.55; + let Test.278 : List U8 = CallByName Test.3 Test.57 Test.280 Test.281; + let Test.279 : List U8 = CallByName Str.12 Test.55; + let Test.276 : List U8 = CallByName List.8 Test.278 Test.279; + let Test.277 : U8 = 32i64; + let Test.275 : List U8 = CallByName List.4 Test.276 Test.277; + ret Test.275; -procedure TotallyNotJson.25 (TotallyNotJson.149): - let TotallyNotJson.1017 : Str = CallByName Encode.23 TotallyNotJson.149; - ret TotallyNotJson.1017; +procedure Test.67 (Test.68, Test.261, Test.66): + let Test.289 : I64 = 114i64; + let Test.290 : U64 = CallByName List.6 Test.66; + let Test.69 : List U8 = CallByName Test.3 Test.68 Test.289 Test.290; + let Test.264 : {} = Struct {}; + let Test.263 : List U8 = CallByName List.18 Test.66 Test.69 Test.264; + ret Test.263; -procedure TotallyNotJson.26 (TotallyNotJson.152): - let TotallyNotJson.153 : List U8 = CallByName Str.12 TotallyNotJson.152; - let TotallyNotJson.1099 : U64 = 0i64; - let TotallyNotJson.1100 : Int1 = true; - let TotallyNotJson.154 : {U64, Int1} = Struct {TotallyNotJson.1099, TotallyNotJson.1100}; - let TotallyNotJson.1069 : {} = Struct {}; - inc TotallyNotJson.153; - let TotallyNotJson.155 : {U64, Int1} = CallByName List.26 TotallyNotJson.153 TotallyNotJson.154 TotallyNotJson.1069; - let TotallyNotJson.1023 : Int1 = StructAtIndex 1 TotallyNotJson.155; - let TotallyNotJson.1067 : Int1 = true; - let TotallyNotJson.1068 : Int1 = lowlevel Eq TotallyNotJson.1067 TotallyNotJson.1023; - if TotallyNotJson.1068 then - let TotallyNotJson.1033 : U64 = CallByName List.6 TotallyNotJson.153; - let TotallyNotJson.1034 : U64 = 2i64; - let TotallyNotJson.1032 : U64 = CallByName Num.19 TotallyNotJson.1033 TotallyNotJson.1034; - let TotallyNotJson.1029 : List U8 = CallByName List.68 TotallyNotJson.1032; - let TotallyNotJson.1031 : U8 = 34i64; - let TotallyNotJson.1030 : List U8 = Array [TotallyNotJson.1031]; - let TotallyNotJson.1028 : List U8 = CallByName List.8 TotallyNotJson.1029 TotallyNotJson.1030; - let TotallyNotJson.1025 : List U8 = CallByName List.8 TotallyNotJson.1028 TotallyNotJson.153; - let TotallyNotJson.1027 : U8 = 34i64; - let TotallyNotJson.1026 : List U8 = Array [TotallyNotJson.1027]; - let TotallyNotJson.1024 : List U8 = CallByName List.8 TotallyNotJson.1025 TotallyNotJson.1026; - ret TotallyNotJson.1024; - else - inc TotallyNotJson.153; - let TotallyNotJson.1066 : U64 = StructAtIndex 0 TotallyNotJson.155; - let TotallyNotJson.1065 : {List U8, List U8} = CallByName List.52 TotallyNotJson.153 TotallyNotJson.1066; - let TotallyNotJson.179 : List U8 = StructAtIndex 0 TotallyNotJson.1065; - let TotallyNotJson.181 : List U8 = StructAtIndex 1 TotallyNotJson.1065; - let TotallyNotJson.1063 : U64 = CallByName List.6 TotallyNotJson.153; - dec TotallyNotJson.153; - let TotallyNotJson.1064 : U64 = 120i64; - let TotallyNotJson.1061 : U64 = CallByName Num.21 TotallyNotJson.1063 TotallyNotJson.1064; - let TotallyNotJson.1062 : U64 = 100i64; - let TotallyNotJson.1060 : U64 = CallByName Num.137 TotallyNotJson.1061 TotallyNotJson.1062; - let TotallyNotJson.1057 : List U8 = CallByName List.68 TotallyNotJson.1060; - let TotallyNotJson.1059 : U8 = 34i64; - let TotallyNotJson.1058 : List U8 = Array [TotallyNotJson.1059]; - let TotallyNotJson.1056 : List U8 = CallByName List.8 TotallyNotJson.1057 TotallyNotJson.1058; - let TotallyNotJson.182 : List U8 = CallByName List.8 TotallyNotJson.1056 TotallyNotJson.179; - let TotallyNotJson.1039 : {} = Struct {}; - let TotallyNotJson.1036 : List U8 = CallByName List.18 TotallyNotJson.181 TotallyNotJson.182 TotallyNotJson.1039; - let TotallyNotJson.1038 : U8 = 34i64; - let TotallyNotJson.1037 : List U8 = Array [TotallyNotJson.1038]; - let TotallyNotJson.1035 : List U8 = CallByName List.8 TotallyNotJson.1036 TotallyNotJson.1037; - ret TotallyNotJson.1035; - -procedure TotallyNotJson.27 (TotallyNotJson.186): - switch TotallyNotJson.186: - case 34: - let TotallyNotJson.1042 : List U8 = Array [92i64, 34i64]; - ret TotallyNotJson.1042; - - case 92: - let TotallyNotJson.1043 : List U8 = Array [92i64, 92i64]; - ret TotallyNotJson.1043; - - case 47: - let TotallyNotJson.1044 : List U8 = Array [92i64, 47i64]; - ret TotallyNotJson.1044; - - case 8: - let TotallyNotJson.1046 : U8 = 98i64; - let TotallyNotJson.1045 : List U8 = Array [92i64, TotallyNotJson.1046]; - ret TotallyNotJson.1045; - - case 12: - let TotallyNotJson.1048 : U8 = 102i64; - let TotallyNotJson.1047 : List U8 = Array [92i64, TotallyNotJson.1048]; - ret TotallyNotJson.1047; - - case 10: - let TotallyNotJson.1050 : U8 = 110i64; - let TotallyNotJson.1049 : List U8 = Array [92i64, TotallyNotJson.1050]; - ret TotallyNotJson.1049; - - case 13: - let TotallyNotJson.1052 : U8 = 114i64; - let TotallyNotJson.1051 : List U8 = Array [92i64, TotallyNotJson.1052]; - ret TotallyNotJson.1051; - - case 9: - let TotallyNotJson.1054 : U8 = 114i64; - let TotallyNotJson.1053 : List U8 = Array [92i64, TotallyNotJson.1054]; - ret TotallyNotJson.1053; - - default: - let TotallyNotJson.1055 : List U8 = Array [TotallyNotJson.186]; - ret TotallyNotJson.1055; - - -procedure TotallyNotJson.29 (TotallyNotJson.201): - let TotallyNotJson.974 : List {Str, Str} = CallByName Encode.23 TotallyNotJson.201; - ret TotallyNotJson.974; - -procedure TotallyNotJson.8 (): - let TotallyNotJson.1013 : {} = Struct {}; - ret TotallyNotJson.1013; +procedure Test.70 (Test.71, Test.265): + let Test.72 : Str = StructAtIndex 0 Test.265; + let Test.73 : Str = StructAtIndex 1 Test.265; + let Test.269 : Str = CallByName Test.19 Test.72; + let Test.270 : {} = Struct {}; + let Test.267 : List U8 = CallByName Encode.24 Test.71 Test.269 Test.270; + let Test.268 : {} = Struct {}; + let Test.266 : List U8 = CallByName Encode.24 Test.267 Test.73 Test.268; + ret Test.266; procedure Test.0 (): - let Test.11 : Str = "foo"; - let Test.10 : {} = CallByName TotallyNotJson.8; - let Test.8 : List U8 = CallByName Encode.26 Test.11 Test.10; - let Test.1 : [C {U64, U8}, C Str] = CallByName Str.9 Test.8; - let Test.5 : U8 = 1i64; - let Test.6 : U8 = GetTagId Test.1; - let Test.7 : Int1 = lowlevel Eq Test.5 Test.6; - if Test.7 then - let Test.2 : Str = UnionAtIndex (Id 1) (Index 0) Test.1; - ret Test.2; + let Test.258 : Str = "foo"; + let Test.256 : {} = CallByName Test.2; + let Test.254 : List U8 = CallByName Encode.26 Test.258 Test.256; + let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; + let Test.251 : U8 = 1i64; + let Test.252 : U8 = GetTagId Test.209; + let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; + if Test.253 then + let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; + ret Test.210; else - dec Test.1; - let Test.4 : Str = ""; - ret Test.4; + dec Test.209; + let Test.250 : Str = ""; + ret Test.250; 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 9e227a089e..11b0ab78f1 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt @@ -6,22 +6,18 @@ procedure #Derived.2 (#Derived.3, #Derived.4, #Derived.1): let #Derived_gen.11 : Str = "a"; let #Derived_gen.13 : Str = StructAtIndex 0 #Derived.1; inc #Derived_gen.13; - let #Derived_gen.12 : Str = CallByName TotallyNotJson.25 #Derived_gen.13; + let #Derived_gen.12 : Str = CallByName Test.19 #Derived_gen.13; let #Derived_gen.6 : {Str, Str} = Struct {#Derived_gen.11, #Derived_gen.12}; let #Derived_gen.8 : Str = "b"; let #Derived_gen.10 : Str = StructAtIndex 1 #Derived.1; dec #Derived_gen.13; - let #Derived_gen.9 : Str = CallByName TotallyNotJson.25 #Derived_gen.10; + let #Derived_gen.9 : Str = CallByName Test.19 #Derived_gen.10; let #Derived_gen.7 : {Str, Str} = Struct {#Derived_gen.8, #Derived_gen.9}; let #Derived_gen.5 : List {Str, Str} = Array [#Derived_gen.6, #Derived_gen.7]; - let #Derived_gen.4 : List {Str, Str} = CallByName TotallyNotJson.29 #Derived_gen.5; + let #Derived_gen.4 : List {Str, Str} = CallByName Test.21 #Derived_gen.5; let #Derived_gen.3 : List U8 = CallByName Encode.24 #Derived.3 #Derived_gen.4 #Derived.4; ret #Derived_gen.3; -procedure Bool.11 (#Attr.2, #Attr.3): - let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.23; - procedure Encode.23 (Encode.98): ret Encode.98; @@ -36,12 +32,12 @@ procedure Encode.24 (Encode.99, Encode.107, Encode.101): ret Encode.111; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName TotallyNotJson.202 Encode.99 Encode.101 Encode.107; + let Encode.113 : List U8 = CallByName Test.67 Encode.99 Encode.101 Encode.107; ret Encode.113; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.117 : List U8 = CallByName TotallyNotJson.150 Encode.99 Encode.101 Encode.107; - ret Encode.117; + let Encode.119 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; + ret Encode.119; procedure Encode.26 (Encode.105, Encode.106): let Encode.109 : List U8 = Array []; @@ -49,200 +45,78 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.104 (List.488, List.489, List.490): - let List.652 : U64 = 0i64; - let List.653 : U64 = CallByName List.6 List.488; - let List.651 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.488 List.489 List.490 List.652 List.653; - ret List.651; - procedure List.18 (List.160, List.161, List.162): - let List.595 : U64 = 0i64; - let List.596 : U64 = CallByName List.6 List.160; - let List.594 : {List U8, U64} = CallByName List.92 List.160 List.161 List.162 List.595 List.596; - ret List.594; - -procedure List.18 (List.160, List.161, List.162): - let List.607 : U64 = 0i64; - let List.608 : U64 = CallByName List.6 List.160; - let List.606 : List U8 = CallByName List.92 List.160 List.161 List.162 List.607 List.608; - ret List.606; - -procedure List.26 (List.201, List.202, List.203): - let List.645 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.104 List.201 List.202 List.203; - let List.648 : U8 = 1i64; - let List.649 : U8 = GetTagId List.645; - let List.650 : Int1 = lowlevel Eq List.648 List.649; - if List.650 then - let List.204 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.645; - ret List.204; - else - let List.205 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.645; - ret List.205; + let List.575 : U64 = 0i64; + let List.576 : U64 = CallByName List.6 List.160; + let List.574 : List U8 = CallByName List.92 List.160 List.161 List.162 List.575 List.576; + ret List.574; procedure List.4 (List.124, List.125): - let List.593 : U64 = 1i64; - let List.592 : List U8 = CallByName List.70 List.124 List.593; - let List.591 : List U8 = CallByName List.71 List.592 List.125; - ret List.591; - -procedure List.49 (List.420, List.421): - let List.636 : U64 = StructAtIndex 1 List.421; - let List.637 : U64 = StructAtIndex 0 List.421; - let List.635 : List U8 = CallByName List.72 List.420 List.636 List.637; - ret List.635; - -procedure List.52 (List.435, List.436): - let List.437 : U64 = CallByName List.6 List.435; - joinpoint List.643 List.438: - let List.641 : U64 = 0i64; - let List.640 : {U64, U64} = Struct {List.438, List.641}; - inc List.435; - let List.439 : List U8 = CallByName List.49 List.435 List.640; - let List.639 : U64 = CallByName Num.75 List.437 List.438; - let List.634 : {U64, U64} = Struct {List.639, List.438}; - let List.440 : List U8 = CallByName List.49 List.435 List.634; - let List.633 : {List U8, List U8} = Struct {List.439, List.440}; - ret List.633; - in - let List.644 : Int1 = CallByName Num.24 List.437 List.436; - if List.644 then - jump List.643 List.436; - else - jump List.643 List.437; + let List.596 : U64 = 1i64; + let List.595 : List U8 = CallByName List.70 List.124 List.596; + let List.594 : List U8 = CallByName List.71 List.595 List.125; + ret List.594; procedure List.6 (#Attr.2): - let List.628 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.628; - -procedure List.6 (#Attr.2): - let List.630 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.630; + let List.599 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.599; procedure List.66 (#Attr.2, #Attr.3): - let List.604 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.604; - -procedure List.66 (#Attr.2, #Attr.3): - let List.616 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.616; - -procedure List.68 (#Attr.2): - let List.632 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.632; + let List.584 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.584; procedure List.70 (#Attr.2, #Attr.3): - let List.578 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.578; + let List.590 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.590; procedure List.71 (#Attr.2, #Attr.3): - let List.576 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.576; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.638 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.638; + let List.588 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.588; procedure List.8 (#Attr.2, #Attr.3): - let List.627 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.627; + let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.598; -procedure List.80 (#Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21): - joinpoint List.654 List.491 List.492 List.493 List.494 List.495: - let List.656 : Int1 = CallByName Num.22 List.494 List.495; - if List.656 then - let List.665 : U8 = CallByName List.66 List.491 List.494; - let List.657 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.157 List.492 List.665; - let List.662 : U8 = 1i64; - let List.663 : U8 = GetTagId List.657; - let List.664 : Int1 = lowlevel Eq List.662 List.663; - if List.664 then - let List.496 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.657; - let List.660 : U64 = 1i64; - let List.659 : U64 = CallByName Num.51 List.494 List.660; - jump List.654 List.491 List.496 List.493 List.659 List.495; - else - dec List.491; - let List.497 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.657; - let List.661 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.497; - ret List.661; - else - dec List.491; - let List.655 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.492; - ret List.655; - in - jump List.654 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21; - -procedure List.92 (#Derived_gen.28, #Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32): - joinpoint List.597 List.163 List.164 List.165 List.166 List.167: - let List.599 : Int1 = CallByName Num.22 List.166 List.167; - if List.599 then - let List.603 : {Str, Str} = CallByName List.66 List.163 List.166; - inc List.603; - let List.168 : {List U8, U64} = CallByName TotallyNotJson.204 List.164 List.603; - let List.602 : U64 = 1i64; - let List.601 : U64 = CallByName Num.51 List.166 List.602; - jump List.597 List.163 List.168 List.165 List.601 List.167; +procedure List.92 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): + joinpoint List.577 List.163 List.164 List.165 List.166 List.167: + let List.579 : Int1 = CallByName Num.22 List.166 List.167; + if List.579 then + let List.583 : {Str, Str} = CallByName List.66 List.163 List.166; + inc List.583; + let List.168 : List U8 = CallByName Test.70 List.164 List.583; + let List.582 : U64 = 1i64; + let List.581 : U64 = CallByName Num.51 List.166 List.582; + jump List.577 List.163 List.168 List.165 List.581 List.167; else dec List.163; ret List.164; in - jump List.597 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32; - -procedure List.92 (#Derived_gen.33, #Derived_gen.34, #Derived_gen.35, #Derived_gen.36, #Derived_gen.37): - joinpoint List.609 List.163 List.164 List.165 List.166 List.167: - let List.611 : Int1 = CallByName Num.22 List.166 List.167; - if List.611 then - let List.615 : U8 = CallByName List.66 List.163 List.166; - let List.168 : List U8 = CallByName TotallyNotJson.183 List.164 List.615; - let List.614 : U64 = 1i64; - let List.613 : U64 = CallByName Num.51 List.166 List.614; - jump List.609 List.163 List.168 List.165 List.613 List.167; - else - dec List.163; - ret List.164; - in - jump List.609 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37; + jump List.577 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; procedure Num.127 (#Attr.2): - let Num.284 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.284; - -procedure Num.137 (#Attr.2, #Attr.3): - let Num.290 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; - ret Num.290; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.289 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.289; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.286 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.286; - -procedure Num.21 (#Attr.2, #Attr.3): - let Num.291 : U64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.291; + let Num.280 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.280; procedure Num.22 (#Attr.2, #Attr.3): - let Num.297 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.297; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.299 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.299; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.294 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.294; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; -procedure Num.75 (#Attr.2, #Attr.3): - let Num.298 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.298; +procedure Num.96 (#Attr.2): + let Num.279 : Str = lowlevel NumToStr #Attr.2; + ret Num.279; procedure Str.12 (#Attr.2): let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; ret Str.241; +procedure Str.36 (#Attr.2): + let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.242; + procedure Str.43 (#Attr.2): let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; ret Str.239; @@ -257,261 +131,76 @@ procedure Str.9 (Str.67): else let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.38 : Str = StructAtIndex 1 Str.68; - dec #Derived_gen.38; + let #Derived_gen.28 : Str = StructAtIndex 1 Str.68; + dec #Derived_gen.28; let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; ret Str.232; -procedure TotallyNotJson.150 (TotallyNotJson.151, TotallyNotJson.1019, TotallyNotJson.149): - let TotallyNotJson.1022 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.149; - let TotallyNotJson.1021 : List U8 = CallByName List.8 TotallyNotJson.151 TotallyNotJson.1022; - ret TotallyNotJson.1021; +procedure Test.19 (Test.55): + let Test.295 : Str = CallByName Encode.23 Test.55; + ret Test.295; -procedure TotallyNotJson.157 (TotallyNotJson.1070, TotallyNotJson.160): - let TotallyNotJson.158 : U64 = StructAtIndex 0 TotallyNotJson.1070; - let TotallyNotJson.159 : Int1 = StructAtIndex 1 TotallyNotJson.1070; - switch TotallyNotJson.160: - case 34: - let TotallyNotJson.1073 : Int1 = false; - let TotallyNotJson.1072 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1073}; - let TotallyNotJson.1071 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1072; - ret TotallyNotJson.1071; - - case 92: - let TotallyNotJson.1076 : Int1 = false; - let TotallyNotJson.1075 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1076}; - let TotallyNotJson.1074 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1075; - ret TotallyNotJson.1074; - - case 47: - let TotallyNotJson.1079 : Int1 = false; - let TotallyNotJson.1078 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1079}; - let TotallyNotJson.1077 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1078; - ret TotallyNotJson.1077; - - case 8: - let TotallyNotJson.1082 : Int1 = false; - let TotallyNotJson.1081 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1082}; - let TotallyNotJson.1080 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1081; - ret TotallyNotJson.1080; - - case 12: - let TotallyNotJson.1085 : Int1 = false; - let TotallyNotJson.1084 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1085}; - let TotallyNotJson.1083 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1084; - ret TotallyNotJson.1083; - - case 10: - let TotallyNotJson.1088 : Int1 = false; - let TotallyNotJson.1087 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1088}; - let TotallyNotJson.1086 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1087; - ret TotallyNotJson.1086; - - case 13: - let TotallyNotJson.1091 : Int1 = false; - let TotallyNotJson.1090 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1091}; - let TotallyNotJson.1089 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1090; - ret TotallyNotJson.1089; - - case 9: - let TotallyNotJson.1094 : Int1 = false; - let TotallyNotJson.1093 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1094}; - let TotallyNotJson.1092 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1093; - ret TotallyNotJson.1092; - - default: - let TotallyNotJson.1098 : U64 = 1i64; - let TotallyNotJson.1097 : U64 = CallByName Num.19 TotallyNotJson.158 TotallyNotJson.1098; - let TotallyNotJson.1096 : {U64, Int1} = Struct {TotallyNotJson.1097, TotallyNotJson.159}; - let TotallyNotJson.1095 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) TotallyNotJson.1096; - ret TotallyNotJson.1095; - +procedure Test.2 (): + let Test.257 : {} = Struct {}; + ret Test.257; -procedure TotallyNotJson.183 (TotallyNotJson.184, TotallyNotJson.185): - let TotallyNotJson.1041 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.185; - let TotallyNotJson.1040 : List U8 = CallByName List.8 TotallyNotJson.184 TotallyNotJson.1041; - ret TotallyNotJson.1040; +procedure Test.21 (Test.66): + let Test.260 : List {Str, Str} = CallByName Encode.23 Test.66; + ret Test.260; -procedure TotallyNotJson.202 (TotallyNotJson.203, TotallyNotJson.976, TotallyNotJson.201): - let TotallyNotJson.1016 : I64 = 123i64; - let TotallyNotJson.1015 : U8 = CallByName Num.127 TotallyNotJson.1016; - let TotallyNotJson.205 : List U8 = CallByName List.4 TotallyNotJson.203 TotallyNotJson.1015; - let TotallyNotJson.1014 : U64 = CallByName List.6 TotallyNotJson.201; - let TotallyNotJson.984 : {List U8, U64} = Struct {TotallyNotJson.205, TotallyNotJson.1014}; - let TotallyNotJson.985 : {} = Struct {}; - let TotallyNotJson.983 : {List U8, U64} = CallByName List.18 TotallyNotJson.201 TotallyNotJson.984 TotallyNotJson.985; - let TotallyNotJson.207 : List U8 = StructAtIndex 0 TotallyNotJson.983; - let TotallyNotJson.982 : I64 = 125i64; - let TotallyNotJson.981 : U8 = CallByName Num.127 TotallyNotJson.982; - let TotallyNotJson.980 : List U8 = CallByName List.4 TotallyNotJson.207 TotallyNotJson.981; - ret TotallyNotJson.980; +procedure Test.3 (Test.48, Test.49, Test.50): + let Test.289 : U8 = CallByName Num.127 Test.49; + let Test.286 : List U8 = CallByName List.4 Test.48 Test.289; + let Test.288 : Str = CallByName Num.96 Test.50; + let Test.287 : List U8 = CallByName Str.12 Test.288; + let Test.284 : List U8 = CallByName List.8 Test.286 Test.287; + let Test.285 : U8 = 32i64; + let Test.283 : List U8 = CallByName List.4 Test.284 Test.285; + ret Test.283; -procedure TotallyNotJson.204 (TotallyNotJson.978, TotallyNotJson.979): - let TotallyNotJson.210 : Str = StructAtIndex 0 TotallyNotJson.979; - let TotallyNotJson.211 : Str = StructAtIndex 1 TotallyNotJson.979; - let TotallyNotJson.208 : List U8 = StructAtIndex 0 TotallyNotJson.978; - let TotallyNotJson.209 : U64 = StructAtIndex 1 TotallyNotJson.978; - let TotallyNotJson.1011 : List U8 = Array []; - let TotallyNotJson.1012 : {} = CallByName TotallyNotJson.8; - let TotallyNotJson.212 : List U8 = CallByName Encode.24 TotallyNotJson.1011 TotallyNotJson.211 TotallyNotJson.1012; - let TotallyNotJson.1010 : List U8 = Array []; - let TotallyNotJson.1006 : Int1 = CallByName Bool.11 TotallyNotJson.212 TotallyNotJson.1010; - dec TotallyNotJson.1010; - if TotallyNotJson.1006 then - dec TotallyNotJson.210; - dec TotallyNotJson.212; - let TotallyNotJson.1009 : U64 = 1i64; - let TotallyNotJson.1008 : U64 = CallByName Num.20 TotallyNotJson.209 TotallyNotJson.1009; - let TotallyNotJson.1007 : {List U8, U64} = Struct {TotallyNotJson.208, TotallyNotJson.1008}; - ret TotallyNotJson.1007; - else - let TotallyNotJson.1005 : I64 = 34i64; - let TotallyNotJson.1004 : U8 = CallByName Num.127 TotallyNotJson.1005; - let TotallyNotJson.1002 : List U8 = CallByName List.4 TotallyNotJson.208 TotallyNotJson.1004; - let TotallyNotJson.1003 : List U8 = CallByName Str.12 TotallyNotJson.210; - let TotallyNotJson.999 : List U8 = CallByName List.8 TotallyNotJson.1002 TotallyNotJson.1003; - let TotallyNotJson.1001 : I64 = 34i64; - let TotallyNotJson.1000 : U8 = CallByName Num.127 TotallyNotJson.1001; - let TotallyNotJson.996 : List U8 = CallByName List.4 TotallyNotJson.999 TotallyNotJson.1000; - let TotallyNotJson.998 : I64 = 58i64; - let TotallyNotJson.997 : U8 = CallByName Num.127 TotallyNotJson.998; - let TotallyNotJson.995 : List U8 = CallByName List.4 TotallyNotJson.996 TotallyNotJson.997; - let TotallyNotJson.214 : List U8 = CallByName List.8 TotallyNotJson.995 TotallyNotJson.212; - joinpoint TotallyNotJson.990 TotallyNotJson.215: - let TotallyNotJson.988 : U64 = 1i64; - let TotallyNotJson.987 : U64 = CallByName Num.20 TotallyNotJson.209 TotallyNotJson.988; - let TotallyNotJson.986 : {List U8, U64} = Struct {TotallyNotJson.215, TotallyNotJson.987}; - ret TotallyNotJson.986; - in - let TotallyNotJson.994 : U64 = 1i64; - let TotallyNotJson.991 : Int1 = CallByName Num.24 TotallyNotJson.209 TotallyNotJson.994; - if TotallyNotJson.991 then - let TotallyNotJson.993 : I64 = 44i64; - let TotallyNotJson.992 : U8 = CallByName Num.127 TotallyNotJson.993; - let TotallyNotJson.989 : List U8 = CallByName List.4 TotallyNotJson.214 TotallyNotJson.992; - jump TotallyNotJson.990 TotallyNotJson.989; - else - jump TotallyNotJson.990 TotallyNotJson.214; +procedure Test.56 (Test.57, Test.274, Test.55): + let Test.281 : I64 = 115i64; + let Test.282 : U64 = CallByName Str.36 Test.55; + let Test.279 : List U8 = CallByName Test.3 Test.57 Test.281 Test.282; + let Test.280 : List U8 = CallByName Str.12 Test.55; + let Test.277 : List U8 = CallByName List.8 Test.279 Test.280; + let Test.278 : U8 = 32i64; + let Test.276 : List U8 = CallByName List.4 Test.277 Test.278; + ret Test.276; -procedure TotallyNotJson.25 (TotallyNotJson.149): - let TotallyNotJson.1101 : Str = CallByName Encode.23 TotallyNotJson.149; - ret TotallyNotJson.1101; +procedure Test.67 (Test.68, Test.262, Test.66): + let Test.290 : I64 = 114i64; + let Test.291 : U64 = CallByName List.6 Test.66; + let Test.69 : List U8 = CallByName Test.3 Test.68 Test.290 Test.291; + let Test.265 : {} = Struct {}; + let Test.264 : List U8 = CallByName List.18 Test.66 Test.69 Test.265; + ret Test.264; -procedure TotallyNotJson.26 (TotallyNotJson.152): - let TotallyNotJson.153 : List U8 = CallByName Str.12 TotallyNotJson.152; - let TotallyNotJson.1099 : U64 = 0i64; - let TotallyNotJson.1100 : Int1 = true; - let TotallyNotJson.154 : {U64, Int1} = Struct {TotallyNotJson.1099, TotallyNotJson.1100}; - let TotallyNotJson.1069 : {} = Struct {}; - inc TotallyNotJson.153; - let TotallyNotJson.155 : {U64, Int1} = CallByName List.26 TotallyNotJson.153 TotallyNotJson.154 TotallyNotJson.1069; - let TotallyNotJson.1023 : Int1 = StructAtIndex 1 TotallyNotJson.155; - let TotallyNotJson.1067 : Int1 = true; - let TotallyNotJson.1068 : Int1 = lowlevel Eq TotallyNotJson.1067 TotallyNotJson.1023; - if TotallyNotJson.1068 then - let TotallyNotJson.1033 : U64 = CallByName List.6 TotallyNotJson.153; - let TotallyNotJson.1034 : U64 = 2i64; - let TotallyNotJson.1032 : U64 = CallByName Num.19 TotallyNotJson.1033 TotallyNotJson.1034; - let TotallyNotJson.1029 : List U8 = CallByName List.68 TotallyNotJson.1032; - let TotallyNotJson.1031 : U8 = 34i64; - let TotallyNotJson.1030 : List U8 = Array [TotallyNotJson.1031]; - let TotallyNotJson.1028 : List U8 = CallByName List.8 TotallyNotJson.1029 TotallyNotJson.1030; - let TotallyNotJson.1025 : List U8 = CallByName List.8 TotallyNotJson.1028 TotallyNotJson.153; - let TotallyNotJson.1027 : U8 = 34i64; - let TotallyNotJson.1026 : List U8 = Array [TotallyNotJson.1027]; - let TotallyNotJson.1024 : List U8 = CallByName List.8 TotallyNotJson.1025 TotallyNotJson.1026; - ret TotallyNotJson.1024; - else - inc TotallyNotJson.153; - let TotallyNotJson.1066 : U64 = StructAtIndex 0 TotallyNotJson.155; - let TotallyNotJson.1065 : {List U8, List U8} = CallByName List.52 TotallyNotJson.153 TotallyNotJson.1066; - let TotallyNotJson.179 : List U8 = StructAtIndex 0 TotallyNotJson.1065; - let TotallyNotJson.181 : List U8 = StructAtIndex 1 TotallyNotJson.1065; - let TotallyNotJson.1063 : U64 = CallByName List.6 TotallyNotJson.153; - dec TotallyNotJson.153; - let TotallyNotJson.1064 : U64 = 120i64; - let TotallyNotJson.1061 : U64 = CallByName Num.21 TotallyNotJson.1063 TotallyNotJson.1064; - let TotallyNotJson.1062 : U64 = 100i64; - let TotallyNotJson.1060 : U64 = CallByName Num.137 TotallyNotJson.1061 TotallyNotJson.1062; - let TotallyNotJson.1057 : List U8 = CallByName List.68 TotallyNotJson.1060; - let TotallyNotJson.1059 : U8 = 34i64; - let TotallyNotJson.1058 : List U8 = Array [TotallyNotJson.1059]; - let TotallyNotJson.1056 : List U8 = CallByName List.8 TotallyNotJson.1057 TotallyNotJson.1058; - let TotallyNotJson.182 : List U8 = CallByName List.8 TotallyNotJson.1056 TotallyNotJson.179; - let TotallyNotJson.1039 : {} = Struct {}; - let TotallyNotJson.1036 : List U8 = CallByName List.18 TotallyNotJson.181 TotallyNotJson.182 TotallyNotJson.1039; - let TotallyNotJson.1038 : U8 = 34i64; - let TotallyNotJson.1037 : List U8 = Array [TotallyNotJson.1038]; - let TotallyNotJson.1035 : List U8 = CallByName List.8 TotallyNotJson.1036 TotallyNotJson.1037; - ret TotallyNotJson.1035; - -procedure TotallyNotJson.27 (TotallyNotJson.186): - switch TotallyNotJson.186: - case 34: - let TotallyNotJson.1042 : List U8 = Array [92i64, 34i64]; - ret TotallyNotJson.1042; - - case 92: - let TotallyNotJson.1043 : List U8 = Array [92i64, 92i64]; - ret TotallyNotJson.1043; - - case 47: - let TotallyNotJson.1044 : List U8 = Array [92i64, 47i64]; - ret TotallyNotJson.1044; - - case 8: - let TotallyNotJson.1046 : U8 = 98i64; - let TotallyNotJson.1045 : List U8 = Array [92i64, TotallyNotJson.1046]; - ret TotallyNotJson.1045; - - case 12: - let TotallyNotJson.1048 : U8 = 102i64; - let TotallyNotJson.1047 : List U8 = Array [92i64, TotallyNotJson.1048]; - ret TotallyNotJson.1047; - - case 10: - let TotallyNotJson.1050 : U8 = 110i64; - let TotallyNotJson.1049 : List U8 = Array [92i64, TotallyNotJson.1050]; - ret TotallyNotJson.1049; - - case 13: - let TotallyNotJson.1052 : U8 = 114i64; - let TotallyNotJson.1051 : List U8 = Array [92i64, TotallyNotJson.1052]; - ret TotallyNotJson.1051; - - case 9: - let TotallyNotJson.1054 : U8 = 114i64; - let TotallyNotJson.1053 : List U8 = Array [92i64, TotallyNotJson.1054]; - ret TotallyNotJson.1053; - - default: - let TotallyNotJson.1055 : List U8 = Array [TotallyNotJson.186]; - ret TotallyNotJson.1055; - - -procedure TotallyNotJson.29 (TotallyNotJson.201): - let TotallyNotJson.974 : List {Str, Str} = CallByName Encode.23 TotallyNotJson.201; - ret TotallyNotJson.974; - -procedure TotallyNotJson.8 (): - let TotallyNotJson.1013 : {} = Struct {}; - ret TotallyNotJson.1013; +procedure Test.70 (Test.71, Test.266): + let Test.72 : Str = StructAtIndex 0 Test.266; + let Test.73 : Str = StructAtIndex 1 Test.266; + let Test.270 : Str = CallByName Test.19 Test.72; + let Test.271 : {} = Struct {}; + let Test.268 : List U8 = CallByName Encode.24 Test.71 Test.270 Test.271; + let Test.269 : {} = Struct {}; + let Test.267 : List U8 = CallByName Encode.24 Test.268 Test.73 Test.269; + ret Test.267; procedure Test.0 (): - let Test.11 : Str = "foo"; - let Test.12 : Str = "bar"; - let Test.9 : {Str, Str} = Struct {Test.11, Test.12}; - let Test.10 : {} = CallByName TotallyNotJson.8; - let Test.8 : List U8 = CallByName Encode.26 Test.9 Test.10; - let Test.1 : [C {U64, U8}, C Str] = CallByName Str.9 Test.8; - let Test.5 : U8 = 1i64; - let Test.6 : U8 = GetTagId Test.1; - let Test.7 : Int1 = lowlevel Eq Test.5 Test.6; - if Test.7 then - let Test.2 : Str = UnionAtIndex (Id 1) (Index 0) Test.1; - ret Test.2; + let Test.258 : Str = "foo"; + let Test.259 : Str = "bar"; + let Test.255 : {Str, Str} = Struct {Test.258, Test.259}; + let Test.256 : {} = CallByName Test.2; + let Test.254 : List U8 = CallByName Encode.26 Test.255 Test.256; + let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; + let Test.251 : U8 = 1i64; + let Test.252 : U8 = GetTagId Test.209; + let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; + if Test.253 then + let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; + ret Test.210; else - dec Test.1; - let Test.4 : Str = ""; - ret Test.4; + dec Test.209; + let Test.250 : Str = ""; + ret Test.250; diff --git a/crates/compiler/test_mono/generated/encode_derived_string.txt b/crates/compiler/test_mono/generated/encode_derived_string.txt index b9c7b92b43..7e0c164ae4 100644 --- a/crates/compiler/test_mono/generated/encode_derived_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_string.txt @@ -2,156 +2,48 @@ procedure Encode.23 (Encode.98): ret Encode.98; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.111 : List U8 = CallByName TotallyNotJson.150 Encode.99 Encode.101 Encode.107; + let Encode.111 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; ret Encode.111; procedure Encode.26 (Encode.105, Encode.106): let Encode.109 : List U8 = Array []; - let Encode.110 : Str = CallByName TotallyNotJson.25 Encode.105; + let Encode.110 : Str = CallByName Test.19 Encode.105; let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.104 (List.488, List.489, List.490): - let List.616 : U64 = 0i64; - let List.617 : U64 = CallByName List.6 List.488; - let List.615 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.488 List.489 List.490 List.616 List.617; - ret List.615; +procedure List.4 (List.124, List.125): + let List.584 : U64 = 1i64; + let List.583 : List U8 = CallByName List.70 List.124 List.584; + let List.582 : List U8 = CallByName List.71 List.583 List.125; + ret List.582; -procedure List.18 (List.160, List.161, List.162): - let List.587 : U64 = 0i64; - let List.588 : U64 = CallByName List.6 List.160; - let List.586 : List U8 = CallByName List.92 List.160 List.161 List.162 List.587 List.588; - ret List.586; +procedure List.70 (#Attr.2, #Attr.3): + let List.578 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.578; -procedure List.26 (List.201, List.202, List.203): - let List.609 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.104 List.201 List.202 List.203; - let List.612 : U8 = 1i64; - let List.613 : U8 = GetTagId List.609; - let List.614 : Int1 = lowlevel Eq List.612 List.613; - if List.614 then - let List.204 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.609; - ret List.204; - else - let List.205 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.609; - ret List.205; - -procedure List.49 (List.420, List.421): - let List.600 : U64 = StructAtIndex 1 List.421; - let List.601 : U64 = StructAtIndex 0 List.421; - let List.599 : List U8 = CallByName List.72 List.420 List.600 List.601; - ret List.599; - -procedure List.52 (List.435, List.436): - let List.437 : U64 = CallByName List.6 List.435; - joinpoint List.607 List.438: - let List.605 : U64 = 0i64; - let List.604 : {U64, U64} = Struct {List.438, List.605}; - inc List.435; - let List.439 : List U8 = CallByName List.49 List.435 List.604; - let List.603 : U64 = CallByName Num.75 List.437 List.438; - let List.598 : {U64, U64} = Struct {List.603, List.438}; - let List.440 : List U8 = CallByName List.49 List.435 List.598; - let List.597 : {List U8, List U8} = Struct {List.439, List.440}; - ret List.597; - in - let List.608 : Int1 = CallByName Num.24 List.437 List.436; - if List.608 then - jump List.607 List.436; - else - jump List.607 List.437; - -procedure List.6 (#Attr.2): - let List.585 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.585; - -procedure List.66 (#Attr.2, #Attr.3): - let List.596 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.596; - -procedure List.68 (#Attr.2): - let List.583 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.583; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.602 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.602; +procedure List.71 (#Attr.2, #Attr.3): + let List.576 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.576; procedure List.8 (#Attr.2, #Attr.3): - let List.581 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.581; + let List.586 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.586; -procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.618 List.491 List.492 List.493 List.494 List.495: - let List.620 : Int1 = CallByName Num.22 List.494 List.495; - if List.620 then - let List.629 : U8 = CallByName List.66 List.491 List.494; - let List.621 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.157 List.492 List.629; - let List.626 : U8 = 1i64; - let List.627 : U8 = GetTagId List.621; - let List.628 : Int1 = lowlevel Eq List.626 List.627; - if List.628 then - let List.496 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.621; - let List.624 : U64 = 1i64; - let List.623 : U64 = CallByName Num.51 List.494 List.624; - jump List.618 List.491 List.496 List.493 List.623 List.495; - else - dec List.491; - let List.497 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.621; - let List.625 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.497; - ret List.625; - else - dec List.491; - let List.619 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.492; - ret List.619; - in - jump List.618 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; - -procedure List.92 (#Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9): - joinpoint List.589 List.163 List.164 List.165 List.166 List.167: - let List.591 : Int1 = CallByName Num.22 List.166 List.167; - if List.591 then - let List.595 : U8 = CallByName List.66 List.163 List.166; - let List.168 : List U8 = CallByName TotallyNotJson.183 List.164 List.595; - let List.594 : U64 = 1i64; - let List.593 : U64 = CallByName Num.51 List.166 List.594; - jump List.589 List.163 List.168 List.165 List.593 List.167; - else - dec List.163; - ret List.164; - in - jump List.589 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9; - -procedure Num.137 (#Attr.2, #Attr.3): - let Num.281 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; - ret Num.281; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.280 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; +procedure Num.127 (#Attr.2): + let Num.280 : U8 = lowlevel NumIntCast #Attr.2; ret Num.280; -procedure Num.21 (#Attr.2, #Attr.3): - let Num.282 : U64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.282; - -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.288 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.288; - -procedure Num.51 (#Attr.2, #Attr.3): - let Num.284 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.284; - -procedure Num.75 (#Attr.2, #Attr.3): - let Num.287 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.287; +procedure Num.96 (#Attr.2): + let Num.279 : Str = lowlevel NumToStr #Attr.2; + ret Num.279; procedure Str.12 (#Attr.2): - let Str.240 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.240; + let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.241; + +procedure Str.36 (#Attr.2): + let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.242; procedure Str.43 (#Attr.2): let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; @@ -167,194 +59,52 @@ procedure Str.9 (Str.67): else let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.13 : Str = StructAtIndex 1 Str.68; - dec #Derived_gen.13; + let #Derived_gen.3 : Str = StructAtIndex 1 Str.68; + dec #Derived_gen.3; let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; ret Str.232; -procedure TotallyNotJson.150 (TotallyNotJson.151, TotallyNotJson.976, TotallyNotJson.149): - let TotallyNotJson.979 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.149; - let TotallyNotJson.978 : List U8 = CallByName List.8 TotallyNotJson.151 TotallyNotJson.979; - ret TotallyNotJson.978; +procedure Test.19 (Test.55): + let Test.258 : Str = CallByName Encode.23 Test.55; + ret Test.258; -procedure TotallyNotJson.157 (TotallyNotJson.1027, TotallyNotJson.160): - let TotallyNotJson.158 : U64 = StructAtIndex 0 TotallyNotJson.1027; - let TotallyNotJson.159 : Int1 = StructAtIndex 1 TotallyNotJson.1027; - switch TotallyNotJson.160: - case 34: - let TotallyNotJson.1030 : Int1 = false; - let TotallyNotJson.1029 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1030}; - let TotallyNotJson.1028 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1029; - ret TotallyNotJson.1028; - - case 92: - let TotallyNotJson.1033 : Int1 = false; - let TotallyNotJson.1032 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1033}; - let TotallyNotJson.1031 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1032; - ret TotallyNotJson.1031; - - case 47: - let TotallyNotJson.1036 : Int1 = false; - let TotallyNotJson.1035 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1036}; - let TotallyNotJson.1034 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1035; - ret TotallyNotJson.1034; - - case 8: - let TotallyNotJson.1039 : Int1 = false; - let TotallyNotJson.1038 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1039}; - let TotallyNotJson.1037 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1038; - ret TotallyNotJson.1037; - - case 12: - let TotallyNotJson.1042 : Int1 = false; - let TotallyNotJson.1041 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1042}; - let TotallyNotJson.1040 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1041; - ret TotallyNotJson.1040; - - case 10: - let TotallyNotJson.1045 : Int1 = false; - let TotallyNotJson.1044 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1045}; - let TotallyNotJson.1043 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1044; - ret TotallyNotJson.1043; - - case 13: - let TotallyNotJson.1048 : Int1 = false; - let TotallyNotJson.1047 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1048}; - let TotallyNotJson.1046 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1047; - ret TotallyNotJson.1046; - - case 9: - let TotallyNotJson.1051 : Int1 = false; - let TotallyNotJson.1050 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1051}; - let TotallyNotJson.1049 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1050; - ret TotallyNotJson.1049; - - default: - let TotallyNotJson.1055 : U64 = 1i64; - let TotallyNotJson.1054 : U64 = CallByName Num.19 TotallyNotJson.158 TotallyNotJson.1055; - let TotallyNotJson.1053 : {U64, Int1} = Struct {TotallyNotJson.1054, TotallyNotJson.159}; - let TotallyNotJson.1052 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) TotallyNotJson.1053; - ret TotallyNotJson.1052; - +procedure Test.2 (): + let Test.257 : {} = Struct {}; + ret Test.257; -procedure TotallyNotJson.183 (TotallyNotJson.184, TotallyNotJson.185): - let TotallyNotJson.998 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.185; - let TotallyNotJson.997 : List U8 = CallByName List.8 TotallyNotJson.184 TotallyNotJson.998; - ret TotallyNotJson.997; +procedure Test.3 (Test.48, Test.49, Test.50): + let Test.275 : U8 = CallByName Num.127 Test.49; + let Test.272 : List U8 = CallByName List.4 Test.48 Test.275; + let Test.274 : Str = CallByName Num.96 Test.50; + let Test.273 : List U8 = CallByName Str.12 Test.274; + let Test.270 : List U8 = CallByName List.8 Test.272 Test.273; + let Test.271 : U8 = 32i64; + let Test.269 : List U8 = CallByName List.4 Test.270 Test.271; + ret Test.269; -procedure TotallyNotJson.25 (TotallyNotJson.149): - let TotallyNotJson.974 : Str = CallByName Encode.23 TotallyNotJson.149; - ret TotallyNotJson.974; - -procedure TotallyNotJson.26 (TotallyNotJson.152): - let TotallyNotJson.153 : List U8 = CallByName Str.12 TotallyNotJson.152; - let TotallyNotJson.1056 : U64 = 0i64; - let TotallyNotJson.1057 : Int1 = true; - let TotallyNotJson.154 : {U64, Int1} = Struct {TotallyNotJson.1056, TotallyNotJson.1057}; - let TotallyNotJson.1026 : {} = Struct {}; - inc TotallyNotJson.153; - let TotallyNotJson.155 : {U64, Int1} = CallByName List.26 TotallyNotJson.153 TotallyNotJson.154 TotallyNotJson.1026; - let TotallyNotJson.980 : Int1 = StructAtIndex 1 TotallyNotJson.155; - let TotallyNotJson.1024 : Int1 = true; - let TotallyNotJson.1025 : Int1 = lowlevel Eq TotallyNotJson.1024 TotallyNotJson.980; - if TotallyNotJson.1025 then - let TotallyNotJson.990 : U64 = CallByName List.6 TotallyNotJson.153; - let TotallyNotJson.991 : U64 = 2i64; - let TotallyNotJson.989 : U64 = CallByName Num.19 TotallyNotJson.990 TotallyNotJson.991; - let TotallyNotJson.986 : List U8 = CallByName List.68 TotallyNotJson.989; - let TotallyNotJson.988 : U8 = 34i64; - let TotallyNotJson.987 : List U8 = Array [TotallyNotJson.988]; - let TotallyNotJson.985 : List U8 = CallByName List.8 TotallyNotJson.986 TotallyNotJson.987; - let TotallyNotJson.982 : List U8 = CallByName List.8 TotallyNotJson.985 TotallyNotJson.153; - let TotallyNotJson.984 : U8 = 34i64; - let TotallyNotJson.983 : List U8 = Array [TotallyNotJson.984]; - let TotallyNotJson.981 : List U8 = CallByName List.8 TotallyNotJson.982 TotallyNotJson.983; - ret TotallyNotJson.981; - else - inc TotallyNotJson.153; - let TotallyNotJson.1023 : U64 = StructAtIndex 0 TotallyNotJson.155; - let TotallyNotJson.1022 : {List U8, List U8} = CallByName List.52 TotallyNotJson.153 TotallyNotJson.1023; - let TotallyNotJson.179 : List U8 = StructAtIndex 0 TotallyNotJson.1022; - let TotallyNotJson.181 : List U8 = StructAtIndex 1 TotallyNotJson.1022; - let TotallyNotJson.1020 : U64 = CallByName List.6 TotallyNotJson.153; - dec TotallyNotJson.153; - let TotallyNotJson.1021 : U64 = 120i64; - let TotallyNotJson.1018 : U64 = CallByName Num.21 TotallyNotJson.1020 TotallyNotJson.1021; - let TotallyNotJson.1019 : U64 = 100i64; - let TotallyNotJson.1017 : U64 = CallByName Num.137 TotallyNotJson.1018 TotallyNotJson.1019; - let TotallyNotJson.1014 : List U8 = CallByName List.68 TotallyNotJson.1017; - let TotallyNotJson.1016 : U8 = 34i64; - let TotallyNotJson.1015 : List U8 = Array [TotallyNotJson.1016]; - let TotallyNotJson.1013 : List U8 = CallByName List.8 TotallyNotJson.1014 TotallyNotJson.1015; - let TotallyNotJson.182 : List U8 = CallByName List.8 TotallyNotJson.1013 TotallyNotJson.179; - let TotallyNotJson.996 : {} = Struct {}; - let TotallyNotJson.993 : List U8 = CallByName List.18 TotallyNotJson.181 TotallyNotJson.182 TotallyNotJson.996; - let TotallyNotJson.995 : U8 = 34i64; - let TotallyNotJson.994 : List U8 = Array [TotallyNotJson.995]; - let TotallyNotJson.992 : List U8 = CallByName List.8 TotallyNotJson.993 TotallyNotJson.994; - ret TotallyNotJson.992; - -procedure TotallyNotJson.27 (TotallyNotJson.186): - switch TotallyNotJson.186: - case 34: - let TotallyNotJson.999 : List U8 = Array [92i64, 34i64]; - ret TotallyNotJson.999; - - case 92: - let TotallyNotJson.1000 : List U8 = Array [92i64, 92i64]; - ret TotallyNotJson.1000; - - case 47: - let TotallyNotJson.1001 : List U8 = Array [92i64, 47i64]; - ret TotallyNotJson.1001; - - case 8: - let TotallyNotJson.1003 : U8 = 98i64; - let TotallyNotJson.1002 : List U8 = Array [92i64, TotallyNotJson.1003]; - ret TotallyNotJson.1002; - - case 12: - let TotallyNotJson.1005 : U8 = 102i64; - let TotallyNotJson.1004 : List U8 = Array [92i64, TotallyNotJson.1005]; - ret TotallyNotJson.1004; - - case 10: - let TotallyNotJson.1007 : U8 = 110i64; - let TotallyNotJson.1006 : List U8 = Array [92i64, TotallyNotJson.1007]; - ret TotallyNotJson.1006; - - case 13: - let TotallyNotJson.1009 : U8 = 114i64; - let TotallyNotJson.1008 : List U8 = Array [92i64, TotallyNotJson.1009]; - ret TotallyNotJson.1008; - - case 9: - let TotallyNotJson.1011 : U8 = 114i64; - let TotallyNotJson.1010 : List U8 = Array [92i64, TotallyNotJson.1011]; - ret TotallyNotJson.1010; - - default: - let TotallyNotJson.1012 : List U8 = Array [TotallyNotJson.186]; - ret TotallyNotJson.1012; - - -procedure TotallyNotJson.8 (): - let TotallyNotJson.973 : {} = Struct {}; - ret TotallyNotJson.973; +procedure Test.56 (Test.57, Test.260, Test.55): + let Test.267 : I64 = 115i64; + let Test.268 : U64 = CallByName Str.36 Test.55; + let Test.265 : List U8 = CallByName Test.3 Test.57 Test.267 Test.268; + let Test.266 : List U8 = CallByName Str.12 Test.55; + let Test.263 : List U8 = CallByName List.8 Test.265 Test.266; + let Test.264 : U8 = 32i64; + let Test.262 : List U8 = CallByName List.4 Test.263 Test.264; + ret Test.262; procedure Test.0 (): - let Test.9 : Str = "abc"; - let Test.10 : {} = CallByName TotallyNotJson.8; - let Test.8 : List U8 = CallByName Encode.26 Test.9 Test.10; - let Test.1 : [C {U64, U8}, C Str] = CallByName Str.9 Test.8; - let Test.5 : U8 = 1i64; - let Test.6 : U8 = GetTagId Test.1; - let Test.7 : Int1 = lowlevel Eq Test.5 Test.6; - if Test.7 then - let Test.2 : Str = UnionAtIndex (Id 1) (Index 0) Test.1; - ret Test.2; + let Test.255 : Str = "abc"; + let Test.256 : {} = CallByName Test.2; + let Test.254 : List U8 = CallByName Encode.26 Test.255 Test.256; + let Test.209 : [C {U64, U8}, C Str] = CallByName Str.9 Test.254; + let Test.251 : U8 = 1i64; + let Test.252 : U8 = GetTagId Test.209; + let Test.253 : Int1 = lowlevel Eq Test.251 Test.252; + if Test.253 then + let Test.210 : Str = UnionAtIndex (Id 1) (Index 0) Test.209; + ret Test.210; else - dec Test.1; - let Test.4 : Str = ""; - ret Test.4; + dec Test.209; + let Test.250 : Str = ""; + ret Test.250; 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 b689246b52..b256c0ab53 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt @@ -8,9 +8,9 @@ procedure #Derived.3 (#Derived.4, #Derived.5, #Derived.1): ret #Derived_gen.3; in let #Derived_gen.7 : Str = "A"; - let #Derived_gen.9 : Str = CallByName TotallyNotJson.25 #Derived.1; + let #Derived_gen.9 : Str = CallByName Test.19 #Derived.1; let #Derived_gen.8 : List Str = Array [#Derived_gen.9]; - let #Derived_gen.6 : {Str, List Str} = CallByName TotallyNotJson.31 #Derived_gen.7 #Derived_gen.8; + let #Derived_gen.6 : {List Str, {}} = CallByName Test.23 #Derived_gen.7 #Derived_gen.8; jump #Derived_gen.5 #Derived_gen.6; procedure Encode.23 (Encode.98): @@ -27,12 +27,12 @@ procedure Encode.24 (Encode.99, Encode.107, Encode.101): ret Encode.111; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName TotallyNotJson.231 Encode.99 Encode.101 Encode.107; + let Encode.113 : List U8 = CallByName Test.60 Encode.99 Encode.101 Encode.107; ret Encode.113; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.116 : List U8 = CallByName TotallyNotJson.150 Encode.99 Encode.101 Encode.107; - ret Encode.116; + let Encode.117 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; + ret Encode.117; procedure Encode.26 (Encode.105, Encode.106): let Encode.109 : List U8 = Array []; @@ -40,200 +40,82 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.104 (List.488, List.489, List.490): - let List.657 : U64 = 0i64; - let List.658 : U64 = CallByName List.6 List.488; - let List.656 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.488 List.489 List.490 List.657 List.658; - ret List.656; - -procedure List.18 (List.160, List.161, List.162): - let List.601 : U64 = 0i64; - let List.602 : U64 = CallByName List.6 List.160; - let List.600 : {List U8, U64} = CallByName List.92 List.160 List.161 List.162 List.601 List.602; +procedure List.13 (#Attr.2, #Attr.3): + let List.600 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; ret List.600; procedure List.18 (List.160, List.161, List.162): - let List.613 : U64 = 0i64; - let List.614 : U64 = CallByName List.6 List.160; - let List.612 : List U8 = CallByName List.92 List.160 List.161 List.162 List.613 List.614; - ret List.612; - -procedure List.26 (List.201, List.202, List.203): - let List.650 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.104 List.201 List.202 List.203; - let List.653 : U8 = 1i64; - let List.654 : U8 = GetTagId List.650; - let List.655 : Int1 = lowlevel Eq List.653 List.654; - if List.655 then - let List.204 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.650; - ret List.204; - else - let List.205 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.650; - ret List.205; + let List.575 : U64 = 0i64; + let List.576 : U64 = CallByName List.6 List.160; + let List.574 : List U8 = CallByName List.92 List.160 List.161 List.162 List.575 List.576; + ret List.574; procedure List.4 (List.124, List.125): - let List.599 : U64 = 1i64; - let List.598 : List U8 = CallByName List.70 List.124 List.599; - let List.597 : List U8 = CallByName List.71 List.598 List.125; - ret List.597; - -procedure List.49 (List.420, List.421): - let List.641 : U64 = StructAtIndex 1 List.421; - let List.642 : U64 = StructAtIndex 0 List.421; - let List.640 : List U8 = CallByName List.72 List.420 List.641 List.642; - ret List.640; - -procedure List.52 (List.435, List.436): - let List.437 : U64 = CallByName List.6 List.435; - joinpoint List.648 List.438: - let List.646 : U64 = 0i64; - let List.645 : {U64, U64} = Struct {List.438, List.646}; - inc List.435; - let List.439 : List U8 = CallByName List.49 List.435 List.645; - let List.644 : U64 = CallByName Num.75 List.437 List.438; - let List.639 : {U64, U64} = Struct {List.644, List.438}; - let List.440 : List U8 = CallByName List.49 List.435 List.639; - let List.638 : {List U8, List U8} = Struct {List.439, List.440}; - ret List.638; - in - let List.649 : Int1 = CallByName Num.24 List.437 List.436; - if List.649 then - jump List.648 List.436; - else - jump List.648 List.437; + let List.596 : U64 = 1i64; + let List.595 : List U8 = CallByName List.70 List.124 List.596; + let List.594 : List U8 = CallByName List.71 List.595 List.125; + ret List.594; procedure List.6 (#Attr.2): - let List.624 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.624; - -procedure List.6 (#Attr.2): - let List.626 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.626; + let List.599 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.599; procedure List.66 (#Attr.2, #Attr.3): - let List.610 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.610; - -procedure List.66 (#Attr.2, #Attr.3): - let List.622 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.622; - -procedure List.68 (#Attr.2): - let List.637 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.637; + let List.584 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.584; procedure List.70 (#Attr.2, #Attr.3): - let List.578 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.578; + let List.590 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.590; procedure List.71 (#Attr.2, #Attr.3): - let List.576 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.576; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.643 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.643; + let List.588 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.588; procedure List.8 (#Attr.2, #Attr.3): - let List.635 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.635; + let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.598; -procedure List.80 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): - joinpoint List.659 List.491 List.492 List.493 List.494 List.495: - let List.661 : Int1 = CallByName Num.22 List.494 List.495; - if List.661 then - let List.670 : U8 = CallByName List.66 List.491 List.494; - let List.662 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.157 List.492 List.670; - let List.667 : U8 = 1i64; - let List.668 : U8 = GetTagId List.662; - let List.669 : Int1 = lowlevel Eq List.667 List.668; - if List.669 then - let List.496 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.662; - let List.665 : U64 = 1i64; - let List.664 : U64 = CallByName Num.51 List.494 List.665; - jump List.659 List.491 List.496 List.493 List.664 List.495; - else - dec List.491; - let List.497 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.662; - let List.666 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.497; - ret List.666; - else - dec List.491; - let List.660 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.492; - ret List.660; - in - jump List.659 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; - -procedure List.92 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): - joinpoint List.603 List.163 List.164 List.165 List.166 List.167: - let List.605 : Int1 = CallByName Num.22 List.166 List.167; - if List.605 then - let List.609 : Str = CallByName List.66 List.163 List.166; - inc List.609; - let List.168 : {List U8, U64} = CallByName TotallyNotJson.233 List.164 List.609; - let List.608 : U64 = 1i64; - let List.607 : U64 = CallByName Num.51 List.166 List.608; - jump List.603 List.163 List.168 List.165 List.607 List.167; +procedure List.92 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): + joinpoint List.577 List.163 List.164 List.165 List.166 List.167: + let List.579 : Int1 = CallByName Num.22 List.166 List.167; + if List.579 then + let List.583 : Str = CallByName List.66 List.163 List.166; + inc List.583; + let List.168 : List U8 = CallByName Test.63 List.164 List.583 List.165; + let List.582 : U64 = 1i64; + let List.581 : U64 = CallByName Num.51 List.166 List.582; + jump List.577 List.163 List.168 List.165 List.581 List.167; else dec List.163; ret List.164; in - jump List.603 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; - -procedure List.92 (#Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27): - joinpoint List.615 List.163 List.164 List.165 List.166 List.167: - let List.617 : Int1 = CallByName Num.22 List.166 List.167; - if List.617 then - let List.621 : U8 = CallByName List.66 List.163 List.166; - let List.168 : List U8 = CallByName TotallyNotJson.183 List.164 List.621; - let List.620 : U64 = 1i64; - let List.619 : U64 = CallByName Num.51 List.166 List.620; - jump List.615 List.163 List.168 List.165 List.619 List.167; - else - dec List.163; - ret List.164; - in - jump List.615 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27; + jump List.577 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; procedure Num.127 (#Attr.2): - let Num.286 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.286; - -procedure Num.137 (#Attr.2, #Attr.3): - let Num.291 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; - ret Num.291; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.290 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.290; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.287 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.287; - -procedure Num.21 (#Attr.2, #Attr.3): - let Num.292 : U64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.292; + let Num.280 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.280; procedure Num.22 (#Attr.2, #Attr.3): - let Num.298 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.298; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.300 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.300; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.295 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.295; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; -procedure Num.75 (#Attr.2, #Attr.3): - let Num.299 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.299; +procedure Num.96 (#Attr.2): + let Num.279 : Str = lowlevel NumToStr #Attr.2; + ret Num.279; procedure Str.12 (#Attr.2): let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; ret Str.241; +procedure Str.36 (#Attr.2): + let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.242; + procedure Str.43 (#Attr.2): let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; ret Str.239; @@ -248,253 +130,86 @@ procedure Str.9 (Str.67): else let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.34 : Str = StructAtIndex 1 Str.68; - dec #Derived_gen.34; + let #Derived_gen.27 : Str = StructAtIndex 1 Str.68; + dec #Derived_gen.27; let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; ret Str.232; -procedure TotallyNotJson.150 (TotallyNotJson.151, TotallyNotJson.1017, TotallyNotJson.149): - let TotallyNotJson.1020 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.149; - let TotallyNotJson.1019 : List U8 = CallByName List.8 TotallyNotJson.151 TotallyNotJson.1020; - ret TotallyNotJson.1019; +procedure Test.19 (Test.55): + let Test.296 : Str = CallByName Encode.23 Test.55; + ret Test.296; -procedure TotallyNotJson.157 (TotallyNotJson.1068, TotallyNotJson.160): - let TotallyNotJson.158 : U64 = StructAtIndex 0 TotallyNotJson.1068; - let TotallyNotJson.159 : Int1 = StructAtIndex 1 TotallyNotJson.1068; - switch TotallyNotJson.160: - case 34: - let TotallyNotJson.1071 : Int1 = false; - let TotallyNotJson.1070 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1071}; - let TotallyNotJson.1069 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1070; - ret TotallyNotJson.1069; - - case 92: - let TotallyNotJson.1074 : Int1 = false; - let TotallyNotJson.1073 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1074}; - let TotallyNotJson.1072 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1073; - ret TotallyNotJson.1072; - - case 47: - let TotallyNotJson.1077 : Int1 = false; - let TotallyNotJson.1076 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1077}; - let TotallyNotJson.1075 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1076; - ret TotallyNotJson.1075; - - case 8: - let TotallyNotJson.1080 : Int1 = false; - let TotallyNotJson.1079 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1080}; - let TotallyNotJson.1078 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1079; - ret TotallyNotJson.1078; - - case 12: - let TotallyNotJson.1083 : Int1 = false; - let TotallyNotJson.1082 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1083}; - let TotallyNotJson.1081 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1082; - ret TotallyNotJson.1081; - - case 10: - let TotallyNotJson.1086 : Int1 = false; - let TotallyNotJson.1085 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1086}; - let TotallyNotJson.1084 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1085; - ret TotallyNotJson.1084; - - case 13: - let TotallyNotJson.1089 : Int1 = false; - let TotallyNotJson.1088 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1089}; - let TotallyNotJson.1087 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1088; - ret TotallyNotJson.1087; - - case 9: - let TotallyNotJson.1092 : Int1 = false; - let TotallyNotJson.1091 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1092}; - let TotallyNotJson.1090 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1091; - ret TotallyNotJson.1090; - - default: - let TotallyNotJson.1096 : U64 = 1i64; - let TotallyNotJson.1095 : U64 = CallByName Num.19 TotallyNotJson.158 TotallyNotJson.1096; - let TotallyNotJson.1094 : {U64, Int1} = Struct {TotallyNotJson.1095, TotallyNotJson.159}; - let TotallyNotJson.1093 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) TotallyNotJson.1094; - ret TotallyNotJson.1093; - +procedure Test.2 (): + let Test.258 : {} = Struct {}; + ret Test.258; -procedure TotallyNotJson.183 (TotallyNotJson.184, TotallyNotJson.185): - let TotallyNotJson.1039 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.185; - let TotallyNotJson.1038 : List U8 = CallByName List.8 TotallyNotJson.184 TotallyNotJson.1039; - ret TotallyNotJson.1038; +procedure Test.20 (Test.58, Test.59): + let Test.265 : {List Str, {}} = Struct {Test.58, Test.59}; + let Test.264 : {List Str, {}} = CallByName Encode.23 Test.265; + ret Test.264; -procedure TotallyNotJson.231 (TotallyNotJson.232, TotallyNotJson.976, #Attr.12): - let TotallyNotJson.230 : List Str = StructAtIndex 1 #Attr.12; - let TotallyNotJson.229 : Str = StructAtIndex 0 #Attr.12; - let TotallyNotJson.1014 : I64 = 123i64; - let TotallyNotJson.1013 : U8 = CallByName Num.127 TotallyNotJson.1014; - let TotallyNotJson.1010 : List U8 = CallByName List.4 TotallyNotJson.232 TotallyNotJson.1013; - let TotallyNotJson.1012 : I64 = 34i64; - let TotallyNotJson.1011 : U8 = CallByName Num.127 TotallyNotJson.1012; - let TotallyNotJson.1008 : List U8 = CallByName List.4 TotallyNotJson.1010 TotallyNotJson.1011; - let TotallyNotJson.1009 : List U8 = CallByName Str.12 TotallyNotJson.229; - let TotallyNotJson.1005 : List U8 = CallByName List.8 TotallyNotJson.1008 TotallyNotJson.1009; - let TotallyNotJson.1007 : I64 = 34i64; - let TotallyNotJson.1006 : U8 = CallByName Num.127 TotallyNotJson.1007; - let TotallyNotJson.1002 : List U8 = CallByName List.4 TotallyNotJson.1005 TotallyNotJson.1006; - let TotallyNotJson.1004 : I64 = 58i64; - let TotallyNotJson.1003 : U8 = CallByName Num.127 TotallyNotJson.1004; - let TotallyNotJson.999 : List U8 = CallByName List.4 TotallyNotJson.1002 TotallyNotJson.1003; - let TotallyNotJson.1001 : I64 = 91i64; - let TotallyNotJson.1000 : U8 = CallByName Num.127 TotallyNotJson.1001; - let TotallyNotJson.234 : List U8 = CallByName List.4 TotallyNotJson.999 TotallyNotJson.1000; - let TotallyNotJson.998 : U64 = CallByName List.6 TotallyNotJson.230; - let TotallyNotJson.986 : {List U8, U64} = Struct {TotallyNotJson.234, TotallyNotJson.998}; - let TotallyNotJson.987 : {} = Struct {}; - let TotallyNotJson.985 : {List U8, U64} = CallByName List.18 TotallyNotJson.230 TotallyNotJson.986 TotallyNotJson.987; - let TotallyNotJson.236 : List U8 = StructAtIndex 0 TotallyNotJson.985; - let TotallyNotJson.984 : I64 = 93i64; - let TotallyNotJson.983 : U8 = CallByName Num.127 TotallyNotJson.984; - let TotallyNotJson.980 : List U8 = CallByName List.4 TotallyNotJson.236 TotallyNotJson.983; - let TotallyNotJson.982 : I64 = 125i64; - let TotallyNotJson.981 : U8 = CallByName Num.127 TotallyNotJson.982; - let TotallyNotJson.979 : List U8 = CallByName List.4 TotallyNotJson.980 TotallyNotJson.981; - ret TotallyNotJson.979; +procedure Test.22 (Test.74): + let Test.263 : {} = Struct {}; + let Test.262 : {List Str, {}} = CallByName Test.20 Test.74 Test.263; + ret Test.262; -procedure TotallyNotJson.233 (TotallyNotJson.978, TotallyNotJson.239): - let TotallyNotJson.237 : List U8 = StructAtIndex 0 TotallyNotJson.978; - let TotallyNotJson.238 : U64 = StructAtIndex 1 TotallyNotJson.978; - let TotallyNotJson.997 : {} = Struct {}; - let TotallyNotJson.240 : List U8 = CallByName Encode.24 TotallyNotJson.237 TotallyNotJson.239 TotallyNotJson.997; - joinpoint TotallyNotJson.992 TotallyNotJson.241: - let TotallyNotJson.990 : U64 = 1i64; - let TotallyNotJson.989 : U64 = CallByName Num.20 TotallyNotJson.238 TotallyNotJson.990; - let TotallyNotJson.988 : {List U8, U64} = Struct {TotallyNotJson.241, TotallyNotJson.989}; - ret TotallyNotJson.988; - in - let TotallyNotJson.996 : U64 = 1i64; - let TotallyNotJson.993 : Int1 = CallByName Num.24 TotallyNotJson.238 TotallyNotJson.996; - if TotallyNotJson.993 then - let TotallyNotJson.995 : I64 = 44i64; - let TotallyNotJson.994 : U8 = CallByName Num.127 TotallyNotJson.995; - let TotallyNotJson.991 : List U8 = CallByName List.4 TotallyNotJson.240 TotallyNotJson.994; - jump TotallyNotJson.992 TotallyNotJson.991; - else - jump TotallyNotJson.992 TotallyNotJson.240; +procedure Test.23 (Test.77, Test.78): + let Test.284 : Str = CallByName Test.19 Test.77; + let Test.261 : List Str = CallByName List.13 Test.78 Test.284; + let Test.260 : {List Str, {}} = CallByName Test.22 Test.261; + ret Test.260; -procedure TotallyNotJson.25 (TotallyNotJson.149): - let TotallyNotJson.1015 : Str = CallByName Encode.23 TotallyNotJson.149; - ret TotallyNotJson.1015; +procedure Test.3 (Test.48, Test.49, Test.50): + let Test.282 : U8 = CallByName Num.127 Test.49; + let Test.279 : List U8 = CallByName List.4 Test.48 Test.282; + let Test.281 : Str = CallByName Num.96 Test.50; + let Test.280 : List U8 = CallByName Str.12 Test.281; + let Test.277 : List U8 = CallByName List.8 Test.279 Test.280; + let Test.278 : U8 = 32i64; + let Test.276 : List U8 = CallByName List.4 Test.277 Test.278; + ret Test.276; -procedure TotallyNotJson.26 (TotallyNotJson.152): - let TotallyNotJson.153 : List U8 = CallByName Str.12 TotallyNotJson.152; - let TotallyNotJson.1097 : U64 = 0i64; - let TotallyNotJson.1098 : Int1 = true; - let TotallyNotJson.154 : {U64, Int1} = Struct {TotallyNotJson.1097, TotallyNotJson.1098}; - let TotallyNotJson.1067 : {} = Struct {}; - inc TotallyNotJson.153; - let TotallyNotJson.155 : {U64, Int1} = CallByName List.26 TotallyNotJson.153 TotallyNotJson.154 TotallyNotJson.1067; - let TotallyNotJson.1021 : Int1 = StructAtIndex 1 TotallyNotJson.155; - let TotallyNotJson.1065 : Int1 = true; - let TotallyNotJson.1066 : Int1 = lowlevel Eq TotallyNotJson.1065 TotallyNotJson.1021; - if TotallyNotJson.1066 then - let TotallyNotJson.1031 : U64 = CallByName List.6 TotallyNotJson.153; - let TotallyNotJson.1032 : U64 = 2i64; - let TotallyNotJson.1030 : U64 = CallByName Num.19 TotallyNotJson.1031 TotallyNotJson.1032; - let TotallyNotJson.1027 : List U8 = CallByName List.68 TotallyNotJson.1030; - let TotallyNotJson.1029 : U8 = 34i64; - let TotallyNotJson.1028 : List U8 = Array [TotallyNotJson.1029]; - let TotallyNotJson.1026 : List U8 = CallByName List.8 TotallyNotJson.1027 TotallyNotJson.1028; - let TotallyNotJson.1023 : List U8 = CallByName List.8 TotallyNotJson.1026 TotallyNotJson.153; - let TotallyNotJson.1025 : U8 = 34i64; - let TotallyNotJson.1024 : List U8 = Array [TotallyNotJson.1025]; - let TotallyNotJson.1022 : List U8 = CallByName List.8 TotallyNotJson.1023 TotallyNotJson.1024; - ret TotallyNotJson.1022; - else - inc TotallyNotJson.153; - let TotallyNotJson.1064 : U64 = StructAtIndex 0 TotallyNotJson.155; - let TotallyNotJson.1063 : {List U8, List U8} = CallByName List.52 TotallyNotJson.153 TotallyNotJson.1064; - let TotallyNotJson.179 : List U8 = StructAtIndex 0 TotallyNotJson.1063; - let TotallyNotJson.181 : List U8 = StructAtIndex 1 TotallyNotJson.1063; - let TotallyNotJson.1061 : U64 = CallByName List.6 TotallyNotJson.153; - dec TotallyNotJson.153; - let TotallyNotJson.1062 : U64 = 120i64; - let TotallyNotJson.1059 : U64 = CallByName Num.21 TotallyNotJson.1061 TotallyNotJson.1062; - let TotallyNotJson.1060 : U64 = 100i64; - let TotallyNotJson.1058 : U64 = CallByName Num.137 TotallyNotJson.1059 TotallyNotJson.1060; - let TotallyNotJson.1055 : List U8 = CallByName List.68 TotallyNotJson.1058; - let TotallyNotJson.1057 : U8 = 34i64; - let TotallyNotJson.1056 : List U8 = Array [TotallyNotJson.1057]; - let TotallyNotJson.1054 : List U8 = CallByName List.8 TotallyNotJson.1055 TotallyNotJson.1056; - let TotallyNotJson.182 : List U8 = CallByName List.8 TotallyNotJson.1054 TotallyNotJson.179; - let TotallyNotJson.1037 : {} = Struct {}; - let TotallyNotJson.1034 : List U8 = CallByName List.18 TotallyNotJson.181 TotallyNotJson.182 TotallyNotJson.1037; - let TotallyNotJson.1036 : U8 = 34i64; - let TotallyNotJson.1035 : List U8 = Array [TotallyNotJson.1036]; - let TotallyNotJson.1033 : List U8 = CallByName List.8 TotallyNotJson.1034 TotallyNotJson.1035; - ret TotallyNotJson.1033; +procedure Test.56 (Test.57, Test.287, Test.55): + let Test.294 : I64 = 115i64; + let Test.295 : U64 = CallByName Str.36 Test.55; + let Test.292 : List U8 = CallByName Test.3 Test.57 Test.294 Test.295; + let Test.293 : List U8 = CallByName Str.12 Test.55; + let Test.290 : List U8 = CallByName List.8 Test.292 Test.293; + let Test.291 : U8 = 32i64; + let Test.289 : List U8 = CallByName List.4 Test.290 Test.291; + ret Test.289; -procedure TotallyNotJson.27 (TotallyNotJson.186): - switch TotallyNotJson.186: - case 34: - let TotallyNotJson.1040 : List U8 = Array [92i64, 34i64]; - ret TotallyNotJson.1040; - - case 92: - let TotallyNotJson.1041 : List U8 = Array [92i64, 92i64]; - ret TotallyNotJson.1041; - - case 47: - let TotallyNotJson.1042 : List U8 = Array [92i64, 47i64]; - ret TotallyNotJson.1042; - - case 8: - let TotallyNotJson.1044 : U8 = 98i64; - let TotallyNotJson.1043 : List U8 = Array [92i64, TotallyNotJson.1044]; - ret TotallyNotJson.1043; - - case 12: - let TotallyNotJson.1046 : U8 = 102i64; - let TotallyNotJson.1045 : List U8 = Array [92i64, TotallyNotJson.1046]; - ret TotallyNotJson.1045; - - case 10: - let TotallyNotJson.1048 : U8 = 110i64; - let TotallyNotJson.1047 : List U8 = Array [92i64, TotallyNotJson.1048]; - ret TotallyNotJson.1047; - - case 13: - let TotallyNotJson.1050 : U8 = 114i64; - let TotallyNotJson.1049 : List U8 = Array [92i64, TotallyNotJson.1050]; - ret TotallyNotJson.1049; - - case 9: - let TotallyNotJson.1052 : U8 = 114i64; - let TotallyNotJson.1051 : List U8 = Array [92i64, TotallyNotJson.1052]; - ret TotallyNotJson.1051; - - default: - let TotallyNotJson.1053 : List U8 = Array [TotallyNotJson.186]; - ret TotallyNotJson.1053; - +procedure Test.60 (Test.61, Test.266, #Attr.12): + let Test.59 : {} = StructAtIndex 1 #Attr.12; + let Test.58 : List Str = StructAtIndex 0 #Attr.12; + let Test.274 : I64 = 108i64; + let Test.275 : U64 = CallByName List.6 Test.58; + let Test.62 : List U8 = CallByName Test.3 Test.61 Test.274 Test.275; + let Test.268 : List U8 = CallByName List.18 Test.58 Test.62 Test.59; + ret Test.268; -procedure TotallyNotJson.31 (TotallyNotJson.229, TotallyNotJson.230): - let TotallyNotJson.975 : {Str, List Str} = Struct {TotallyNotJson.229, TotallyNotJson.230}; - let TotallyNotJson.974 : {Str, List Str} = CallByName Encode.23 TotallyNotJson.975; - ret TotallyNotJson.974; +procedure Test.63 (Test.64, Test.65, Test.59): + let Test.272 : Str = CallByName Test.75 Test.65; + let Test.273 : {} = Struct {}; + let Test.271 : List U8 = CallByName Encode.24 Test.64 Test.272 Test.273; + ret Test.271; -procedure TotallyNotJson.8 (): - let TotallyNotJson.973 : {} = Struct {}; - ret TotallyNotJson.973; +procedure Test.75 (Test.76): + ret Test.76; procedure Test.0 (): - let Test.12 : Str = "foo"; - let Test.11 : {} = CallByName TotallyNotJson.8; - let Test.10 : List U8 = CallByName Encode.26 Test.12 Test.11; - let Test.2 : [C {U64, U8}, C Str] = CallByName Str.9 Test.10; - let Test.7 : U8 = 1i64; - let Test.8 : U8 = GetTagId Test.2; - let Test.9 : Int1 = lowlevel Eq Test.7 Test.8; - if Test.9 then - let Test.4 : Str = UnionAtIndex (Id 1) (Index 0) Test.2; - ret Test.4; + let Test.259 : Str = "foo"; + let Test.257 : {} = CallByName Test.2; + let Test.256 : List U8 = CallByName Encode.26 Test.259 Test.257; + let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.256; + let Test.253 : U8 = 1i64; + let Test.254 : U8 = GetTagId Test.210; + let Test.255 : Int1 = lowlevel Eq Test.253 Test.254; + if Test.255 then + let Test.212 : Str = UnionAtIndex (Id 1) (Index 0) Test.210; + ret Test.212; else - dec Test.2; - let Test.6 : Str = ""; - ret Test.6; + dec Test.210; + let Test.252 : Str = ""; + ret Test.252; 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 095270d244..2fd445f303 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt @@ -10,10 +10,10 @@ procedure #Derived.4 (#Derived.5, #Derived.6, #Derived.1): let #Derived.2 : Str = StructAtIndex 0 #Derived.1; let #Derived.3 : Str = StructAtIndex 1 #Derived.1; let #Derived_gen.7 : Str = "A"; - let #Derived_gen.9 : Str = CallByName TotallyNotJson.25 #Derived.2; - let #Derived_gen.10 : Str = CallByName TotallyNotJson.25 #Derived.3; + let #Derived_gen.9 : Str = CallByName Test.19 #Derived.2; + let #Derived_gen.10 : Str = CallByName Test.19 #Derived.3; let #Derived_gen.8 : List Str = Array [#Derived_gen.9, #Derived_gen.10]; - let #Derived_gen.6 : {Str, List Str} = CallByName TotallyNotJson.31 #Derived_gen.7 #Derived_gen.8; + let #Derived_gen.6 : {List Str, {}} = CallByName Test.23 #Derived_gen.7 #Derived_gen.8; jump #Derived_gen.5 #Derived_gen.6; procedure Encode.23 (Encode.98): @@ -30,12 +30,12 @@ procedure Encode.24 (Encode.99, Encode.107, Encode.101): ret Encode.111; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName TotallyNotJson.231 Encode.99 Encode.101 Encode.107; + let Encode.113 : List U8 = CallByName Test.60 Encode.99 Encode.101 Encode.107; ret Encode.113; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.117 : List U8 = CallByName TotallyNotJson.150 Encode.99 Encode.101 Encode.107; - ret Encode.117; + let Encode.118 : List U8 = CallByName Test.56 Encode.99 Encode.101 Encode.107; + ret Encode.118; procedure Encode.26 (Encode.105, Encode.106): let Encode.109 : List U8 = Array []; @@ -43,200 +43,82 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.104 (List.488, List.489, List.490): - let List.657 : U64 = 0i64; - let List.658 : U64 = CallByName List.6 List.488; - let List.656 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.488 List.489 List.490 List.657 List.658; - ret List.656; - -procedure List.18 (List.160, List.161, List.162): - let List.601 : U64 = 0i64; - let List.602 : U64 = CallByName List.6 List.160; - let List.600 : {List U8, U64} = CallByName List.92 List.160 List.161 List.162 List.601 List.602; +procedure List.13 (#Attr.2, #Attr.3): + let List.600 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; ret List.600; procedure List.18 (List.160, List.161, List.162): - let List.613 : U64 = 0i64; - let List.614 : U64 = CallByName List.6 List.160; - let List.612 : List U8 = CallByName List.92 List.160 List.161 List.162 List.613 List.614; - ret List.612; - -procedure List.26 (List.201, List.202, List.203): - let List.650 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.104 List.201 List.202 List.203; - let List.653 : U8 = 1i64; - let List.654 : U8 = GetTagId List.650; - let List.655 : Int1 = lowlevel Eq List.653 List.654; - if List.655 then - let List.204 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.650; - ret List.204; - else - let List.205 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.650; - ret List.205; + let List.575 : U64 = 0i64; + let List.576 : U64 = CallByName List.6 List.160; + let List.574 : List U8 = CallByName List.92 List.160 List.161 List.162 List.575 List.576; + ret List.574; procedure List.4 (List.124, List.125): - let List.599 : U64 = 1i64; - let List.598 : List U8 = CallByName List.70 List.124 List.599; - let List.597 : List U8 = CallByName List.71 List.598 List.125; - ret List.597; - -procedure List.49 (List.420, List.421): - let List.641 : U64 = StructAtIndex 1 List.421; - let List.642 : U64 = StructAtIndex 0 List.421; - let List.640 : List U8 = CallByName List.72 List.420 List.641 List.642; - ret List.640; - -procedure List.52 (List.435, List.436): - let List.437 : U64 = CallByName List.6 List.435; - joinpoint List.648 List.438: - let List.646 : U64 = 0i64; - let List.645 : {U64, U64} = Struct {List.438, List.646}; - inc List.435; - let List.439 : List U8 = CallByName List.49 List.435 List.645; - let List.644 : U64 = CallByName Num.75 List.437 List.438; - let List.639 : {U64, U64} = Struct {List.644, List.438}; - let List.440 : List U8 = CallByName List.49 List.435 List.639; - let List.638 : {List U8, List U8} = Struct {List.439, List.440}; - ret List.638; - in - let List.649 : Int1 = CallByName Num.24 List.437 List.436; - if List.649 then - jump List.648 List.436; - else - jump List.648 List.437; + let List.596 : U64 = 1i64; + let List.595 : List U8 = CallByName List.70 List.124 List.596; + let List.594 : List U8 = CallByName List.71 List.595 List.125; + ret List.594; procedure List.6 (#Attr.2): - let List.624 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.624; - -procedure List.6 (#Attr.2): - let List.626 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.626; + let List.599 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.599; procedure List.66 (#Attr.2, #Attr.3): - let List.610 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.610; - -procedure List.66 (#Attr.2, #Attr.3): - let List.622 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.622; - -procedure List.68 (#Attr.2): - let List.637 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.637; + let List.584 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.584; procedure List.70 (#Attr.2, #Attr.3): - let List.578 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.578; + let List.590 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.590; procedure List.71 (#Attr.2, #Attr.3): - let List.576 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.576; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.643 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.643; + let List.588 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.588; procedure List.8 (#Attr.2, #Attr.3): - let List.635 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.635; - -procedure List.80 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): - joinpoint List.659 List.491 List.492 List.493 List.494 List.495: - let List.661 : Int1 = CallByName Num.22 List.494 List.495; - if List.661 then - let List.670 : U8 = CallByName List.66 List.491 List.494; - let List.662 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.157 List.492 List.670; - let List.667 : U8 = 1i64; - let List.668 : U8 = GetTagId List.662; - let List.669 : Int1 = lowlevel Eq List.667 List.668; - if List.669 then - let List.496 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.662; - let List.665 : U64 = 1i64; - let List.664 : U64 = CallByName Num.51 List.494 List.665; - jump List.659 List.491 List.496 List.493 List.664 List.495; - else - dec List.491; - let List.497 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.662; - let List.666 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.497; - ret List.666; - else - dec List.491; - let List.660 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.492; - ret List.660; - in - jump List.659 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; + let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.598; procedure List.92 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): - joinpoint List.615 List.163 List.164 List.165 List.166 List.167: - let List.617 : Int1 = CallByName Num.22 List.166 List.167; - if List.617 then - let List.621 : U8 = CallByName List.66 List.163 List.166; - let List.168 : List U8 = CallByName TotallyNotJson.183 List.164 List.621; - let List.620 : U64 = 1i64; - let List.619 : U64 = CallByName Num.51 List.166 List.620; - jump List.615 List.163 List.168 List.165 List.619 List.167; + joinpoint List.577 List.163 List.164 List.165 List.166 List.167: + let List.579 : Int1 = CallByName Num.22 List.166 List.167; + if List.579 then + let List.583 : Str = CallByName List.66 List.163 List.166; + inc List.583; + let List.168 : List U8 = CallByName Test.63 List.164 List.583 List.165; + let List.582 : U64 = 1i64; + let List.581 : U64 = CallByName Num.51 List.166 List.582; + jump List.577 List.163 List.168 List.165 List.581 List.167; else dec List.163; ret List.164; in - jump List.615 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; - -procedure List.92 (#Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34): - joinpoint List.603 List.163 List.164 List.165 List.166 List.167: - let List.605 : Int1 = CallByName Num.22 List.166 List.167; - if List.605 then - let List.609 : Str = CallByName List.66 List.163 List.166; - inc List.609; - let List.168 : {List U8, U64} = CallByName TotallyNotJson.233 List.164 List.609; - let List.608 : U64 = 1i64; - let List.607 : U64 = CallByName Num.51 List.166 List.608; - jump List.603 List.163 List.168 List.165 List.607 List.167; - else - dec List.163; - ret List.164; - in - jump List.603 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34; + jump List.577 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; procedure Num.127 (#Attr.2): - let Num.286 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.286; - -procedure Num.137 (#Attr.2, #Attr.3): - let Num.291 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; - ret Num.291; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.290 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.290; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.287 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.287; - -procedure Num.21 (#Attr.2, #Attr.3): - let Num.292 : U64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.292; + let Num.280 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.280; procedure Num.22 (#Attr.2, #Attr.3): - let Num.298 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.298; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.300 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.300; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.295 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.295; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; -procedure Num.75 (#Attr.2, #Attr.3): - let Num.299 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.299; +procedure Num.96 (#Attr.2): + let Num.279 : Str = lowlevel NumToStr #Attr.2; + ret Num.279; procedure Str.12 (#Attr.2): let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; ret Str.241; +procedure Str.36 (#Attr.2): + let Str.242 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.242; + procedure Str.43 (#Attr.2): let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; ret Str.239; @@ -251,255 +133,88 @@ procedure Str.9 (Str.67): else let Str.234 : U8 = StructAtIndex 3 Str.68; let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.35 : Str = StructAtIndex 1 Str.68; - dec #Derived_gen.35; + let #Derived_gen.28 : Str = StructAtIndex 1 Str.68; + dec #Derived_gen.28; let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; ret Str.232; -procedure TotallyNotJson.150 (TotallyNotJson.151, TotallyNotJson.1017, TotallyNotJson.149): - let TotallyNotJson.1020 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.149; - let TotallyNotJson.1019 : List U8 = CallByName List.8 TotallyNotJson.151 TotallyNotJson.1020; - ret TotallyNotJson.1019; +procedure Test.19 (Test.55): + let Test.300 : Str = CallByName Encode.23 Test.55; + ret Test.300; -procedure TotallyNotJson.157 (TotallyNotJson.1068, TotallyNotJson.160): - let TotallyNotJson.158 : U64 = StructAtIndex 0 TotallyNotJson.1068; - let TotallyNotJson.159 : Int1 = StructAtIndex 1 TotallyNotJson.1068; - switch TotallyNotJson.160: - case 34: - let TotallyNotJson.1071 : Int1 = false; - let TotallyNotJson.1070 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1071}; - let TotallyNotJson.1069 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1070; - ret TotallyNotJson.1069; - - case 92: - let TotallyNotJson.1074 : Int1 = false; - let TotallyNotJson.1073 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1074}; - let TotallyNotJson.1072 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1073; - ret TotallyNotJson.1072; - - case 47: - let TotallyNotJson.1077 : Int1 = false; - let TotallyNotJson.1076 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1077}; - let TotallyNotJson.1075 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1076; - ret TotallyNotJson.1075; - - case 8: - let TotallyNotJson.1080 : Int1 = false; - let TotallyNotJson.1079 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1080}; - let TotallyNotJson.1078 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1079; - ret TotallyNotJson.1078; - - case 12: - let TotallyNotJson.1083 : Int1 = false; - let TotallyNotJson.1082 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1083}; - let TotallyNotJson.1081 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1082; - ret TotallyNotJson.1081; - - case 10: - let TotallyNotJson.1086 : Int1 = false; - let TotallyNotJson.1085 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1086}; - let TotallyNotJson.1084 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1085; - ret TotallyNotJson.1084; - - case 13: - let TotallyNotJson.1089 : Int1 = false; - let TotallyNotJson.1088 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1089}; - let TotallyNotJson.1087 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1088; - ret TotallyNotJson.1087; - - case 9: - let TotallyNotJson.1092 : Int1 = false; - let TotallyNotJson.1091 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1092}; - let TotallyNotJson.1090 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1091; - ret TotallyNotJson.1090; - - default: - let TotallyNotJson.1096 : U64 = 1i64; - let TotallyNotJson.1095 : U64 = CallByName Num.19 TotallyNotJson.158 TotallyNotJson.1096; - let TotallyNotJson.1094 : {U64, Int1} = Struct {TotallyNotJson.1095, TotallyNotJson.159}; - let TotallyNotJson.1093 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) TotallyNotJson.1094; - ret TotallyNotJson.1093; - +procedure Test.2 (): + let Test.258 : {} = Struct {}; + ret Test.258; -procedure TotallyNotJson.183 (TotallyNotJson.184, TotallyNotJson.185): - let TotallyNotJson.1039 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.185; - let TotallyNotJson.1038 : List U8 = CallByName List.8 TotallyNotJson.184 TotallyNotJson.1039; - ret TotallyNotJson.1038; +procedure Test.20 (Test.58, Test.59): + let Test.266 : {List Str, {}} = Struct {Test.58, Test.59}; + let Test.265 : {List Str, {}} = CallByName Encode.23 Test.266; + ret Test.265; -procedure TotallyNotJson.231 (TotallyNotJson.232, TotallyNotJson.976, #Attr.12): - let TotallyNotJson.230 : List Str = StructAtIndex 1 #Attr.12; - let TotallyNotJson.229 : Str = StructAtIndex 0 #Attr.12; - let TotallyNotJson.1014 : I64 = 123i64; - let TotallyNotJson.1013 : U8 = CallByName Num.127 TotallyNotJson.1014; - let TotallyNotJson.1010 : List U8 = CallByName List.4 TotallyNotJson.232 TotallyNotJson.1013; - let TotallyNotJson.1012 : I64 = 34i64; - let TotallyNotJson.1011 : U8 = CallByName Num.127 TotallyNotJson.1012; - let TotallyNotJson.1008 : List U8 = CallByName List.4 TotallyNotJson.1010 TotallyNotJson.1011; - let TotallyNotJson.1009 : List U8 = CallByName Str.12 TotallyNotJson.229; - let TotallyNotJson.1005 : List U8 = CallByName List.8 TotallyNotJson.1008 TotallyNotJson.1009; - let TotallyNotJson.1007 : I64 = 34i64; - let TotallyNotJson.1006 : U8 = CallByName Num.127 TotallyNotJson.1007; - let TotallyNotJson.1002 : List U8 = CallByName List.4 TotallyNotJson.1005 TotallyNotJson.1006; - let TotallyNotJson.1004 : I64 = 58i64; - let TotallyNotJson.1003 : U8 = CallByName Num.127 TotallyNotJson.1004; - let TotallyNotJson.999 : List U8 = CallByName List.4 TotallyNotJson.1002 TotallyNotJson.1003; - let TotallyNotJson.1001 : I64 = 91i64; - let TotallyNotJson.1000 : U8 = CallByName Num.127 TotallyNotJson.1001; - let TotallyNotJson.234 : List U8 = CallByName List.4 TotallyNotJson.999 TotallyNotJson.1000; - let TotallyNotJson.998 : U64 = CallByName List.6 TotallyNotJson.230; - let TotallyNotJson.986 : {List U8, U64} = Struct {TotallyNotJson.234, TotallyNotJson.998}; - let TotallyNotJson.987 : {} = Struct {}; - let TotallyNotJson.985 : {List U8, U64} = CallByName List.18 TotallyNotJson.230 TotallyNotJson.986 TotallyNotJson.987; - let TotallyNotJson.236 : List U8 = StructAtIndex 0 TotallyNotJson.985; - let TotallyNotJson.984 : I64 = 93i64; - let TotallyNotJson.983 : U8 = CallByName Num.127 TotallyNotJson.984; - let TotallyNotJson.980 : List U8 = CallByName List.4 TotallyNotJson.236 TotallyNotJson.983; - let TotallyNotJson.982 : I64 = 125i64; - let TotallyNotJson.981 : U8 = CallByName Num.127 TotallyNotJson.982; - let TotallyNotJson.979 : List U8 = CallByName List.4 TotallyNotJson.980 TotallyNotJson.981; - ret TotallyNotJson.979; +procedure Test.22 (Test.74): + let Test.264 : {} = Struct {}; + let Test.263 : {List Str, {}} = CallByName Test.20 Test.74 Test.264; + ret Test.263; -procedure TotallyNotJson.233 (TotallyNotJson.978, TotallyNotJson.239): - let TotallyNotJson.237 : List U8 = StructAtIndex 0 TotallyNotJson.978; - let TotallyNotJson.238 : U64 = StructAtIndex 1 TotallyNotJson.978; - let TotallyNotJson.997 : {} = Struct {}; - let TotallyNotJson.240 : List U8 = CallByName Encode.24 TotallyNotJson.237 TotallyNotJson.239 TotallyNotJson.997; - joinpoint TotallyNotJson.992 TotallyNotJson.241: - let TotallyNotJson.990 : U64 = 1i64; - let TotallyNotJson.989 : U64 = CallByName Num.20 TotallyNotJson.238 TotallyNotJson.990; - let TotallyNotJson.988 : {List U8, U64} = Struct {TotallyNotJson.241, TotallyNotJson.989}; - ret TotallyNotJson.988; - in - let TotallyNotJson.996 : U64 = 1i64; - let TotallyNotJson.993 : Int1 = CallByName Num.24 TotallyNotJson.238 TotallyNotJson.996; - if TotallyNotJson.993 then - let TotallyNotJson.995 : I64 = 44i64; - let TotallyNotJson.994 : U8 = CallByName Num.127 TotallyNotJson.995; - let TotallyNotJson.991 : List U8 = CallByName List.4 TotallyNotJson.240 TotallyNotJson.994; - jump TotallyNotJson.992 TotallyNotJson.991; - else - jump TotallyNotJson.992 TotallyNotJson.240; +procedure Test.23 (Test.77, Test.78): + let Test.285 : Str = CallByName Test.19 Test.77; + let Test.262 : List Str = CallByName List.13 Test.78 Test.285; + let Test.261 : {List Str, {}} = CallByName Test.22 Test.262; + ret Test.261; -procedure TotallyNotJson.25 (TotallyNotJson.149): - let TotallyNotJson.1099 : Str = CallByName Encode.23 TotallyNotJson.149; - ret TotallyNotJson.1099; +procedure Test.3 (Test.48, Test.49, Test.50): + let Test.283 : U8 = CallByName Num.127 Test.49; + let Test.280 : List U8 = CallByName List.4 Test.48 Test.283; + let Test.282 : Str = CallByName Num.96 Test.50; + let Test.281 : List U8 = CallByName Str.12 Test.282; + let Test.278 : List U8 = CallByName List.8 Test.280 Test.281; + let Test.279 : U8 = 32i64; + let Test.277 : List U8 = CallByName List.4 Test.278 Test.279; + ret Test.277; -procedure TotallyNotJson.26 (TotallyNotJson.152): - let TotallyNotJson.153 : List U8 = CallByName Str.12 TotallyNotJson.152; - let TotallyNotJson.1097 : U64 = 0i64; - let TotallyNotJson.1098 : Int1 = true; - let TotallyNotJson.154 : {U64, Int1} = Struct {TotallyNotJson.1097, TotallyNotJson.1098}; - let TotallyNotJson.1067 : {} = Struct {}; - inc TotallyNotJson.153; - let TotallyNotJson.155 : {U64, Int1} = CallByName List.26 TotallyNotJson.153 TotallyNotJson.154 TotallyNotJson.1067; - let TotallyNotJson.1021 : Int1 = StructAtIndex 1 TotallyNotJson.155; - let TotallyNotJson.1065 : Int1 = true; - let TotallyNotJson.1066 : Int1 = lowlevel Eq TotallyNotJson.1065 TotallyNotJson.1021; - if TotallyNotJson.1066 then - let TotallyNotJson.1031 : U64 = CallByName List.6 TotallyNotJson.153; - let TotallyNotJson.1032 : U64 = 2i64; - let TotallyNotJson.1030 : U64 = CallByName Num.19 TotallyNotJson.1031 TotallyNotJson.1032; - let TotallyNotJson.1027 : List U8 = CallByName List.68 TotallyNotJson.1030; - let TotallyNotJson.1029 : U8 = 34i64; - let TotallyNotJson.1028 : List U8 = Array [TotallyNotJson.1029]; - let TotallyNotJson.1026 : List U8 = CallByName List.8 TotallyNotJson.1027 TotallyNotJson.1028; - let TotallyNotJson.1023 : List U8 = CallByName List.8 TotallyNotJson.1026 TotallyNotJson.153; - let TotallyNotJson.1025 : U8 = 34i64; - let TotallyNotJson.1024 : List U8 = Array [TotallyNotJson.1025]; - let TotallyNotJson.1022 : List U8 = CallByName List.8 TotallyNotJson.1023 TotallyNotJson.1024; - ret TotallyNotJson.1022; - else - inc TotallyNotJson.153; - let TotallyNotJson.1064 : U64 = StructAtIndex 0 TotallyNotJson.155; - let TotallyNotJson.1063 : {List U8, List U8} = CallByName List.52 TotallyNotJson.153 TotallyNotJson.1064; - let TotallyNotJson.179 : List U8 = StructAtIndex 0 TotallyNotJson.1063; - let TotallyNotJson.181 : List U8 = StructAtIndex 1 TotallyNotJson.1063; - let TotallyNotJson.1061 : U64 = CallByName List.6 TotallyNotJson.153; - dec TotallyNotJson.153; - let TotallyNotJson.1062 : U64 = 120i64; - let TotallyNotJson.1059 : U64 = CallByName Num.21 TotallyNotJson.1061 TotallyNotJson.1062; - let TotallyNotJson.1060 : U64 = 100i64; - let TotallyNotJson.1058 : U64 = CallByName Num.137 TotallyNotJson.1059 TotallyNotJson.1060; - let TotallyNotJson.1055 : List U8 = CallByName List.68 TotallyNotJson.1058; - let TotallyNotJson.1057 : U8 = 34i64; - let TotallyNotJson.1056 : List U8 = Array [TotallyNotJson.1057]; - let TotallyNotJson.1054 : List U8 = CallByName List.8 TotallyNotJson.1055 TotallyNotJson.1056; - let TotallyNotJson.182 : List U8 = CallByName List.8 TotallyNotJson.1054 TotallyNotJson.179; - let TotallyNotJson.1037 : {} = Struct {}; - let TotallyNotJson.1034 : List U8 = CallByName List.18 TotallyNotJson.181 TotallyNotJson.182 TotallyNotJson.1037; - let TotallyNotJson.1036 : U8 = 34i64; - let TotallyNotJson.1035 : List U8 = Array [TotallyNotJson.1036]; - let TotallyNotJson.1033 : List U8 = CallByName List.8 TotallyNotJson.1034 TotallyNotJson.1035; - ret TotallyNotJson.1033; +procedure Test.56 (Test.57, Test.288, Test.55): + let Test.295 : I64 = 115i64; + let Test.296 : U64 = CallByName Str.36 Test.55; + let Test.293 : List U8 = CallByName Test.3 Test.57 Test.295 Test.296; + let Test.294 : List U8 = CallByName Str.12 Test.55; + let Test.291 : List U8 = CallByName List.8 Test.293 Test.294; + let Test.292 : U8 = 32i64; + let Test.290 : List U8 = CallByName List.4 Test.291 Test.292; + ret Test.290; -procedure TotallyNotJson.27 (TotallyNotJson.186): - switch TotallyNotJson.186: - case 34: - let TotallyNotJson.1040 : List U8 = Array [92i64, 34i64]; - ret TotallyNotJson.1040; - - case 92: - let TotallyNotJson.1041 : List U8 = Array [92i64, 92i64]; - ret TotallyNotJson.1041; - - case 47: - let TotallyNotJson.1042 : List U8 = Array [92i64, 47i64]; - ret TotallyNotJson.1042; - - case 8: - let TotallyNotJson.1044 : U8 = 98i64; - let TotallyNotJson.1043 : List U8 = Array [92i64, TotallyNotJson.1044]; - ret TotallyNotJson.1043; - - case 12: - let TotallyNotJson.1046 : U8 = 102i64; - let TotallyNotJson.1045 : List U8 = Array [92i64, TotallyNotJson.1046]; - ret TotallyNotJson.1045; - - case 10: - let TotallyNotJson.1048 : U8 = 110i64; - let TotallyNotJson.1047 : List U8 = Array [92i64, TotallyNotJson.1048]; - ret TotallyNotJson.1047; - - case 13: - let TotallyNotJson.1050 : U8 = 114i64; - let TotallyNotJson.1049 : List U8 = Array [92i64, TotallyNotJson.1050]; - ret TotallyNotJson.1049; - - case 9: - let TotallyNotJson.1052 : U8 = 114i64; - let TotallyNotJson.1051 : List U8 = Array [92i64, TotallyNotJson.1052]; - ret TotallyNotJson.1051; - - default: - let TotallyNotJson.1053 : List U8 = Array [TotallyNotJson.186]; - ret TotallyNotJson.1053; - +procedure Test.60 (Test.61, Test.267, #Attr.12): + let Test.59 : {} = StructAtIndex 1 #Attr.12; + let Test.58 : List Str = StructAtIndex 0 #Attr.12; + let Test.275 : I64 = 108i64; + let Test.276 : U64 = CallByName List.6 Test.58; + let Test.62 : List U8 = CallByName Test.3 Test.61 Test.275 Test.276; + let Test.269 : List U8 = CallByName List.18 Test.58 Test.62 Test.59; + ret Test.269; -procedure TotallyNotJson.31 (TotallyNotJson.229, TotallyNotJson.230): - let TotallyNotJson.975 : {Str, List Str} = Struct {TotallyNotJson.229, TotallyNotJson.230}; - let TotallyNotJson.974 : {Str, List Str} = CallByName Encode.23 TotallyNotJson.975; - ret TotallyNotJson.974; +procedure Test.63 (Test.64, Test.65, Test.59): + let Test.273 : Str = CallByName Test.75 Test.65; + let Test.274 : {} = Struct {}; + let Test.272 : List U8 = CallByName Encode.24 Test.64 Test.273 Test.274; + ret Test.272; -procedure TotallyNotJson.8 (): - let TotallyNotJson.973 : {} = Struct {}; - ret TotallyNotJson.973; +procedure Test.75 (Test.76): + ret Test.76; procedure Test.0 (): - let Test.13 : Str = "foo"; - let Test.12 : Str = "foo"; - let Test.1 : {Str, Str} = Struct {Test.12, Test.13}; - let Test.11 : {} = CallByName TotallyNotJson.8; - let Test.10 : List U8 = CallByName Encode.26 Test.1 Test.11; - let Test.2 : [C {U64, U8}, C Str] = CallByName Str.9 Test.10; - let Test.7 : U8 = 1i64; - let Test.8 : U8 = GetTagId Test.2; - let Test.9 : Int1 = lowlevel Eq Test.7 Test.8; - if Test.9 then - let Test.4 : Str = UnionAtIndex (Id 1) (Index 0) Test.2; - ret Test.4; + let Test.260 : Str = "foo"; + let Test.259 : Str = "foo"; + let Test.209 : {Str, Str} = Struct {Test.259, Test.260}; + let Test.257 : {} = CallByName Test.2; + let Test.256 : List U8 = CallByName Encode.26 Test.209 Test.257; + let Test.210 : [C {U64, U8}, C Str] = CallByName Str.9 Test.256; + let Test.253 : U8 = 1i64; + let Test.254 : U8 = GetTagId Test.210; + let Test.255 : Int1 = lowlevel Eq Test.253 Test.254; + if Test.255 then + let Test.212 : Str = UnionAtIndex (Id 1) (Index 0) Test.210; + ret Test.212; else - dec Test.2; - let Test.6 : Str = ""; - ret Test.6; + dec Test.210; + let Test.252 : Str = ""; + ret Test.252; diff --git a/crates/compiler/test_mono/generated/issue_4749.txt b/crates/compiler/test_mono/generated/issue_4749.txt index caf7a6ced8..e8681d1433 100644 --- a/crates/compiler/test_mono/generated/issue_4749.txt +++ b/crates/compiler/test_mono/generated/issue_4749.txt @@ -1,823 +1,17 @@ -procedure Bool.1 (): - let Bool.51 : Int1 = false; - ret Bool.51; +procedure Bool.12 (#Attr.2, #Attr.3): + let Bool.24 : Int1 = lowlevel NotEq #Attr.2 #Attr.3; + ret Bool.24; -procedure Bool.11 (#Attr.2, #Attr.3): - let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; +procedure Bool.7 (Bool.19, Bool.20): + let Bool.23 : Int1 = CallByName Bool.12 Bool.19 Bool.20; ret Bool.23; -procedure Bool.11 (#Attr.2, #Attr.3): - let Bool.42 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.42; - -procedure Bool.11 (#Attr.2, #Attr.3): - let Bool.54 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.54; - -procedure Bool.2 (): - let Bool.50 : Int1 = true; - ret Bool.50; - -procedure Bool.3 (#Attr.2, #Attr.3): - let Bool.33 : Int1 = lowlevel And #Attr.2 #Attr.3; - ret Bool.33; - -procedure Bool.4 (#Attr.2, #Attr.3): - let Bool.53 : Int1 = lowlevel Or #Attr.2 #Attr.3; - ret Bool.53; - -procedure Decode.24 (Decode.101): - ret Decode.101; - -procedure Decode.25 (Decode.102, Decode.121, Decode.104): - let Decode.134 : {List U8, [C {}, C Str]} = CallByName TotallyNotJson.491 Decode.102 Decode.104; - ret Decode.134; - -procedure Decode.26 (Decode.105, Decode.106): - let Decode.133 : {} = CallByName TotallyNotJson.59; - let Decode.132 : {List U8, [C {}, C Str]} = CallByName Decode.25 Decode.105 Decode.133 Decode.106; - ret Decode.132; - -procedure Decode.27 (Decode.107, Decode.108): - let Decode.122 : {List U8, [C {}, C Str]} = CallByName Decode.26 Decode.107 Decode.108; - let Decode.110 : List U8 = StructAtIndex 0 Decode.122; - inc Decode.110; - let Decode.109 : [C {}, C Str] = StructAtIndex 1 Decode.122; - let Decode.125 : Int1 = CallByName List.1 Decode.110; - if Decode.125 then - dec Decode.110; - let Decode.129 : U8 = 1i64; - let Decode.130 : U8 = GetTagId Decode.109; - let Decode.131 : Int1 = lowlevel Eq Decode.129 Decode.130; - if Decode.131 then - let Decode.111 : Str = UnionAtIndex (Id 1) (Index 0) Decode.109; - let Decode.126 : [C [C List U8, C ], C Str] = TagId(1) Decode.111; - ret Decode.126; - else - dec Decode.109; - let Decode.128 : [C List U8, C ] = TagId(1) ; - let Decode.127 : [C [C List U8, C ], C Str] = TagId(0) Decode.128; - ret Decode.127; - else - dec Decode.109; - let Decode.124 : [C List U8, C ] = TagId(0) Decode.110; - let Decode.123 : [C [C List U8, C ], C Str] = TagId(0) Decode.124; - ret Decode.123; - -procedure List.1 (List.107): - let List.628 : U64 = CallByName List.6 List.107; - dec List.107; - let List.629 : U64 = 0i64; - let List.627 : Int1 = CallByName Bool.11 List.628 List.629; - ret List.627; - -procedure List.104 (List.488, List.489, List.490): - let List.637 : U64 = 0i64; - let List.638 : U64 = CallByName List.6 List.488; - let List.636 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.488 List.489 List.490 List.637 List.638; - ret List.636; - -procedure List.2 (List.108, List.109): - let List.619 : U64 = CallByName List.6 List.108; - let List.616 : Int1 = CallByName Num.22 List.109 List.619; - if List.616 then - let List.618 : U8 = CallByName List.66 List.108 List.109; - dec List.108; - let List.617 : [C {}, C U8] = TagId(1) List.618; - ret List.617; - else - dec List.108; - let List.615 : {} = Struct {}; - let List.614 : [C {}, C U8] = TagId(0) List.615; - ret List.614; - -procedure List.26 (List.201, List.202, List.203): - let List.630 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.104 List.201 List.202 List.203; - let List.633 : U8 = 1i64; - let List.634 : U8 = GetTagId List.630; - let List.635 : Int1 = lowlevel Eq List.633 List.634; - if List.635 then - let List.204 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.630; - ret List.204; - else - let List.205 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.630; - ret List.205; - -procedure List.38 (List.344, List.345): - let List.596 : U64 = CallByName List.6 List.344; - let List.346 : U64 = CallByName Num.77 List.596 List.345; - let List.595 : List U8 = CallByName List.43 List.344 List.346; - ret List.595; - -procedure List.4 (List.124, List.125): - let List.606 : U64 = 1i64; - let List.605 : List U8 = CallByName List.70 List.124 List.606; - let List.604 : List U8 = CallByName List.71 List.605 List.125; - ret List.604; - -procedure List.43 (List.342, List.343): - let List.586 : U64 = CallByName List.6 List.342; - let List.585 : U64 = CallByName Num.77 List.586 List.343; - let List.580 : {U64, U64} = Struct {List.343, List.585}; - let List.579 : List U8 = CallByName List.49 List.342 List.580; - ret List.579; - -procedure List.49 (List.420, List.421): - let List.624 : U64 = StructAtIndex 1 List.421; - let List.625 : U64 = StructAtIndex 0 List.421; - let List.623 : List U8 = CallByName List.72 List.420 List.624 List.625; - ret List.623; - -procedure List.6 (#Attr.2): - let List.626 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.626; - -procedure List.66 (#Attr.2, #Attr.3): - let List.612 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.612; - -procedure List.70 (#Attr.2, #Attr.3): - let List.603 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.603; - -procedure List.71 (#Attr.2, #Attr.3): - let List.601 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.601; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.584 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.584; - -procedure List.8 (#Attr.2, #Attr.3): - let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.598; - -procedure List.80 (#Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4, #Derived_gen.5): - joinpoint List.639 List.491 List.492 List.493 List.494 List.495: - let List.641 : Int1 = CallByName Num.22 List.494 List.495; - if List.641 then - let List.650 : U8 = CallByName List.66 List.491 List.494; - let List.642 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.61 List.492 List.650; - let List.647 : U8 = 1i64; - let List.648 : U8 = GetTagId List.642; - let List.649 : Int1 = lowlevel Eq List.647 List.648; - if List.649 then - let List.496 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.642; - let List.645 : U64 = 1i64; - let List.644 : U64 = CallByName Num.51 List.494 List.645; - jump List.639 List.491 List.496 List.493 List.644 List.495; - else - dec List.491; - let List.497 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.642; - let List.646 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.497; - ret List.646; - else - dec List.491; - let List.640 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.492; - ret List.640; - in - jump List.639 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.282 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.282; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.291 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.291; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.294 : U8 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.294; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.316 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.316; - -procedure Num.23 (#Attr.2, #Attr.3): - let Num.300 : Int1 = lowlevel NumLte #Attr.2 #Attr.3; - ret Num.300; - -procedure Num.25 (#Attr.2, #Attr.3): - let Num.306 : Int1 = lowlevel NumGte #Attr.2 #Attr.3; - ret Num.306; - -procedure Num.51 (#Attr.2, #Attr.3): - let Num.317 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.317; - -procedure Num.71 (#Attr.2, #Attr.3): - let Num.279 : U8 = lowlevel NumBitwiseOr #Attr.2 #Attr.3; - ret Num.279; - -procedure Num.72 (#Attr.2, #Attr.3): - let Num.280 : U8 = lowlevel NumShiftLeftBy #Attr.2 #Attr.3; - ret Num.280; - -procedure Num.77 (#Attr.2, #Attr.3): - let Num.313 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3; - ret Num.313; - -procedure Str.43 (#Attr.2): - let Str.239 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; - ret Str.239; - -procedure Str.9 (Str.67): - let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; - let Str.236 : Int1 = StructAtIndex 2 Str.68; - if Str.236 then - let Str.238 : Str = StructAtIndex 1 Str.68; - let Str.237 : [C {U64, U8}, C Str] = TagId(1) Str.238; - ret Str.237; - else - let Str.234 : U8 = StructAtIndex 3 Str.68; - let Str.235 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.7 : Str = StructAtIndex 1 Str.68; - dec #Derived_gen.7; - let Str.233 : {U64, U8} = Struct {Str.235, Str.234}; - let Str.232 : [C {U64, U8}, C Str] = TagId(0) Str.233; - ret Str.232; - -procedure Test.3 (): - let Test.0 : List U8 = Array [82i64, 111i64, 99i64]; - let Test.8 : {} = CallByName TotallyNotJson.8; - inc Test.0; - let Test.1 : [C [C List U8, C ], C Str] = CallByName Decode.27 Test.0 Test.8; - let Test.7 : Str = "Roc"; - let Test.6 : [C [C List U8, C ], C Str] = TagId(1) Test.7; - let Test.5 : Int1 = CallByName Bool.11 Test.1 Test.6; - dec Test.7; - expect Test.5; - dec Test.1; - dec Test.0; - let Test.4 : {} = Struct {}; - ret Test.4; - -procedure TotallyNotJson.491 (TotallyNotJson.492, TotallyNotJson.976): - joinpoint TotallyNotJson.1260: - inc TotallyNotJson.492; - let TotallyNotJson.1129 : {List U8, List U8} = CallByName TotallyNotJson.60 TotallyNotJson.492; - let TotallyNotJson.496 : List U8 = StructAtIndex 0 TotallyNotJson.1129; - let TotallyNotJson.495 : List U8 = StructAtIndex 1 TotallyNotJson.1129; - inc TotallyNotJson.495; - let TotallyNotJson.1125 : Int1 = CallByName List.1 TotallyNotJson.495; - if TotallyNotJson.1125 then - dec TotallyNotJson.495; - dec TotallyNotJson.496; - let TotallyNotJson.1128 : {} = Struct {}; - let TotallyNotJson.1127 : [C {}, C Str] = TagId(0) TotallyNotJson.1128; - let TotallyNotJson.1126 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.492, TotallyNotJson.1127}; - ret TotallyNotJson.1126; - else - let TotallyNotJson.1123 : U64 = CallByName List.6 TotallyNotJson.495; - let TotallyNotJson.1124 : U64 = 2i64; - let TotallyNotJson.1121 : U64 = CallByName Num.77 TotallyNotJson.1123 TotallyNotJson.1124; - let TotallyNotJson.1122 : U64 = 1i64; - let TotallyNotJson.1120 : {U64, U64} = Struct {TotallyNotJson.1121, TotallyNotJson.1122}; - let TotallyNotJson.995 : List U8 = CallByName List.49 TotallyNotJson.495 TotallyNotJson.1120; - let TotallyNotJson.996 : {} = Struct {}; - let TotallyNotJson.991 : {List U8, List U8} = CallByName TotallyNotJson.500 TotallyNotJson.995; - let TotallyNotJson.992 : {} = Struct {}; - let TotallyNotJson.990 : List U8 = CallByName TotallyNotJson.502 TotallyNotJson.991; - let TotallyNotJson.499 : [C {U64, U8}, C Str] = CallByName Str.9 TotallyNotJson.990; - let TotallyNotJson.987 : U8 = 1i64; - let TotallyNotJson.988 : U8 = GetTagId TotallyNotJson.499; - let TotallyNotJson.989 : Int1 = lowlevel Eq TotallyNotJson.987 TotallyNotJson.988; - if TotallyNotJson.989 then - dec TotallyNotJson.492; - let TotallyNotJson.503 : Str = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.499; - let TotallyNotJson.983 : [C {}, C Str] = TagId(1) TotallyNotJson.503; - let TotallyNotJson.982 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.496, TotallyNotJson.983}; - ret TotallyNotJson.982; - else - dec TotallyNotJson.499; - dec TotallyNotJson.496; - let TotallyNotJson.986 : {} = Struct {}; - let TotallyNotJson.985 : [C {}, C Str] = TagId(0) TotallyNotJson.986; - let TotallyNotJson.984 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.492, TotallyNotJson.985}; - ret TotallyNotJson.984; - in - let TotallyNotJson.1258 : U64 = lowlevel ListLenUsize TotallyNotJson.492; - let TotallyNotJson.1259 : U64 = 4i64; - let TotallyNotJson.1265 : Int1 = lowlevel NumGte TotallyNotJson.1258 TotallyNotJson.1259; - if TotallyNotJson.1265 then - let TotallyNotJson.1255 : U64 = 3i64; - let TotallyNotJson.1256 : U8 = lowlevel ListGetUnsafe TotallyNotJson.492 TotallyNotJson.1255; - let TotallyNotJson.1257 : U8 = 108i64; - let TotallyNotJson.1264 : Int1 = lowlevel Eq TotallyNotJson.1257 TotallyNotJson.1256; - if TotallyNotJson.1264 then - let TotallyNotJson.1252 : U64 = 2i64; - let TotallyNotJson.1253 : U8 = lowlevel ListGetUnsafe TotallyNotJson.492 TotallyNotJson.1252; - let TotallyNotJson.1254 : U8 = 108i64; - let TotallyNotJson.1263 : Int1 = lowlevel Eq TotallyNotJson.1254 TotallyNotJson.1253; - if TotallyNotJson.1263 then - let TotallyNotJson.1249 : U64 = 1i64; - let TotallyNotJson.1250 : U8 = lowlevel ListGetUnsafe TotallyNotJson.492 TotallyNotJson.1249; - let TotallyNotJson.1251 : U8 = 117i64; - let TotallyNotJson.1262 : Int1 = lowlevel Eq TotallyNotJson.1251 TotallyNotJson.1250; - if TotallyNotJson.1262 then - let TotallyNotJson.1246 : U64 = 0i64; - let TotallyNotJson.1247 : U8 = lowlevel ListGetUnsafe TotallyNotJson.492 TotallyNotJson.1246; - let TotallyNotJson.1248 : U8 = 110i64; - let TotallyNotJson.1261 : Int1 = lowlevel Eq TotallyNotJson.1248 TotallyNotJson.1247; - if TotallyNotJson.1261 then - let TotallyNotJson.981 : U64 = 4i64; - let TotallyNotJson.978 : List U8 = CallByName List.38 TotallyNotJson.492 TotallyNotJson.981; - let TotallyNotJson.980 : Str = "null"; - let TotallyNotJson.979 : [C {}, C Str] = TagId(1) TotallyNotJson.980; - let TotallyNotJson.977 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.978, TotallyNotJson.979}; - ret TotallyNotJson.977; - else - jump TotallyNotJson.1260; - else - jump TotallyNotJson.1260; - else - jump TotallyNotJson.1260; - else - jump TotallyNotJson.1260; - else - jump TotallyNotJson.1260; - -procedure TotallyNotJson.500 (TotallyNotJson.501): - let TotallyNotJson.1119 : List U8 = Array []; - let TotallyNotJson.998 : {List U8, List U8} = Struct {TotallyNotJson.501, TotallyNotJson.1119}; - let TotallyNotJson.997 : {List U8, List U8} = CallByName TotallyNotJson.69 TotallyNotJson.998; - ret TotallyNotJson.997; - -procedure TotallyNotJson.502 (TotallyNotJson.993): - let TotallyNotJson.994 : List U8 = StructAtIndex 1 TotallyNotJson.993; - let #Derived_gen.6 : List U8 = StructAtIndex 0 TotallyNotJson.993; - dec #Derived_gen.6; - ret TotallyNotJson.994; - -procedure TotallyNotJson.59 (): - let TotallyNotJson.975 : {} = Struct {}; - let TotallyNotJson.974 : {} = CallByName Decode.24 TotallyNotJson.975; - ret TotallyNotJson.974; - -procedure TotallyNotJson.60 (TotallyNotJson.507): - let TotallyNotJson.1141 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(4) ; - let TotallyNotJson.1142 : {} = Struct {}; - inc TotallyNotJson.507; - let TotallyNotJson.1130 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = CallByName List.26 TotallyNotJson.507 TotallyNotJson.1141 TotallyNotJson.1142; - let TotallyNotJson.1138 : U8 = 2i64; - let TotallyNotJson.1139 : U8 = GetTagId TotallyNotJson.1130; - let TotallyNotJson.1140 : Int1 = lowlevel Eq TotallyNotJson.1138 TotallyNotJson.1139; - if TotallyNotJson.1140 then - inc TotallyNotJson.507; - let TotallyNotJson.509 : U64 = UnionAtIndex (Id 2) (Index 0) TotallyNotJson.1130; - let TotallyNotJson.1132 : List U8 = CallByName List.38 TotallyNotJson.507 TotallyNotJson.509; - let TotallyNotJson.1135 : U64 = 0i64; - let TotallyNotJson.1134 : {U64, U64} = Struct {TotallyNotJson.509, TotallyNotJson.1135}; - let TotallyNotJson.1133 : List U8 = CallByName List.49 TotallyNotJson.507 TotallyNotJson.1134; - let TotallyNotJson.1131 : {List U8, List U8} = Struct {TotallyNotJson.1132, TotallyNotJson.1133}; - ret TotallyNotJson.1131; - else - let TotallyNotJson.1137 : List U8 = Array []; - let TotallyNotJson.1136 : {List U8, List U8} = Struct {TotallyNotJson.507, TotallyNotJson.1137}; - ret TotallyNotJson.1136; - -procedure TotallyNotJson.61 (TotallyNotJson.510, TotallyNotJson.511): - let TotallyNotJson.1143 : {[C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], U8} = Struct {TotallyNotJson.510, TotallyNotJson.511}; - joinpoint TotallyNotJson.1186: - let TotallyNotJson.1184 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(3) ; - let TotallyNotJson.1183 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) TotallyNotJson.1184; - ret TotallyNotJson.1183; - in - let TotallyNotJson.1187 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.1245 : U8 = GetTagId TotallyNotJson.1187; - switch TotallyNotJson.1245: - case 4: - let TotallyNotJson.512 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1189 TotallyNotJson.1188: - if TotallyNotJson.1188 then - let TotallyNotJson.1146 : U64 = 1i64; - let TotallyNotJson.1145 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(0) TotallyNotJson.1146; - let TotallyNotJson.1144 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1145; - ret TotallyNotJson.1144; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1191 : U8 = 34i64; - let TotallyNotJson.1190 : Int1 = CallByName Bool.11 TotallyNotJson.512 TotallyNotJson.1191; - jump TotallyNotJson.1189 TotallyNotJson.1190; - - case 0: - let TotallyNotJson.1202 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.515 : U64 = UnionAtIndex (Id 0) (Index 0) TotallyNotJson.1202; - let TotallyNotJson.516 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1199 TotallyNotJson.1193: - if TotallyNotJson.1193 then - let TotallyNotJson.1150 : U64 = 1i64; - let TotallyNotJson.1149 : U64 = CallByName Num.19 TotallyNotJson.515 TotallyNotJson.1150; - let TotallyNotJson.1148 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(2) TotallyNotJson.1149; - let TotallyNotJson.1147 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) TotallyNotJson.1148; - ret TotallyNotJson.1147; - else - let TotallyNotJson.1198 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.519 : U64 = UnionAtIndex (Id 0) (Index 0) TotallyNotJson.1198; - let TotallyNotJson.520 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1195 TotallyNotJson.1194: - if TotallyNotJson.1194 then - let TotallyNotJson.1154 : U64 = 1i64; - let TotallyNotJson.1153 : U64 = CallByName Num.19 TotallyNotJson.519 TotallyNotJson.1154; - let TotallyNotJson.1152 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(1) TotallyNotJson.1153; - let TotallyNotJson.1151 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1152; - ret TotallyNotJson.1151; - else - let TotallyNotJson.1185 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.523 : U64 = UnionAtIndex (Id 0) (Index 0) TotallyNotJson.1185; - let TotallyNotJson.1158 : U64 = 1i64; - let TotallyNotJson.1157 : U64 = CallByName Num.19 TotallyNotJson.523 TotallyNotJson.1158; - let TotallyNotJson.1156 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(0) TotallyNotJson.1157; - let TotallyNotJson.1155 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1156; - ret TotallyNotJson.1155; - in - let TotallyNotJson.1197 : U8 = 92i64; - let TotallyNotJson.1196 : Int1 = CallByName Bool.11 TotallyNotJson.520 TotallyNotJson.1197; - jump TotallyNotJson.1195 TotallyNotJson.1196; - in - let TotallyNotJson.1201 : U8 = 34i64; - let TotallyNotJson.1200 : Int1 = CallByName Bool.11 TotallyNotJson.516 TotallyNotJson.1201; - jump TotallyNotJson.1199 TotallyNotJson.1200; - - case 1: - let TotallyNotJson.1211 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.526 : U64 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1211; - let TotallyNotJson.527 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1209 TotallyNotJson.1203: - if TotallyNotJson.1203 then - let TotallyNotJson.1162 : U64 = 1i64; - let TotallyNotJson.1161 : U64 = CallByName Num.19 TotallyNotJson.526 TotallyNotJson.1162; - let TotallyNotJson.1160 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(0) TotallyNotJson.1161; - let TotallyNotJson.1159 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1160; - ret TotallyNotJson.1159; - else - let TotallyNotJson.1208 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.530 : U64 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1208; - let TotallyNotJson.531 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1205 TotallyNotJson.1204: - if TotallyNotJson.1204 then - let TotallyNotJson.1166 : U64 = 1i64; - let TotallyNotJson.1165 : U64 = CallByName Num.19 TotallyNotJson.530 TotallyNotJson.1166; - let TotallyNotJson.1164 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(5) TotallyNotJson.1165; - let TotallyNotJson.1163 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1164; - ret TotallyNotJson.1163; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1207 : U8 = 117i64; - let TotallyNotJson.1206 : Int1 = CallByName Bool.11 TotallyNotJson.531 TotallyNotJson.1207; - jump TotallyNotJson.1205 TotallyNotJson.1206; - in - let TotallyNotJson.1210 : Int1 = CallByName TotallyNotJson.62 TotallyNotJson.527; - jump TotallyNotJson.1209 TotallyNotJson.1210; - - case 5: - let TotallyNotJson.1232 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.534 : U64 = UnionAtIndex (Id 5) (Index 0) TotallyNotJson.1232; - let TotallyNotJson.535 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1213 TotallyNotJson.1212: - if TotallyNotJson.1212 then - let TotallyNotJson.1170 : U64 = 1i64; - let TotallyNotJson.1169 : U64 = CallByName Num.19 TotallyNotJson.534 TotallyNotJson.1170; - let TotallyNotJson.1168 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(6) TotallyNotJson.1169; - let TotallyNotJson.1167 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1168; - ret TotallyNotJson.1167; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1214 : Int1 = CallByName TotallyNotJson.64 TotallyNotJson.535; - jump TotallyNotJson.1213 TotallyNotJson.1214; - - case 6: - let TotallyNotJson.1236 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.538 : U64 = UnionAtIndex (Id 6) (Index 0) TotallyNotJson.1236; - let TotallyNotJson.539 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1234 TotallyNotJson.1233: - if TotallyNotJson.1233 then - let TotallyNotJson.1174 : U64 = 1i64; - let TotallyNotJson.1173 : U64 = CallByName Num.19 TotallyNotJson.538 TotallyNotJson.1174; - let TotallyNotJson.1172 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(7) TotallyNotJson.1173; - let TotallyNotJson.1171 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1172; - ret TotallyNotJson.1171; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1235 : Int1 = CallByName TotallyNotJson.64 TotallyNotJson.539; - jump TotallyNotJson.1234 TotallyNotJson.1235; - - case 7: - let TotallyNotJson.1240 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.542 : U64 = UnionAtIndex (Id 7) (Index 0) TotallyNotJson.1240; - let TotallyNotJson.543 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1238 TotallyNotJson.1237: - if TotallyNotJson.1237 then - let TotallyNotJson.1178 : U64 = 1i64; - let TotallyNotJson.1177 : U64 = CallByName Num.19 TotallyNotJson.542 TotallyNotJson.1178; - let TotallyNotJson.1176 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(8) TotallyNotJson.1177; - let TotallyNotJson.1175 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1176; - ret TotallyNotJson.1175; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1239 : Int1 = CallByName TotallyNotJson.64 TotallyNotJson.543; - jump TotallyNotJson.1238 TotallyNotJson.1239; - - case 8: - let TotallyNotJson.1244 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.546 : U64 = UnionAtIndex (Id 8) (Index 0) TotallyNotJson.1244; - let TotallyNotJson.547 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1242 TotallyNotJson.1241: - if TotallyNotJson.1241 then - let TotallyNotJson.1182 : U64 = 1i64; - let TotallyNotJson.1181 : U64 = CallByName Num.19 TotallyNotJson.546 TotallyNotJson.1182; - let TotallyNotJson.1180 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(0) TotallyNotJson.1181; - let TotallyNotJson.1179 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1180; - ret TotallyNotJson.1179; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1243 : Int1 = CallByName TotallyNotJson.64 TotallyNotJson.547; - jump TotallyNotJson.1242 TotallyNotJson.1243; - - default: - jump TotallyNotJson.1186; - - -procedure TotallyNotJson.62 (TotallyNotJson.552): - switch TotallyNotJson.552: - case 34: - let TotallyNotJson.1087 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1087; - - case 92: - let TotallyNotJson.1088 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1088; - - case 47: - let TotallyNotJson.1089 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1089; - - case 98: - let TotallyNotJson.1090 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1090; - - case 102: - let TotallyNotJson.1091 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1091; - - case 110: - let TotallyNotJson.1092 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1092; - - case 114: - let TotallyNotJson.1093 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1093; - - case 116: - let TotallyNotJson.1094 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1094; - - default: - let TotallyNotJson.1095 : Int1 = CallByName Bool.1; - ret TotallyNotJson.1095; - - -procedure TotallyNotJson.63 (TotallyNotJson.553): - switch TotallyNotJson.553: - case 34: - let TotallyNotJson.1064 : U8 = 34i64; - ret TotallyNotJson.1064; - - case 92: - let TotallyNotJson.1065 : U8 = 92i64; - ret TotallyNotJson.1065; - - case 47: - let TotallyNotJson.1066 : U8 = 47i64; - ret TotallyNotJson.1066; - - case 98: - let TotallyNotJson.1067 : U8 = 8i64; - ret TotallyNotJson.1067; - - case 102: - let TotallyNotJson.1068 : U8 = 12i64; - ret TotallyNotJson.1068; - - case 110: - let TotallyNotJson.1069 : U8 = 10i64; - ret TotallyNotJson.1069; - - case 114: - let TotallyNotJson.1070 : U8 = 13i64; - ret TotallyNotJson.1070; - - case 116: - let TotallyNotJson.1071 : U8 = 9i64; - ret TotallyNotJson.1071; - - default: - ret TotallyNotJson.553; - - -procedure TotallyNotJson.64 (TotallyNotJson.554): - let TotallyNotJson.1231 : U8 = 48i64; - let TotallyNotJson.1228 : Int1 = CallByName Num.25 TotallyNotJson.554 TotallyNotJson.1231; - let TotallyNotJson.1230 : U8 = 57i64; - let TotallyNotJson.1229 : Int1 = CallByName Num.23 TotallyNotJson.554 TotallyNotJson.1230; - let TotallyNotJson.1216 : Int1 = CallByName Bool.3 TotallyNotJson.1228 TotallyNotJson.1229; - let TotallyNotJson.1227 : U8 = 97i64; - let TotallyNotJson.1224 : Int1 = CallByName Num.25 TotallyNotJson.554 TotallyNotJson.1227; - let TotallyNotJson.1226 : U8 = 102i64; - let TotallyNotJson.1225 : Int1 = CallByName Num.23 TotallyNotJson.554 TotallyNotJson.1226; - let TotallyNotJson.1218 : Int1 = CallByName Bool.3 TotallyNotJson.1224 TotallyNotJson.1225; - let TotallyNotJson.1223 : U8 = 65i64; - let TotallyNotJson.1220 : Int1 = CallByName Num.25 TotallyNotJson.554 TotallyNotJson.1223; - let TotallyNotJson.1222 : U8 = 70i64; - let TotallyNotJson.1221 : Int1 = CallByName Num.23 TotallyNotJson.554 TotallyNotJson.1222; - let TotallyNotJson.1219 : Int1 = CallByName Bool.3 TotallyNotJson.1220 TotallyNotJson.1221; - let TotallyNotJson.1217 : Int1 = CallByName Bool.4 TotallyNotJson.1218 TotallyNotJson.1219; - let TotallyNotJson.1215 : Int1 = CallByName Bool.4 TotallyNotJson.1216 TotallyNotJson.1217; - ret TotallyNotJson.1215; - -procedure TotallyNotJson.65 (TotallyNotJson.555): - let TotallyNotJson.1043 : U8 = 48i64; - let TotallyNotJson.1040 : Int1 = CallByName Num.25 TotallyNotJson.555 TotallyNotJson.1043; - let TotallyNotJson.1042 : U8 = 57i64; - let TotallyNotJson.1041 : Int1 = CallByName Num.23 TotallyNotJson.555 TotallyNotJson.1042; - let TotallyNotJson.1037 : Int1 = CallByName Bool.3 TotallyNotJson.1040 TotallyNotJson.1041; - if TotallyNotJson.1037 then - let TotallyNotJson.1039 : U8 = 48i64; - let TotallyNotJson.1038 : U8 = CallByName Num.20 TotallyNotJson.555 TotallyNotJson.1039; - ret TotallyNotJson.1038; - else - let TotallyNotJson.1036 : U8 = 97i64; - let TotallyNotJson.1033 : Int1 = CallByName Num.25 TotallyNotJson.555 TotallyNotJson.1036; - let TotallyNotJson.1035 : U8 = 102i64; - let TotallyNotJson.1034 : Int1 = CallByName Num.23 TotallyNotJson.555 TotallyNotJson.1035; - let TotallyNotJson.1028 : Int1 = CallByName Bool.3 TotallyNotJson.1033 TotallyNotJson.1034; - if TotallyNotJson.1028 then - let TotallyNotJson.1032 : U8 = 97i64; - let TotallyNotJson.1030 : U8 = CallByName Num.20 TotallyNotJson.555 TotallyNotJson.1032; - let TotallyNotJson.1031 : U8 = 10i64; - let TotallyNotJson.1029 : U8 = CallByName Num.19 TotallyNotJson.1030 TotallyNotJson.1031; - ret TotallyNotJson.1029; - else - let TotallyNotJson.1027 : U8 = 65i64; - let TotallyNotJson.1024 : Int1 = CallByName Num.25 TotallyNotJson.555 TotallyNotJson.1027; - let TotallyNotJson.1026 : U8 = 70i64; - let TotallyNotJson.1025 : Int1 = CallByName Num.23 TotallyNotJson.555 TotallyNotJson.1026; - let TotallyNotJson.1019 : Int1 = CallByName Bool.3 TotallyNotJson.1024 TotallyNotJson.1025; - if TotallyNotJson.1019 then - let TotallyNotJson.1023 : U8 = 65i64; - let TotallyNotJson.1021 : U8 = CallByName Num.20 TotallyNotJson.555 TotallyNotJson.1023; - let TotallyNotJson.1022 : U8 = 10i64; - let TotallyNotJson.1020 : U8 = CallByName Num.19 TotallyNotJson.1021 TotallyNotJson.1022; - ret TotallyNotJson.1020; - else - let TotallyNotJson.1018 : Str = "got an invalid hex char"; - Crash TotallyNotJson.1018 - -procedure TotallyNotJson.66 (TotallyNotJson.556, TotallyNotJson.557): - let TotallyNotJson.1009 : U8 = 4i64; - let TotallyNotJson.1008 : U8 = CallByName Num.72 TotallyNotJson.556 TotallyNotJson.1009; - let TotallyNotJson.1007 : U8 = CallByName Num.71 TotallyNotJson.1008 TotallyNotJson.557; - ret TotallyNotJson.1007; - -procedure TotallyNotJson.67 (TotallyNotJson.558, TotallyNotJson.559, TotallyNotJson.560, TotallyNotJson.561): - let TotallyNotJson.562 : U8 = CallByName TotallyNotJson.65 TotallyNotJson.558; - let TotallyNotJson.563 : U8 = CallByName TotallyNotJson.65 TotallyNotJson.559; - let TotallyNotJson.564 : U8 = CallByName TotallyNotJson.65 TotallyNotJson.560; - let TotallyNotJson.565 : U8 = CallByName TotallyNotJson.65 TotallyNotJson.561; - let TotallyNotJson.1016 : U8 = 0i64; - let TotallyNotJson.1013 : Int1 = CallByName Bool.11 TotallyNotJson.562 TotallyNotJson.1016; - let TotallyNotJson.1015 : U8 = 0i64; - let TotallyNotJson.1014 : Int1 = CallByName Bool.11 TotallyNotJson.563 TotallyNotJson.1015; - let TotallyNotJson.1010 : Int1 = CallByName Bool.3 TotallyNotJson.1013 TotallyNotJson.1014; - if TotallyNotJson.1010 then - let TotallyNotJson.1012 : U8 = CallByName TotallyNotJson.66 TotallyNotJson.564 TotallyNotJson.565; - let TotallyNotJson.1011 : List U8 = Array [TotallyNotJson.1012]; - ret TotallyNotJson.1011; - else - let TotallyNotJson.1005 : U8 = CallByName TotallyNotJson.66 TotallyNotJson.562 TotallyNotJson.563; - let TotallyNotJson.1006 : U8 = CallByName TotallyNotJson.66 TotallyNotJson.564 TotallyNotJson.565; - let TotallyNotJson.1004 : List U8 = Array [TotallyNotJson.1005, TotallyNotJson.1006]; - ret TotallyNotJson.1004; - -procedure TotallyNotJson.68 (): - let TotallyNotJson.1049 : U8 = 102i64; - let TotallyNotJson.1050 : U8 = 102i64; - let TotallyNotJson.1051 : U8 = 100i64; - let TotallyNotJson.1052 : U8 = 100i64; - let TotallyNotJson.1048 : List U8 = CallByName TotallyNotJson.67 TotallyNotJson.1049 TotallyNotJson.1050 TotallyNotJson.1051 TotallyNotJson.1052; - ret TotallyNotJson.1048; - -procedure TotallyNotJson.69 (#Derived_gen.0): - joinpoint TotallyNotJson.999 TotallyNotJson.970: - let TotallyNotJson.566 : List U8 = StructAtIndex 0 TotallyNotJson.970; - inc 4 TotallyNotJson.566; - let TotallyNotJson.567 : List U8 = StructAtIndex 1 TotallyNotJson.970; - let TotallyNotJson.1118 : U64 = 0i64; - let TotallyNotJson.568 : [C {}, C U8] = CallByName List.2 TotallyNotJson.566 TotallyNotJson.1118; - let TotallyNotJson.1117 : U64 = 1i64; - let TotallyNotJson.569 : [C {}, C U8] = CallByName List.2 TotallyNotJson.566 TotallyNotJson.1117; - let TotallyNotJson.1116 : U64 = 2i64; - let TotallyNotJson.570 : List U8 = CallByName List.38 TotallyNotJson.566 TotallyNotJson.1116; - let TotallyNotJson.1115 : U64 = 6i64; - let TotallyNotJson.571 : List U8 = CallByName List.38 TotallyNotJson.566 TotallyNotJson.1115; - let TotallyNotJson.1000 : {[C {}, C U8], [C {}, C U8]} = Struct {TotallyNotJson.568, TotallyNotJson.569}; - joinpoint TotallyNotJson.1080: - let TotallyNotJson.1079 : [C {}, C U8] = StructAtIndex 0 TotallyNotJson.1000; - let TotallyNotJson.582 : U8 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1079; - let TotallyNotJson.1077 : U64 = 1i64; - let TotallyNotJson.1075 : List U8 = CallByName List.38 TotallyNotJson.566 TotallyNotJson.1077; - let TotallyNotJson.1076 : List U8 = CallByName List.4 TotallyNotJson.567 TotallyNotJson.582; - let TotallyNotJson.1074 : {List U8, List U8} = Struct {TotallyNotJson.1075, TotallyNotJson.1076}; - jump TotallyNotJson.999 TotallyNotJson.1074; - in - let TotallyNotJson.1111 : [C {}, C U8] = StructAtIndex 0 TotallyNotJson.1000; - let TotallyNotJson.1112 : U8 = 1i64; - let TotallyNotJson.1113 : U8 = GetTagId TotallyNotJson.1111; - let TotallyNotJson.1114 : Int1 = lowlevel Eq TotallyNotJson.1112 TotallyNotJson.1113; - if TotallyNotJson.1114 then - let TotallyNotJson.1107 : [C {}, C U8] = StructAtIndex 1 TotallyNotJson.1000; - let TotallyNotJson.1108 : U8 = 1i64; - let TotallyNotJson.1109 : U8 = GetTagId TotallyNotJson.1107; - let TotallyNotJson.1110 : Int1 = lowlevel Eq TotallyNotJson.1108 TotallyNotJson.1109; - if TotallyNotJson.1110 then - let TotallyNotJson.1106 : [C {}, C U8] = StructAtIndex 0 TotallyNotJson.1000; - let TotallyNotJson.573 : U8 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1106; - let TotallyNotJson.1105 : [C {}, C U8] = StructAtIndex 1 TotallyNotJson.1000; - let TotallyNotJson.574 : U8 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1105; - joinpoint TotallyNotJson.1099 TotallyNotJson.1081: - if TotallyNotJson.1081 then - dec TotallyNotJson.566; - let TotallyNotJson.1057 : U64 = lowlevel ListLenUsize TotallyNotJson.570; - let TotallyNotJson.1058 : U64 = 4i64; - let TotallyNotJson.1059 : Int1 = lowlevel NumGte TotallyNotJson.1057 TotallyNotJson.1058; - if TotallyNotJson.1059 then - let TotallyNotJson.1056 : U64 = 0i64; - let TotallyNotJson.575 : U8 = lowlevel ListGetUnsafe TotallyNotJson.570 TotallyNotJson.1056; - let TotallyNotJson.1055 : U64 = 1i64; - let TotallyNotJson.576 : U8 = lowlevel ListGetUnsafe TotallyNotJson.570 TotallyNotJson.1055; - let TotallyNotJson.1054 : U64 = 2i64; - let TotallyNotJson.577 : U8 = lowlevel ListGetUnsafe TotallyNotJson.570 TotallyNotJson.1054; - let TotallyNotJson.1053 : U64 = 3i64; - let TotallyNotJson.578 : U8 = lowlevel ListGetUnsafe TotallyNotJson.570 TotallyNotJson.1053; - dec TotallyNotJson.570; - let TotallyNotJson.579 : List U8 = CallByName TotallyNotJson.67 TotallyNotJson.575 TotallyNotJson.576 TotallyNotJson.577 TotallyNotJson.578; - let TotallyNotJson.1003 : List U8 = CallByName List.8 TotallyNotJson.567 TotallyNotJson.579; - let TotallyNotJson.1002 : {List U8, List U8} = Struct {TotallyNotJson.571, TotallyNotJson.1003}; - jump TotallyNotJson.999 TotallyNotJson.1002; - else - dec TotallyNotJson.571; - let TotallyNotJson.1047 : List U8 = CallByName TotallyNotJson.68; - let TotallyNotJson.1046 : List U8 = CallByName List.8 TotallyNotJson.567 TotallyNotJson.1047; - let TotallyNotJson.1045 : {List U8, List U8} = Struct {TotallyNotJson.570, TotallyNotJson.1046}; - jump TotallyNotJson.999 TotallyNotJson.1045; - else - dec TotallyNotJson.571; - let TotallyNotJson.1098 : [C {}, C U8] = StructAtIndex 0 TotallyNotJson.1000; - let TotallyNotJson.580 : U8 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1098; - let TotallyNotJson.1097 : [C {}, C U8] = StructAtIndex 1 TotallyNotJson.1000; - let TotallyNotJson.581 : U8 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1097; - joinpoint TotallyNotJson.1083 TotallyNotJson.1082: - if TotallyNotJson.1082 then - dec TotallyNotJson.566; - let TotallyNotJson.1063 : U8 = CallByName TotallyNotJson.63 TotallyNotJson.581; - let TotallyNotJson.1062 : List U8 = CallByName List.4 TotallyNotJson.567 TotallyNotJson.1063; - let TotallyNotJson.1061 : {List U8, List U8} = Struct {TotallyNotJson.570, TotallyNotJson.1062}; - jump TotallyNotJson.999 TotallyNotJson.1061; - else - dec TotallyNotJson.570; - jump TotallyNotJson.1080; - in - let TotallyNotJson.1096 : U8 = 92i64; - let TotallyNotJson.1085 : Int1 = CallByName Bool.11 TotallyNotJson.580 TotallyNotJson.1096; - let TotallyNotJson.1086 : Int1 = CallByName TotallyNotJson.62 TotallyNotJson.581; - let TotallyNotJson.1084 : Int1 = CallByName Bool.3 TotallyNotJson.1085 TotallyNotJson.1086; - jump TotallyNotJson.1083 TotallyNotJson.1084; - in - let TotallyNotJson.1104 : U8 = 92i64; - let TotallyNotJson.1101 : Int1 = CallByName Bool.11 TotallyNotJson.573 TotallyNotJson.1104; - let TotallyNotJson.1103 : U8 = 117i64; - let TotallyNotJson.1102 : Int1 = CallByName Bool.11 TotallyNotJson.574 TotallyNotJson.1103; - let TotallyNotJson.1100 : Int1 = CallByName Bool.3 TotallyNotJson.1101 TotallyNotJson.1102; - jump TotallyNotJson.1099 TotallyNotJson.1100; - else - dec TotallyNotJson.571; - dec TotallyNotJson.570; - jump TotallyNotJson.1080; - else - dec TotallyNotJson.571; - dec TotallyNotJson.570; - let TotallyNotJson.1078 : {List U8, List U8} = Struct {TotallyNotJson.566, TotallyNotJson.567}; - ret TotallyNotJson.1078; - in - jump TotallyNotJson.999 #Derived_gen.0; - -procedure TotallyNotJson.8 (): - let TotallyNotJson.973 : {} = Struct {}; - ret TotallyNotJson.973; +procedure Test.6 (): + let Test.10 : Int1 = false; + let Test.0 : [C Int1, C Int1, C Int1] = TagId(2) Test.10; + let Test.9 : Int1 = false; + let Test.1 : [C Int1, C Int1, C Int1] = TagId(0) Test.9; + let Test.8 : Int1 = CallByName Bool.7 Test.0 Test.1; + expect Test.8; + let Test.7 : {} = Struct {}; + ret Test.7; diff --git a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt index 3ec962c7ce..376a770fff 100644 --- a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt +++ b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt @@ -1,197 +1,23 @@ -procedure Bool.1 (): - let Bool.51 : Int1 = false; - ret Bool.51; - procedure Bool.11 (#Attr.2, #Attr.3): let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.23; procedure Bool.11 (#Attr.2, #Attr.3): - let Bool.42 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.42; - -procedure Bool.11 (#Attr.2, #Attr.3): - let Bool.54 : Int1 = lowlevel Eq #Attr.2 #Attr.3; - ret Bool.54; - -procedure Bool.2 (): - let Bool.50 : Int1 = true; - ret Bool.50; - -procedure Bool.3 (#Attr.2, #Attr.3): - let Bool.33 : Int1 = lowlevel And #Attr.2 #Attr.3; - ret Bool.33; - -procedure Bool.4 (#Attr.2, #Attr.3): - let Bool.53 : Int1 = lowlevel Or #Attr.2 #Attr.3; - ret Bool.53; + let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3; + ret Bool.24; procedure Decode.24 (Decode.101): ret Decode.101; procedure Decode.25 (Decode.102, Decode.121, Decode.104): - let Decode.124 : {List U8, [C {}, C Str]} = CallByName TotallyNotJson.491 Decode.102 Decode.104; + let Decode.124 : {List U8, [C {}, C Str]} = CallByName Test.76 Decode.102 Decode.104; ret Decode.124; procedure Decode.26 (Decode.105, Decode.106): - let Decode.123 : {} = CallByName TotallyNotJson.59; + let Decode.123 : {} = CallByName Test.15; let Decode.122 : {List U8, [C {}, C Str]} = CallByName Decode.25 Decode.105 Decode.123 Decode.106; ret Decode.122; -procedure List.1 (List.107): - let List.624 : U64 = CallByName List.6 List.107; - dec List.107; - let List.625 : U64 = 0i64; - let List.623 : Int1 = CallByName Bool.11 List.624 List.625; - ret List.623; - -procedure List.104 (List.488, List.489, List.490): - let List.633 : U64 = 0i64; - let List.634 : U64 = CallByName List.6 List.488; - let List.632 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.488 List.489 List.490 List.633 List.634; - ret List.632; - -procedure List.2 (List.108, List.109): - let List.615 : U64 = CallByName List.6 List.108; - let List.612 : Int1 = CallByName Num.22 List.109 List.615; - if List.612 then - let List.614 : U8 = CallByName List.66 List.108 List.109; - dec List.108; - let List.613 : [C {}, C U8] = TagId(1) List.614; - ret List.613; - else - dec List.108; - let List.611 : {} = Struct {}; - let List.610 : [C {}, C U8] = TagId(0) List.611; - ret List.610; - -procedure List.26 (List.201, List.202, List.203): - let List.626 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.104 List.201 List.202 List.203; - let List.629 : U8 = 1i64; - let List.630 : U8 = GetTagId List.626; - let List.631 : Int1 = lowlevel Eq List.629 List.630; - if List.631 then - let List.204 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.626; - ret List.204; - else - let List.205 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.626; - ret List.205; - -procedure List.38 (List.344, List.345): - let List.592 : U64 = CallByName List.6 List.344; - let List.346 : U64 = CallByName Num.77 List.592 List.345; - let List.591 : List U8 = CallByName List.43 List.344 List.346; - ret List.591; - -procedure List.4 (List.124, List.125): - let List.602 : U64 = 1i64; - let List.601 : List U8 = CallByName List.70 List.124 List.602; - let List.600 : List U8 = CallByName List.71 List.601 List.125; - ret List.600; - -procedure List.43 (List.342, List.343): - let List.582 : U64 = CallByName List.6 List.342; - let List.581 : U64 = CallByName Num.77 List.582 List.343; - let List.576 : {U64, U64} = Struct {List.343, List.581}; - let List.575 : List U8 = CallByName List.49 List.342 List.576; - ret List.575; - -procedure List.49 (List.420, List.421): - let List.620 : U64 = StructAtIndex 1 List.421; - let List.621 : U64 = StructAtIndex 0 List.421; - let List.619 : List U8 = CallByName List.72 List.420 List.620 List.621; - ret List.619; - -procedure List.6 (#Attr.2): - let List.622 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.622; - -procedure List.66 (#Attr.2, #Attr.3): - let List.608 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.608; - -procedure List.70 (#Attr.2, #Attr.3): - let List.599 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.599; - -procedure List.71 (#Attr.2, #Attr.3): - let List.597 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.597; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.580 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.580; - -procedure List.8 (#Attr.2, #Attr.3): - let List.594 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.594; - -procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.635 List.491 List.492 List.493 List.494 List.495: - let List.637 : Int1 = CallByName Num.22 List.494 List.495; - if List.637 then - let List.646 : U8 = CallByName List.66 List.491 List.494; - let List.638 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.61 List.492 List.646; - let List.643 : U8 = 1i64; - let List.644 : U8 = GetTagId List.638; - let List.645 : Int1 = lowlevel Eq List.643 List.644; - if List.645 then - let List.496 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.638; - let List.641 : U64 = 1i64; - let List.640 : U64 = CallByName Num.51 List.494 List.641; - jump List.635 List.491 List.496 List.493 List.640 List.495; - else - dec List.491; - let List.497 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.638; - let List.642 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.497; - ret List.642; - else - dec List.491; - let List.636 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.492; - ret List.636; - in - jump List.635 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.282 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.282; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.291 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.291; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.294 : U8 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.294; - -procedure Num.22 (#Attr.2, #Attr.3): - let Num.316 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.316; - -procedure Num.23 (#Attr.2, #Attr.3): - let Num.300 : Int1 = lowlevel NumLte #Attr.2 #Attr.3; - ret Num.300; - -procedure Num.25 (#Attr.2, #Attr.3): - let Num.306 : Int1 = lowlevel NumGte #Attr.2 #Attr.3; - ret Num.306; - -procedure Num.51 (#Attr.2, #Attr.3): - let Num.317 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.317; - -procedure Num.71 (#Attr.2, #Attr.3): - let Num.279 : U8 = lowlevel NumBitwiseOr #Attr.2 #Attr.3; - ret Num.279; - -procedure Num.72 (#Attr.2, #Attr.3): - let Num.280 : U8 = lowlevel NumShiftLeftBy #Attr.2 #Attr.3; - ret Num.280; - -procedure Num.77 (#Attr.2, #Attr.3): - let Num.313 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3; - ret Num.313; - procedure Str.12 (#Attr.2): let Str.241 : List U8 = lowlevel StrToUtf8 #Attr.2; ret Str.241; @@ -204,10 +30,6 @@ procedure Str.42 (#Attr.2): let Str.240 : {I64, U8} = lowlevel StrToNum #Attr.2; ret Str.240; -procedure Str.43 (#Attr.2): - let Str.249 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8 #Attr.2; - ret Str.249; - procedure Str.60 (Str.185): let Str.186 : {I64, U8} = CallByName Str.42 Str.185; dec Str.185; @@ -223,633 +45,59 @@ procedure Str.60 (Str.185): let Str.233 : [C {}, C I64] = TagId(0) Str.234; ret Str.233; -procedure Str.9 (Str.67): - let Str.68 : {U64, Str, Int1, U8} = CallByName Str.43 Str.67; - let Str.246 : Int1 = StructAtIndex 2 Str.68; - if Str.246 then - let Str.248 : Str = StructAtIndex 1 Str.68; - let Str.247 : [C {U64, U8}, C Str] = TagId(1) Str.248; - ret Str.247; - else - let Str.244 : U8 = StructAtIndex 3 Str.68; - let Str.245 : U64 = StructAtIndex 0 Str.68; - let #Derived_gen.7 : Str = StructAtIndex 1 Str.68; - dec #Derived_gen.7; - let Str.243 : {U64, U8} = Struct {Str.245, Str.244}; - let Str.242 : [C {U64, U8}, C Str] = TagId(0) Str.243; - ret Str.242; +procedure Test.103 (): + let Test.101 : [C Str, C {List U8, I64}] = CallByName Test.19; + let Test.115 : List U8 = Array []; + let Test.116 : I64 = -1234i64; + let Test.114 : {List U8, I64} = Struct {Test.115, Test.116}; + let Test.113 : [C Str, C {List U8, I64}] = TagId(1) Test.114; + let Test.112 : Int1 = CallByName Bool.11 Test.101 Test.113; + dec Test.114; + expect Test.112; + dec Test.101; + let Test.111 : {} = Struct {}; + ret Test.111; -procedure Test.0 (): - let Test.37 : Str = "-1234"; - let Test.35 : List U8 = CallByName Str.12 Test.37; - let Test.36 : {} = CallByName TotallyNotJson.8; - let Test.34 : {List U8, [C {}, C Str]} = CallByName Decode.26 Test.35 Test.36; - let Test.2 : List U8 = StructAtIndex 0 Test.34; - let Test.1 : [C {}, C Str] = StructAtIndex 1 Test.34; - let Test.31 : U8 = 1i64; - let Test.32 : U8 = GetTagId Test.1; - let Test.33 : Int1 = lowlevel Eq Test.31 Test.32; - if Test.33 then - let Test.3 : Str = UnionAtIndex (Id 1) (Index 0) Test.1; - let Test.19 : [C {}, C I64] = CallByName Str.27 Test.3; - let Test.25 : U8 = 1i64; - let Test.26 : U8 = GetTagId Test.19; - let Test.27 : Int1 = lowlevel Eq Test.25 Test.26; - if Test.27 then - let Test.4 : I64 = UnionAtIndex (Id 1) (Index 0) Test.19; - let Test.21 : {List U8, I64} = Struct {Test.2, Test.4}; - let Test.20 : [C Str, C {List U8, I64}] = TagId(1) Test.21; - ret Test.20; +procedure Test.15 (): + let Test.137 : {} = Struct {}; + let Test.136 : {} = CallByName Decode.24 Test.137; + ret Test.136; + +procedure Test.19 (): + let Test.135 : Str = "-1234"; + let Test.133 : List U8 = CallByName Str.12 Test.135; + let Test.134 : {} = Struct {}; + let Test.132 : {List U8, [C {}, C Str]} = CallByName Decode.26 Test.133 Test.134; + let Test.93 : List U8 = StructAtIndex 0 Test.132; + let Test.92 : [C {}, C Str] = StructAtIndex 1 Test.132; + let Test.129 : U8 = 1i64; + let Test.130 : U8 = GetTagId Test.92; + let Test.131 : Int1 = lowlevel Eq Test.129 Test.130; + if Test.131 then + let Test.94 : Str = UnionAtIndex (Id 1) (Index 0) Test.92; + let Test.117 : [C {}, C I64] = CallByName Str.27 Test.94; + let Test.123 : U8 = 1i64; + let Test.124 : U8 = GetTagId Test.117; + let Test.125 : Int1 = lowlevel Eq Test.123 Test.124; + if Test.125 then + let Test.95 : I64 = UnionAtIndex (Id 1) (Index 0) Test.117; + let Test.119 : {List U8, I64} = Struct {Test.93, Test.95}; + let Test.118 : [C Str, C {List U8, I64}] = TagId(1) Test.119; + ret Test.118; else - dec Test.2; - let Test.24 : Str = "not a number"; - let Test.22 : [C Str, C {List U8, I64}] = TagId(0) Test.24; - ret Test.22; + dec Test.93; + let Test.122 : Str = "not a number"; + let Test.120 : [C Str, C {List U8, I64}] = TagId(0) Test.122; + ret Test.120; else - dec Test.2; - dec Test.1; - let Test.30 : Str = "not a number"; - let Test.28 : [C Str, C {List U8, I64}] = TagId(0) Test.30; - ret Test.28; + dec Test.93; + dec Test.92; + let Test.128 : Str = "not a number"; + let Test.126 : [C Str, C {List U8, I64}] = TagId(0) Test.128; + ret Test.126; -procedure Test.12 (): - let Test.10 : [C Str, C {List U8, I64}] = CallByName Test.0; - let Test.17 : List U8 = Array []; - let Test.18 : I64 = -1234i64; - let Test.16 : {List U8, I64} = Struct {Test.17, Test.18}; - let Test.15 : [C Str, C {List U8, I64}] = TagId(1) Test.16; - let Test.14 : Int1 = CallByName Bool.11 Test.10 Test.15; - dec Test.16; - expect Test.14; - dec Test.10; - let Test.13 : {} = Struct {}; - ret Test.13; - -procedure TotallyNotJson.491 (TotallyNotJson.492, TotallyNotJson.976): - joinpoint TotallyNotJson.1260: - inc TotallyNotJson.492; - let TotallyNotJson.1129 : {List U8, List U8} = CallByName TotallyNotJson.60 TotallyNotJson.492; - let TotallyNotJson.496 : List U8 = StructAtIndex 0 TotallyNotJson.1129; - let TotallyNotJson.495 : List U8 = StructAtIndex 1 TotallyNotJson.1129; - inc TotallyNotJson.495; - let TotallyNotJson.1125 : Int1 = CallByName List.1 TotallyNotJson.495; - if TotallyNotJson.1125 then - dec TotallyNotJson.495; - dec TotallyNotJson.496; - let TotallyNotJson.1128 : {} = Struct {}; - let TotallyNotJson.1127 : [C {}, C Str] = TagId(0) TotallyNotJson.1128; - let TotallyNotJson.1126 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.492, TotallyNotJson.1127}; - ret TotallyNotJson.1126; - else - let TotallyNotJson.1123 : U64 = CallByName List.6 TotallyNotJson.495; - let TotallyNotJson.1124 : U64 = 2i64; - let TotallyNotJson.1121 : U64 = CallByName Num.77 TotallyNotJson.1123 TotallyNotJson.1124; - let TotallyNotJson.1122 : U64 = 1i64; - let TotallyNotJson.1120 : {U64, U64} = Struct {TotallyNotJson.1121, TotallyNotJson.1122}; - let TotallyNotJson.995 : List U8 = CallByName List.49 TotallyNotJson.495 TotallyNotJson.1120; - let TotallyNotJson.996 : {} = Struct {}; - let TotallyNotJson.991 : {List U8, List U8} = CallByName TotallyNotJson.500 TotallyNotJson.995; - let TotallyNotJson.992 : {} = Struct {}; - let TotallyNotJson.990 : List U8 = CallByName TotallyNotJson.502 TotallyNotJson.991; - let TotallyNotJson.499 : [C {U64, U8}, C Str] = CallByName Str.9 TotallyNotJson.990; - let TotallyNotJson.987 : U8 = 1i64; - let TotallyNotJson.988 : U8 = GetTagId TotallyNotJson.499; - let TotallyNotJson.989 : Int1 = lowlevel Eq TotallyNotJson.987 TotallyNotJson.988; - if TotallyNotJson.989 then - dec TotallyNotJson.492; - let TotallyNotJson.503 : Str = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.499; - let TotallyNotJson.983 : [C {}, C Str] = TagId(1) TotallyNotJson.503; - let TotallyNotJson.982 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.496, TotallyNotJson.983}; - ret TotallyNotJson.982; - else - dec TotallyNotJson.499; - dec TotallyNotJson.496; - let TotallyNotJson.986 : {} = Struct {}; - let TotallyNotJson.985 : [C {}, C Str] = TagId(0) TotallyNotJson.986; - let TotallyNotJson.984 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.492, TotallyNotJson.985}; - ret TotallyNotJson.984; - in - let TotallyNotJson.1258 : U64 = lowlevel ListLenUsize TotallyNotJson.492; - let TotallyNotJson.1259 : U64 = 4i64; - let TotallyNotJson.1265 : Int1 = lowlevel NumGte TotallyNotJson.1258 TotallyNotJson.1259; - if TotallyNotJson.1265 then - let TotallyNotJson.1255 : U64 = 3i64; - let TotallyNotJson.1256 : U8 = lowlevel ListGetUnsafe TotallyNotJson.492 TotallyNotJson.1255; - let TotallyNotJson.1257 : U8 = 108i64; - let TotallyNotJson.1264 : Int1 = lowlevel Eq TotallyNotJson.1257 TotallyNotJson.1256; - if TotallyNotJson.1264 then - let TotallyNotJson.1252 : U64 = 2i64; - let TotallyNotJson.1253 : U8 = lowlevel ListGetUnsafe TotallyNotJson.492 TotallyNotJson.1252; - let TotallyNotJson.1254 : U8 = 108i64; - let TotallyNotJson.1263 : Int1 = lowlevel Eq TotallyNotJson.1254 TotallyNotJson.1253; - if TotallyNotJson.1263 then - let TotallyNotJson.1249 : U64 = 1i64; - let TotallyNotJson.1250 : U8 = lowlevel ListGetUnsafe TotallyNotJson.492 TotallyNotJson.1249; - let TotallyNotJson.1251 : U8 = 117i64; - let TotallyNotJson.1262 : Int1 = lowlevel Eq TotallyNotJson.1251 TotallyNotJson.1250; - if TotallyNotJson.1262 then - let TotallyNotJson.1246 : U64 = 0i64; - let TotallyNotJson.1247 : U8 = lowlevel ListGetUnsafe TotallyNotJson.492 TotallyNotJson.1246; - let TotallyNotJson.1248 : U8 = 110i64; - let TotallyNotJson.1261 : Int1 = lowlevel Eq TotallyNotJson.1248 TotallyNotJson.1247; - if TotallyNotJson.1261 then - let TotallyNotJson.981 : U64 = 4i64; - let TotallyNotJson.978 : List U8 = CallByName List.38 TotallyNotJson.492 TotallyNotJson.981; - let TotallyNotJson.980 : Str = "null"; - let TotallyNotJson.979 : [C {}, C Str] = TagId(1) TotallyNotJson.980; - let TotallyNotJson.977 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.978, TotallyNotJson.979}; - ret TotallyNotJson.977; - else - jump TotallyNotJson.1260; - else - jump TotallyNotJson.1260; - else - jump TotallyNotJson.1260; - else - jump TotallyNotJson.1260; - else - jump TotallyNotJson.1260; - -procedure TotallyNotJson.500 (TotallyNotJson.501): - let TotallyNotJson.1119 : List U8 = Array []; - let TotallyNotJson.998 : {List U8, List U8} = Struct {TotallyNotJson.501, TotallyNotJson.1119}; - let TotallyNotJson.997 : {List U8, List U8} = CallByName TotallyNotJson.69 TotallyNotJson.998; - ret TotallyNotJson.997; - -procedure TotallyNotJson.502 (TotallyNotJson.993): - let TotallyNotJson.994 : List U8 = StructAtIndex 1 TotallyNotJson.993; - let #Derived_gen.6 : List U8 = StructAtIndex 0 TotallyNotJson.993; - dec #Derived_gen.6; - ret TotallyNotJson.994; - -procedure TotallyNotJson.59 (): - let TotallyNotJson.975 : {} = Struct {}; - let TotallyNotJson.974 : {} = CallByName Decode.24 TotallyNotJson.975; - ret TotallyNotJson.974; - -procedure TotallyNotJson.60 (TotallyNotJson.507): - let TotallyNotJson.1141 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(4) ; - let TotallyNotJson.1142 : {} = Struct {}; - inc TotallyNotJson.507; - let TotallyNotJson.1130 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = CallByName List.26 TotallyNotJson.507 TotallyNotJson.1141 TotallyNotJson.1142; - let TotallyNotJson.1138 : U8 = 2i64; - let TotallyNotJson.1139 : U8 = GetTagId TotallyNotJson.1130; - let TotallyNotJson.1140 : Int1 = lowlevel Eq TotallyNotJson.1138 TotallyNotJson.1139; - if TotallyNotJson.1140 then - inc TotallyNotJson.507; - let TotallyNotJson.509 : U64 = UnionAtIndex (Id 2) (Index 0) TotallyNotJson.1130; - let TotallyNotJson.1132 : List U8 = CallByName List.38 TotallyNotJson.507 TotallyNotJson.509; - let TotallyNotJson.1135 : U64 = 0i64; - let TotallyNotJson.1134 : {U64, U64} = Struct {TotallyNotJson.509, TotallyNotJson.1135}; - let TotallyNotJson.1133 : List U8 = CallByName List.49 TotallyNotJson.507 TotallyNotJson.1134; - let TotallyNotJson.1131 : {List U8, List U8} = Struct {TotallyNotJson.1132, TotallyNotJson.1133}; - ret TotallyNotJson.1131; - else - let TotallyNotJson.1137 : List U8 = Array []; - let TotallyNotJson.1136 : {List U8, List U8} = Struct {TotallyNotJson.507, TotallyNotJson.1137}; - ret TotallyNotJson.1136; - -procedure TotallyNotJson.61 (TotallyNotJson.510, TotallyNotJson.511): - let TotallyNotJson.1143 : {[C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], U8} = Struct {TotallyNotJson.510, TotallyNotJson.511}; - joinpoint TotallyNotJson.1186: - let TotallyNotJson.1184 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(3) ; - let TotallyNotJson.1183 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) TotallyNotJson.1184; - ret TotallyNotJson.1183; - in - let TotallyNotJson.1187 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.1245 : U8 = GetTagId TotallyNotJson.1187; - switch TotallyNotJson.1245: - case 4: - let TotallyNotJson.512 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1189 TotallyNotJson.1188: - if TotallyNotJson.1188 then - let TotallyNotJson.1146 : U64 = 1i64; - let TotallyNotJson.1145 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(0) TotallyNotJson.1146; - let TotallyNotJson.1144 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1145; - ret TotallyNotJson.1144; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1191 : U8 = 34i64; - let TotallyNotJson.1190 : Int1 = CallByName Bool.11 TotallyNotJson.512 TotallyNotJson.1191; - jump TotallyNotJson.1189 TotallyNotJson.1190; - - case 0: - let TotallyNotJson.1202 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.515 : U64 = UnionAtIndex (Id 0) (Index 0) TotallyNotJson.1202; - let TotallyNotJson.516 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1199 TotallyNotJson.1193: - if TotallyNotJson.1193 then - let TotallyNotJson.1150 : U64 = 1i64; - let TotallyNotJson.1149 : U64 = CallByName Num.19 TotallyNotJson.515 TotallyNotJson.1150; - let TotallyNotJson.1148 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(2) TotallyNotJson.1149; - let TotallyNotJson.1147 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) TotallyNotJson.1148; - ret TotallyNotJson.1147; - else - let TotallyNotJson.1198 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.519 : U64 = UnionAtIndex (Id 0) (Index 0) TotallyNotJson.1198; - let TotallyNotJson.520 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1195 TotallyNotJson.1194: - if TotallyNotJson.1194 then - let TotallyNotJson.1154 : U64 = 1i64; - let TotallyNotJson.1153 : U64 = CallByName Num.19 TotallyNotJson.519 TotallyNotJson.1154; - let TotallyNotJson.1152 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(1) TotallyNotJson.1153; - let TotallyNotJson.1151 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1152; - ret TotallyNotJson.1151; - else - let TotallyNotJson.1185 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.523 : U64 = UnionAtIndex (Id 0) (Index 0) TotallyNotJson.1185; - let TotallyNotJson.1158 : U64 = 1i64; - let TotallyNotJson.1157 : U64 = CallByName Num.19 TotallyNotJson.523 TotallyNotJson.1158; - let TotallyNotJson.1156 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(0) TotallyNotJson.1157; - let TotallyNotJson.1155 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1156; - ret TotallyNotJson.1155; - in - let TotallyNotJson.1197 : U8 = 92i64; - let TotallyNotJson.1196 : Int1 = CallByName Bool.11 TotallyNotJson.520 TotallyNotJson.1197; - jump TotallyNotJson.1195 TotallyNotJson.1196; - in - let TotallyNotJson.1201 : U8 = 34i64; - let TotallyNotJson.1200 : Int1 = CallByName Bool.11 TotallyNotJson.516 TotallyNotJson.1201; - jump TotallyNotJson.1199 TotallyNotJson.1200; - - case 1: - let TotallyNotJson.1211 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.526 : U64 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1211; - let TotallyNotJson.527 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1209 TotallyNotJson.1203: - if TotallyNotJson.1203 then - let TotallyNotJson.1162 : U64 = 1i64; - let TotallyNotJson.1161 : U64 = CallByName Num.19 TotallyNotJson.526 TotallyNotJson.1162; - let TotallyNotJson.1160 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(0) TotallyNotJson.1161; - let TotallyNotJson.1159 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1160; - ret TotallyNotJson.1159; - else - let TotallyNotJson.1208 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.530 : U64 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1208; - let TotallyNotJson.531 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1205 TotallyNotJson.1204: - if TotallyNotJson.1204 then - let TotallyNotJson.1166 : U64 = 1i64; - let TotallyNotJson.1165 : U64 = CallByName Num.19 TotallyNotJson.530 TotallyNotJson.1166; - let TotallyNotJson.1164 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(5) TotallyNotJson.1165; - let TotallyNotJson.1163 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1164; - ret TotallyNotJson.1163; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1207 : U8 = 117i64; - let TotallyNotJson.1206 : Int1 = CallByName Bool.11 TotallyNotJson.531 TotallyNotJson.1207; - jump TotallyNotJson.1205 TotallyNotJson.1206; - in - let TotallyNotJson.1210 : Int1 = CallByName TotallyNotJson.62 TotallyNotJson.527; - jump TotallyNotJson.1209 TotallyNotJson.1210; - - case 5: - let TotallyNotJson.1232 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.534 : U64 = UnionAtIndex (Id 5) (Index 0) TotallyNotJson.1232; - let TotallyNotJson.535 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1213 TotallyNotJson.1212: - if TotallyNotJson.1212 then - let TotallyNotJson.1170 : U64 = 1i64; - let TotallyNotJson.1169 : U64 = CallByName Num.19 TotallyNotJson.534 TotallyNotJson.1170; - let TotallyNotJson.1168 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(6) TotallyNotJson.1169; - let TotallyNotJson.1167 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1168; - ret TotallyNotJson.1167; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1214 : Int1 = CallByName TotallyNotJson.64 TotallyNotJson.535; - jump TotallyNotJson.1213 TotallyNotJson.1214; - - case 6: - let TotallyNotJson.1236 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.538 : U64 = UnionAtIndex (Id 6) (Index 0) TotallyNotJson.1236; - let TotallyNotJson.539 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1234 TotallyNotJson.1233: - if TotallyNotJson.1233 then - let TotallyNotJson.1174 : U64 = 1i64; - let TotallyNotJson.1173 : U64 = CallByName Num.19 TotallyNotJson.538 TotallyNotJson.1174; - let TotallyNotJson.1172 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(7) TotallyNotJson.1173; - let TotallyNotJson.1171 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1172; - ret TotallyNotJson.1171; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1235 : Int1 = CallByName TotallyNotJson.64 TotallyNotJson.539; - jump TotallyNotJson.1234 TotallyNotJson.1235; - - case 7: - let TotallyNotJson.1240 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.542 : U64 = UnionAtIndex (Id 7) (Index 0) TotallyNotJson.1240; - let TotallyNotJson.543 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1238 TotallyNotJson.1237: - if TotallyNotJson.1237 then - let TotallyNotJson.1178 : U64 = 1i64; - let TotallyNotJson.1177 : U64 = CallByName Num.19 TotallyNotJson.542 TotallyNotJson.1178; - let TotallyNotJson.1176 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(8) TotallyNotJson.1177; - let TotallyNotJson.1175 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1176; - ret TotallyNotJson.1175; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1239 : Int1 = CallByName TotallyNotJson.64 TotallyNotJson.543; - jump TotallyNotJson.1238 TotallyNotJson.1239; - - case 8: - let TotallyNotJson.1244 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = StructAtIndex 0 TotallyNotJson.1143; - let TotallyNotJson.546 : U64 = UnionAtIndex (Id 8) (Index 0) TotallyNotJson.1244; - let TotallyNotJson.547 : U8 = StructAtIndex 1 TotallyNotJson.1143; - joinpoint TotallyNotJson.1242 TotallyNotJson.1241: - if TotallyNotJson.1241 then - let TotallyNotJson.1182 : U64 = 1i64; - let TotallyNotJson.1181 : U64 = CallByName Num.19 TotallyNotJson.546 TotallyNotJson.1182; - let TotallyNotJson.1180 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = TagId(0) TotallyNotJson.1181; - let TotallyNotJson.1179 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) TotallyNotJson.1180; - ret TotallyNotJson.1179; - else - jump TotallyNotJson.1186; - in - let TotallyNotJson.1243 : Int1 = CallByName TotallyNotJson.64 TotallyNotJson.547; - jump TotallyNotJson.1242 TotallyNotJson.1243; - - default: - jump TotallyNotJson.1186; - - -procedure TotallyNotJson.62 (TotallyNotJson.552): - switch TotallyNotJson.552: - case 34: - let TotallyNotJson.1087 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1087; - - case 92: - let TotallyNotJson.1088 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1088; - - case 47: - let TotallyNotJson.1089 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1089; - - case 98: - let TotallyNotJson.1090 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1090; - - case 102: - let TotallyNotJson.1091 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1091; - - case 110: - let TotallyNotJson.1092 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1092; - - case 114: - let TotallyNotJson.1093 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1093; - - case 116: - let TotallyNotJson.1094 : Int1 = CallByName Bool.2; - ret TotallyNotJson.1094; - - default: - let TotallyNotJson.1095 : Int1 = CallByName Bool.1; - ret TotallyNotJson.1095; - - -procedure TotallyNotJson.63 (TotallyNotJson.553): - switch TotallyNotJson.553: - case 34: - let TotallyNotJson.1064 : U8 = 34i64; - ret TotallyNotJson.1064; - - case 92: - let TotallyNotJson.1065 : U8 = 92i64; - ret TotallyNotJson.1065; - - case 47: - let TotallyNotJson.1066 : U8 = 47i64; - ret TotallyNotJson.1066; - - case 98: - let TotallyNotJson.1067 : U8 = 8i64; - ret TotallyNotJson.1067; - - case 102: - let TotallyNotJson.1068 : U8 = 12i64; - ret TotallyNotJson.1068; - - case 110: - let TotallyNotJson.1069 : U8 = 10i64; - ret TotallyNotJson.1069; - - case 114: - let TotallyNotJson.1070 : U8 = 13i64; - ret TotallyNotJson.1070; - - case 116: - let TotallyNotJson.1071 : U8 = 9i64; - ret TotallyNotJson.1071; - - default: - ret TotallyNotJson.553; - - -procedure TotallyNotJson.64 (TotallyNotJson.554): - let TotallyNotJson.1231 : U8 = 48i64; - let TotallyNotJson.1228 : Int1 = CallByName Num.25 TotallyNotJson.554 TotallyNotJson.1231; - let TotallyNotJson.1230 : U8 = 57i64; - let TotallyNotJson.1229 : Int1 = CallByName Num.23 TotallyNotJson.554 TotallyNotJson.1230; - let TotallyNotJson.1216 : Int1 = CallByName Bool.3 TotallyNotJson.1228 TotallyNotJson.1229; - let TotallyNotJson.1227 : U8 = 97i64; - let TotallyNotJson.1224 : Int1 = CallByName Num.25 TotallyNotJson.554 TotallyNotJson.1227; - let TotallyNotJson.1226 : U8 = 102i64; - let TotallyNotJson.1225 : Int1 = CallByName Num.23 TotallyNotJson.554 TotallyNotJson.1226; - let TotallyNotJson.1218 : Int1 = CallByName Bool.3 TotallyNotJson.1224 TotallyNotJson.1225; - let TotallyNotJson.1223 : U8 = 65i64; - let TotallyNotJson.1220 : Int1 = CallByName Num.25 TotallyNotJson.554 TotallyNotJson.1223; - let TotallyNotJson.1222 : U8 = 70i64; - let TotallyNotJson.1221 : Int1 = CallByName Num.23 TotallyNotJson.554 TotallyNotJson.1222; - let TotallyNotJson.1219 : Int1 = CallByName Bool.3 TotallyNotJson.1220 TotallyNotJson.1221; - let TotallyNotJson.1217 : Int1 = CallByName Bool.4 TotallyNotJson.1218 TotallyNotJson.1219; - let TotallyNotJson.1215 : Int1 = CallByName Bool.4 TotallyNotJson.1216 TotallyNotJson.1217; - ret TotallyNotJson.1215; - -procedure TotallyNotJson.65 (TotallyNotJson.555): - let TotallyNotJson.1043 : U8 = 48i64; - let TotallyNotJson.1040 : Int1 = CallByName Num.25 TotallyNotJson.555 TotallyNotJson.1043; - let TotallyNotJson.1042 : U8 = 57i64; - let TotallyNotJson.1041 : Int1 = CallByName Num.23 TotallyNotJson.555 TotallyNotJson.1042; - let TotallyNotJson.1037 : Int1 = CallByName Bool.3 TotallyNotJson.1040 TotallyNotJson.1041; - if TotallyNotJson.1037 then - let TotallyNotJson.1039 : U8 = 48i64; - let TotallyNotJson.1038 : U8 = CallByName Num.20 TotallyNotJson.555 TotallyNotJson.1039; - ret TotallyNotJson.1038; - else - let TotallyNotJson.1036 : U8 = 97i64; - let TotallyNotJson.1033 : Int1 = CallByName Num.25 TotallyNotJson.555 TotallyNotJson.1036; - let TotallyNotJson.1035 : U8 = 102i64; - let TotallyNotJson.1034 : Int1 = CallByName Num.23 TotallyNotJson.555 TotallyNotJson.1035; - let TotallyNotJson.1028 : Int1 = CallByName Bool.3 TotallyNotJson.1033 TotallyNotJson.1034; - if TotallyNotJson.1028 then - let TotallyNotJson.1032 : U8 = 97i64; - let TotallyNotJson.1030 : U8 = CallByName Num.20 TotallyNotJson.555 TotallyNotJson.1032; - let TotallyNotJson.1031 : U8 = 10i64; - let TotallyNotJson.1029 : U8 = CallByName Num.19 TotallyNotJson.1030 TotallyNotJson.1031; - ret TotallyNotJson.1029; - else - let TotallyNotJson.1027 : U8 = 65i64; - let TotallyNotJson.1024 : Int1 = CallByName Num.25 TotallyNotJson.555 TotallyNotJson.1027; - let TotallyNotJson.1026 : U8 = 70i64; - let TotallyNotJson.1025 : Int1 = CallByName Num.23 TotallyNotJson.555 TotallyNotJson.1026; - let TotallyNotJson.1019 : Int1 = CallByName Bool.3 TotallyNotJson.1024 TotallyNotJson.1025; - if TotallyNotJson.1019 then - let TotallyNotJson.1023 : U8 = 65i64; - let TotallyNotJson.1021 : U8 = CallByName Num.20 TotallyNotJson.555 TotallyNotJson.1023; - let TotallyNotJson.1022 : U8 = 10i64; - let TotallyNotJson.1020 : U8 = CallByName Num.19 TotallyNotJson.1021 TotallyNotJson.1022; - ret TotallyNotJson.1020; - else - let TotallyNotJson.1018 : Str = "got an invalid hex char"; - Crash TotallyNotJson.1018 - -procedure TotallyNotJson.66 (TotallyNotJson.556, TotallyNotJson.557): - let TotallyNotJson.1009 : U8 = 4i64; - let TotallyNotJson.1008 : U8 = CallByName Num.72 TotallyNotJson.556 TotallyNotJson.1009; - let TotallyNotJson.1007 : U8 = CallByName Num.71 TotallyNotJson.1008 TotallyNotJson.557; - ret TotallyNotJson.1007; - -procedure TotallyNotJson.67 (TotallyNotJson.558, TotallyNotJson.559, TotallyNotJson.560, TotallyNotJson.561): - let TotallyNotJson.562 : U8 = CallByName TotallyNotJson.65 TotallyNotJson.558; - let TotallyNotJson.563 : U8 = CallByName TotallyNotJson.65 TotallyNotJson.559; - let TotallyNotJson.564 : U8 = CallByName TotallyNotJson.65 TotallyNotJson.560; - let TotallyNotJson.565 : U8 = CallByName TotallyNotJson.65 TotallyNotJson.561; - let TotallyNotJson.1016 : U8 = 0i64; - let TotallyNotJson.1013 : Int1 = CallByName Bool.11 TotallyNotJson.562 TotallyNotJson.1016; - let TotallyNotJson.1015 : U8 = 0i64; - let TotallyNotJson.1014 : Int1 = CallByName Bool.11 TotallyNotJson.563 TotallyNotJson.1015; - let TotallyNotJson.1010 : Int1 = CallByName Bool.3 TotallyNotJson.1013 TotallyNotJson.1014; - if TotallyNotJson.1010 then - let TotallyNotJson.1012 : U8 = CallByName TotallyNotJson.66 TotallyNotJson.564 TotallyNotJson.565; - let TotallyNotJson.1011 : List U8 = Array [TotallyNotJson.1012]; - ret TotallyNotJson.1011; - else - let TotallyNotJson.1005 : U8 = CallByName TotallyNotJson.66 TotallyNotJson.562 TotallyNotJson.563; - let TotallyNotJson.1006 : U8 = CallByName TotallyNotJson.66 TotallyNotJson.564 TotallyNotJson.565; - let TotallyNotJson.1004 : List U8 = Array [TotallyNotJson.1005, TotallyNotJson.1006]; - ret TotallyNotJson.1004; - -procedure TotallyNotJson.68 (): - let TotallyNotJson.1049 : U8 = 102i64; - let TotallyNotJson.1050 : U8 = 102i64; - let TotallyNotJson.1051 : U8 = 100i64; - let TotallyNotJson.1052 : U8 = 100i64; - let TotallyNotJson.1048 : List U8 = CallByName TotallyNotJson.67 TotallyNotJson.1049 TotallyNotJson.1050 TotallyNotJson.1051 TotallyNotJson.1052; - ret TotallyNotJson.1048; - -procedure TotallyNotJson.69 (#Derived_gen.5): - joinpoint TotallyNotJson.999 TotallyNotJson.970: - let TotallyNotJson.566 : List U8 = StructAtIndex 0 TotallyNotJson.970; - inc 4 TotallyNotJson.566; - let TotallyNotJson.567 : List U8 = StructAtIndex 1 TotallyNotJson.970; - let TotallyNotJson.1118 : U64 = 0i64; - let TotallyNotJson.568 : [C {}, C U8] = CallByName List.2 TotallyNotJson.566 TotallyNotJson.1118; - let TotallyNotJson.1117 : U64 = 1i64; - let TotallyNotJson.569 : [C {}, C U8] = CallByName List.2 TotallyNotJson.566 TotallyNotJson.1117; - let TotallyNotJson.1116 : U64 = 2i64; - let TotallyNotJson.570 : List U8 = CallByName List.38 TotallyNotJson.566 TotallyNotJson.1116; - let TotallyNotJson.1115 : U64 = 6i64; - let TotallyNotJson.571 : List U8 = CallByName List.38 TotallyNotJson.566 TotallyNotJson.1115; - let TotallyNotJson.1000 : {[C {}, C U8], [C {}, C U8]} = Struct {TotallyNotJson.568, TotallyNotJson.569}; - joinpoint TotallyNotJson.1080: - let TotallyNotJson.1079 : [C {}, C U8] = StructAtIndex 0 TotallyNotJson.1000; - let TotallyNotJson.582 : U8 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1079; - let TotallyNotJson.1077 : U64 = 1i64; - let TotallyNotJson.1075 : List U8 = CallByName List.38 TotallyNotJson.566 TotallyNotJson.1077; - let TotallyNotJson.1076 : List U8 = CallByName List.4 TotallyNotJson.567 TotallyNotJson.582; - let TotallyNotJson.1074 : {List U8, List U8} = Struct {TotallyNotJson.1075, TotallyNotJson.1076}; - jump TotallyNotJson.999 TotallyNotJson.1074; - in - let TotallyNotJson.1111 : [C {}, C U8] = StructAtIndex 0 TotallyNotJson.1000; - let TotallyNotJson.1112 : U8 = 1i64; - let TotallyNotJson.1113 : U8 = GetTagId TotallyNotJson.1111; - let TotallyNotJson.1114 : Int1 = lowlevel Eq TotallyNotJson.1112 TotallyNotJson.1113; - if TotallyNotJson.1114 then - let TotallyNotJson.1107 : [C {}, C U8] = StructAtIndex 1 TotallyNotJson.1000; - let TotallyNotJson.1108 : U8 = 1i64; - let TotallyNotJson.1109 : U8 = GetTagId TotallyNotJson.1107; - let TotallyNotJson.1110 : Int1 = lowlevel Eq TotallyNotJson.1108 TotallyNotJson.1109; - if TotallyNotJson.1110 then - let TotallyNotJson.1106 : [C {}, C U8] = StructAtIndex 0 TotallyNotJson.1000; - let TotallyNotJson.573 : U8 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1106; - let TotallyNotJson.1105 : [C {}, C U8] = StructAtIndex 1 TotallyNotJson.1000; - let TotallyNotJson.574 : U8 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1105; - joinpoint TotallyNotJson.1099 TotallyNotJson.1081: - if TotallyNotJson.1081 then - dec TotallyNotJson.566; - let TotallyNotJson.1057 : U64 = lowlevel ListLenUsize TotallyNotJson.570; - let TotallyNotJson.1058 : U64 = 4i64; - let TotallyNotJson.1059 : Int1 = lowlevel NumGte TotallyNotJson.1057 TotallyNotJson.1058; - if TotallyNotJson.1059 then - let TotallyNotJson.1056 : U64 = 0i64; - let TotallyNotJson.575 : U8 = lowlevel ListGetUnsafe TotallyNotJson.570 TotallyNotJson.1056; - let TotallyNotJson.1055 : U64 = 1i64; - let TotallyNotJson.576 : U8 = lowlevel ListGetUnsafe TotallyNotJson.570 TotallyNotJson.1055; - let TotallyNotJson.1054 : U64 = 2i64; - let TotallyNotJson.577 : U8 = lowlevel ListGetUnsafe TotallyNotJson.570 TotallyNotJson.1054; - let TotallyNotJson.1053 : U64 = 3i64; - let TotallyNotJson.578 : U8 = lowlevel ListGetUnsafe TotallyNotJson.570 TotallyNotJson.1053; - dec TotallyNotJson.570; - let TotallyNotJson.579 : List U8 = CallByName TotallyNotJson.67 TotallyNotJson.575 TotallyNotJson.576 TotallyNotJson.577 TotallyNotJson.578; - let TotallyNotJson.1003 : List U8 = CallByName List.8 TotallyNotJson.567 TotallyNotJson.579; - let TotallyNotJson.1002 : {List U8, List U8} = Struct {TotallyNotJson.571, TotallyNotJson.1003}; - jump TotallyNotJson.999 TotallyNotJson.1002; - else - dec TotallyNotJson.571; - let TotallyNotJson.1047 : List U8 = CallByName TotallyNotJson.68; - let TotallyNotJson.1046 : List U8 = CallByName List.8 TotallyNotJson.567 TotallyNotJson.1047; - let TotallyNotJson.1045 : {List U8, List U8} = Struct {TotallyNotJson.570, TotallyNotJson.1046}; - jump TotallyNotJson.999 TotallyNotJson.1045; - else - dec TotallyNotJson.571; - let TotallyNotJson.1098 : [C {}, C U8] = StructAtIndex 0 TotallyNotJson.1000; - let TotallyNotJson.580 : U8 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1098; - let TotallyNotJson.1097 : [C {}, C U8] = StructAtIndex 1 TotallyNotJson.1000; - let TotallyNotJson.581 : U8 = UnionAtIndex (Id 1) (Index 0) TotallyNotJson.1097; - joinpoint TotallyNotJson.1083 TotallyNotJson.1082: - if TotallyNotJson.1082 then - dec TotallyNotJson.566; - let TotallyNotJson.1063 : U8 = CallByName TotallyNotJson.63 TotallyNotJson.581; - let TotallyNotJson.1062 : List U8 = CallByName List.4 TotallyNotJson.567 TotallyNotJson.1063; - let TotallyNotJson.1061 : {List U8, List U8} = Struct {TotallyNotJson.570, TotallyNotJson.1062}; - jump TotallyNotJson.999 TotallyNotJson.1061; - else - dec TotallyNotJson.570; - jump TotallyNotJson.1080; - in - let TotallyNotJson.1096 : U8 = 92i64; - let TotallyNotJson.1085 : Int1 = CallByName Bool.11 TotallyNotJson.580 TotallyNotJson.1096; - let TotallyNotJson.1086 : Int1 = CallByName TotallyNotJson.62 TotallyNotJson.581; - let TotallyNotJson.1084 : Int1 = CallByName Bool.3 TotallyNotJson.1085 TotallyNotJson.1086; - jump TotallyNotJson.1083 TotallyNotJson.1084; - in - let TotallyNotJson.1104 : U8 = 92i64; - let TotallyNotJson.1101 : Int1 = CallByName Bool.11 TotallyNotJson.573 TotallyNotJson.1104; - let TotallyNotJson.1103 : U8 = 117i64; - let TotallyNotJson.1102 : Int1 = CallByName Bool.11 TotallyNotJson.574 TotallyNotJson.1103; - let TotallyNotJson.1100 : Int1 = CallByName Bool.3 TotallyNotJson.1101 TotallyNotJson.1102; - jump TotallyNotJson.1099 TotallyNotJson.1100; - else - dec TotallyNotJson.571; - dec TotallyNotJson.570; - jump TotallyNotJson.1080; - else - dec TotallyNotJson.571; - dec TotallyNotJson.570; - let TotallyNotJson.1078 : {List U8, List U8} = Struct {TotallyNotJson.566, TotallyNotJson.567}; - ret TotallyNotJson.1078; - in - jump TotallyNotJson.999 #Derived_gen.5; - -procedure TotallyNotJson.8 (): - let TotallyNotJson.973 : {} = Struct {}; - ret TotallyNotJson.973; +procedure Test.76 (Test.77, Test.138): + let Test.141 : {} = Struct {}; + let Test.140 : [C {}, C Str] = TagId(0) Test.141; + let Test.139 : {List U8, [C {}, C Str]} = Struct {Test.77, Test.140}; + ret Test.139; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt index 050c35cc3b..44b28965f9 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt @@ -12,483 +12,198 @@ procedure Encode.23 (Encode.98): ret Encode.98; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.111 : List U8 = CallByName Test.5 Encode.99 Encode.101 Encode.107; + let Encode.111 : List U8 = CallByName Test.213 Encode.99 Encode.101 Encode.107; ret Encode.111; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName TotallyNotJson.231 Encode.99 Encode.101 Encode.107; - ret Encode.113; + let Encode.115 : List U8 = CallByName Test.63 Encode.99 Encode.101 Encode.107; + ret Encode.115; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.118 : List U8 = CallByName TotallyNotJson.150 Encode.99 Encode.101 Encode.107; - ret Encode.118; + let Encode.116 : List U8 = CallByName Test.59 Encode.99 Encode.101 Encode.107; + ret Encode.116; procedure Encode.26 (Encode.105, Encode.106): let Encode.109 : List U8 = Array []; - let Encode.110 : {Str, Str} = CallByName Test.2 Encode.105; + let Encode.110 : {Str, Str} = CallByName Test.49 Encode.105; let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.104 (List.488, List.489, List.490): - let List.657 : U64 = 0i64; - let List.658 : U64 = CallByName List.6 List.488; - let List.656 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.488 List.489 List.490 List.657 List.658; - ret List.656; - -procedure List.18 (List.160, List.161, List.162): - let List.601 : U64 = 0i64; - let List.602 : U64 = CallByName List.6 List.160; - let List.600 : {List U8, U64} = CallByName List.92 List.160 List.161 List.162 List.601 List.602; +procedure List.13 (#Attr.2, #Attr.3): + let List.600 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; ret List.600; procedure List.18 (List.160, List.161, List.162): - let List.613 : U64 = 0i64; - let List.614 : U64 = CallByName List.6 List.160; - let List.612 : List U8 = CallByName List.92 List.160 List.161 List.162 List.613 List.614; - ret List.612; - -procedure List.26 (List.201, List.202, List.203): - let List.650 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.104 List.201 List.202 List.203; - let List.653 : U8 = 1i64; - let List.654 : U8 = GetTagId List.650; - let List.655 : Int1 = lowlevel Eq List.653 List.654; - if List.655 then - let List.204 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.650; - ret List.204; - else - let List.205 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.650; - ret List.205; + let List.575 : U64 = 0i64; + let List.576 : U64 = CallByName List.6 List.160; + let List.574 : List U8 = CallByName List.92 List.160 List.161 List.162 List.575 List.576; + ret List.574; procedure List.4 (List.124, List.125): - let List.599 : U64 = 1i64; - let List.598 : List U8 = CallByName List.70 List.124 List.599; - let List.597 : List U8 = CallByName List.71 List.598 List.125; - ret List.597; - -procedure List.49 (List.420, List.421): - let List.641 : U64 = StructAtIndex 1 List.421; - let List.642 : U64 = StructAtIndex 0 List.421; - let List.640 : List U8 = CallByName List.72 List.420 List.641 List.642; - ret List.640; - -procedure List.52 (List.435, List.436): - let List.437 : U64 = CallByName List.6 List.435; - joinpoint List.648 List.438: - let List.646 : U64 = 0i64; - let List.645 : {U64, U64} = Struct {List.438, List.646}; - inc List.435; - let List.439 : List U8 = CallByName List.49 List.435 List.645; - let List.644 : U64 = CallByName Num.75 List.437 List.438; - let List.639 : {U64, U64} = Struct {List.644, List.438}; - let List.440 : List U8 = CallByName List.49 List.435 List.639; - let List.638 : {List U8, List U8} = Struct {List.439, List.440}; - ret List.638; - in - let List.649 : Int1 = CallByName Num.24 List.437 List.436; - if List.649 then - jump List.648 List.436; - else - jump List.648 List.437; + let List.596 : U64 = 1i64; + let List.595 : List U8 = CallByName List.70 List.124 List.596; + let List.594 : List U8 = CallByName List.71 List.595 List.125; + ret List.594; procedure List.6 (#Attr.2): - let List.624 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.624; - -procedure List.6 (#Attr.2): - let List.626 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.626; + let List.599 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.599; procedure List.66 (#Attr.2, #Attr.3): - let List.610 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.610; - -procedure List.66 (#Attr.2, #Attr.3): - let List.622 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.622; - -procedure List.68 (#Attr.2): - let List.637 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.637; + let List.584 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.584; procedure List.70 (#Attr.2, #Attr.3): - let List.578 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.578; + let List.590 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.590; procedure List.71 (#Attr.2, #Attr.3): - let List.576 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.576; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.643 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.643; + let List.588 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.588; procedure List.8 (#Attr.2, #Attr.3): - let List.635 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.635; + let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.598; -procedure List.80 (#Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12): - joinpoint List.659 List.491 List.492 List.493 List.494 List.495: - let List.661 : Int1 = CallByName Num.22 List.494 List.495; - if List.661 then - let List.670 : U8 = CallByName List.66 List.491 List.494; - let List.662 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.157 List.492 List.670; - let List.667 : U8 = 1i64; - let List.668 : U8 = GetTagId List.662; - let List.669 : Int1 = lowlevel Eq List.667 List.668; - if List.669 then - let List.496 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.662; - let List.665 : U64 = 1i64; - let List.664 : U64 = CallByName Num.51 List.494 List.665; - jump List.659 List.491 List.496 List.493 List.664 List.495; - else - dec List.491; - let List.497 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.662; - let List.666 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.497; - ret List.666; - else - dec List.491; - let List.660 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.492; - ret List.660; - in - jump List.659 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; - -procedure List.92 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): - joinpoint List.615 List.163 List.164 List.165 List.166 List.167: - let List.617 : Int1 = CallByName Num.22 List.166 List.167; - if List.617 then - let List.621 : U8 = CallByName List.66 List.163 List.166; - let List.168 : List U8 = CallByName TotallyNotJson.183 List.164 List.621; - let List.620 : U64 = 1i64; - let List.619 : U64 = CallByName Num.51 List.166 List.620; - jump List.615 List.163 List.168 List.165 List.619 List.167; +procedure List.92 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.577 List.163 List.164 List.165 List.166 List.167: + let List.579 : Int1 = CallByName Num.22 List.166 List.167; + if List.579 then + let List.583 : Str = CallByName List.66 List.163 List.166; + inc List.583; + let List.168 : List U8 = CallByName Test.66 List.164 List.583 List.165; + let List.582 : U64 = 1i64; + let List.581 : U64 = CallByName Num.51 List.166 List.582; + jump List.577 List.163 List.168 List.165 List.581 List.167; else dec List.163; ret List.164; in - jump List.615 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; - -procedure List.92 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.603 List.163 List.164 List.165 List.166 List.167: - let List.605 : Int1 = CallByName Num.22 List.166 List.167; - if List.605 then - let List.609 : Str = CallByName List.66 List.163 List.166; - inc List.609; - let List.168 : {List U8, U64} = CallByName TotallyNotJson.233 List.164 List.609; - let List.608 : U64 = 1i64; - let List.607 : U64 = CallByName Num.51 List.166 List.608; - jump List.603 List.163 List.168 List.165 List.607 List.167; - else - dec List.163; - ret List.164; - in - jump List.603 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + jump List.577 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.127 (#Attr.2): - let Num.286 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.286; - -procedure Num.137 (#Attr.2, #Attr.3): - let Num.291 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; - ret Num.291; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.290 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.290; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.287 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.287; - -procedure Num.21 (#Attr.2, #Attr.3): - let Num.292 : U64 = lowlevel NumMul #Attr.2 #Attr.3; - ret Num.292; + let Num.280 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.280; procedure Num.22 (#Attr.2, #Attr.3): - let Num.298 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.298; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.300 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.300; + let Num.282 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.282; procedure Num.51 (#Attr.2, #Attr.3): - let Num.295 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.295; + let Num.281 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.281; -procedure Num.75 (#Attr.2, #Attr.3): - let Num.299 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.299; +procedure Num.96 (#Attr.2): + let Num.279 : Str = lowlevel NumToStr #Attr.2; + ret Num.279; procedure Str.12 (#Attr.2): let Str.233 : List U8 = lowlevel StrToUtf8 #Attr.2; ret Str.233; -procedure Test.2 (Test.10): - let Test.15 : {Str, Str} = CallByName Encode.23 Test.10; - ret Test.15; +procedure Str.36 (#Attr.2): + let Str.234 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.234; + +procedure Test.20 (Test.58): + let Test.295 : Str = CallByName Encode.23 Test.58; + ret Test.295; + +procedure Test.21 (Test.61, Test.62): + let Test.275 : {List Str, {}} = Struct {Test.61, Test.62}; + let Test.274 : {List Str, {}} = CallByName Encode.23 Test.275; + ret Test.274; + +procedure Test.213 (Test.214, Test.215, Test.212): + joinpoint Test.267 Test.216: + let Test.265 : List U8 = CallByName Encode.24 Test.214 Test.216 Test.215; + ret Test.265; + in + let Test.308 : Int1 = CallByName Bool.2; + if Test.308 then + let Test.309 : Str = "A"; + let Test.312 : Str = StructAtIndex 0 Test.212; + let #Derived_gen.17 : Str = StructAtIndex 1 Test.212; + dec #Derived_gen.17; + let Test.311 : Str = CallByName Test.20 Test.312; + let Test.310 : List Str = Array [Test.311]; + let Test.266 : {List Str, {}} = CallByName Test.24 Test.309 Test.310; + jump Test.267 Test.266; + else + let Test.268 : Str = "B"; + let Test.307 : Str = StructAtIndex 1 Test.212; + let #Derived_gen.18 : Str = StructAtIndex 0 Test.212; + dec #Derived_gen.18; + let Test.306 : Str = CallByName Test.20 Test.307; + let Test.269 : List Str = Array [Test.306]; + let Test.266 : {List Str, {}} = CallByName Test.24 Test.268 Test.269; + jump Test.267 Test.266; + +procedure Test.23 (Test.77): + let Test.273 : {} = Struct {}; + let Test.272 : {List Str, {}} = CallByName Test.21 Test.77 Test.273; + ret Test.272; + +procedure Test.24 (Test.80, Test.81): + let Test.294 : Str = CallByName Test.20 Test.80; + let Test.271 : List Str = CallByName List.13 Test.81 Test.294; + let Test.270 : {List Str, {}} = CallByName Test.23 Test.271; + ret Test.270; procedure Test.3 (): - let Test.9 : Str = ""; - inc Test.9; - let Test.14 : {Str, Str} = Struct {Test.9, Test.9}; - ret Test.14; + let Test.260 : {} = Struct {}; + ret Test.260; -procedure Test.5 (Test.6, Test.7, Test.4): - joinpoint Test.20 Test.8: - let Test.18 : List U8 = CallByName Encode.24 Test.6 Test.8 Test.7; - ret Test.18; - in - let Test.25 : Int1 = CallByName Bool.2; - if Test.25 then - let Test.26 : Str = "A"; - let Test.29 : Str = StructAtIndex 0 Test.4; - let #Derived_gen.24 : Str = StructAtIndex 1 Test.4; - dec #Derived_gen.24; - let Test.28 : Str = CallByName TotallyNotJson.25 Test.29; - let Test.27 : List Str = Array [Test.28]; - let Test.19 : {Str, List Str} = CallByName TotallyNotJson.31 Test.26 Test.27; - jump Test.20 Test.19; - else - let Test.21 : Str = "B"; - let Test.24 : Str = StructAtIndex 1 Test.4; - let #Derived_gen.25 : Str = StructAtIndex 0 Test.4; - dec #Derived_gen.25; - let Test.23 : Str = CallByName TotallyNotJson.25 Test.24; - let Test.22 : List Str = Array [Test.23]; - let Test.19 : {Str, List Str} = CallByName TotallyNotJson.31 Test.21 Test.22; - jump Test.20 Test.19; +procedure Test.4 (Test.51, Test.52, Test.53): + let Test.292 : U8 = CallByName Num.127 Test.52; + let Test.289 : List U8 = CallByName List.4 Test.51 Test.292; + let Test.291 : Str = CallByName Num.96 Test.53; + let Test.290 : List U8 = CallByName Str.12 Test.291; + let Test.287 : List U8 = CallByName List.8 Test.289 Test.290; + let Test.288 : U8 = 32i64; + let Test.286 : List U8 = CallByName List.4 Test.287 Test.288; + ret Test.286; -procedure TotallyNotJson.150 (TotallyNotJson.151, TotallyNotJson.1020, TotallyNotJson.149): - let TotallyNotJson.1023 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.149; - let TotallyNotJson.1022 : List U8 = CallByName List.8 TotallyNotJson.151 TotallyNotJson.1023; - ret TotallyNotJson.1022; +procedure Test.49 (Test.255): + let Test.262 : {Str, Str} = CallByName Encode.23 Test.255; + ret Test.262; -procedure TotallyNotJson.157 (TotallyNotJson.1071, TotallyNotJson.160): - let TotallyNotJson.158 : U64 = StructAtIndex 0 TotallyNotJson.1071; - let TotallyNotJson.159 : Int1 = StructAtIndex 1 TotallyNotJson.1071; - switch TotallyNotJson.160: - case 34: - let TotallyNotJson.1074 : Int1 = false; - let TotallyNotJson.1073 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1074}; - let TotallyNotJson.1072 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1073; - ret TotallyNotJson.1072; - - case 92: - let TotallyNotJson.1077 : Int1 = false; - let TotallyNotJson.1076 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1077}; - let TotallyNotJson.1075 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1076; - ret TotallyNotJson.1075; - - case 47: - let TotallyNotJson.1080 : Int1 = false; - let TotallyNotJson.1079 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1080}; - let TotallyNotJson.1078 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1079; - ret TotallyNotJson.1078; - - case 8: - let TotallyNotJson.1083 : Int1 = false; - let TotallyNotJson.1082 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1083}; - let TotallyNotJson.1081 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1082; - ret TotallyNotJson.1081; - - case 12: - let TotallyNotJson.1086 : Int1 = false; - let TotallyNotJson.1085 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1086}; - let TotallyNotJson.1084 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1085; - ret TotallyNotJson.1084; - - case 10: - let TotallyNotJson.1089 : Int1 = false; - let TotallyNotJson.1088 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1089}; - let TotallyNotJson.1087 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1088; - ret TotallyNotJson.1087; - - case 13: - let TotallyNotJson.1092 : Int1 = false; - let TotallyNotJson.1091 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1092}; - let TotallyNotJson.1090 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1091; - ret TotallyNotJson.1090; - - case 9: - let TotallyNotJson.1095 : Int1 = false; - let TotallyNotJson.1094 : {U64, Int1} = Struct {TotallyNotJson.158, TotallyNotJson.1095}; - let TotallyNotJson.1093 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) TotallyNotJson.1094; - ret TotallyNotJson.1093; - - default: - let TotallyNotJson.1099 : U64 = 1i64; - let TotallyNotJson.1098 : U64 = CallByName Num.19 TotallyNotJson.158 TotallyNotJson.1099; - let TotallyNotJson.1097 : {U64, Int1} = Struct {TotallyNotJson.1098, TotallyNotJson.159}; - let TotallyNotJson.1096 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) TotallyNotJson.1097; - ret TotallyNotJson.1096; - +procedure Test.50 (): + let Test.217 : Str = ""; + inc Test.217; + let Test.261 : {Str, Str} = Struct {Test.217, Test.217}; + ret Test.261; -procedure TotallyNotJson.183 (TotallyNotJson.184, TotallyNotJson.185): - let TotallyNotJson.1042 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.185; - let TotallyNotJson.1041 : List U8 = CallByName List.8 TotallyNotJson.184 TotallyNotJson.1042; - ret TotallyNotJson.1041; +procedure Test.59 (Test.60, Test.297, Test.58): + let Test.304 : I64 = 115i64; + let Test.305 : U64 = CallByName Str.36 Test.58; + let Test.302 : List U8 = CallByName Test.4 Test.60 Test.304 Test.305; + let Test.303 : List U8 = CallByName Str.12 Test.58; + let Test.300 : List U8 = CallByName List.8 Test.302 Test.303; + let Test.301 : U8 = 32i64; + let Test.299 : List U8 = CallByName List.4 Test.300 Test.301; + ret Test.299; -procedure TotallyNotJson.231 (TotallyNotJson.232, TotallyNotJson.976, #Attr.12): - let TotallyNotJson.230 : List Str = StructAtIndex 1 #Attr.12; - let TotallyNotJson.229 : Str = StructAtIndex 0 #Attr.12; - let TotallyNotJson.1014 : I64 = 123i64; - let TotallyNotJson.1013 : U8 = CallByName Num.127 TotallyNotJson.1014; - let TotallyNotJson.1010 : List U8 = CallByName List.4 TotallyNotJson.232 TotallyNotJson.1013; - let TotallyNotJson.1012 : I64 = 34i64; - let TotallyNotJson.1011 : U8 = CallByName Num.127 TotallyNotJson.1012; - let TotallyNotJson.1008 : List U8 = CallByName List.4 TotallyNotJson.1010 TotallyNotJson.1011; - let TotallyNotJson.1009 : List U8 = CallByName Str.12 TotallyNotJson.229; - let TotallyNotJson.1005 : List U8 = CallByName List.8 TotallyNotJson.1008 TotallyNotJson.1009; - let TotallyNotJson.1007 : I64 = 34i64; - let TotallyNotJson.1006 : U8 = CallByName Num.127 TotallyNotJson.1007; - let TotallyNotJson.1002 : List U8 = CallByName List.4 TotallyNotJson.1005 TotallyNotJson.1006; - let TotallyNotJson.1004 : I64 = 58i64; - let TotallyNotJson.1003 : U8 = CallByName Num.127 TotallyNotJson.1004; - let TotallyNotJson.999 : List U8 = CallByName List.4 TotallyNotJson.1002 TotallyNotJson.1003; - let TotallyNotJson.1001 : I64 = 91i64; - let TotallyNotJson.1000 : U8 = CallByName Num.127 TotallyNotJson.1001; - let TotallyNotJson.234 : List U8 = CallByName List.4 TotallyNotJson.999 TotallyNotJson.1000; - let TotallyNotJson.998 : U64 = CallByName List.6 TotallyNotJson.230; - let TotallyNotJson.986 : {List U8, U64} = Struct {TotallyNotJson.234, TotallyNotJson.998}; - let TotallyNotJson.987 : {} = Struct {}; - let TotallyNotJson.985 : {List U8, U64} = CallByName List.18 TotallyNotJson.230 TotallyNotJson.986 TotallyNotJson.987; - let TotallyNotJson.236 : List U8 = StructAtIndex 0 TotallyNotJson.985; - let TotallyNotJson.984 : I64 = 93i64; - let TotallyNotJson.983 : U8 = CallByName Num.127 TotallyNotJson.984; - let TotallyNotJson.980 : List U8 = CallByName List.4 TotallyNotJson.236 TotallyNotJson.983; - let TotallyNotJson.982 : I64 = 125i64; - let TotallyNotJson.981 : U8 = CallByName Num.127 TotallyNotJson.982; - let TotallyNotJson.979 : List U8 = CallByName List.4 TotallyNotJson.980 TotallyNotJson.981; - ret TotallyNotJson.979; +procedure Test.63 (Test.64, Test.276, #Attr.12): + let Test.62 : {} = StructAtIndex 1 #Attr.12; + let Test.61 : List Str = StructAtIndex 0 #Attr.12; + let Test.284 : I64 = 108i64; + let Test.285 : U64 = CallByName List.6 Test.61; + let Test.65 : List U8 = CallByName Test.4 Test.64 Test.284 Test.285; + let Test.278 : List U8 = CallByName List.18 Test.61 Test.65 Test.62; + ret Test.278; -procedure TotallyNotJson.233 (TotallyNotJson.978, TotallyNotJson.239): - let TotallyNotJson.237 : List U8 = StructAtIndex 0 TotallyNotJson.978; - let TotallyNotJson.238 : U64 = StructAtIndex 1 TotallyNotJson.978; - let TotallyNotJson.997 : {} = Struct {}; - let TotallyNotJson.240 : List U8 = CallByName Encode.24 TotallyNotJson.237 TotallyNotJson.239 TotallyNotJson.997; - joinpoint TotallyNotJson.992 TotallyNotJson.241: - let TotallyNotJson.990 : U64 = 1i64; - let TotallyNotJson.989 : U64 = CallByName Num.20 TotallyNotJson.238 TotallyNotJson.990; - let TotallyNotJson.988 : {List U8, U64} = Struct {TotallyNotJson.241, TotallyNotJson.989}; - ret TotallyNotJson.988; - in - let TotallyNotJson.996 : U64 = 1i64; - let TotallyNotJson.993 : Int1 = CallByName Num.24 TotallyNotJson.238 TotallyNotJson.996; - if TotallyNotJson.993 then - let TotallyNotJson.995 : I64 = 44i64; - let TotallyNotJson.994 : U8 = CallByName Num.127 TotallyNotJson.995; - let TotallyNotJson.991 : List U8 = CallByName List.4 TotallyNotJson.240 TotallyNotJson.994; - jump TotallyNotJson.992 TotallyNotJson.991; - else - jump TotallyNotJson.992 TotallyNotJson.240; +procedure Test.66 (Test.67, Test.68, Test.62): + let Test.282 : Str = CallByName Test.78 Test.68; + let Test.283 : {} = Struct {}; + let Test.281 : List U8 = CallByName Encode.24 Test.67 Test.282 Test.283; + ret Test.281; -procedure TotallyNotJson.25 (TotallyNotJson.149): - let TotallyNotJson.1102 : Str = CallByName Encode.23 TotallyNotJson.149; - ret TotallyNotJson.1102; - -procedure TotallyNotJson.26 (TotallyNotJson.152): - let TotallyNotJson.153 : List U8 = CallByName Str.12 TotallyNotJson.152; - let TotallyNotJson.1100 : U64 = 0i64; - let TotallyNotJson.1101 : Int1 = true; - let TotallyNotJson.154 : {U64, Int1} = Struct {TotallyNotJson.1100, TotallyNotJson.1101}; - let TotallyNotJson.1070 : {} = Struct {}; - inc TotallyNotJson.153; - let TotallyNotJson.155 : {U64, Int1} = CallByName List.26 TotallyNotJson.153 TotallyNotJson.154 TotallyNotJson.1070; - let TotallyNotJson.1024 : Int1 = StructAtIndex 1 TotallyNotJson.155; - let TotallyNotJson.1068 : Int1 = true; - let TotallyNotJson.1069 : Int1 = lowlevel Eq TotallyNotJson.1068 TotallyNotJson.1024; - if TotallyNotJson.1069 then - let TotallyNotJson.1034 : U64 = CallByName List.6 TotallyNotJson.153; - let TotallyNotJson.1035 : U64 = 2i64; - let TotallyNotJson.1033 : U64 = CallByName Num.19 TotallyNotJson.1034 TotallyNotJson.1035; - let TotallyNotJson.1030 : List U8 = CallByName List.68 TotallyNotJson.1033; - let TotallyNotJson.1032 : U8 = 34i64; - let TotallyNotJson.1031 : List U8 = Array [TotallyNotJson.1032]; - let TotallyNotJson.1029 : List U8 = CallByName List.8 TotallyNotJson.1030 TotallyNotJson.1031; - let TotallyNotJson.1026 : List U8 = CallByName List.8 TotallyNotJson.1029 TotallyNotJson.153; - let TotallyNotJson.1028 : U8 = 34i64; - let TotallyNotJson.1027 : List U8 = Array [TotallyNotJson.1028]; - let TotallyNotJson.1025 : List U8 = CallByName List.8 TotallyNotJson.1026 TotallyNotJson.1027; - ret TotallyNotJson.1025; - else - inc TotallyNotJson.153; - let TotallyNotJson.1067 : U64 = StructAtIndex 0 TotallyNotJson.155; - let TotallyNotJson.1066 : {List U8, List U8} = CallByName List.52 TotallyNotJson.153 TotallyNotJson.1067; - let TotallyNotJson.179 : List U8 = StructAtIndex 0 TotallyNotJson.1066; - let TotallyNotJson.181 : List U8 = StructAtIndex 1 TotallyNotJson.1066; - let TotallyNotJson.1064 : U64 = CallByName List.6 TotallyNotJson.153; - dec TotallyNotJson.153; - let TotallyNotJson.1065 : U64 = 120i64; - let TotallyNotJson.1062 : U64 = CallByName Num.21 TotallyNotJson.1064 TotallyNotJson.1065; - let TotallyNotJson.1063 : U64 = 100i64; - let TotallyNotJson.1061 : U64 = CallByName Num.137 TotallyNotJson.1062 TotallyNotJson.1063; - let TotallyNotJson.1058 : List U8 = CallByName List.68 TotallyNotJson.1061; - let TotallyNotJson.1060 : U8 = 34i64; - let TotallyNotJson.1059 : List U8 = Array [TotallyNotJson.1060]; - let TotallyNotJson.1057 : List U8 = CallByName List.8 TotallyNotJson.1058 TotallyNotJson.1059; - let TotallyNotJson.182 : List U8 = CallByName List.8 TotallyNotJson.1057 TotallyNotJson.179; - let TotallyNotJson.1040 : {} = Struct {}; - let TotallyNotJson.1037 : List U8 = CallByName List.18 TotallyNotJson.181 TotallyNotJson.182 TotallyNotJson.1040; - let TotallyNotJson.1039 : U8 = 34i64; - let TotallyNotJson.1038 : List U8 = Array [TotallyNotJson.1039]; - let TotallyNotJson.1036 : List U8 = CallByName List.8 TotallyNotJson.1037 TotallyNotJson.1038; - ret TotallyNotJson.1036; - -procedure TotallyNotJson.27 (TotallyNotJson.186): - switch TotallyNotJson.186: - case 34: - let TotallyNotJson.1043 : List U8 = Array [92i64, 34i64]; - ret TotallyNotJson.1043; - - case 92: - let TotallyNotJson.1044 : List U8 = Array [92i64, 92i64]; - ret TotallyNotJson.1044; - - case 47: - let TotallyNotJson.1045 : List U8 = Array [92i64, 47i64]; - ret TotallyNotJson.1045; - - case 8: - let TotallyNotJson.1047 : U8 = 98i64; - let TotallyNotJson.1046 : List U8 = Array [92i64, TotallyNotJson.1047]; - ret TotallyNotJson.1046; - - case 12: - let TotallyNotJson.1049 : U8 = 102i64; - let TotallyNotJson.1048 : List U8 = Array [92i64, TotallyNotJson.1049]; - ret TotallyNotJson.1048; - - case 10: - let TotallyNotJson.1051 : U8 = 110i64; - let TotallyNotJson.1050 : List U8 = Array [92i64, TotallyNotJson.1051]; - ret TotallyNotJson.1050; - - case 13: - let TotallyNotJson.1053 : U8 = 114i64; - let TotallyNotJson.1052 : List U8 = Array [92i64, TotallyNotJson.1053]; - ret TotallyNotJson.1052; - - case 9: - let TotallyNotJson.1055 : U8 = 114i64; - let TotallyNotJson.1054 : List U8 = Array [92i64, TotallyNotJson.1055]; - ret TotallyNotJson.1054; - - default: - let TotallyNotJson.1056 : List U8 = Array [TotallyNotJson.186]; - ret TotallyNotJson.1056; - - -procedure TotallyNotJson.31 (TotallyNotJson.229, TotallyNotJson.230): - let TotallyNotJson.1016 : {Str, List Str} = Struct {TotallyNotJson.229, TotallyNotJson.230}; - let TotallyNotJson.1015 : {Str, List Str} = CallByName Encode.23 TotallyNotJson.1016; - ret TotallyNotJson.1015; - -procedure TotallyNotJson.8 (): - let TotallyNotJson.973 : {} = Struct {}; - ret TotallyNotJson.973; +procedure Test.78 (Test.79): + ret Test.79; procedure Test.0 (): - let Test.12 : {Str, Str} = CallByName Test.3; - let Test.13 : {} = CallByName TotallyNotJson.8; - let Test.11 : List U8 = CallByName Encode.26 Test.12 Test.13; - ret Test.11; + let Test.258 : {Str, Str} = CallByName Test.50; + let Test.259 : {} = CallByName Test.3; + let Test.257 : List U8 = CallByName Encode.26 Test.258 Test.259; + ret Test.257; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt index fa523d640b..46f2f1546d 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt @@ -1,6 +1,6 @@ procedure #Derived.0 (#Derived.1): - let #Derived_gen.11 : [C {}, C {}] = TagId(0) #Derived.1; - let #Derived_gen.10 : [C {}, C {}] = CallByName Encode.23 #Derived_gen.11; + let #Derived_gen.11 : [C {}, C {}, C Str] = TagId(0) #Derived.1; + let #Derived_gen.10 : [C {}, C {}, C Str] = CallByName Encode.23 #Derived_gen.11; ret #Derived_gen.10; procedure #Derived.2 (#Derived.3, #Derived.4, #Attr.12): @@ -10,13 +10,13 @@ procedure #Derived.2 (#Derived.3, #Derived.4, #Attr.12): ret #Derived_gen.13; in let #Derived_gen.17 : Str = "A"; - let #Derived_gen.18 : List [] = Array []; - let #Derived_gen.16 : {Str, List []} = CallByName TotallyNotJson.31 #Derived_gen.17 #Derived_gen.18; + let #Derived_gen.18 : List Str = Array []; + let #Derived_gen.16 : {List Str, {}} = CallByName Test.24 #Derived_gen.17 #Derived_gen.18; jump #Derived_gen.15 #Derived_gen.16; procedure #Derived.5 (#Derived.6): - let #Derived_gen.1 : [C {}, C {}] = TagId(1) #Derived.6; - let #Derived_gen.0 : [C {}, C {}] = CallByName Encode.23 #Derived_gen.1; + let #Derived_gen.1 : [C {}, C {}, C Str] = TagId(1) #Derived.6; + let #Derived_gen.0 : [C {}, C {}, C Str] = CallByName Encode.23 #Derived_gen.1; ret #Derived_gen.0; procedure #Derived.7 (#Derived.8, #Derived.9, #Attr.12): @@ -26,8 +26,8 @@ procedure #Derived.7 (#Derived.8, #Derived.9, #Attr.12): ret #Derived_gen.3; in let #Derived_gen.7 : Str = "B"; - let #Derived_gen.8 : List [] = Array []; - let #Derived_gen.6 : {Str, List []} = CallByName TotallyNotJson.31 #Derived_gen.7 #Derived_gen.8; + let #Derived_gen.8 : List Str = Array []; + let #Derived_gen.6 : {List Str, {}} = CallByName Test.24 #Derived_gen.7 #Derived_gen.8; jump #Derived_gen.5 #Derived_gen.6; procedure Bool.2 (): @@ -46,18 +46,16 @@ procedure Encode.23 (Encode.98): procedure Encode.23 (Encode.98): ret Encode.98; -procedure Encode.24 (Encode.99, Encode.107, Encode.101): - dec Encode.99; - let Encode.125 : Str = "a Lambda Set is empty. Most likely there is a type error in your program."; - Crash Encode.125 +procedure Encode.23 (Encode.98): + ret Encode.98; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.111 : List U8 = CallByName Test.5 Encode.99 Encode.101 Encode.107; + let Encode.111 : List U8 = CallByName Test.213 Encode.99 Encode.101 Encode.107; ret Encode.111; procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.113 : List U8 = CallByName TotallyNotJson.231 Encode.99 Encode.101 Encode.107; - ret Encode.113; + let Encode.115 : List U8 = CallByName Test.63 Encode.99 Encode.101 Encode.107; + ret Encode.115; procedure Encode.24 (Encode.99, Encode.107, Encode.101): let Encode.117 : U8 = GetTagId Encode.107; @@ -66,276 +64,284 @@ procedure Encode.24 (Encode.99, Encode.107, Encode.101): let Encode.116 : List U8 = CallByName #Derived.2 Encode.99 Encode.101 Encode.107; ret Encode.116; - default: + case 1: let Encode.116 : List U8 = CallByName #Derived.7 Encode.99 Encode.101 Encode.107; ret Encode.116; + default: + let Encode.116 : List U8 = CallByName Test.59 Encode.99 Encode.101 Encode.107; + ret Encode.116; + procedure Encode.24 (Encode.99, Encode.107, Encode.101): - let Encode.121 : List U8 = CallByName TotallyNotJson.231 Encode.99 Encode.101 Encode.107; + let Encode.121 : List U8 = CallByName Test.63 Encode.99 Encode.101 Encode.107; ret Encode.121; +procedure Encode.24 (Encode.99, Encode.107, Encode.101): + let Encode.124 : List U8 = CallByName Test.59 Encode.99 Encode.101 Encode.107; + ret Encode.124; + procedure Encode.26 (Encode.105, Encode.106): let Encode.109 : List U8 = Array []; - let Encode.110 : {{}, {}} = CallByName Test.2 Encode.105; + let Encode.110 : {{}, {}} = CallByName Test.49 Encode.105; let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.18 (List.160, List.161, List.162): - let List.601 : U64 = 0i64; - let List.602 : U64 = CallByName List.6 List.160; - let List.600 : {List U8, U64} = CallByName List.92 List.160 List.161 List.162 List.601 List.602; +procedure List.13 (#Attr.2, #Attr.3): + let List.600 : List [C {}, C {}, C Str] = lowlevel ListPrepend #Attr.2 #Attr.3; ret List.600; +procedure List.13 (#Attr.2, #Attr.3): + let List.628 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.628; + procedure List.18 (List.160, List.161, List.162): - let List.641 : U64 = 0i64; - let List.642 : U64 = CallByName List.6 List.160; - let List.640 : {List U8, U64} = CallByName List.92 List.160 List.161 List.162 List.641 List.642; - ret List.640; + let List.575 : U64 = 0i64; + let List.576 : U64 = CallByName List.6 List.160; + let List.574 : List U8 = CallByName List.92 List.160 List.161 List.162 List.575 List.576; + ret List.574; + +procedure List.18 (List.160, List.161, List.162): + let List.602 : U64 = 0i64; + let List.603 : U64 = CallByName List.6 List.160; + let List.601 : List U8 = CallByName List.92 List.160 List.161 List.162 List.602 List.603; + ret List.601; procedure List.4 (List.124, List.125): - let List.639 : U64 = 1i64; - let List.638 : List U8 = CallByName List.70 List.124 List.639; - let List.637 : List U8 = CallByName List.71 List.638 List.125; - ret List.637; + let List.623 : U64 = 1i64; + let List.622 : List U8 = CallByName List.70 List.124 List.623; + let List.621 : List U8 = CallByName List.71 List.622 List.125; + ret List.621; procedure List.6 (#Attr.2): - let List.612 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.612; + let List.599 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.599; procedure List.6 (#Attr.2): - let List.652 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.652; + let List.626 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.626; procedure List.66 (#Attr.2, #Attr.3): - let List.610 : [C {}, C {}] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.610; + let List.584 : [C {}, C {}, C Str] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.584; procedure List.66 (#Attr.2, #Attr.3): - let List.650 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.650; + let List.611 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.611; procedure List.70 (#Attr.2, #Attr.3): - let List.618 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.618; + let List.617 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.617; procedure List.71 (#Attr.2, #Attr.3): - let List.616 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.616; + let List.615 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.615; procedure List.8 (#Attr.2, #Attr.3): - let List.653 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.653; + let List.625 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.625; -procedure List.92 (#Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24): - joinpoint List.603 List.163 List.164 List.165 List.166 List.167: - let List.605 : Int1 = CallByName Num.22 List.166 List.167; - if List.605 then - let List.609 : [C {}, C {}] = CallByName List.66 List.163 List.166; - let List.168 : {List U8, U64} = CallByName TotallyNotJson.233 List.164 List.609; - let List.608 : U64 = 1i64; - let List.607 : U64 = CallByName Num.51 List.166 List.608; - jump List.603 List.163 List.168 List.165 List.607 List.167; +procedure List.92 (#Derived_gen.44, #Derived_gen.45, #Derived_gen.46, #Derived_gen.47, #Derived_gen.48): + joinpoint List.577 List.163 List.164 List.165 List.166 List.167: + let List.579 : Int1 = CallByName Num.22 List.166 List.167; + if List.579 then + let List.583 : [C {}, C {}, C Str] = CallByName List.66 List.163 List.166; + inc List.583; + let List.168 : List U8 = CallByName Test.66 List.164 List.583 List.165; + let List.582 : U64 = 1i64; + let List.581 : U64 = CallByName Num.51 List.166 List.582; + jump List.577 List.163 List.168 List.165 List.581 List.167; else dec List.163; ret List.164; in - jump List.603 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24; + jump List.577 #Derived_gen.44 #Derived_gen.45 #Derived_gen.46 #Derived_gen.47 #Derived_gen.48; -procedure List.92 (#Derived_gen.40, #Derived_gen.41, #Derived_gen.42, #Derived_gen.43, #Derived_gen.44): - joinpoint List.643 List.163 List.164 List.165 List.166 List.167: - let List.645 : Int1 = CallByName Num.22 List.166 List.167; - if List.645 then - let List.649 : [] = CallByName List.66 List.163 List.166; - let List.168 : {List U8, U64} = CallByName TotallyNotJson.233 List.164 List.649; - let List.648 : U64 = 1i64; - let List.647 : U64 = CallByName Num.51 List.166 List.648; - jump List.643 List.163 List.168 List.165 List.647 List.167; +procedure List.92 (#Derived_gen.52, #Derived_gen.53, #Derived_gen.54, #Derived_gen.55, #Derived_gen.56): + joinpoint List.604 List.163 List.164 List.165 List.166 List.167: + let List.606 : Int1 = CallByName Num.22 List.166 List.167; + if List.606 then + let List.610 : Str = CallByName List.66 List.163 List.166; + inc List.610; + let List.168 : List U8 = CallByName Test.66 List.164 List.610 List.165; + let List.609 : U64 = 1i64; + let List.608 : U64 = CallByName Num.51 List.166 List.609; + jump List.604 List.163 List.168 List.165 List.608 List.167; else dec List.163; ret List.164; in - jump List.643 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42 #Derived_gen.43 #Derived_gen.44; + jump List.604 #Derived_gen.52 #Derived_gen.53 #Derived_gen.54 #Derived_gen.55 #Derived_gen.56; procedure Num.127 (#Attr.2): - let Num.298 : U8 = lowlevel NumIntCast #Attr.2; - ret Num.298; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.299 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.299; + let Num.284 : U8 = lowlevel NumIntCast #Attr.2; + ret Num.284; procedure Num.22 (#Attr.2, #Attr.3): - let Num.302 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.302; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.300 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.300; + let Num.286 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.286; procedure Num.51 (#Attr.2, #Attr.3): - let Num.301 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.301; + let Num.285 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.285; + +procedure Num.96 (#Attr.2): + let Num.283 : Str = lowlevel NumToStr #Attr.2; + ret Num.283; procedure Str.12 (#Attr.2): - let Str.233 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.233; + let Str.236 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.236; -procedure Test.2 (Test.11): - let Test.18 : {{}, {}} = CallByName Encode.23 Test.11; - ret Test.18; +procedure Str.36 (#Attr.2): + let Str.237 : U64 = lowlevel StrCountUtf8Bytes #Attr.2; + ret Str.237; + +procedure Test.20 (Test.58): + let Test.299 : [C {}, C {}, C Str] = TagId(2) Test.58; + let Test.298 : [C {}, C {}, C Str] = CallByName Encode.23 Test.299; + ret Test.298; + +procedure Test.20 (Test.58): + let Test.342 : Str = CallByName Encode.23 Test.58; + ret Test.342; + +procedure Test.21 (Test.61, Test.62): + let Test.278 : {List [C {}, C {}, C Str], {}} = Struct {Test.61, Test.62}; + let Test.277 : {List [C {}, C {}, C Str], {}} = CallByName Encode.23 Test.278; + ret Test.277; + +procedure Test.21 (Test.61, Test.62): + let Test.322 : {List Str, {}} = Struct {Test.61, Test.62}; + let Test.321 : {List Str, {}} = CallByName Encode.23 Test.322; + ret Test.321; + +procedure Test.213 (Test.214, Test.215, Test.212): + joinpoint Test.270 Test.216: + let Test.268 : List U8 = CallByName Encode.24 Test.214 Test.216 Test.215; + ret Test.268; + in + let Test.312 : Int1 = CallByName Bool.2; + if Test.312 then + let Test.313 : Str = "A"; + let Test.316 : {} = StructAtIndex 0 Test.212; + let Test.315 : [C {}, C {}, C Str] = CallByName #Derived.0 Test.316; + let Test.314 : List [C {}, C {}, C Str] = Array [Test.315]; + let Test.269 : {List [C {}, C {}, C Str], {}} = CallByName Test.24 Test.313 Test.314; + jump Test.270 Test.269; + else + let Test.271 : Str = "B"; + let Test.311 : {} = StructAtIndex 1 Test.212; + let Test.310 : [C {}, C {}, C Str] = CallByName #Derived.5 Test.311; + let Test.272 : List [C {}, C {}, C Str] = Array [Test.310]; + let Test.269 : {List [C {}, C {}, C Str], {}} = CallByName Test.24 Test.271 Test.272; + jump Test.270 Test.269; + +procedure Test.23 (Test.77): + let Test.276 : {} = Struct {}; + let Test.275 : {List [C {}, C {}, C Str], {}} = CallByName Test.21 Test.77 Test.276; + ret Test.275; + +procedure Test.23 (Test.77): + let Test.320 : {} = Struct {}; + let Test.319 : {List Str, {}} = CallByName Test.21 Test.77 Test.320; + ret Test.319; + +procedure Test.24 (Test.80, Test.81): + let Test.297 : [C {}, C {}, C Str] = CallByName Test.20 Test.80; + let Test.274 : List [C {}, C {}, C Str] = CallByName List.13 Test.81 Test.297; + let Test.273 : {List [C {}, C {}, C Str], {}} = CallByName Test.23 Test.274; + ret Test.273; + +procedure Test.24 (Test.80, Test.81): + let Test.355 : Str = CallByName Test.20 Test.80; + let Test.354 : List Str = CallByName List.13 Test.81 Test.355; + let Test.353 : {List Str, {}} = CallByName Test.23 Test.354; + ret Test.353; procedure Test.3 (): - let Test.16 : {} = Struct {}; - let Test.17 : {} = Struct {}; - let Test.15 : {{}, {}} = Struct {Test.16, Test.17}; - ret Test.15; + let Test.261 : {} = Struct {}; + ret Test.261; -procedure Test.5 (Test.6, Test.7, Test.4): - joinpoint Test.23 Test.8: - let Test.21 : List U8 = CallByName Encode.24 Test.6 Test.8 Test.7; - ret Test.21; - in - let Test.28 : Int1 = CallByName Bool.2; - if Test.28 then - let Test.29 : Str = "A"; - let Test.32 : {} = StructAtIndex 0 Test.4; - let Test.31 : [C {}, C {}] = CallByName #Derived.0 Test.32; - let Test.30 : List [C {}, C {}] = Array [Test.31]; - let Test.22 : {Str, List [C {}, C {}]} = CallByName TotallyNotJson.31 Test.29 Test.30; - jump Test.23 Test.22; - else - let Test.24 : Str = "B"; - let Test.27 : {} = StructAtIndex 1 Test.4; - let Test.26 : [C {}, C {}] = CallByName #Derived.5 Test.27; - let Test.25 : List [C {}, C {}] = Array [Test.26]; - let Test.22 : {Str, List [C {}, C {}]} = CallByName TotallyNotJson.31 Test.24 Test.25; - jump Test.23 Test.22; +procedure Test.4 (Test.51, Test.52, Test.53): + let Test.339 : U8 = CallByName Num.127 Test.52; + let Test.336 : List U8 = CallByName List.4 Test.51 Test.339; + let Test.338 : Str = CallByName Num.96 Test.53; + let Test.337 : List U8 = CallByName Str.12 Test.338; + let Test.334 : List U8 = CallByName List.8 Test.336 Test.337; + let Test.335 : U8 = 32i64; + let Test.333 : List U8 = CallByName List.4 Test.334 Test.335; + ret Test.333; -procedure TotallyNotJson.231 (TotallyNotJson.232, TotallyNotJson.976, #Attr.12): - let TotallyNotJson.230 : List [C {}, C {}] = StructAtIndex 1 #Attr.12; - let TotallyNotJson.229 : Str = StructAtIndex 0 #Attr.12; - let TotallyNotJson.1014 : I64 = 123i64; - let TotallyNotJson.1013 : U8 = CallByName Num.127 TotallyNotJson.1014; - let TotallyNotJson.1010 : List U8 = CallByName List.4 TotallyNotJson.232 TotallyNotJson.1013; - let TotallyNotJson.1012 : I64 = 34i64; - let TotallyNotJson.1011 : U8 = CallByName Num.127 TotallyNotJson.1012; - let TotallyNotJson.1008 : List U8 = CallByName List.4 TotallyNotJson.1010 TotallyNotJson.1011; - let TotallyNotJson.1009 : List U8 = CallByName Str.12 TotallyNotJson.229; - let TotallyNotJson.1005 : List U8 = CallByName List.8 TotallyNotJson.1008 TotallyNotJson.1009; - let TotallyNotJson.1007 : I64 = 34i64; - let TotallyNotJson.1006 : U8 = CallByName Num.127 TotallyNotJson.1007; - let TotallyNotJson.1002 : List U8 = CallByName List.4 TotallyNotJson.1005 TotallyNotJson.1006; - let TotallyNotJson.1004 : I64 = 58i64; - let TotallyNotJson.1003 : U8 = CallByName Num.127 TotallyNotJson.1004; - let TotallyNotJson.999 : List U8 = CallByName List.4 TotallyNotJson.1002 TotallyNotJson.1003; - let TotallyNotJson.1001 : I64 = 91i64; - let TotallyNotJson.1000 : U8 = CallByName Num.127 TotallyNotJson.1001; - let TotallyNotJson.234 : List U8 = CallByName List.4 TotallyNotJson.999 TotallyNotJson.1000; - let TotallyNotJson.998 : U64 = CallByName List.6 TotallyNotJson.230; - let TotallyNotJson.986 : {List U8, U64} = Struct {TotallyNotJson.234, TotallyNotJson.998}; - let TotallyNotJson.987 : {} = Struct {}; - let TotallyNotJson.985 : {List U8, U64} = CallByName List.18 TotallyNotJson.230 TotallyNotJson.986 TotallyNotJson.987; - let TotallyNotJson.236 : List U8 = StructAtIndex 0 TotallyNotJson.985; - let TotallyNotJson.984 : I64 = 93i64; - let TotallyNotJson.983 : U8 = CallByName Num.127 TotallyNotJson.984; - let TotallyNotJson.980 : List U8 = CallByName List.4 TotallyNotJson.236 TotallyNotJson.983; - let TotallyNotJson.982 : I64 = 125i64; - let TotallyNotJson.981 : U8 = CallByName Num.127 TotallyNotJson.982; - let TotallyNotJson.979 : List U8 = CallByName List.4 TotallyNotJson.980 TotallyNotJson.981; - ret TotallyNotJson.979; +procedure Test.49 (Test.256): + let Test.265 : {{}, {}} = CallByName Encode.23 Test.256; + ret Test.265; -procedure TotallyNotJson.231 (TotallyNotJson.232, TotallyNotJson.976, #Attr.12): - let TotallyNotJson.230 : List [] = StructAtIndex 1 #Attr.12; - let TotallyNotJson.229 : Str = StructAtIndex 0 #Attr.12; - let TotallyNotJson.1057 : I64 = 123i64; - let TotallyNotJson.1056 : U8 = CallByName Num.127 TotallyNotJson.1057; - let TotallyNotJson.1053 : List U8 = CallByName List.4 TotallyNotJson.232 TotallyNotJson.1056; - let TotallyNotJson.1055 : I64 = 34i64; - let TotallyNotJson.1054 : U8 = CallByName Num.127 TotallyNotJson.1055; - let TotallyNotJson.1051 : List U8 = CallByName List.4 TotallyNotJson.1053 TotallyNotJson.1054; - let TotallyNotJson.1052 : List U8 = CallByName Str.12 TotallyNotJson.229; - let TotallyNotJson.1048 : List U8 = CallByName List.8 TotallyNotJson.1051 TotallyNotJson.1052; - let TotallyNotJson.1050 : I64 = 34i64; - let TotallyNotJson.1049 : U8 = CallByName Num.127 TotallyNotJson.1050; - let TotallyNotJson.1045 : List U8 = CallByName List.4 TotallyNotJson.1048 TotallyNotJson.1049; - let TotallyNotJson.1047 : I64 = 58i64; - let TotallyNotJson.1046 : U8 = CallByName Num.127 TotallyNotJson.1047; - let TotallyNotJson.1042 : List U8 = CallByName List.4 TotallyNotJson.1045 TotallyNotJson.1046; - let TotallyNotJson.1044 : I64 = 91i64; - let TotallyNotJson.1043 : U8 = CallByName Num.127 TotallyNotJson.1044; - let TotallyNotJson.234 : List U8 = CallByName List.4 TotallyNotJson.1042 TotallyNotJson.1043; - let TotallyNotJson.1041 : U64 = CallByName List.6 TotallyNotJson.230; - let TotallyNotJson.1029 : {List U8, U64} = Struct {TotallyNotJson.234, TotallyNotJson.1041}; - let TotallyNotJson.1030 : {} = Struct {}; - let TotallyNotJson.1028 : {List U8, U64} = CallByName List.18 TotallyNotJson.230 TotallyNotJson.1029 TotallyNotJson.1030; - let TotallyNotJson.236 : List U8 = StructAtIndex 0 TotallyNotJson.1028; - let TotallyNotJson.1027 : I64 = 93i64; - let TotallyNotJson.1026 : U8 = CallByName Num.127 TotallyNotJson.1027; - let TotallyNotJson.1023 : List U8 = CallByName List.4 TotallyNotJson.236 TotallyNotJson.1026; - let TotallyNotJson.1025 : I64 = 125i64; - let TotallyNotJson.1024 : U8 = CallByName Num.127 TotallyNotJson.1025; - let TotallyNotJson.1022 : List U8 = CallByName List.4 TotallyNotJson.1023 TotallyNotJson.1024; - ret TotallyNotJson.1022; +procedure Test.50 (): + let Test.263 : {} = Struct {}; + let Test.264 : {} = Struct {}; + let Test.262 : {{}, {}} = Struct {Test.263, Test.264}; + ret Test.262; -procedure TotallyNotJson.233 (TotallyNotJson.978, TotallyNotJson.239): - let TotallyNotJson.237 : List U8 = StructAtIndex 0 TotallyNotJson.978; - let TotallyNotJson.238 : U64 = StructAtIndex 1 TotallyNotJson.978; - let TotallyNotJson.1040 : {} = Struct {}; - let TotallyNotJson.240 : List U8 = CallByName Encode.24 TotallyNotJson.237 TotallyNotJson.239 TotallyNotJson.1040; - joinpoint TotallyNotJson.1035 TotallyNotJson.241: - let TotallyNotJson.1033 : U64 = 1i64; - let TotallyNotJson.1032 : U64 = CallByName Num.20 TotallyNotJson.238 TotallyNotJson.1033; - let TotallyNotJson.1031 : {List U8, U64} = Struct {TotallyNotJson.241, TotallyNotJson.1032}; - ret TotallyNotJson.1031; - in - let TotallyNotJson.1039 : U64 = 1i64; - let TotallyNotJson.1036 : Int1 = CallByName Num.24 TotallyNotJson.238 TotallyNotJson.1039; - if TotallyNotJson.1036 then - let TotallyNotJson.1038 : I64 = 44i64; - let TotallyNotJson.1037 : U8 = CallByName Num.127 TotallyNotJson.1038; - let TotallyNotJson.1034 : List U8 = CallByName List.4 TotallyNotJson.240 TotallyNotJson.1037; - jump TotallyNotJson.1035 TotallyNotJson.1034; - else - jump TotallyNotJson.1035 TotallyNotJson.240; +procedure Test.59 (Test.60, Test.300, #Attr.12): + let Test.309 : Str = UnionAtIndex (Id 2) (Index 0) #Attr.12; + let Test.307 : I64 = 115i64; + let Test.308 : U64 = CallByName Str.36 Test.309; + let Test.305 : List U8 = CallByName Test.4 Test.60 Test.307 Test.308; + let Test.306 : List U8 = CallByName Str.12 Test.309; + let Test.303 : List U8 = CallByName List.8 Test.305 Test.306; + let Test.304 : U8 = 32i64; + let Test.302 : List U8 = CallByName List.4 Test.303 Test.304; + ret Test.302; -procedure TotallyNotJson.233 (TotallyNotJson.978, TotallyNotJson.239): - let TotallyNotJson.237 : List U8 = StructAtIndex 0 TotallyNotJson.978; - let TotallyNotJson.238 : U64 = StructAtIndex 1 TotallyNotJson.978; - let TotallyNotJson.997 : {} = Struct {}; - let TotallyNotJson.240 : List U8 = CallByName Encode.24 TotallyNotJson.237 TotallyNotJson.239 TotallyNotJson.997; - joinpoint TotallyNotJson.992 TotallyNotJson.241: - let TotallyNotJson.990 : U64 = 1i64; - let TotallyNotJson.989 : U64 = CallByName Num.20 TotallyNotJson.238 TotallyNotJson.990; - let TotallyNotJson.988 : {List U8, U64} = Struct {TotallyNotJson.241, TotallyNotJson.989}; - ret TotallyNotJson.988; - in - let TotallyNotJson.996 : U64 = 1i64; - let TotallyNotJson.993 : Int1 = CallByName Num.24 TotallyNotJson.238 TotallyNotJson.996; - if TotallyNotJson.993 then - let TotallyNotJson.995 : I64 = 44i64; - let TotallyNotJson.994 : U8 = CallByName Num.127 TotallyNotJson.995; - let TotallyNotJson.991 : List U8 = CallByName List.4 TotallyNotJson.240 TotallyNotJson.994; - jump TotallyNotJson.992 TotallyNotJson.991; - else - jump TotallyNotJson.992 TotallyNotJson.240; +procedure Test.59 (Test.60, Test.300, Test.58): + let Test.351 : I64 = 115i64; + let Test.352 : U64 = CallByName Str.36 Test.58; + let Test.349 : List U8 = CallByName Test.4 Test.60 Test.351 Test.352; + let Test.350 : List U8 = CallByName Str.12 Test.58; + let Test.347 : List U8 = CallByName List.8 Test.349 Test.350; + let Test.348 : U8 = 32i64; + let Test.346 : List U8 = CallByName List.4 Test.347 Test.348; + ret Test.346; -procedure TotallyNotJson.31 (TotallyNotJson.229, TotallyNotJson.230): - let TotallyNotJson.1016 : {Str, List [C {}, C {}]} = Struct {TotallyNotJson.229, TotallyNotJson.230}; - let TotallyNotJson.1015 : {Str, List [C {}, C {}]} = CallByName Encode.23 TotallyNotJson.1016; - ret TotallyNotJson.1015; +procedure Test.63 (Test.64, Test.279, #Attr.12): + let Test.62 : {} = StructAtIndex 1 #Attr.12; + let Test.61 : List Str = StructAtIndex 0 #Attr.12; + let Test.331 : I64 = 108i64; + let Test.332 : U64 = CallByName List.6 Test.61; + let Test.65 : List U8 = CallByName Test.4 Test.64 Test.331 Test.332; + let Test.325 : List U8 = CallByName List.18 Test.61 Test.65 Test.62; + ret Test.325; -procedure TotallyNotJson.31 (TotallyNotJson.229, TotallyNotJson.230): - let TotallyNotJson.1059 : {Str, List []} = Struct {TotallyNotJson.229, TotallyNotJson.230}; - let TotallyNotJson.1058 : {Str, List []} = CallByName Encode.23 TotallyNotJson.1059; - ret TotallyNotJson.1058; +procedure Test.63 (Test.64, Test.279, #Attr.12): + let Test.62 : {} = StructAtIndex 1 #Attr.12; + let Test.61 : List [C {}, C {}, C Str] = StructAtIndex 0 #Attr.12; + let Test.287 : I64 = 108i64; + let Test.288 : U64 = CallByName List.6 Test.61; + let Test.65 : List U8 = CallByName Test.4 Test.64 Test.287 Test.288; + let Test.281 : List U8 = CallByName List.18 Test.61 Test.65 Test.62; + ret Test.281; -procedure TotallyNotJson.8 (): - let TotallyNotJson.973 : {} = Struct {}; - ret TotallyNotJson.973; +procedure Test.66 (Test.67, Test.68, Test.62): + let Test.285 : [C {}, C {}, C Str] = CallByName Test.78 Test.68; + let Test.286 : {} = Struct {}; + let Test.284 : List U8 = CallByName Encode.24 Test.67 Test.285 Test.286; + ret Test.284; + +procedure Test.66 (Test.67, Test.68, Test.62): + let Test.329 : Str = CallByName Test.78 Test.68; + let Test.330 : {} = Struct {}; + let Test.328 : List U8 = CallByName Encode.24 Test.67 Test.329 Test.330; + ret Test.328; + +procedure Test.78 (Test.79): + ret Test.79; + +procedure Test.78 (Test.79): + ret Test.79; procedure Test.0 (): - let Test.13 : {{}, {}} = CallByName Test.3; - let Test.14 : {} = CallByName TotallyNotJson.8; - let Test.12 : List U8 = CallByName Encode.26 Test.13 Test.14; - ret Test.12; + let Test.259 : {{}, {}} = CallByName Test.50; + let Test.260 : {} = CallByName Test.3; + let Test.258 : List U8 = CallByName Encode.26 Test.259 Test.260; + ret Test.258; diff --git a/crates/compiler/test_mono/src/tests.rs b/crates/compiler/test_mono/src/tests.rs index de52dedb9c..9a0a4f2846 100644 --- a/crates/compiler/test_mono/src/tests.rs +++ b/crates/compiler/test_mono/src/tests.rs @@ -5,15 +5,13 @@ // we actually want to compare against the literal float bits #![allow(clippy::float_cmp)] -#[macro_use] -extern crate indoc; - /// Used in the with_larger_debug_stack() function, for tests that otherwise /// run out of stack space in debug builds (but don't in --release builds) #[allow(dead_code)] const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024; use bumpalo::Bump; +use indoc::{formatdoc, indoc}; use roc_collections::all::MutMap; use roc_load::ExecutionMode; use roc_load::FunctionKind; @@ -25,10 +23,59 @@ use roc_module::symbol::Symbol; use roc_mono::ir::Proc; use roc_mono::ir::ProcLayout; use roc_mono::layout::STLayoutInterner; +use roc_test_utils::TAG_LEN_ENCODER_FMT; use test_mono_macros::*; const TARGET: roc_target::Target = roc_target::Target::LinuxX64; +/// err decoder is a trivial implementation of a decoder which only returns an error +/// useful when you need a decoder implementation, but want minimal code generation +pub const ERR_DECODER_FMT: &str = r#" +ErrDecoder := {} implements [ + DecoderFormatting { + u8: decodeU8, + u16: decodeU16, + u32: decodeU32, + u64: decodeU64, + u128: decodeU128, + i8: decodeI8, + i16: decodeI16, + i32: decodeI32, + i64: decodeI64, + i128: decodeI128, + f32: decodeF32, + f64: decodeF64, + dec: decodeDec, + bool: decodeBool, + string: decodeString, + list: decodeList, + record: decodeRecord, + tuple: decodeTuple, + }, + ] +decodeU8 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeU16 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeU32 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeU64 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeU128 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeI8 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeI16 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeI32 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeI64 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeI128 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeF32 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeF64 = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeDec = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeBool = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeString = Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeList : Decoder elem ErrDecoder -> Decoder (List elem) ErrDecoder +decodeList = \_ -> Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeRecord : state, (state, Str -> [Keep (Decoder state ErrDecoder), Skip]), (state, ErrDecoder -> Result val DecodeError) -> Decoder val ErrDecoder +decodeRecord = \_, _, _ -> Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +decodeTuple : state, (state, U64 -> [Next (Decoder state ErrDecoder), TooLong]), (state -> Result val DecodeError) -> Decoder val ErrDecoder +decodeTuple = \_, _, _ -> Decode.custom \rest, @ErrDecoder {} -> { result: Err TooShort, rest } +"#; + /// Without this, some tests pass in `cargo test --release` but fail without /// the --release flag because they run out of stack space. This increases /// stack size for debug builds only, while leaving the stack space at the default @@ -1522,20 +1569,22 @@ fn list_sort_asc() { #[mono_test] #[ignore] fn encode_custom_type() { - indoc!( + &formatdoc!( r#" app "test" - imports [Encode.{ toEncoder }, TotallyNotJson] + imports [Encode.{{ toEncoder }}] provides [main] to "./platform" - HelloWorld := {} - toEncoder = \@HelloWorld {} -> + {TAG_LEN_ENCODER_FMT} + + HelloWorld := {{}} + toEncoder = \@HelloWorld {{}} -> Encode.custom \bytes, fmt -> bytes |> Encode.appendWith (Encode.string "Hello, World!\n") fmt main = - result = Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes (@HelloWorld {{}}) tagLenFmt) when result is Ok s -> s _ -> "" @@ -1545,14 +1594,16 @@ fn encode_custom_type() { #[mono_test] fn encode_derived_string() { - indoc!( + &formatdoc!( r#" app "test" - imports [Encode.{ toEncoder }, TotallyNotJson] + imports [Encode.{{ toEncoder }}] provides [main] to "./platform" + {TAG_LEN_ENCODER_FMT} + main = - result = Str.fromUtf8 (Encode.toBytes "abc" TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes "abc" tagLenFmt) when result is Ok s -> s _ -> "" @@ -1563,14 +1614,16 @@ fn encode_derived_string() { #[mono_test] #[ignore = "TODO"] fn encode_derived_record() { - indoc!( + &formatdoc!( r#" app "test" - imports [Encode.{ toEncoder }, TotallyNotJson] + imports [Encode.{{ toEncoder }}] provides [main] to "./platform" + {TAG_LEN_ENCODER_FMT} + main = - result = Str.fromUtf8 (Encode.toBytes {a: "a"} TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes {{a: "a"}} tagLenFmt) when result is Ok s -> s _ -> "" @@ -1905,14 +1958,16 @@ fn instantiate_annotated_as_recursive_alias_multiple_polymorphic_expr() { #[mono_test(large_stack = "true")] fn encode_derived_record_one_field_string() { - indoc!( + &formatdoc!( r#" app "test" - imports [Encode.{ toEncoder }, TotallyNotJson] + imports [Encode.{{ toEncoder }}] provides [main] to "./platform" + {TAG_LEN_ENCODER_FMT} + main = - result = Str.fromUtf8 (Encode.toBytes {a: "foo"} TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes {{a: "foo"}} tagLenFmt) when result is Ok s -> s _ -> "" @@ -1922,14 +1977,16 @@ fn encode_derived_record_one_field_string() { #[mono_test(large_stack = "true")] fn encode_derived_record_two_field_strings() { - indoc!( + &formatdoc!( r#" app "test" - imports [Encode.{ toEncoder }, TotallyNotJson] + imports [Encode.{{ toEncoder }}] provides [main] to "./platform" + {TAG_LEN_ENCODER_FMT} + main = - result = Str.fromUtf8 (Encode.toBytes {a: "foo", b: "bar"} TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes {{a: "foo", b: "bar"}} tagLenFmt) when result is Ok s -> s _ -> "" @@ -1939,14 +1996,16 @@ fn encode_derived_record_two_field_strings() { #[mono_test(large_stack = "true")] fn encode_derived_nested_record_string() { - indoc!( + &formatdoc!( r#" app "test" - imports [Encode.{ toEncoder }, TotallyNotJson] + imports [Encode.{{ toEncoder }}] provides [main] to "./platform" + {TAG_LEN_ENCODER_FMT} + main = - result = Str.fromUtf8 (Encode.toBytes {a: {b: "bar"}} TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes {{a: {{b: "bar"}}}} tagLenFmt) when result is Ok s -> s _ -> "" @@ -1956,16 +2015,18 @@ fn encode_derived_nested_record_string() { #[mono_test] fn encode_derived_tag_one_field_string() { - indoc!( + &formatdoc!( r#" app "test" - imports [Encode.{ toEncoder }, TotallyNotJson] + imports [Encode.{{ toEncoder }}] provides [main] to "./platform" + {TAG_LEN_ENCODER_FMT} + main = x : [A Str] x = A "foo" - result = Str.fromUtf8 (Encode.toBytes x TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes x tagLenFmt) when result is Ok s -> s _ -> "" @@ -1997,16 +2058,18 @@ fn polymorphic_expression_unification() { #[mono_test] fn encode_derived_tag_two_payloads_string() { - indoc!( + &formatdoc!( r#" app "test" - imports [Encode.{ toEncoder }, TotallyNotJson] + imports [Encode.{{ toEncoder }}] provides [main] to "./platform" + {TAG_LEN_ENCODER_FMT} + main = x : [A Str Str] x = A "foo" "foo" - result = Str.fromUtf8 (Encode.toBytes x TotallyNotJson.json) + result = Str.fromUtf8 (Encode.toBytes x tagLenFmt) when result is Ok s -> s _ -> "" @@ -2271,14 +2334,18 @@ fn issue_4705() { #[mono_test(mode = "test", large_stack = "true")] fn issue_4749() { - indoc!( + &formatdoc!( r#" - interface Test exposes [] imports [TotallyNotJson] + interface Test exposes [] imports [] expect - input = [82, 111, 99] - got = Decode.fromBytes input TotallyNotJson.json - got == Ok "Roc" + got : [Y [Y1, Y2], Z [Z1, Z2]]_ + got = Z Z1 + + t : [A [A1, A2]]_ + t = A A1 + + got != t "# ) } @@ -2485,18 +2552,20 @@ fn function_specialization_information_in_lambda_set_thunk_independent_defs() { #[mono_test(mode = "test", large_stack = "true")] fn issue_4772_weakened_monomorphic_destructure() { - indoc!( + &formatdoc!( r#" - interface Test exposes [] imports [TotallyNotJson] + interface Test exposes [] imports [] + + {ERR_DECODER_FMT} getNumber = - { result, rest } = Decode.fromBytesPartial (Str.toUtf8 "-1234") TotallyNotJson.json + {{ result, rest }} = Decode.fromBytesPartial (Str.toUtf8 "-1234") (@ErrDecoder {{}}) when result is Ok val -> when Str.toI64 val is Ok number -> - Ok {val : number, input : rest} + Ok {{val : number, input : rest}} Err InvalidNumStr -> Err (ParsingFailure "not a number") @@ -2505,7 +2574,7 @@ fn issue_4772_weakened_monomorphic_destructure() { expect result = getNumber - result == Ok {val : -1234i64, input : []} + result == Ok {{val : -1234i64, input : []}} "# ) } @@ -2682,11 +2751,13 @@ fn unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unifica // be, because they in fact represent to different specializations of needed encoders. In // particular, the lambda set `[[] + [A]:toEncoder:1 + [B]:toEncoder:1]` must be preserved, // rather than collapsing to `[[] + [A, B]:toEncoder:1]`. - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" imports [] provides [main] to "./platform" - Q a b := { a: a, b: b } implements [Encoding {toEncoder: toEncoderQ}] + {TAG_LEN_ENCODER_FMT} + + Q a b := {{ a: a, b: b }} implements [Encoding {{toEncoder: toEncoderQ}}] toEncoderQ = \@Q t -> Encode.custom \bytes, fmt -> @@ -2696,10 +2767,10 @@ fn unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unifica Encode.appendWith bytes f fmt - accessor = @Q {a : A, b: B} + accessor = @Q {{a : A, b: B}} main = - Encode.toBytes accessor TotallyNotJson.json + Encode.toBytes accessor tagLenFmt "# ) } @@ -2720,11 +2791,13 @@ fn unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_ty // such, the lambda set `[[] + Str:toEncoder:1]` should be produced during compaction, rather // than staying as the expanded `[[] + Str:toEncoder:1 + Str:toEncoder:1]` after the types of // `t.a` and `t.b` are filled in. - indoc!( + &formatdoc!( r#" - app "test" imports [TotallyNotJson] provides [main] to "./platform" + app "test" imports [] provides [main] to "./platform" - Q a b := { a: a, b: b } implements [Encoding {toEncoder: toEncoderQ}] + {TAG_LEN_ENCODER_FMT} + + Q a b := {{ a: a, b: b }} implements [Encoding {{toEncoder: toEncoderQ}}] toEncoderQ = \@Q t -> Encode.custom \bytes, fmt -> @@ -2736,10 +2809,10 @@ fn unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_ty accessor = x = "" - @Q {a : x, b: x} + @Q {{a : x, b: x}} main = - Encode.toBytes accessor TotallyNotJson.json + Encode.toBytes accessor tagLenFmt "# ) } From d90da3af52ad4ccc136e58f44a7669e497dfada0 Mon Sep 17 00:00:00 2001 From: shua Date: Fri, 28 Jun 2024 15:23:48 +0200 Subject: [PATCH 39/42] rm TotallyNotJson TotallyNotJson.roc now lives on the farm in virtual-dom-wip as Json.roc. Any reference in stdlib or builtins has been removed, as well as the last places it was used (in python/ruby-interop examples). --- crates/compiler/builtins/roc/main.roc | 1 - crates/compiler/builtins/src/roc.rs | 2 -- crates/compiler/load/build.rs | 1 - crates/compiler/load_internal/src/file.rs | 1 - crates/compiler/load_internal/src/lib.rs | 1 - .../load_internal/src/module_cache.rs | 1 - crates/compiler/module/src/ident.rs | 1 - crates/compiler/module/src/symbol.rs | 14 ++--------- .../generated/capture_void_layout_task.txt | 18 +++++++------- ...lambda_set_productive_nullable_wrapped.txt | 24 +++++++++---------- .../encode_derived_nested_record_string.txt | 4 ++-- ...encode_derived_record_one_field_string.txt | 4 ++-- ...ncode_derived_record_two_field_strings.txt | 4 ++-- .../encode_derived_tag_one_field_string.txt | 4 ++-- ..._return_joinpoints_in_union_lambda_set.txt | 4 ++-- ..._4772_weakened_monomorphic_destructure.txt | 2 +- ...ist_map_take_capturing_or_noncapturing.txt | 2 +- .../generated/pattern_as_toplevel.txt | 2 +- ...function_and_union_with_inference_hole.txt | 4 ++-- ..._set_resolved_only_upon_specialization.txt | 8 +++---- .../generated/recursively_build_effect.txt | 18 +++++++------- .../generated/specialize_after_match.txt | 24 +++++++++---------- ...types_without_unification_of_unifiable.txt | 4 ++-- examples/python-interop/.gitignore | 3 +++ examples/python-interop/build.sh | 8 ++----- examples/python-interop/demo.c | 10 +------- .../python-interop/{main.roc => libhello.roc} | 0 examples/python-interop/platform/main.roc | 14 +++++++---- examples/ruby-interop/.gitignore | 2 ++ examples/ruby-interop/README.md | 2 +- examples/ruby-interop/demo.c | 24 ++++++++----------- examples/ruby-interop/extconf.rb | 5 ++-- examples/ruby-interop/platform/main.roc | 14 +++++++---- .../platform/Html/Internal/Client.roc | 10 ++++---- .../platform/Html/Internal/Server.roc | 4 ++-- .../virtual-dom-wip/platform/Json.roc | 10 +------- .../virtual-dom-wip/platform/server-side.roc | 4 ++-- 37 files changed, 114 insertions(+), 144 deletions(-) create mode 100644 examples/python-interop/.gitignore rename examples/python-interop/{main.roc => libhello.roc} (100%) create mode 100644 examples/ruby-interop/.gitignore rename crates/compiler/builtins/roc/TotallyNotJson.roc => examples/virtual-dom-wip/platform/Json.roc (99%) diff --git a/crates/compiler/builtins/roc/main.roc b/crates/compiler/builtins/roc/main.roc index 5fb1daef3b..e884058468 100644 --- a/crates/compiler/builtins/roc/main.roc +++ b/crates/compiler/builtins/roc/main.roc @@ -10,6 +10,5 @@ package [ Encode, Hash, Box, - TotallyNotJson, Inspect, ] {} diff --git a/crates/compiler/builtins/src/roc.rs b/crates/compiler/builtins/src/roc.rs index 158c698de2..d69f73f914 100644 --- a/crates/compiler/builtins/src/roc.rs +++ b/crates/compiler/builtins/src/roc.rs @@ -16,7 +16,6 @@ pub fn module_source(module_id: ModuleId) -> &'static str { ModuleId::DECODE => DECODE, ModuleId::HASH => HASH, ModuleId::INSPECT => INSPECT, - ModuleId::JSON => JSON, _ => internal_error!( "ModuleId {:?} is not part of the standard library", module_id @@ -36,4 +35,3 @@ const ENCODE: &str = include_str!("../roc/Encode.roc"); const DECODE: &str = include_str!("../roc/Decode.roc"); const HASH: &str = include_str!("../roc/Hash.roc"); const INSPECT: &str = include_str!("../roc/Inspect.roc"); -const JSON: &str = include_str!("../roc/TotallyNotJson.roc"); diff --git a/crates/compiler/load/build.rs b/crates/compiler/load/build.rs index 3f4c98a8f5..f99826dce7 100644 --- a/crates/compiler/load/build.rs +++ b/crates/compiler/load/build.rs @@ -25,7 +25,6 @@ const MODULES: &[(ModuleId, &str)] = &[ (ModuleId::DECODE, "Decode.roc"), (ModuleId::HASH, "Hash.roc"), (ModuleId::INSPECT, "Inspect.roc"), - (ModuleId::JSON, "TotallyNotJson.roc"), ]; fn main() { diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index 5491cf3a15..06ded0003d 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -3630,7 +3630,6 @@ fn load_module<'a>( "Decode", ModuleId::DECODE "Hash", ModuleId::HASH "Inspect", ModuleId::INSPECT - "TotallyNotJson", ModuleId::JSON } let (filename, opt_shorthand) = module_name_to_path(src_dir, &module_name, arc_shorthands); diff --git a/crates/compiler/load_internal/src/lib.rs b/crates/compiler/load_internal/src/lib.rs index 919832ab4f..ef7860a54a 100644 --- a/crates/compiler/load_internal/src/lib.rs +++ b/crates/compiler/load_internal/src/lib.rs @@ -25,5 +25,4 @@ pub const BUILTIN_MODULES: &[(ModuleId, &str)] = &[ (ModuleId::DECODE, "Decode"), (ModuleId::HASH, "Hash"), (ModuleId::INSPECT, "Inspect"), - (ModuleId::JSON, "TotallyNotJson"), ]; diff --git a/crates/compiler/load_internal/src/module_cache.rs b/crates/compiler/load_internal/src/module_cache.rs index ff3e300fd6..0c202d93d1 100644 --- a/crates/compiler/load_internal/src/module_cache.rs +++ b/crates/compiler/load_internal/src/module_cache.rs @@ -91,7 +91,6 @@ impl Default for ModuleCache<'_> { DECODE, HASH, INSPECT, - JSON, } Self { diff --git a/crates/compiler/module/src/ident.rs b/crates/compiler/module/src/ident.rs index f54f089110..0e955b2a3e 100644 --- a/crates/compiler/module/src/ident.rs +++ b/crates/compiler/module/src/ident.rs @@ -131,7 +131,6 @@ impl ModuleName { pub const HASH: &'static str = "Hash"; pub const INSPECT: &'static str = "Inspect"; pub const TASK: &'static str = "Task"; - pub const JSON: &'static str = "TotallyNotJson"; pub fn as_str(&self) -> &str { self.0.as_str() diff --git a/crates/compiler/module/src/symbol.rs b/crates/compiler/module/src/symbol.rs index f03b981d5b..e100dd50b2 100644 --- a/crates/compiler/module/src/symbol.rs +++ b/crates/compiler/module/src/symbol.rs @@ -395,8 +395,7 @@ impl ModuleId { } pub fn is_automatically_imported(self) -> bool { - // The deprecated TotallyNotJson module is not automatically imported. - self.is_builtin() && self != ModuleId::JSON + self.is_builtin() } } @@ -1738,15 +1737,6 @@ define_builtins! { 32 INSPECT_TO_INSPECTOR: "toInspector" 33 INSPECT_TO_STR: "toStr" } - 15 JSON: "TotallyNotJson" => { - 0 JSON_JSON: "TotallyNotJson" - 1 JSON_FIELD_NAME_MAPPING: "FieldNameMapping" - 2 JSON_NUMBER_STATE: "NumberState" - 3 JSON_STRING_STATE: "StringState" - 4 JSON_ARRAY_OPENING_STATE: "ArrayOpeningState" - 5 JSON_ARRAY_CLOSING_STATE: "ArrayClosingState" - 6 JSON_OBJECT_STATE: "ObjectState" - } - num_modules: 16 // Keep this count up to date by hand! (TODO: see the mut_map! macro for how we could determine this count correctly in the macro) + num_modules: 15 // Keep this count up to date by hand! (TODO: see the mut_map! macro for how we could determine this count correctly in the macro) } diff --git a/crates/compiler/test_mono/generated/capture_void_layout_task.txt b/crates/compiler/test_mono/generated/capture_void_layout_task.txt index 0724cf50e0..eaf6539940 100644 --- a/crates/compiler/test_mono/generated/capture_void_layout_task.txt +++ b/crates/compiler/test_mono/generated/capture_void_layout_task.txt @@ -12,7 +12,7 @@ procedure List.66 (#Attr.2, #Attr.3): let List.584 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; ret List.584; -procedure List.92 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): +procedure List.92 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): joinpoint List.577 List.163 List.164 List.165 List.166 List.167: let List.579 : Int1 = CallByName Num.22 List.166 List.167; if List.579 then @@ -25,7 +25,7 @@ procedure List.92 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_g dec List.163; ret List.164; in - jump List.577 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; + jump List.577 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; procedure Num.22 (#Attr.2, #Attr.3): let Num.280 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; @@ -37,8 +37,8 @@ procedure Num.51 (#Attr.2, #Attr.3): procedure Test.10 (Test.69, #Attr.12): let Test.72 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12; - let #Derived_gen.20 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.20 then + let #Derived_gen.18 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.18 then free #Attr.12; ret Test.72; else @@ -52,7 +52,7 @@ procedure Test.10 (Test.69, #Attr.12): procedure Test.14 (Test.45, #Attr.12): let Test.55 : {{}, []} = UnionAtIndex (Id 1) (Index 1) #Attr.12; let Test.54 : [C {}, C *self {{}, []}] = UnionAtIndex (Id 1) (Index 0) #Attr.12; - joinpoint #Derived_gen.18: + joinpoint #Derived_gen.19: let Test.50 : {} = Struct {}; let Test.51 : U8 = GetTagId Test.54; joinpoint Test.52 Test.15: @@ -79,14 +79,14 @@ procedure Test.14 (Test.45, #Attr.12): jump Test.52 Test.53; in - let #Derived_gen.19 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.19 then + let #Derived_gen.20 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.20 then free #Attr.12; - jump #Derived_gen.18; + jump #Derived_gen.19; else inc Test.54; decref #Attr.12; - jump #Derived_gen.18; + jump #Derived_gen.19; procedure Test.20 (Test.21, Test.18): let Test.23 : [C {}, C []] = CallByName Test.32 Test.21 Test.18; diff --git a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt index fda755162d..a41cf0fd3a 100644 --- a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt +++ b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt @@ -46,11 +46,11 @@ procedure Str.3 (#Attr.2, #Attr.3): procedure Test.1 (Test.5): ret Test.5; -procedure Test.11 (#Derived_gen.3, #Derived_gen.4): +procedure Test.11 (#Derived_gen.10, #Derived_gen.11): joinpoint Test.27 Test.12 #Attr.12: let Test.34 : Int1 = UnionAtIndex (Id 2) (Index 1) #Attr.12; let Test.33 : [, C *self Int1, C *self Int1] = UnionAtIndex (Id 2) (Index 0) #Attr.12; - joinpoint #Derived_gen.12: + joinpoint #Derived_gen.14: joinpoint Test.31 Test.29: let Test.30 : U8 = GetTagId Test.33; switch Test.30: @@ -77,16 +77,16 @@ procedure Test.11 (#Derived_gen.3, #Derived_gen.4): jump Test.31 Test.32; in - let #Derived_gen.13 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.13 then + let #Derived_gen.15 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.15 then free #Attr.12; - jump #Derived_gen.12; + jump #Derived_gen.14; else inc Test.33; decref #Attr.12; - jump #Derived_gen.12; + jump #Derived_gen.14; in - jump Test.27 #Derived_gen.3 #Derived_gen.4; + jump Test.27 #Derived_gen.10 #Derived_gen.11; procedure Test.2 (Test.13): ret Test.13; @@ -117,7 +117,7 @@ procedure Test.6 (Test.7, Test.8, Test.5): procedure Test.9 (Test.10, #Attr.12): let Test.43 : Int1 = UnionAtIndex (Id 1) (Index 1) #Attr.12; let Test.42 : [, C *self Int1, C *self Int1] = UnionAtIndex (Id 1) (Index 0) #Attr.12; - joinpoint #Derived_gen.14: + joinpoint #Derived_gen.12: let Test.39 : U8 = GetTagId Test.42; joinpoint Test.40 Test.38: switch Test.43: @@ -145,14 +145,14 @@ procedure Test.9 (Test.10, #Attr.12): jump Test.40 Test.41; in - let #Derived_gen.15 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.15 then + let #Derived_gen.13 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.13 then free #Attr.12; - jump #Derived_gen.14; + jump #Derived_gen.12; else inc Test.42; decref #Attr.12; - jump #Derived_gen.14; + jump #Derived_gen.12; procedure Test.0 (): let Test.45 : Int1 = false; 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 5741a7127b..84ac36e1fb 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 @@ -111,7 +111,7 @@ procedure List.8 (#Attr.2, #Attr.3): let List.624 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.624; -procedure List.92 (#Derived_gen.32, #Derived_gen.33, #Derived_gen.34, #Derived_gen.35, #Derived_gen.36): +procedure List.92 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): joinpoint List.603 List.163 List.164 List.165 List.166 List.167: let List.605 : Int1 = CallByName Num.22 List.166 List.167; if List.605 then @@ -125,7 +125,7 @@ procedure List.92 (#Derived_gen.32, #Derived_gen.33, #Derived_gen.34, #Derived_g dec List.163; ret List.164; in - jump List.603 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35 #Derived_gen.36; + jump List.603 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; procedure List.92 (#Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40, #Derived_gen.41): joinpoint List.577 List.163 List.164 List.165 List.166 List.167: 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 4fef47e28f..ce4b3d2917 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 @@ -70,7 +70,7 @@ procedure List.8 (#Attr.2, #Attr.3): let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.598; -procedure List.92 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): +procedure List.92 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): joinpoint List.577 List.163 List.164 List.165 List.166 List.167: let List.579 : Int1 = CallByName Num.22 List.166 List.167; if List.579 then @@ -84,7 +84,7 @@ procedure List.92 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_g dec List.163; ret List.164; in - jump List.577 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; + jump List.577 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; procedure Num.127 (#Attr.2): let Num.280 : U8 = lowlevel NumIntCast #Attr.2; 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 11b0ab78f1..e29591e854 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 @@ -77,7 +77,7 @@ procedure List.8 (#Attr.2, #Attr.3): let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.598; -procedure List.92 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): +procedure List.92 (#Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21): joinpoint List.577 List.163 List.164 List.165 List.166 List.167: let List.579 : Int1 = CallByName Num.22 List.166 List.167; if List.579 then @@ -91,7 +91,7 @@ procedure List.92 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_g dec List.163; ret List.164; in - jump List.577 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; + jump List.577 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21; procedure Num.127 (#Attr.2): let Num.280 : U8 = lowlevel NumIntCast #Attr.2; 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 b256c0ab53..884b2de4a3 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 @@ -76,7 +76,7 @@ procedure List.8 (#Attr.2, #Attr.3): let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.598; -procedure List.92 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): +procedure List.92 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): joinpoint List.577 List.163 List.164 List.165 List.166 List.167: let List.579 : Int1 = CallByName Num.22 List.166 List.167; if List.579 then @@ -90,7 +90,7 @@ procedure List.92 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_g dec List.163; ret List.164; in - jump List.577 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; + jump List.577 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; procedure Num.127 (#Attr.2): let Num.280 : U8 = lowlevel NumIntCast #Attr.2; diff --git a/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt b/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt index 4cad7bf090..9451b2635d 100644 --- a/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt +++ b/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt @@ -17,7 +17,7 @@ procedure Test.4 (Test.5, #Attr.12): let Test.16 : I64 = CallByName Num.19 Test.5 Test.17; ret Test.16; -procedure Test.0 (#Derived_gen.2): +procedure Test.0 (#Derived_gen.0): joinpoint Test.7 Test.1: let Test.21 : I64 = 1i64; let Test.9 : I64 = CallByName Num.19 Test.1 Test.21; @@ -33,4 +33,4 @@ procedure Test.0 (#Derived_gen.2): ret Test.8; in - jump Test.7 #Derived_gen.2; + jump Test.7 #Derived_gen.0; diff --git a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt index 376a770fff..5f34b99efd 100644 --- a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt +++ b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt @@ -90,8 +90,8 @@ procedure Test.19 (): let Test.120 : [C Str, C {List U8, I64}] = TagId(0) Test.122; ret Test.120; else - dec Test.93; dec Test.92; + dec Test.93; let Test.128 : Str = "not a number"; let Test.126 : [C Str, C {List U8, I64}] = TagId(0) Test.128; ret Test.126; diff --git a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt index fd079d4414..9bed8ce12b 100644 --- a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt +++ b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt @@ -57,8 +57,8 @@ procedure Test.0 (): else let Test.22 : Str = "B"; let Test.23 : Int1 = lowlevel Eq Test.22 Test.12; - dec Test.12; dec Test.22; + dec Test.12; if Test.23 then let Test.17 : [C U8, C U8, C ] = TagId(1) Test.2; jump Test.13 Test.17; diff --git a/crates/compiler/test_mono/generated/pattern_as_toplevel.txt b/crates/compiler/test_mono/generated/pattern_as_toplevel.txt index a124668cf0..4a70501f51 100644 --- a/crates/compiler/test_mono/generated/pattern_as_toplevel.txt +++ b/crates/compiler/test_mono/generated/pattern_as_toplevel.txt @@ -20,9 +20,9 @@ procedure Test.0 (): if Test.13 then let Test.6 : {I64, Str} = CallByName Test.1; let Test.5 : Int1 = CallByName Bool.11 Test.6 Test.4; + dec Test.6; let #Derived_gen.0 : Str = StructAtIndex 1 Test.4; dec #Derived_gen.0; - dec Test.6; ret Test.5; else let #Derived_gen.1 : Str = StructAtIndex 1 Test.4; diff --git a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt index b6a9f8d79d..f8267319e6 100644 --- a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt +++ b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt @@ -6,10 +6,10 @@ procedure List.5 (#Attr.2, #Attr.3): procedure Test.2 (Test.5): let Test.6 : List [C List *self] = UnionAtIndex (Id 0) (Index 0) Test.5; inc Test.6; - let #Derived_gen.1 : [C List *self] = Reset { symbol: Test.5, id: UpdateModeId { id: 0 } }; + let #Derived_gen.2 : [C List *self] = Reset { symbol: Test.5, id: UpdateModeId { id: 1 } }; let Test.15 : {} = Struct {}; let Test.7 : List [C List *self] = CallByName List.5 Test.6 Test.15; - let Test.14 : [C List *self] = Reuse #Derived_gen.1 UpdateModeId { id: 0 } TagId(0) Test.7; + let Test.14 : [C List *self] = Reuse #Derived_gen.2 UpdateModeId { id: 1 } TagId(0) Test.7; ret Test.14; procedure Test.0 (): diff --git a/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt b/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt index 2e262e0bbe..2e9faa9d1b 100644 --- a/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt +++ b/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt @@ -10,7 +10,7 @@ procedure Num.21 (#Attr.2, #Attr.3): let Num.279 : U8 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.279; -procedure Test.1 (#Derived_gen.2, #Derived_gen.3): +procedure Test.1 (#Derived_gen.0, #Derived_gen.1): joinpoint Test.11 Test.2 Test.3: let Test.26 : U8 = 0i64; let Test.22 : Int1 = CallByName Bool.11 Test.2 Test.26; @@ -33,9 +33,9 @@ procedure Test.1 (#Derived_gen.2, #Derived_gen.3): let Test.14 : [, C *self U8] = TagId(0) Test.3 Test.2; jump Test.11 Test.13 Test.14; in - jump Test.11 #Derived_gen.2 #Derived_gen.3; + jump Test.11 #Derived_gen.0 #Derived_gen.1; -procedure Test.4 (#Derived_gen.0, #Derived_gen.1): +procedure Test.4 (#Derived_gen.2, #Derived_gen.3): joinpoint Test.15 Test.5 #Attr.12: let Test.20 : U8 = UnionAtIndex (Id 0) (Index 1) #Attr.12; let Test.19 : [, C *self U8] = UnionAtIndex (Id 0) (Index 0) #Attr.12; @@ -61,7 +61,7 @@ procedure Test.4 (#Derived_gen.0, #Derived_gen.1): decref #Attr.12; jump #Derived_gen.4; in - jump Test.15 #Derived_gen.0 #Derived_gen.1; + jump Test.15 #Derived_gen.2 #Derived_gen.3; procedure Test.6 (Test.7): ret Test.7; diff --git a/crates/compiler/test_mono/generated/recursively_build_effect.txt b/crates/compiler/test_mono/generated/recursively_build_effect.txt index ab911ff89e..a6bcf407a8 100644 --- a/crates/compiler/test_mono/generated/recursively_build_effect.txt +++ b/crates/compiler/test_mono/generated/recursively_build_effect.txt @@ -8,8 +8,8 @@ procedure Str.3 (#Attr.2, #Attr.3): procedure Test.11 (Test.29, #Attr.12): let Test.32 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12; - let #Derived_gen.11 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.11 then + let #Derived_gen.9 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.9 then free #Attr.12; ret Test.32; else @@ -19,11 +19,11 @@ procedure Test.11 (Test.29, #Attr.12): procedure Test.11 (Test.29, Test.10): ret Test.10; -procedure Test.14 (#Derived_gen.0, #Derived_gen.1): +procedure Test.14 (#Derived_gen.7, #Derived_gen.8): joinpoint Test.38 Test.37 #Attr.12: let Test.46 : {} = UnionAtIndex (Id 1) (Index 1) #Attr.12; let Test.45 : I64 = UnionAtIndex (Id 1) (Index 0) #Attr.12; - joinpoint #Derived_gen.9: + joinpoint #Derived_gen.10: let Test.44 : {} = Struct {}; let Test.43 : {} = CallByName Test.11 Test.44 Test.46; let Test.39 : [C {}, C I64 {}] = CallByName Test.9 Test.43 Test.45; @@ -38,15 +38,15 @@ procedure Test.14 (#Derived_gen.0, #Derived_gen.1): jump Test.38 Test.41 Test.39; in - let #Derived_gen.10 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.10 then + let #Derived_gen.11 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.11 then free #Attr.12; - jump #Derived_gen.9; + jump #Derived_gen.10; else decref #Attr.12; - jump #Derived_gen.9; + jump #Derived_gen.10; in - jump Test.38 #Derived_gen.0 #Derived_gen.1; + jump Test.38 #Derived_gen.7 #Derived_gen.8; procedure Test.2 (): let Test.6 : Str = "Hello"; diff --git a/crates/compiler/test_mono/generated/specialize_after_match.txt b/crates/compiler/test_mono/generated/specialize_after_match.txt index 278075a7fc..832e559bd4 100644 --- a/crates/compiler/test_mono/generated/specialize_after_match.txt +++ b/crates/compiler/test_mono/generated/specialize_after_match.txt @@ -23,7 +23,7 @@ procedure Test.2 (Test.9, Test.10): let Test.29 : U64 = CallByName Test.3 Test.9; ret Test.29; else - joinpoint #Derived_gen.1: + joinpoint #Derived_gen.4: let Test.13 : Str = UnionAtIndex (Id 0) (Index 0) Test.10; let Test.14 : [, C Str *self] = UnionAtIndex (Id 0) (Index 1) Test.10; let Test.33 : U64 = CallByName Test.3 Test.12; @@ -36,15 +36,15 @@ procedure Test.2 (Test.9, Test.10): else ret Test.16; in - let #Derived_gen.2 : Int1 = lowlevel RefCountIsUnique Test.9; - if #Derived_gen.2 then + let #Derived_gen.5 : Int1 = lowlevel RefCountIsUnique Test.9; + if #Derived_gen.5 then dec Test.11; free Test.9; - jump #Derived_gen.1; + jump #Derived_gen.4; else inc Test.12; decref Test.9; - jump #Derived_gen.1; + jump #Derived_gen.4; procedure Test.3 (Test.17): let Test.26 : U8 = 1i64; @@ -55,22 +55,22 @@ procedure Test.3 (Test.17): ret Test.22; else let Test.18 : [, C Str *self] = UnionAtIndex (Id 0) (Index 1) Test.17; - joinpoint #Derived_gen.3: + joinpoint #Derived_gen.1: let Test.24 : U64 = 1i64; let Test.25 : U64 = CallByName Test.3 Test.18; let Test.23 : U64 = CallByName Num.19 Test.24 Test.25; ret Test.23; in - let #Derived_gen.5 : Int1 = lowlevel RefCountIsUnique Test.17; - if #Derived_gen.5 then - let #Derived_gen.4 : Str = UnionAtIndex (Id 0) (Index 0) Test.17; - dec #Derived_gen.4; + let #Derived_gen.3 : Int1 = lowlevel RefCountIsUnique Test.17; + if #Derived_gen.3 then + let #Derived_gen.2 : Str = UnionAtIndex (Id 0) (Index 0) Test.17; + dec #Derived_gen.2; free Test.17; - jump #Derived_gen.3; + jump #Derived_gen.1; else inc Test.18; decref Test.17; - jump #Derived_gen.3; + jump #Derived_gen.1; procedure Test.0 (): let Test.5 : [, C Str *self] = TagId(1) ; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt index 46f2f1546d..3fd9af2eeb 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt @@ -141,7 +141,7 @@ procedure List.8 (#Attr.2, #Attr.3): let List.625 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.625; -procedure List.92 (#Derived_gen.44, #Derived_gen.45, #Derived_gen.46, #Derived_gen.47, #Derived_gen.48): +procedure List.92 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): joinpoint List.577 List.163 List.164 List.165 List.166 List.167: let List.579 : Int1 = CallByName Num.22 List.166 List.167; if List.579 then @@ -155,7 +155,7 @@ procedure List.92 (#Derived_gen.44, #Derived_gen.45, #Derived_gen.46, #Derived_g dec List.163; ret List.164; in - jump List.577 #Derived_gen.44 #Derived_gen.45 #Derived_gen.46 #Derived_gen.47 #Derived_gen.48; + jump List.577 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; procedure List.92 (#Derived_gen.52, #Derived_gen.53, #Derived_gen.54, #Derived_gen.55, #Derived_gen.56): joinpoint List.604 List.163 List.164 List.165 List.166 List.167: diff --git a/examples/python-interop/.gitignore b/examples/python-interop/.gitignore new file mode 100644 index 0000000000..3bbb2128c9 --- /dev/null +++ b/examples/python-interop/.gitignore @@ -0,0 +1,3 @@ +.interop_env +demo.egg-info +dist diff --git a/examples/python-interop/build.sh b/examples/python-interop/build.sh index b6fcaab081..181260fe3c 100755 --- a/examples/python-interop/build.sh +++ b/examples/python-interop/build.sh @@ -5,12 +5,7 @@ set -euxo pipefail # Could assume roc binary on path but this may be preferable cargo build --release -../../target/release/roc build --lib - -# Neither the application nor python needs a .0, so we can just rename it -mv libhello.so.1.0 libhello.so.1 -# but one of which does expect plain libhello.so, so we symlink it -ln -sf libhello.so.1 libhello.so +../../target/release/roc build --lib libhello.roc # For Python to find libhello, it needs it to be in a known library path, so we export export LD_LIBRARY_PATH=$(pwd):$LD_LIBRARY_PATH @@ -24,6 +19,7 @@ export cc=clang python -m venv .interop_env source .interop_env/bin/activate python setup.py install +set +x echo "You may now enter your virtual environment. In bash/zsh, run: source .interop_env/bin/activate In fish, run: source .interop_env/bin/activate.fish diff --git a/examples/python-interop/demo.c b/examples/python-interop/demo.c index 453adf6028..566d43dcd8 100644 --- a/examples/python-interop/demo.c +++ b/examples/python-interop/demo.c @@ -227,15 +227,7 @@ PyObject * call_roc(PyObject *self, PyObject *args) roc__mainForHost_1_exposed_generic(&ret, &arg); // Create a Python string from the heap-allocated JSON bytes the Roc function returned. - PyObject* json_bytes = PyUnicode_FromStringAndSize((char*)ret.bytes, ret.len); - PyObject* json_module = PyImport_ImportModule("json"); - PyObject* loads_func = PyObject_GetAttrString(json_module, "loads"); - PyObject *loads_args = PyTuple_Pack(1, json_bytes); - PyObject* py_obj = PyObject_CallObject(loads_func, loads_args); - Py_XDECREF(loads_args); - Py_XDECREF(loads_func); - Py_XDECREF(json_module); - Py_XDECREF(json_bytes); + PyObject* py_obj = PyUnicode_FromStringAndSize((char*)ret.bytes, ret.len); // Now that we've created py_str, we're no longer referencing the RocBytes. decref((void *)&ret, alignof(uint8_t *)); diff --git a/examples/python-interop/main.roc b/examples/python-interop/libhello.roc similarity index 100% rename from examples/python-interop/main.roc rename to examples/python-interop/libhello.roc diff --git a/examples/python-interop/platform/main.roc b/examples/python-interop/platform/main.roc index ffcf7cbfff..7162c931fc 100644 --- a/examples/python-interop/platform/main.roc +++ b/examples/python-interop/platform/main.roc @@ -1,12 +1,16 @@ platform "python-interop" - requires {} { main : arg -> ret where arg implements Decoding, ret implements Encoding } + requires {} { main : U64 -> Str } exposes [] packages {} - imports [TotallyNotJson] + imports [] provides [mainForHost] mainForHost : List U8 -> List U8 -mainForHost = \json -> - when Decode.fromBytes json TotallyNotJson.json is - Ok arg -> Encode.toBytes (main arg) TotallyNotJson.json +mainForHost = \input -> + when Str.fromUtf8 input is + Ok arg -> + when Str.toU64 arg is + Ok num -> main num |> Str.toUtf8 + Err _ -> [] + Err _ -> [] diff --git a/examples/ruby-interop/.gitignore b/examples/ruby-interop/.gitignore new file mode 100644 index 0000000000..7d7b7f76d6 --- /dev/null +++ b/examples/ruby-interop/.gitignore @@ -0,0 +1,2 @@ +extconf.h +mkmf.log diff --git a/examples/ruby-interop/README.md b/examples/ruby-interop/README.md index 134e879f34..8a86637877 100644 --- a/examples/ruby-interop/README.md +++ b/examples/ruby-interop/README.md @@ -47,7 +47,7 @@ This uses the `Makefile` generated earlier to take the compiled Roc library and You can now try this out in Ruby's REPL (`irb`), like so: ```sh -$ irb +$ LD_LIBRARY_PATH="$PWD" irb irb(main):001:0> require_relative 'demo' => true irb(main):002:0> RocApp::call_roc 42 diff --git a/examples/ruby-interop/demo.c b/examples/ruby-interop/demo.c index 7bbbcf1eb1..5e76d3377e 100644 --- a/examples/ruby-interop/demo.c +++ b/examples/ruby-interop/demo.c @@ -194,32 +194,28 @@ size_t roc_str_len(struct RocStr str) extern void roc__mainForHost_1_exposed_generic(struct RocBytes *ret, struct RocBytes *arg); -// Receive a value from Ruby, JSON serialized it and pass it to Roc as a List U8 +// Receive a value from Ruby, serialize 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. +// which roc_panic will translate into a Ruby exception), then get some utf-8 string back from Roc +// - also as a List U8 - and have Ruby decode it into a plain Ruby value to return. VALUE call_roc(VALUE self, VALUE rb_arg) { - // This must be required before the to_json method will exist on String. - rb_require("json"); + VALUE str_arg = rb_funcall(rb_arg, rb_intern("to_s"), 0); + VALUE str_utf8_arg = rb_funcall(str_arg, rb_intern("force_encoding"), 1, rb_str_new_cstr("utf-8")); - // 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 arg = init_rocbytes((uint8_t *)RSTRING_PTR(str_utf8_arg), RSTRING_LEN(str_utf8_arg)); struct RocBytes ret; // Call the Roc function to populate `ret`'s bytes. roc__mainForHost_1_exposed_generic(&ret, &arg); - // 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); + // Create a rb_utf8_str from the heap-allocated utf-8 bytes the Roc function returned. + VALUE returned_str = rb_utf8_str_new((char *)ret.bytes, ret.len); - // Now that we've created our Ruby JSON string, we're no longer referencing the RocBytes. + // Now that we've created our Ruby string, we're no longer referencing the RocBytes. decref((void *)&ret, alignof(uint8_t *)); - return rb_funcall(rb_define_module("JSON"), rb_intern("parse"), 1, returned_json); + return returned_str; } void Init_demo() diff --git a/examples/ruby-interop/extconf.rb b/examples/ruby-interop/extconf.rb index 1af49ae6b6..a3a10ebf32 100644 --- a/examples/ruby-interop/extconf.rb +++ b/examples/ruby-interop/extconf.rb @@ -2,9 +2,8 @@ require 'mkmf' # preparation for compilation goes here -dir_config('') # include the current directory in the library search path -have_library('hello') # depend on `libhello.dylib` being in the current path - # (.dylib is macOS-specific; other OSes would have different extensions) +# HACK: pass 'demo.c' as a header because otherwise ruby complains that roc_*alloc are not defined +have_library('hello', nil, 'demo.c') create_header create_makefile 'demo' diff --git a/examples/ruby-interop/platform/main.roc b/examples/ruby-interop/platform/main.roc index 901c1a1298..c4a7379a3a 100644 --- a/examples/ruby-interop/platform/main.roc +++ b/examples/ruby-interop/platform/main.roc @@ -1,12 +1,16 @@ platform "ruby-interop" - requires {} { main : arg -> ret where arg implements Decoding, ret implements Encoding } + requires {} { main : U64 -> Str } exposes [] packages {} - imports [TotallyNotJson] + imports [] provides [mainForHost] mainForHost : List U8 -> List U8 -mainForHost = \json -> - when Decode.fromBytes json TotallyNotJson.json is - Ok arg -> Encode.toBytes (main arg) TotallyNotJson.json +mainForHost = \input -> + when Str.fromUtf8 input is + Ok arg -> + when Str.toU64 arg is + Ok num -> main num |> Str.toUtf8 + Err _ -> [] + Err _ -> [] # TODO panic so that Ruby raises an exception diff --git a/examples/virtual-dom-wip/platform/Html/Internal/Client.roc b/examples/virtual-dom-wip/platform/Html/Internal/Client.roc index 51e8759fb1..00e42d1fd4 100644 --- a/examples/virtual-dom-wip/platform/Html/Internal/Client.roc +++ b/examples/virtual-dom-wip/platform/Html/Internal/Client.roc @@ -20,7 +20,7 @@ import Html.Internal.Shared exposing [ Handler, translateStatic, ] -import TotallyNotJson +import Json import Action PlatformState state initData : { @@ -101,7 +101,7 @@ initClientAppHelp : List U8, App state initData -> { state, rendered : RenderedT initClientAppHelp = \json, app -> state = json - |> Decode.fromBytes TotallyNotJson.json + |> Decode.fromBytes Json.json |> app.init dynamicView = app.render state @@ -441,7 +441,7 @@ diffAttr = \{ nodeId, attrs, patches, handlers, deletedHandlerCache }, attr -> if accessors == newAccessors then Tuple attrs patches else - json = newAccessors |> Encode.toBytes TotallyNotJson.json + json = newAccessors |> Encode.toBytes Json.json Tuple { attrs & eventListeners: Dict.insert attrs.eventListeners eventName { accessors, handlerId } } @@ -593,7 +593,7 @@ renderAttr = \{ nodeId, attrs, patches, handlers, deletedHandlerCache }, attr -> newDeletedHandlerCache: deletedHandlerCache, } accessorsJson = - accessors |> Encode.toBytes TotallyNotJson.json + accessors |> Encode.toBytes Json.json patch = SetListener nodeId eventType accessorsJson handlerId @@ -771,7 +771,7 @@ expect initJson : List U8 initJson = - { answer: 42 } |> Encode.toBytes TotallyNotJson.json # panics at mono/src/ir.rs:5739:56 + { answer: 42 } |> Encode.toBytes Json.json # panics at mono/src/ir.rs:5739:56 expected : { state : State, rendered : RenderedTree State, patches : List Patch } expected = { state: { answer: 42 }, diff --git a/examples/virtual-dom-wip/platform/Html/Internal/Server.roc b/examples/virtual-dom-wip/platform/Html/Internal/Server.roc index 01d5291795..9c20390f8c 100644 --- a/examples/virtual-dom-wip/platform/Html/Internal/Server.roc +++ b/examples/virtual-dom-wip/platform/Html/Internal/Server.roc @@ -4,7 +4,7 @@ module [ ] import Html.Internal.Shared exposing [Html, Attribute, App, translateStatic, text, element] -import TotallyNotJson +import Json # ------------------------------- # STATIC HTML @@ -69,7 +69,7 @@ insertRocScript = \document, initData, wasmUrl, hostJavaScript -> encode = \value -> value - |> Encode.toBytes TotallyNotJson.json + |> Encode.toBytes Json.json |> Str.fromUtf8 |> Result.withDefault "" diff --git a/crates/compiler/builtins/roc/TotallyNotJson.roc b/examples/virtual-dom-wip/platform/Json.roc similarity index 99% rename from crates/compiler/builtins/roc/TotallyNotJson.roc rename to examples/virtual-dom-wip/platform/Json.roc index 38fdbe421d..d28c2e925b 100644 --- a/crates/compiler/builtins/roc/TotallyNotJson.roc +++ b/examples/virtual-dom-wip/platform/Json.roc @@ -1,18 +1,10 @@ -## THIS MODULE IS DEPRECATED AND CURRENTLY IN THE PROCESS OF BEING REMOVED -## FROM STD LIBRARY module [ Json, json, jsonWithOptions, ] -import List -import Str -import Result -import Encode exposing [EncoderFormatting, appendWith] -import Decode exposing [DecoderFormatting, DecodeResult] -import Num exposing [U8, U16, U64, F32, F64, Dec] -import Bool exposing [Bool] +import Encode exposing [appendWith] ## An opaque type with the `EncoderFormatting` and ## `DecoderFormatting` abilities. diff --git a/examples/virtual-dom-wip/platform/server-side.roc b/examples/virtual-dom-wip/platform/server-side.roc index 05460ca9a0..fabc20eb7f 100644 --- a/examples/virtual-dom-wip/platform/server-side.roc +++ b/examples/virtual-dom-wip/platform/server-side.roc @@ -6,7 +6,7 @@ platform "server-side" Html.Internal.Shared.{ App }, Html.Internal.Server.{ initServerApp }, Html.{ renderStatic }, - TotallyNotJson, + Json, ] provides [main] @@ -14,7 +14,7 @@ main : Str, Str -> Result Str Str main = \initJson, hostJavaScript -> initJson |> Str.toUtf8 - |> Decode.fromBytes TotallyNotJson.json + |> Decode.fromBytes Json.json |> Result.try \initData -> initServerApp app initData hostJavaScript |> Result.map renderStatic |> Result.mapErr \err -> From 3edc5510431e2524b8b427b2bf037571b0209767 Mon Sep 17 00:00:00 2001 From: Ryan Barth Date: Mon, 1 Jul 2024 15:01:32 -0700 Subject: [PATCH 40/42] chore: cargo fmt --- crates/linker/src/macho.rs | 2 +- crates/linker/src/pe.rs | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/crates/linker/src/macho.rs b/crates/linker/src/macho.rs index 0c80d7f2e5..4323ece88d 100644 --- a/crates/linker/src/macho.rs +++ b/crates/linker/src/macho.rs @@ -18,12 +18,12 @@ use std::{ time::Instant, }; +use crate::util::{is_roc_definition, is_roc_undefined, report_timing}; use crate::{ align_by_constraint, align_to_offset_by_constraint, load_struct_inplace, load_struct_inplace_mut, load_structs_inplace, load_structs_inplace_mut, open_mmap, open_mmap_mut, }; -use crate::util::{report_timing, is_roc_undefined, is_roc_definition}; const MIN_SECTION_ALIGNMENT: usize = 0x40; diff --git a/crates/linker/src/pe.rs b/crates/linker/src/pe.rs index 091e628dc5..743d4c6af9 100644 --- a/crates/linker/src/pe.rs +++ b/crates/linker/src/pe.rs @@ -19,10 +19,8 @@ use roc_collections::{MutMap, VecMap}; use roc_error_macros::internal_error; use crate::{ - generate_dylib::APP_DLL, - load_struct_inplace, load_struct_inplace_mut, load_structs_inplace_mut, open_mmap, - open_mmap_mut, - util::is_roc_definition, + generate_dylib::APP_DLL, load_struct_inplace, load_struct_inplace_mut, + load_structs_inplace_mut, open_mmap, open_mmap_mut, util::is_roc_definition, }; /// The metadata stores information about/from the host .exe because @@ -193,10 +191,7 @@ pub(crate) fn preprocess_windows( Ok(obj) => obj, Err(e) => internal_error!("Failed to parse shared library file: {e}"), }; - let dummy_dll_symbols = shared_lib_obj - .symbols() - .filter(is_roc_definition) - .count(); + let dummy_dll_symbols = shared_lib_obj.symbols().filter(is_roc_definition).count(); let new_sections = [*b".text\0\0\0", *b".rdata\0\0"]; let mut preprocessed = Preprocessor::preprocess( From a88419e653dc989a6761a058940a92c506b528fa Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 1 Jul 2024 20:40:53 -0400 Subject: [PATCH 41/42] Update corporate sponsor list --- www/content/index.md | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/www/content/index.md b/www/content/index.md index 02c5bfb782..735383c49d 100644 --- a/www/content/index.md +++ b/www/content/index.md @@ -118,25 +118,9 @@ The [tutorial](/tutorial) introduces these gradually and in more depth, but this ## [Sponsors](#sponsors) {#sponsors} -We are very grateful for our corporate sponsors! They are: [Vendr](https://www.vendr.com/), [RWX](https://www.rwx.com), [Tweede golf](https://tweedegolf.nl/en), ohne-makler, and [Decem](https://www.decem.com.au). +We are very grateful for our corporate sponsors! They are: [Tweede golf](https://tweedegolf.nl/en), ohne-makler, and [Decem](https://www.decem.com.au).