From 1eb663c952366f13d92c717dfb727f4f7f600293 Mon Sep 17 00:00:00 2001 From: Dawid Danieluk Date: Thu, 19 Dec 2024 23:53:24 +0100 Subject: [PATCH 01/24] add buildRocPackage to nix folder --- flake.nix | 4 ++++ nix/buildRocPackage.nix | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 nix/buildRocPackage.nix diff --git a/flake.nix b/flake.nix index e211ff8d00..53b184afd3 100644 --- a/flake.nix +++ b/flake.nix @@ -161,6 +161,10 @@ lang-server-debug = rocBuild.roc-lang-server-debug; }; + lib = { + buildRocPackage = import ./nix/buildRocPackage.nix; + }; + apps = { default = { type = "app"; diff --git a/nix/buildRocPackage.nix b/nix/buildRocPackage.nix new file mode 100644 index 0000000000..c268f6ceb7 --- /dev/null +++ b/nix/buildRocPackage.nix @@ -0,0 +1,37 @@ +{ pkgs, roc-cli, name, entryPoint, src, outputHash, ... }: +let + packageDependencies = pkgs.stdenv.mkDerivation { + inherit src; + name = "roc-dependencies"; + nativeBuildInputs = with pkgs; [ gnutar brotli ripgrep wget ]; + + buildPhase = '' + list=$(rg -o 'https://github.com[^"]*' ${entryPoint}) + for url in $list; do + path=$(echo $url | awk -F'github.com/|/[^/]*$' '{print $2}') + packagePath=$out/roc/packages/github.com/$path + mkdir -p $packagePath + wget -P $packagePath $url --no-check-certificate + cd $packagePath + brotli -d *.tar.br + tar -xf *.tar --one-top-level + rm *.tar + done + ''; + + outputHashMode = "recursive"; + outputHashAlgo = "sha256"; + outputHash = outputHash; + }; +in pkgs.stdenv.mkDerivation { + inherit name src; + nativeBuildInputs = [ roc-cli ]; + buildPhase = '' + export XDG_CACHE_HOME=${packageDependencies} + roc build ${entryPoint} --output ${name} --optimize --linker=legacy + + mkdir -p $out/bin + mv ${name} $out/bin/${name} + ''; +} + From 832501b22e7ca8559a95d7fb65f5fd3ef0d23ae9 Mon Sep 17 00:00:00 2001 From: Dawid Danieluk Date: Fri, 20 Dec 2024 00:04:42 +0100 Subject: [PATCH 02/24] move env variable outside of buildPhase --- flake.nix | 50 ++++++++++++++++++++--------------------- nix/buildRocPackage.nix | 4 +++- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/flake.nix b/flake.nix index 53b184afd3..6d849b682a 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,8 @@ description = "Roc flake"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs?rev=184957277e885c06a505db112b35dfbec7c60494"; + nixpkgs.url = + "github:nixos/nixpkgs?rev=184957277e885c06a505db112b35dfbec7c60494"; # rust from nixpkgs has some libc problems, this is patched in the rust-overlay rust-overlay = { @@ -27,23 +28,26 @@ outputs = { self, nixpkgs, rust-overlay, flake-utils, nixgl, ... }@inputs: let - supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; + supportedSystems = + [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; templates = import ./nix/templates { }; - in - { inherit templates; } // - flake-utils.lib.eachSystem supportedSystems (system: + lib = { buildRocPackage = import ./nix/buildRocPackage.nix; }; + in { + inherit templates lib; + } // flake-utils.lib.eachSystem supportedSystems (system: let overlays = [ (import rust-overlay) ] - ++ (if system == "x86_64-linux" then [ nixgl.overlay ] else [ ]); + ++ (if system == "x86_64-linux" then [ nixgl.overlay ] else [ ]); pkgs = import nixpkgs { inherit system overlays; }; rocBuild = import ./nix { inherit pkgs; }; compile-deps = rocBuild.compile-deps; - inherit (compile-deps) zigPkg llvmPkgs llvmVersion - llvmMajorMinorStr glibcPath libGccSPath darwinInputs; + inherit (compile-deps) + zigPkg llvmPkgs llvmVersion llvmMajorMinorStr glibcPath libGccSPath + darwinInputs; # DevInputs are not necessary to build roc as a user linuxDevInputs = with pkgs; @@ -64,11 +68,11 @@ # DevInputs are not necessary to build roc as a user darwinDevInputs = with pkgs; lib.optionals stdenv.isDarwin - (with pkgs.darwin.apple_sdk.frameworks; [ - CoreVideo # for examples/gui - Metal # for examples/gui - curl # for wasm-bindgen-cli libcurl (see ./ci/www-repl.sh) - ]); + (with pkgs.darwin.apple_sdk.frameworks; [ + CoreVideo # for examples/gui + Metal # for examples/gui + curl # for wasm-bindgen-cli libcurl (see ./ci/www-repl.sh) + ]); sharedInputs = (with pkgs; [ # build libraries @@ -114,15 +118,15 @@ alias fmtc='cargo fmt --all -- --check' ''; - in - { + in { devShell = pkgs.mkShell { - buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs ++ darwinDevInputs ++ linuxDevInputs - ++ (if system == "x86_64-linux" then - [ pkgs.nixgl.nixVulkanIntel ] - else - [ ]); + buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs + ++ darwinDevInputs ++ linuxDevInputs + ++ (if system == "x86_64-linux" then + [ pkgs.nixgl.nixVulkanIntel ] + else + [ ]); # nix does not store libs in /usr/lib or /lib # for libgcc_s.so.1 @@ -134,7 +138,7 @@ LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath - ([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ] + ([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ] ++ linuxDevInputs); NIXPKGS_ALLOW_UNFREE = 1; # to run the GUI examples with NVIDIA's closed source drivers @@ -161,10 +165,6 @@ lang-server-debug = rocBuild.roc-lang-server-debug; }; - lib = { - buildRocPackage = import ./nix/buildRocPackage.nix; - }; - apps = { default = { type = "app"; diff --git a/nix/buildRocPackage.nix b/nix/buildRocPackage.nix index c268f6ceb7..fd93cea99c 100644 --- a/nix/buildRocPackage.nix +++ b/nix/buildRocPackage.nix @@ -15,6 +15,7 @@ let cd $packagePath brotli -d *.tar.br tar -xf *.tar --one-top-level + rm *.tar.br rm *.tar done ''; @@ -26,8 +27,9 @@ let in pkgs.stdenv.mkDerivation { inherit name src; nativeBuildInputs = [ roc-cli ]; + XDG_CACHE_HOME = packageDependencies; + buildPhase = '' - export XDG_CACHE_HOME=${packageDependencies} roc build ${entryPoint} --output ${name} --optimize --linker=legacy mkdir -p $out/bin From 8cbb6de28cb8436eee563d2cc934fdaf6d57ba16 Mon Sep 17 00:00:00 2001 From: Dawid Danieluk Date: Fri, 20 Dec 2024 00:40:26 +0100 Subject: [PATCH 03/24] make diff smaller --- flake.nix | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/flake.nix b/flake.nix index 6d849b682a..cae998ad1f 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,7 @@ description = "Roc flake"; inputs = { - nixpkgs.url = - "github:nixos/nixpkgs?rev=184957277e885c06a505db112b35dfbec7c60494"; + nixpkgs.url = "github:nixos/nixpkgs?rev=184957277e885c06a505db112b35dfbec7c60494"; # rust from nixpkgs has some libc problems, this is patched in the rust-overlay rust-overlay = { @@ -28,26 +27,25 @@ outputs = { self, nixpkgs, rust-overlay, flake-utils, nixgl, ... }@inputs: let - supportedSystems = - [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; + supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; templates = import ./nix/templates { }; lib = { buildRocPackage = import ./nix/buildRocPackage.nix; }; in { inherit templates lib; - } // flake-utils.lib.eachSystem supportedSystems (system: + } // + flake-utils.lib.eachSystem supportedSystems (system: let overlays = [ (import rust-overlay) ] - ++ (if system == "x86_64-linux" then [ nixgl.overlay ] else [ ]); + ++ (if system == "x86_64-linux" then [ nixgl.overlay ] else [ ]); pkgs = import nixpkgs { inherit system overlays; }; rocBuild = import ./nix { inherit pkgs; }; compile-deps = rocBuild.compile-deps; - inherit (compile-deps) - zigPkg llvmPkgs llvmVersion llvmMajorMinorStr glibcPath libGccSPath - darwinInputs; + inherit (compile-deps) zigPkg llvmPkgs llvmVersion + llvmMajorMinorStr glibcPath libGccSPath darwinInputs; # DevInputs are not necessary to build roc as a user linuxDevInputs = with pkgs; @@ -68,11 +66,11 @@ # DevInputs are not necessary to build roc as a user darwinDevInputs = with pkgs; lib.optionals stdenv.isDarwin - (with pkgs.darwin.apple_sdk.frameworks; [ - CoreVideo # for examples/gui - Metal # for examples/gui - curl # for wasm-bindgen-cli libcurl (see ./ci/www-repl.sh) - ]); + (with pkgs.darwin.apple_sdk.frameworks; [ + CoreVideo # for examples/gui + Metal # for examples/gui + curl # for wasm-bindgen-cli libcurl (see ./ci/www-repl.sh) + ]); sharedInputs = (with pkgs; [ # build libraries @@ -118,15 +116,15 @@ alias fmtc='cargo fmt --all -- --check' ''; - in { + in + { devShell = pkgs.mkShell { - buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs - ++ darwinDevInputs ++ linuxDevInputs - ++ (if system == "x86_64-linux" then - [ pkgs.nixgl.nixVulkanIntel ] - else - [ ]); + buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs ++ darwinDevInputs ++ linuxDevInputs + ++ (if system == "x86_64-linux" then + [ pkgs.nixgl.nixVulkanIntel ] + else + [ ]); # nix does not store libs in /usr/lib or /lib # for libgcc_s.so.1 @@ -138,7 +136,7 @@ LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath - ([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ] + ([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ] ++ linuxDevInputs); NIXPKGS_ALLOW_UNFREE = 1; # to run the GUI examples with NVIDIA's closed source drivers From ce0920677dc28a8dbd41b784570bb74d5267eb0d Mon Sep 17 00:00:00 2001 From: Dawid Danieluk Date: Fri, 20 Dec 2024 01:11:04 +0100 Subject: [PATCH 04/24] allow changing linker --- nix/buildRocPackage.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nix/buildRocPackage.nix b/nix/buildRocPackage.nix index fd93cea99c..c7e3554b1b 100644 --- a/nix/buildRocPackage.nix +++ b/nix/buildRocPackage.nix @@ -1,4 +1,4 @@ -{ pkgs, roc-cli, name, entryPoint, src, outputHash, ... }: +{ pkgs, roc-cli, name, entryPoint, src, outputHash, linker ? "", ... }: let packageDependencies = pkgs.stdenv.mkDerivation { inherit src; @@ -30,7 +30,9 @@ in pkgs.stdenv.mkDerivation { XDG_CACHE_HOME = packageDependencies; buildPhase = '' - roc build ${entryPoint} --output ${name} --optimize --linker=legacy + roc build ${entryPoint} --output ${name} --optimize ${ + if linker != "" then "--linker=${linker}" else "" + } mkdir -p $out/bin mv ${name} $out/bin/${name} From 21caf7843a88c0c2ebd9c0f438498911aea76644 Mon Sep 17 00:00:00 2001 From: Dawid Danieluk Date: Tue, 31 Dec 2024 12:19:45 +0100 Subject: [PATCH 05/24] dont use --no-check-certificate flag --- nix/buildRocPackage.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/buildRocPackage.nix b/nix/buildRocPackage.nix index c7e3554b1b..62569c2241 100644 --- a/nix/buildRocPackage.nix +++ b/nix/buildRocPackage.nix @@ -11,7 +11,7 @@ let path=$(echo $url | awk -F'github.com/|/[^/]*$' '{print $2}') packagePath=$out/roc/packages/github.com/$path mkdir -p $packagePath - wget -P $packagePath $url --no-check-certificate + wget -P $packagePath $url cd $packagePath brotli -d *.tar.br tar -xf *.tar --one-top-level From 5e167ed835a5a64fda4e2f5139e2fdfb4164f104 Mon Sep 17 00:00:00 2001 From: Dawid Danieluk Date: Tue, 31 Dec 2024 12:27:13 +0100 Subject: [PATCH 06/24] add openssl package to roc-dependencies --- nix/buildRocPackage.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/buildRocPackage.nix b/nix/buildRocPackage.nix index 62569c2241..50d137640f 100644 --- a/nix/buildRocPackage.nix +++ b/nix/buildRocPackage.nix @@ -3,7 +3,7 @@ let packageDependencies = pkgs.stdenv.mkDerivation { inherit src; name = "roc-dependencies"; - nativeBuildInputs = with pkgs; [ gnutar brotli ripgrep wget ]; + nativeBuildInputs = with pkgs; [ gnutar brotli ripgrep wget openssl ]; buildPhase = '' list=$(rg -o 'https://github.com[^"]*' ${entryPoint}) From 30df8a066a4404059ec30d44a788d795699286db Mon Sep 17 00:00:00 2001 From: Dawid Danieluk Date: Tue, 31 Dec 2024 12:30:09 +0100 Subject: [PATCH 07/24] add cacert to nativeBuildInputs --- nix/buildRocPackage.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nix/buildRocPackage.nix b/nix/buildRocPackage.nix index 50d137640f..4ea5cf4c0f 100644 --- a/nix/buildRocPackage.nix +++ b/nix/buildRocPackage.nix @@ -3,7 +3,14 @@ let packageDependencies = pkgs.stdenv.mkDerivation { inherit src; name = "roc-dependencies"; - nativeBuildInputs = with pkgs; [ gnutar brotli ripgrep wget openssl ]; + nativeBuildInputs = with pkgs; [ + gnutar + brotli + ripgrep + wget + openssl + cacert + ]; buildPhase = '' list=$(rg -o 'https://github.com[^"]*' ${entryPoint}) From 819e35703c446023d21f93fe3cd70b069c9b4a3d Mon Sep 17 00:00:00 2001 From: Dawid Danieluk Date: Tue, 31 Dec 2024 12:33:17 +0100 Subject: [PATCH 08/24] revert adding openssl to nativeBuildInputs --- nix/buildRocPackage.nix | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/nix/buildRocPackage.nix b/nix/buildRocPackage.nix index 4ea5cf4c0f..a95f0802d0 100644 --- a/nix/buildRocPackage.nix +++ b/nix/buildRocPackage.nix @@ -3,14 +3,7 @@ let packageDependencies = pkgs.stdenv.mkDerivation { inherit src; name = "roc-dependencies"; - nativeBuildInputs = with pkgs; [ - gnutar - brotli - ripgrep - wget - openssl - cacert - ]; + nativeBuildInputs = with pkgs; [ gnutar brotli ripgrep wget cacert ]; buildPhase = '' list=$(rg -o 'https://github.com[^"]*' ${entryPoint}) From b1e619be4afa2dcf4fc4658305ff1fd0eed04094 Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Wed, 8 Jan 2025 16:16:22 +1100 Subject: [PATCH 09/24] fix nix flake --- flake.lock | 12 ++++++------ flake.nix | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index a9daebbed0..6481d19862 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1732722421, - "narHash": "sha256-HRJ/18p+WoXpWJkcdsk9St5ZiukCqSDgbOGFa8Okehg=", + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", "owner": "edolstra", "repo": "flake-compat", - "rev": "9ed2ac151eada2306ca8c418ebd97807bb08f6ac", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", "type": "github" }, "original": { @@ -89,11 +89,11 @@ ] }, "locked": { - "lastModified": 1732802692, - "narHash": "sha256-kFrxb45qj52TT/OFUFyTdmvXkn/KXDUL0/DOtjHEQvs=", + "lastModified": 1736303309, + "narHash": "sha256-IKrk7RL+Q/2NC6+Ql6dwwCNZI6T6JH2grTdJaVWHF0A=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "34971069ec33755b2adf2481851f66d8ec9a6bfa", + "rev": "a0b81d4fa349d9af1765b0f0b4a899c13776f706", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c5927c9811..8648f55a7e 100644 --- a/flake.nix +++ b/flake.nix @@ -33,7 +33,7 @@ lib = { buildRocPackage = import ./nix/buildRocPackage.nix; }; in { inherit templates lib; - } // + } // flake-utils.lib.eachSystem supportedSystems (system: let @@ -49,7 +49,7 @@ # DevInputs are not necessary to build roc as a user linuxDevInputs = with pkgs; - lib.optionals stdenv.isLinux [ + pkgs.lib.optionals stdenv.isLinux [ valgrind # used in cli tests, see cli/tests/cli_tests.rs vulkan-headers # here and below is all graphics stuff for examples/gui vulkan-loader @@ -61,12 +61,12 @@ xorg.libXi xorg.libxcb cargo-llvm-cov # to visualize code coverage - + ]; # DevInputs are not necessary to build roc as a user darwinDevInputs = with pkgs; - lib.optionals stdenv.isDarwin + pkgs.lib.optionals stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [ CoreVideo # for examples/gui Metal # for examples/gui @@ -122,7 +122,7 @@ in { - devShell = pkgs.mkShell { + devShells.default = pkgs.mkShell { buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs ++ darwinDevInputs ++ linuxDevInputs ++ (if system == "x86_64-linux" then [ pkgs.nixgl.nixVulkanIntel ] @@ -137,10 +137,10 @@ NIX_GLIBC_PATH = if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else ""; - LD_LIBRARY_PATH = with pkgs; - lib.makeLibraryPath - ([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ] - ++ linuxDevInputs); + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath + ([ pkgs.pkg-config pkgs.stdenv.cc.cc.lib pkgs.libffi pkgs.ncurses pkgs.zlib ] + ++ linuxDevInputs); + NIXPKGS_ALLOW_UNFREE = 1; # to run the GUI examples with NVIDIA's closed source drivers From bb79964aaa34cb4d46427b5529e03d2b3e930d3e Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 8 Jan 2025 19:17:22 +0100 Subject: [PATCH 10/24] try out old devShell syntax --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 8648f55a7e..ee5637ec03 100644 --- a/flake.nix +++ b/flake.nix @@ -122,7 +122,7 @@ in { - devShells.default = pkgs.mkShell { + devShell = pkgs.mkShell { buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs ++ darwinDevInputs ++ linuxDevInputs ++ (if system == "x86_64-linux" then [ pkgs.nixgl.nixVulkanIntel ] From e6d3e8496a8649aadcf1d358abcadb39aa340dc8 Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Thu, 9 Jan 2025 14:13:24 +1100 Subject: [PATCH 11/24] add workflow_dispatch to www job --- .github/workflows/www.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/www.yml b/.github/workflows/www.yml index 73e58c7501..ea32bd79ae 100644 --- a/.github/workflows/www.yml +++ b/.github/workflows/www.yml @@ -1,21 +1,24 @@ name: deploy www.roc-lang.org -# Whenever a commit lands on `main`, deploy the site on: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + + # Whenever a commit lands on `main`, deploy the site push: branches: - deploy-www jobs: deploy: - name: 'Deploy to Netlify' + name: "Deploy to Netlify" runs-on: [self-hosted, linux] steps: - uses: jsmrcaga/action-netlify-deploy@v1.6.0 with: - install_command: 'pwd; cd ../../www' - build_command: 'bash build.sh' - build_directory: 'build' + install_command: "pwd; cd ../../www" + build_command: "bash build.sh" + build_directory: "build" NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} NETLIFY_DEPLOY_MESSAGE: "Deploy git ref ${{ github.ref }}" From 0438c175032c4f65ae39dc082d124b5294fe4502 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Wed, 8 Jan 2025 21:25:39 -0800 Subject: [PATCH 12/24] Fix pnc args multiine in the presence of final comments --- crates/compiler/fmt/src/expr.rs | 5 +-- ...y_comment_after_newline.expr.formatted.roc | 4 +++ ...pply_comment_after_newline.expr.result-ast | 31 +++++++++++++++++++ .../pnc_apply_comment_after_newline.expr.roc | 2 ++ .../test_syntax/tests/test_snapshots.rs | 3 +- 5 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.formatted.roc create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.result-ast create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.roc diff --git a/crates/compiler/fmt/src/expr.rs b/crates/compiler/fmt/src/expr.rs index 0e1101fab0..ae91cad16b 100644 --- a/crates/compiler/fmt/src/expr.rs +++ b/crates/compiler/fmt/src/expr.rs @@ -521,10 +521,7 @@ pub fn expr_is_multiline(me: &Expr<'_>, comments_only: bool) -> bool { .any(|loc_arg| expr_is_multiline(&loc_arg.value, comments_only)) } Expr::PncApply(loc_expr, args) => { - expr_is_multiline(&loc_expr.value, comments_only) - || args - .iter() - .any(|loc_arg| expr_is_multiline(&loc_arg.value, comments_only)) + expr_is_multiline(&loc_expr.value, comments_only) || is_collection_multiline(args) } Expr::DbgStmt { .. } => true, diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.formatted.roc new file mode 100644 index 0000000000..5f4ed8e6dc --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.formatted.roc @@ -0,0 +1,4 @@ +i( + i, +) + t \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.result-ast new file mode 100644 index 0000000000..02c6b9701b --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.result-ast @@ -0,0 +1,31 @@ +@0-7 SpaceAfter( + Apply( + @0-6 PncApply( + @0-1 Var { + module_name: "", + ident: "i", + }, + Collection { + items: [ + @2-3 Var { + module_name: "", + ident: "i", + }, + ], + final_comments: [ + Newline, + ], + }, + ), + [ + @6-7 Var { + module_name: "", + ident: "t", + }, + ], + Space, + ), + [ + Newline, + ], +) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.roc new file mode 100644 index 0000000000..044f8f9f9e --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_apply_comment_after_newline.expr.roc @@ -0,0 +1,2 @@ +i(i, +)t diff --git a/crates/compiler/test_syntax/tests/test_snapshots.rs b/crates/compiler/test_syntax/tests/test_snapshots.rs index 4d9c44565d..4b17513e28 100644 --- a/crates/compiler/test_syntax/tests/test_snapshots.rs +++ b/crates/compiler/test_syntax/tests/test_snapshots.rs @@ -189,8 +189,8 @@ mod test_snapshots { fail/ability_demands_not_indented_with_first.expr, fail/ability_first_demand_not_indented_enough.expr, fail/ability_non_signature_expression.expr, - fail/all_the_bangs.expr, fail/alias_or_opaque_fail.expr, + fail/all_the_bangs.expr, fail/bound_variable.expr, fail/comment_with_tab.expr, fail/d_assign_return_bang.expr, @@ -631,6 +631,7 @@ mod test_snapshots { pass/pizza_question.moduledefs, pass/plus_if.expr, pass/plus_when.expr, + pass/pnc_apply_comment_after_newline.expr, pass/pos_inf_float.expr, pass/positive_float.expr, pass/positive_int.expr, From ffa1dd5703c824e63f56ae3f165f4c02440b46cb Mon Sep 17 00:00:00 2001 From: Ian McLerran Date: Thu, 9 Jan 2025 09:40:59 -0600 Subject: [PATCH 13/24] unified formatting for walk --- crates/compiler/builtins/roc/List.roc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index 9f88645869..c25dd43a1a 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -1514,7 +1514,11 @@ for_each_try! = \list, func! -> walk! : List elem, state, (state, elem => state) => state walk! = \list, state, func! -> when list is - [] -> state + [] -> + state + [elem, .. as rest] -> next_state = func!(state, elem) walk!(rest, next_state, func!) + + From ea2a007834768dfb63faeda22026f0dcb7a0dfad Mon Sep 17 00:00:00 2001 From: Ian McLerran Date: Thu, 9 Jan 2025 11:45:01 -0600 Subject: [PATCH 14/24] Add List.walk_try! --- crates/compiler/builtins/roc/List.roc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index c25dd43a1a..9c15c731cf 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -75,6 +75,7 @@ module [ for_each!, for_each_try!, walk!, + walk_try!, ] import Bool exposing [Bool, Eq] @@ -1514,11 +1515,24 @@ for_each_try! = \list, func! -> walk! : List elem, state, (state, elem => state) => state walk! = \list, state, func! -> when list is - [] -> + [] -> state [elem, .. as rest] -> next_state = func!(state, elem) walk!(rest, next_state, func!) +## Build a value from the contents of a list, using an effectful function that might fail. +walk_try! : List elem, state, (state, elem => Result state err) => Result state err +walk_try! = \list, state, func! -> + when list is + [] -> + Ok(state) + [elem, .. as rest] -> + when func!(state, elem) is + Ok(next_state) -> + walk_try!(rest, next_state, func!) + + Err(err) -> + Err(err) From 56f53c56d2eb4a522cbc9ab21fa12a1bdbb8db90 Mon Sep 17 00:00:00 2001 From: Ian McLerran Date: Thu, 9 Jan 2025 12:16:13 -0600 Subject: [PATCH 15/24] add walk_try! to symbols.rs --- crates/compiler/module/src/symbol.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/compiler/module/src/symbol.rs b/crates/compiler/module/src/symbol.rs index 5b99770ac7..61e8d7dbbb 100644 --- a/crates/compiler/module/src/symbol.rs +++ b/crates/compiler/module/src/symbol.rs @@ -1515,6 +1515,7 @@ define_builtins! { 92 LIST_WALK_FX: "walk!" 93 LIST_SPLIT_ON: "split_on" 94 LIST_SPLIT_ON_LIST: "split_on_list" + 95 LIST_WALK_TRY_FX: "walk_try!" } 7 RESULT: "Result" => { 0 RESULT_RESULT: "Result" exposed_type=true // the Result.Result type alias From ab3f39a7c9d2786775ae70847e26668bcca593ab Mon Sep 17 00:00:00 2001 From: Ian McLerran Date: Thu, 9 Jan 2025 13:49:33 -0600 Subject: [PATCH 16/24] Add docs for List.walk_try! --- crates/compiler/builtins/roc/List.roc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index 9c15c731cf..320cc42532 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -1523,6 +1523,21 @@ walk! = \list, state, func! -> walk!(rest, next_state, func!) ## Build a value from the contents of a list, using an effectful function that might fail. +## +## If the function returns `Err`, the iteration stops and the error is returned. +## +## ``` +## names = try List.walk_try!( +## ["First", "Middle", "Last"], +## [], +## \accumulator, which -> +## try Stdout.write! ("$(which) name: ") +## name = try Stdin.line! ({}) +## Ok (List.append accumulator name), +## ) +## ``` +## +## This is the same as [walk_try], except that the step function can have effects. walk_try! : List elem, state, (state, elem => Result state err) => Result state err walk_try! = \list, state, func! -> when list is From 541fb6056c588bf3dc09d3faea4cc53206ae38b3 Mon Sep 17 00:00:00 2001 From: Ian McLerran Date: Thu, 9 Jan 2025 13:53:01 -0600 Subject: [PATCH 17/24] update mono tests --- ...e_in_polymorphic_expression_issue_4717.txt | 116 +++---- .../generated/call_function_in_empty_list.txt | 78 ++--- .../call_function_in_empty_list_unbound.txt | 78 ++--- .../generated/capture_void_layout_task.txt | 44 +-- .../test_mono/generated/closure_in_list.txt | 4 +- ...lambda_set_productive_nullable_wrapped.txt | 44 +-- crates/compiler/test_mono/generated/dict.txt | 4 +- .../generated/empty_list_of_function_type.txt | 28 +- .../compiler/test_mono/generated/encode.txt | 18 +- .../encode_derived_nested_record_string.txt | 126 ++++---- ...encode_derived_record_one_field_string.txt | 74 ++--- ...ncode_derived_record_two_field_strings.txt | 74 ++--- .../generated/encode_derived_string.txt | 22 +- .../encode_derived_tag_one_field_string.txt | 78 ++--- ...encode_derived_tag_two_payloads_string.txt | 78 ++--- .../generated/inspect_derived_dict.txt | 298 +++++++++--------- .../generated/inspect_derived_list.txt | 44 +-- .../inspect_derived_nested_record_string.txt | 102 +++--- .../generated/inspect_derived_record.txt | 46 +-- ...nspect_derived_record_one_field_string.txt | 46 +-- ...spect_derived_record_two_field_strings.txt | 46 +-- .../inspect_derived_tag_one_field_string.txt | 74 ++--- ...nspect_derived_tag_two_payloads_string.txt | 66 ++-- .../test_mono/generated/ir_int_add.txt | 4 +- ...cialize_errors_behind_unified_branches.txt | 54 ++-- .../test_mono/generated/issue_4770.txt | 208 ++++++------ ...ure_with_multiple_recursive_structures.txt | 44 +-- .../test_mono/generated/list_append.txt | 18 +- .../generated/list_append_closure.txt | 18 +- .../generated/list_cannot_update_inplace.txt | 32 +- .../compiler/test_mono/generated/list_get.txt | 28 +- .../compiler/test_mono/generated/list_len.txt | 8 +- .../generated/list_map_closure_borrows.txt | 94 +++--- .../generated/list_map_closure_owns.txt | 94 +++--- ...ist_map_take_capturing_or_noncapturing.txt | 110 +++---- .../generated/list_pass_to_function.txt | 32 +- .../test_mono/generated/list_sort_asc.txt | 12 +- .../test_mono/generated/quicksort_swap.txt | 56 ++-- .../test_mono/generated/record_update.txt | 32 +- ...function_and_union_with_inference_hole.txt | 82 ++--- .../compiler/test_mono/generated/rigids.txt | 56 ++-- ...not_duplicate_identical_concrete_types.txt | 80 ++--- ...types_without_unification_of_unifiable.txt | 134 ++++---- .../weakening_avoids_overspecialization.txt | 116 +++---- 44 files changed, 1450 insertions(+), 1450 deletions(-) diff --git a/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt b/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt index f8450369f3..83a5079000 100644 --- a/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt +++ b/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt @@ -2,81 +2,81 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.23; -procedure List.115 (List.562, List.563, List.564): - let List.683 : U64 = 0i64; - let List.684 : U64 = CallByName List.6 List.562; - let List.682 : [C U64, C U64] = CallByName List.80 List.562 List.563 List.564 List.683 List.684; - ret List.682; +procedure List.116 (List.563, List.564, List.565): + let List.693 : U64 = 0i64; + let List.694 : U64 = CallByName List.6 List.563; + let List.692 : [C U64, C U64] = CallByName List.80 List.563 List.564 List.565 List.693 List.694; + ret List.692; -procedure List.26 (List.212, List.213, List.214): - let List.676 : [C U64, C U64] = CallByName List.115 List.212 List.213 List.214; - let List.679 : U8 = 1i64; - let List.680 : U8 = GetTagId List.676; - let List.681 : Int1 = lowlevel Eq List.679 List.680; - if List.681 then - let List.215 : U64 = UnionAtIndex (Id 1) (Index 0) List.676; - ret List.215; - else - let List.216 : U64 = UnionAtIndex (Id 0) (Index 0) List.676; +procedure List.26 (List.213, List.214, List.215): + let List.686 : [C U64, C U64] = CallByName List.116 List.213 List.214 List.215; + let List.689 : U8 = 1i64; + let List.690 : U8 = GetTagId List.686; + let List.691 : Int1 = lowlevel Eq List.689 List.690; + if List.691 then + let List.216 : U64 = UnionAtIndex (Id 1) (Index 0) List.686; ret List.216; + else + let List.217 : U64 = UnionAtIndex (Id 0) (Index 0) List.686; + ret List.217; -procedure List.38 (List.400, List.401): - let List.675 : U64 = CallByName List.6 List.400; - let List.402 : U64 = CallByName Num.77 List.675 List.401; - let List.665 : List U8 = CallByName List.43 List.400 List.402; - ret List.665; +procedure List.38 (List.401, List.402): + let List.685 : U64 = CallByName List.6 List.401; + let List.403 : U64 = CallByName Num.77 List.685 List.402; + let List.675 : List U8 = CallByName List.43 List.401 List.403; + ret List.675; -procedure List.43 (List.398, List.399): - let List.673 : U64 = CallByName List.6 List.398; - let List.672 : U64 = CallByName Num.77 List.673 List.399; - let List.667 : {U64, U64} = Struct {List.399, List.672}; - let List.666 : List U8 = CallByName List.49 List.398 List.667; - ret List.666; +procedure List.43 (List.399, List.400): + let List.683 : U64 = CallByName List.6 List.399; + let List.682 : U64 = CallByName Num.77 List.683 List.400; + let List.677 : {U64, U64} = Struct {List.400, List.682}; + let List.676 : List U8 = CallByName List.49 List.399 List.677; + ret List.676; -procedure List.49 (List.476, List.477): - let List.669 : U64 = StructAtIndex 1 List.477; - let List.670 : U64 = StructAtIndex 0 List.477; - let List.668 : List U8 = CallByName List.72 List.476 List.669 List.670; - ret List.668; +procedure List.49 (List.477, List.478): + let List.679 : U64 = StructAtIndex 1 List.478; + let List.680 : U64 = StructAtIndex 0 List.478; + let List.678 : List U8 = CallByName List.72 List.477 List.679 List.680; + ret List.678; procedure List.6 (#Attr.2): - let List.674 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.674; + let List.684 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.684; procedure List.66 (#Attr.2, #Attr.3): - let List.697 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.697; + let List.707 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.707; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.671 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.671; + let List.681 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.681; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.685 List.565 List.566 List.567 List.568 List.569: - let List.687 : Int1 = CallByName Num.22 List.568 List.569; - if List.687 then - let List.696 : U8 = CallByName List.66 List.565 List.568; - let List.688 : [C U64, C U64] = CallByName Test.4 List.566 List.696; - let List.693 : U8 = 1i64; - let List.694 : U8 = GetTagId List.688; - let List.695 : Int1 = lowlevel Eq List.693 List.694; - if List.695 then - let List.570 : U64 = UnionAtIndex (Id 1) (Index 0) List.688; - let List.691 : U64 = 1i64; - let List.690 : U64 = CallByName Num.51 List.568 List.691; - jump List.685 List.565 List.570 List.567 List.690 List.569; + joinpoint List.695 List.566 List.567 List.568 List.569 List.570: + let List.697 : Int1 = CallByName Num.22 List.569 List.570; + if List.697 then + let List.706 : U8 = CallByName List.66 List.566 List.569; + let List.698 : [C U64, C U64] = CallByName Test.4 List.567 List.706; + let List.703 : U8 = 1i64; + let List.704 : U8 = GetTagId List.698; + let List.705 : Int1 = lowlevel Eq List.703 List.704; + if List.705 then + let List.571 : U64 = UnionAtIndex (Id 1) (Index 0) List.698; + let List.701 : U64 = 1i64; + let List.700 : U64 = CallByName Num.51 List.569 List.701; + jump List.695 List.566 List.571 List.568 List.700 List.570; else - dec List.565; - let List.571 : U64 = UnionAtIndex (Id 0) (Index 0) List.688; - let List.692 : [C U64, C U64] = TagId(0) List.571; - ret List.692; + dec List.566; + let List.572 : U64 = UnionAtIndex (Id 0) (Index 0) List.698; + let List.702 : [C U64, C U64] = TagId(0) List.572; + ret List.702; else - dec List.565; - let List.686 : [C U64, C U64] = TagId(1) List.566; - ret List.686; + dec List.566; + let List.696 : [C U64, C U64] = TagId(1) List.567; + ret List.696; in inc #Derived_gen.0; - jump List.685 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.695 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.22 (#Attr.2, #Attr.3): let Num.286 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt index 202ff21f0f..51eb352941 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt @@ -1,51 +1,51 @@ -procedure List.100 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.671 List.174 List.175 List.176 List.177 List.178: - let List.673 : Int1 = CallByName Num.22 List.177 List.178; - if List.673 then - let List.677 : [] = CallByName List.66 List.174 List.177; - let List.179 : List {} = CallByName List.283 List.175 List.677 List.176; - let List.676 : U64 = 1i64; - let List.675 : U64 = CallByName Num.51 List.177 List.676; - jump List.671 List.174 List.179 List.176 List.675 List.178; +procedure List.101 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.681 List.175 List.176 List.177 List.178 List.179: + let List.683 : Int1 = CallByName Num.22 List.178 List.179; + if List.683 then + let List.687 : [] = CallByName List.66 List.175 List.178; + let List.180 : List {} = CallByName List.284 List.176 List.687 List.177; + let List.686 : U64 = 1i64; + let List.685 : U64 = CallByName Num.51 List.178 List.686; + jump List.681 List.175 List.180 List.177 List.685 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in inc #Derived_gen.0; - jump List.671 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.681 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.18 (List.171, List.172, List.173): - let List.669 : U64 = 0i64; - let List.670 : U64 = CallByName List.6 List.171; - let List.668 : List {} = CallByName List.100 List.171 List.172 List.173 List.669 List.670; - ret List.668; - -procedure List.283 (List.284, List.285, List.281): - let List.682 : {} = CallByName Test.2 List.285; - let List.681 : List {} = CallByName List.71 List.284 List.682; - ret List.681; - -procedure List.5 (List.280, List.281): - let List.282 : U64 = CallByName List.6 List.280; - let List.666 : List {} = CallByName List.68 List.282; - let List.665 : List {} = CallByName List.18 List.280 List.666 List.281; - ret List.665; - -procedure List.6 (#Attr.2): - let List.679 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.679; - -procedure List.66 (#Attr.2, #Attr.3): - let List.678 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.679 : U64 = 0i64; + let List.680 : U64 = CallByName List.6 List.172; + let List.678 : List {} = CallByName List.101 List.172 List.173 List.174 List.679 List.680; ret List.678; +procedure List.284 (List.285, List.286, List.282): + let List.692 : {} = CallByName Test.2 List.286; + let List.691 : List {} = CallByName List.71 List.285 List.692; + ret List.691; + +procedure List.5 (List.281, List.282): + let List.283 : U64 = CallByName List.6 List.281; + let List.676 : List {} = CallByName List.68 List.283; + let List.675 : List {} = CallByName List.18 List.281 List.676 List.282; + ret List.675; + +procedure List.6 (#Attr.2): + let List.689 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.689; + +procedure List.66 (#Attr.2, #Attr.3): + let List.688 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.688; + procedure List.68 (#Attr.2): - let List.684 : List {} = lowlevel ListWithCapacity #Attr.2; - ret List.684; + let List.694 : List {} = lowlevel ListWithCapacity #Attr.2; + ret List.694; procedure List.71 (#Attr.2, #Attr.3): - let List.683 : List {} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.683; + let List.693 : List {} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.693; procedure Num.22 (#Attr.2, #Attr.3): let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt index fd6401ba7b..11ac4c443d 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt @@ -1,51 +1,51 @@ -procedure List.100 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.671 List.174 List.175 List.176 List.177 List.178: - let List.673 : Int1 = CallByName Num.22 List.177 List.178; - if List.673 then - let List.677 : [] = CallByName List.66 List.174 List.177; - let List.179 : List [] = CallByName List.283 List.175 List.677 List.176; - let List.676 : U64 = 1i64; - let List.675 : U64 = CallByName Num.51 List.177 List.676; - jump List.671 List.174 List.179 List.176 List.675 List.178; +procedure List.101 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.681 List.175 List.176 List.177 List.178 List.179: + let List.683 : Int1 = CallByName Num.22 List.178 List.179; + if List.683 then + let List.687 : [] = CallByName List.66 List.175 List.178; + let List.180 : List [] = CallByName List.284 List.176 List.687 List.177; + let List.686 : U64 = 1i64; + let List.685 : U64 = CallByName Num.51 List.178 List.686; + jump List.681 List.175 List.180 List.177 List.685 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in inc #Derived_gen.0; - jump List.671 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.681 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.18 (List.171, List.172, List.173): - let List.669 : U64 = 0i64; - let List.670 : U64 = CallByName List.6 List.171; - let List.668 : List [] = CallByName List.100 List.171 List.172 List.173 List.669 List.670; - ret List.668; - -procedure List.283 (List.284, List.285, List.281): - let List.682 : [] = CallByName Test.2 List.285; - let List.681 : List [] = CallByName List.71 List.284 List.682; - ret List.681; - -procedure List.5 (List.280, List.281): - let List.282 : U64 = CallByName List.6 List.280; - let List.666 : List [] = CallByName List.68 List.282; - let List.665 : List [] = CallByName List.18 List.280 List.666 List.281; - ret List.665; - -procedure List.6 (#Attr.2): - let List.679 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.679; - -procedure List.66 (#Attr.2, #Attr.3): - let List.678 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.679 : U64 = 0i64; + let List.680 : U64 = CallByName List.6 List.172; + let List.678 : List [] = CallByName List.101 List.172 List.173 List.174 List.679 List.680; ret List.678; +procedure List.284 (List.285, List.286, List.282): + let List.692 : [] = CallByName Test.2 List.286; + let List.691 : List [] = CallByName List.71 List.285 List.692; + ret List.691; + +procedure List.5 (List.281, List.282): + let List.283 : U64 = CallByName List.6 List.281; + let List.676 : List [] = CallByName List.68 List.283; + let List.675 : List [] = CallByName List.18 List.281 List.676 List.282; + ret List.675; + +procedure List.6 (#Attr.2): + let List.689 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.689; + +procedure List.66 (#Attr.2, #Attr.3): + let List.688 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.688; + procedure List.68 (#Attr.2): - let List.684 : List [] = lowlevel ListWithCapacity #Attr.2; - ret List.684; + let List.694 : List [] = lowlevel ListWithCapacity #Attr.2; + ret List.694; procedure List.71 (#Attr.2, #Attr.3): - let List.683 : List [] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.683; + let List.693 : List [] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.693; procedure Num.22 (#Attr.2, #Attr.3): let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; 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 ef79c76147..be67ed8577 100644 --- a/crates/compiler/test_mono/generated/capture_void_layout_task.txt +++ b/crates/compiler/test_mono/generated/capture_void_layout_task.txt @@ -1,32 +1,32 @@ -procedure List.100 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : [] = CallByName List.66 List.174 List.177; - let List.179 : [C {}, C *self {{}, []}] = CallByName Test.29 List.175 List.674 List.176; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : [] = CallByName List.66 List.175 List.178; + let List.180 : [C {}, C *self {{}, []}] = CallByName Test.29 List.176 List.684 List.177; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.11; - jump List.668 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; + inc #Derived_gen.8; + jump List.678 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : [C {}, C *self {{}, []}] = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : [C {}, C *self {{}, []}] = CallByName List.101 List.172 List.173 List.174 List.676 List.677; + ret List.675; procedure List.6 (#Attr.2): - let List.676 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.676; + let List.686 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.686; procedure List.66 (#Attr.2, #Attr.3): - let List.675 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.675; + let List.685 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; procedure Num.22 (#Attr.2, #Attr.3): let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/closure_in_list.txt b/crates/compiler/test_mono/generated/closure_in_list.txt index b326b37918..7647083750 100644 --- a/crates/compiler/test_mono/generated/closure_in_list.txt +++ b/crates/compiler/test_mono/generated/closure_in_list.txt @@ -1,6 +1,6 @@ procedure List.6 (#Attr.2): - let List.665 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.665; + let List.675 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.675; procedure Test.1 (Test.5): let Test.2 : I64 = 41i64; diff --git a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt index 7afd72ba2c..e06264f601 100644 --- a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt +++ b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt @@ -2,35 +2,35 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure List.100 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : Int1 = CallByName List.66 List.174 List.177; - let List.179 : [, C *self Int1, C *self Int1] = CallByName Test.6 List.175 List.674 List.176; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : Int1 = CallByName List.66 List.175 List.178; + let List.180 : [, C *self Int1, C *self Int1] = CallByName Test.6 List.176 List.684 List.177; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.3; - jump List.668 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + inc #Derived_gen.5; + jump List.678 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : [, C *self Int1, C *self Int1] = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : [, C *self Int1, C *self Int1] = CallByName List.101 List.172 List.173 List.174 List.676 List.677; + ret List.675; procedure List.6 (#Attr.2): - let List.676 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.676; + let List.686 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.686; procedure List.66 (#Attr.2, #Attr.3): - let List.675 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.675; + let List.685 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; procedure Num.22 (#Attr.2, #Attr.3): let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/dict.txt b/crates/compiler/test_mono/generated/dict.txt index 67d35d2014..e550ff18e6 100644 --- a/crates/compiler/test_mono/generated/dict.txt +++ b/crates/compiler/test_mono/generated/dict.txt @@ -26,8 +26,8 @@ procedure Dict.52 (): ret Dict.744; procedure List.6 (#Attr.2): - let List.665 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.665; + let List.675 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.675; procedure Num.75 (#Attr.2, #Attr.3): let Num.283 : U8 = lowlevel NumSubWrap #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt index 5ae351eca8..c9c316d0ff 100644 --- a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt +++ b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt @@ -2,25 +2,25 @@ procedure Bool.1 (): let Bool.23 : Int1 = false; ret Bool.23; -procedure List.2 (List.119, List.120): - let List.671 : U64 = CallByName List.6 List.119; - let List.667 : Int1 = CallByName Num.22 List.120 List.671; - if List.667 then - let List.669 : {} = CallByName List.66 List.119 List.120; - let List.668 : [C {}, C {}] = TagId(1) List.669; - ret List.668; +procedure List.2 (List.120, List.121): + let List.681 : U64 = CallByName List.6 List.120; + let List.677 : Int1 = CallByName Num.22 List.121 List.681; + if List.677 then + let List.679 : {} = CallByName List.66 List.120 List.121; + let List.678 : [C {}, C {}] = TagId(1) List.679; + ret List.678; else - let List.666 : {} = Struct {}; - let List.665 : [C {}, C {}] = TagId(0) List.666; - ret List.665; + let List.676 : {} = Struct {}; + let List.675 : [C {}, C {}] = TagId(0) List.676; + ret List.675; procedure List.6 (#Attr.2): - let List.672 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.672; + let List.682 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.682; procedure List.66 (#Attr.2, #Attr.3): - let List.670 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.670; + let List.680 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.680; procedure Num.22 (#Attr.2, #Attr.3): let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/encode.txt b/crates/compiler/test_mono/generated/encode.txt index 0c482651dd..4a61bba9c3 100644 --- a/crates/compiler/test_mono/generated/encode.txt +++ b/crates/compiler/test_mono/generated/encode.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.135, List.136): - let List.668 : U64 = 1i64; - let List.666 : List U8 = CallByName List.70 List.135 List.668; - let List.665 : List U8 = CallByName List.71 List.666 List.136; - ret List.665; +procedure List.4 (List.136, List.137): + let List.678 : U64 = 1i64; + let List.676 : List U8 = CallByName List.70 List.136 List.678; + let List.675 : List U8 = CallByName List.71 List.676 List.137; + ret List.675; procedure List.70 (#Attr.2, #Attr.3): - let List.669 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.669; + let List.679 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.679; procedure List.71 (#Attr.2, #Attr.3): - let List.667 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.667; + let List.677 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.677; procedure Test.23 (Test.24, Test.35, Test.22): let Test.37 : List U8 = CallByName List.4 Test.24 Test.22; diff --git a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt index 31d18ca68d..eee404c564 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 @@ -67,85 +67,85 @@ procedure Encode.26 (Encode.107, Encode.108): let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; ret Encode.110; -procedure List.100 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): - joinpoint List.694 List.174 List.175 List.176 List.177 List.178: - let List.696 : Int1 = CallByName Num.22 List.177 List.178; - if List.696 then - let List.700 : {Str, Str} = CallByName List.66 List.174 List.177; - inc List.700; - let List.179 : List U8 = CallByName Test.71 List.175 List.700; - let List.699 : U64 = 1i64; - let List.698 : U64 = CallByName Num.51 List.177 List.699; - jump List.694 List.174 List.179 List.176 List.698 List.178; +procedure List.101 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : {Str, Str} = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : List U8 = CallByName Test.71 List.176 List.684; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in inc #Derived_gen.26; - jump List.694 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; + jump List.678 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; -procedure List.100 (#Derived_gen.34, #Derived_gen.35, #Derived_gen.36, #Derived_gen.37, #Derived_gen.38): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : {Str, Str} = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : List U8 = CallByName Test.71 List.175 List.674; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34, #Derived_gen.35): + joinpoint List.704 List.175 List.176 List.177 List.178 List.179: + let List.706 : Int1 = CallByName Num.22 List.178 List.179; + if List.706 then + let List.710 : {Str, Str} = CallByName List.66 List.175 List.178; + inc List.710; + let List.180 : List U8 = CallByName Test.71 List.176 List.710; + let List.709 : U64 = 1i64; + let List.708 : U64 = CallByName Num.51 List.178 List.709; + jump List.704 List.175 List.180 List.177 List.708 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.34; - jump List.668 #Derived_gen.34 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38; + inc #Derived_gen.31; + jump List.704 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : List U8 = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; - -procedure List.18 (List.171, List.172, List.173): - let List.692 : U64 = 0i64; - let List.693 : U64 = CallByName List.6 List.171; - let List.691 : List U8 = CallByName List.100 List.171 List.172 List.173 List.692 List.693; - ret List.691; - -procedure List.4 (List.135, List.136): - let List.713 : U64 = 1i64; - let List.712 : List U8 = CallByName List.70 List.135 List.713; - let List.711 : List U8 = CallByName List.71 List.712 List.136; - ret List.711; - -procedure List.6 (#Attr.2): - let List.690 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.690; - -procedure List.6 (#Attr.2): - let List.716 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.716; - -procedure List.66 (#Attr.2, #Attr.3): - let List.675 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : List U8 = CallByName List.101 List.172 List.173 List.174 List.676 List.677; ret List.675; -procedure List.66 (#Attr.2, #Attr.3): - let List.701 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.702 : U64 = 0i64; + let List.703 : U64 = CallByName List.6 List.172; + let List.701 : List U8 = CallByName List.101 List.172 List.173 List.174 List.702 List.703; ret List.701; +procedure List.4 (List.136, List.137): + let List.723 : U64 = 1i64; + let List.722 : List U8 = CallByName List.70 List.136 List.723; + let List.721 : List U8 = CallByName List.71 List.722 List.137; + ret List.721; + +procedure List.6 (#Attr.2): + let List.700 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.700; + +procedure List.6 (#Attr.2): + let List.726 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.726; + +procedure List.66 (#Attr.2, #Attr.3): + let List.685 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; + +procedure List.66 (#Attr.2, #Attr.3): + let List.711 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.711; + procedure List.70 (#Attr.2, #Attr.3): - let List.707 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.707; + let List.717 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.717; procedure List.71 (#Attr.2, #Attr.3): - let List.705 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.705; + let List.715 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.715; procedure List.8 (#Attr.2, #Attr.3): - let List.715 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.715; + let List.725 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.725; procedure Num.127 (#Attr.2): let Num.288 : U8 = lowlevel NumIntCast #Attr.2; 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 8aa802ca3a..89317dea5e 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 @@ -39,54 +39,54 @@ procedure Encode.26 (Encode.107, Encode.108): let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; ret Encode.110; -procedure List.100 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : {Str, Str} = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : List U8 = CallByName Test.71 List.175 List.674; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : {Str, Str} = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : List U8 = CallByName Test.71 List.176 List.684; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in inc #Derived_gen.16; - jump List.668 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; + jump List.678 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : List U8 = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; - -procedure List.4 (List.135, List.136): - let List.687 : U64 = 1i64; - let List.686 : List U8 = CallByName List.70 List.135 List.687; - let List.685 : List U8 = CallByName List.71 List.686 List.136; - ret List.685; - -procedure List.6 (#Attr.2): - let List.690 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.690; - -procedure List.66 (#Attr.2, #Attr.3): - let List.675 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : List U8 = CallByName List.101 List.172 List.173 List.174 List.676 List.677; ret List.675; +procedure List.4 (List.136, List.137): + let List.697 : U64 = 1i64; + let List.696 : List U8 = CallByName List.70 List.136 List.697; + let List.695 : List U8 = CallByName List.71 List.696 List.137; + ret List.695; + +procedure List.6 (#Attr.2): + let List.700 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.700; + +procedure List.66 (#Attr.2, #Attr.3): + let List.685 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; + procedure List.70 (#Attr.2, #Attr.3): - let List.681 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.681; + let List.691 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.691; procedure List.71 (#Attr.2, #Attr.3): - let List.679 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.679; + let List.689 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.689; procedure List.8 (#Attr.2, #Attr.3): - let List.689 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.689; + let List.699 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.699; procedure Num.127 (#Attr.2): let Num.284 : 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 9ca5156043..4934cb386b 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 @@ -46,54 +46,54 @@ procedure Encode.26 (Encode.107, Encode.108): let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; ret Encode.110; -procedure List.100 (#Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : {Str, Str} = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : List U8 = CallByName Test.71 List.175 List.674; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : {Str, Str} = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : List U8 = CallByName Test.71 List.176 List.684; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in inc #Derived_gen.20; - jump List.668 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24; + jump List.678 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : List U8 = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; - -procedure List.4 (List.135, List.136): - let List.687 : U64 = 1i64; - let List.686 : List U8 = CallByName List.70 List.135 List.687; - let List.685 : List U8 = CallByName List.71 List.686 List.136; - ret List.685; - -procedure List.6 (#Attr.2): - let List.690 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.690; - -procedure List.66 (#Attr.2, #Attr.3): - let List.675 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : List U8 = CallByName List.101 List.172 List.173 List.174 List.676 List.677; ret List.675; +procedure List.4 (List.136, List.137): + let List.697 : U64 = 1i64; + let List.696 : List U8 = CallByName List.70 List.136 List.697; + let List.695 : List U8 = CallByName List.71 List.696 List.137; + ret List.695; + +procedure List.6 (#Attr.2): + let List.700 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.700; + +procedure List.66 (#Attr.2, #Attr.3): + let List.685 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; + procedure List.70 (#Attr.2, #Attr.3): - let List.681 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.681; + let List.691 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.691; procedure List.71 (#Attr.2, #Attr.3): - let List.679 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.679; + let List.689 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.689; procedure List.8 (#Attr.2, #Attr.3): - let List.689 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.689; + let List.699 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.699; procedure Num.127 (#Attr.2): let Num.284 : U8 = lowlevel NumIntCast #Attr.2; diff --git a/crates/compiler/test_mono/generated/encode_derived_string.txt b/crates/compiler/test_mono/generated/encode_derived_string.txt index 265b622827..be968f298f 100644 --- a/crates/compiler/test_mono/generated/encode_derived_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_string.txt @@ -11,23 +11,23 @@ procedure Encode.26 (Encode.107, Encode.108): let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; ret Encode.110; -procedure List.4 (List.135, List.136): - let List.675 : U64 = 1i64; - let List.674 : List U8 = CallByName List.70 List.135 List.675; - let List.673 : List U8 = CallByName List.71 List.674 List.136; - ret List.673; +procedure List.4 (List.136, List.137): + let List.685 : U64 = 1i64; + let List.684 : List U8 = CallByName List.70 List.136 List.685; + let List.683 : List U8 = CallByName List.71 List.684 List.137; + ret List.683; procedure List.70 (#Attr.2, #Attr.3): - let List.669 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.669; + let List.679 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.679; procedure List.71 (#Attr.2, #Attr.3): - let List.667 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.667; + let List.677 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.677; procedure List.8 (#Attr.2, #Attr.3): - let List.677 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.677; + let List.687 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.687; procedure Num.127 (#Attr.2): let Num.284 : 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 01194822d9..6f14951fea 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 @@ -40,58 +40,58 @@ procedure Encode.26 (Encode.107, Encode.108): let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; ret Encode.110; -procedure List.100 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : Str = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : List U8 = CallByName Test.64 List.175 List.674 List.176; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : Str = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : List U8 = CallByName Test.64 List.176 List.684 List.177; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in inc #Derived_gen.10; - jump List.668 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; + jump List.678 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; procedure List.13 (#Attr.2, #Attr.3): - let List.691 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.691; + let List.701 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.701; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : List U8 = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; - -procedure List.4 (List.135, List.136): - let List.687 : U64 = 1i64; - let List.686 : List U8 = CallByName List.70 List.135 List.687; - let List.685 : List U8 = CallByName List.71 List.686 List.136; - ret List.685; - -procedure List.6 (#Attr.2): - let List.690 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.690; - -procedure List.66 (#Attr.2, #Attr.3): - let List.675 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : List U8 = CallByName List.101 List.172 List.173 List.174 List.676 List.677; ret List.675; +procedure List.4 (List.136, List.137): + let List.697 : U64 = 1i64; + let List.696 : List U8 = CallByName List.70 List.136 List.697; + let List.695 : List U8 = CallByName List.71 List.696 List.137; + ret List.695; + +procedure List.6 (#Attr.2): + let List.700 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.700; + +procedure List.66 (#Attr.2, #Attr.3): + let List.685 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; + procedure List.70 (#Attr.2, #Attr.3): - let List.681 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.681; + let List.691 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.691; procedure List.71 (#Attr.2, #Attr.3): - let List.679 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.679; + let List.689 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.689; procedure List.8 (#Attr.2, #Attr.3): - let List.689 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.689; + let List.699 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.699; procedure Num.127 (#Attr.2): let Num.284 : U8 = lowlevel NumIntCast #Attr.2; 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 9dc0c45f64..5e331a1f00 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 @@ -43,58 +43,58 @@ procedure Encode.26 (Encode.107, Encode.108): let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; ret Encode.110; -procedure List.100 (#Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : Str = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : List U8 = CallByName Test.64 List.175 List.674 List.176; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : Str = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : List U8 = CallByName Test.64 List.176 List.684 List.177; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in inc #Derived_gen.20; - jump List.668 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24; + jump List.678 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24; procedure List.13 (#Attr.2, #Attr.3): - let List.691 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.691; + let List.701 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.701; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : List U8 = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; - -procedure List.4 (List.135, List.136): - let List.687 : U64 = 1i64; - let List.686 : List U8 = CallByName List.70 List.135 List.687; - let List.685 : List U8 = CallByName List.71 List.686 List.136; - ret List.685; - -procedure List.6 (#Attr.2): - let List.690 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.690; - -procedure List.66 (#Attr.2, #Attr.3): - let List.675 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : List U8 = CallByName List.101 List.172 List.173 List.174 List.676 List.677; ret List.675; +procedure List.4 (List.136, List.137): + let List.697 : U64 = 1i64; + let List.696 : List U8 = CallByName List.70 List.136 List.697; + let List.695 : List U8 = CallByName List.71 List.696 List.137; + ret List.695; + +procedure List.6 (#Attr.2): + let List.700 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.700; + +procedure List.66 (#Attr.2, #Attr.3): + let List.685 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; + procedure List.70 (#Attr.2, #Attr.3): - let List.681 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.681; + let List.691 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.691; procedure List.71 (#Attr.2, #Attr.3): - let List.679 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.679; + let List.689 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.689; procedure List.8 (#Attr.2, #Attr.3): - let List.689 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.689; + let List.699 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.699; procedure Num.127 (#Attr.2): let Num.284 : U8 = lowlevel NumIntCast #Attr.2; diff --git a/crates/compiler/test_mono/generated/inspect_derived_dict.txt b/crates/compiler/test_mono/generated/inspect_derived_dict.txt index 28569ff027..87ba855f30 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_dict.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_dict.txt @@ -312,7 +312,7 @@ procedure Dict.72 (Dict.413, Dict.414, Dict.415): let Dict.855 : {U64, U32} = CallByName Dict.73 Dict.413 Dict.418 Dict.417; ret Dict.855; -procedure Dict.73 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12): +procedure Dict.73 (#Derived_gen.15, #Derived_gen.16, #Derived_gen.17): joinpoint Dict.856 Dict.419 Dict.420 Dict.421: let Dict.422 : {U32, U32} = CallByName Dict.22 Dict.419 Dict.420; let Dict.863 : U32 = StructAtIndex 1 Dict.422; @@ -327,8 +327,8 @@ procedure Dict.73 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12): let Dict.857 : {U64, U32} = Struct {Dict.420, Dict.421}; ret Dict.857; in - inc #Derived_gen.10; - jump Dict.856 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; + inc #Derived_gen.15; + jump Dict.856 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; procedure Dict.74 (#Derived_gen.48, #Derived_gen.49, #Derived_gen.50): joinpoint Dict.762 Dict.423 Dict.424 Dict.425: @@ -902,171 +902,171 @@ procedure Inspect.63 (Inspect.295, Inspect.291): procedure Inspect.64 (Inspect.297): ret Inspect.297; -procedure List.100 (#Derived_gen.34, #Derived_gen.35, #Derived_gen.36, #Derived_gen.37, #Derived_gen.38): - joinpoint List.732 List.174 List.175 List.176 List.177 List.178: - let List.734 : Int1 = CallByName Num.22 List.177 List.178; - if List.734 then - let List.738 : {Str, I64} = CallByName List.66 List.174 List.177; - inc List.738; - let List.179 : {Str, Int1} = CallByName Dict.188 List.175 List.738 List.176; - let List.737 : U64 = 1i64; - let List.736 : U64 = CallByName Num.51 List.177 List.737; - jump List.732 List.174 List.179 List.176 List.736 List.178; +procedure List.101 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : {Str, I64} = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.159 List.176 List.684; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.34; - jump List.732 #Derived_gen.34 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38; + inc #Derived_gen.10; + jump List.678 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; -procedure List.100 (#Derived_gen.60, #Derived_gen.61, #Derived_gen.62, #Derived_gen.63, #Derived_gen.64): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : {Str, I64} = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName Dict.159 List.175 List.674; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.51, #Derived_gen.52, #Derived_gen.53, #Derived_gen.54, #Derived_gen.55): + joinpoint List.742 List.175 List.176 List.177 List.178 List.179: + let List.744 : Int1 = CallByName Num.22 List.178 List.179; + if List.744 then + let List.748 : {Str, I64} = CallByName List.66 List.175 List.178; + inc List.748; + let List.180 : {Str, Int1} = CallByName Dict.188 List.176 List.748 List.177; + let List.747 : U64 = 1i64; + let List.746 : U64 = CallByName Num.51 List.178 List.747; + jump List.742 List.175 List.180 List.177 List.746 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.60; - jump List.668 #Derived_gen.60 #Derived_gen.61 #Derived_gen.62 #Derived_gen.63 #Derived_gen.64; + inc #Derived_gen.51; + jump List.742 #Derived_gen.51 #Derived_gen.52 #Derived_gen.53 #Derived_gen.54 #Derived_gen.55; -procedure List.101 (#Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19): - joinpoint List.707 List.183 List.184 List.185 List.186 List.187: - let List.709 : Int1 = CallByName Num.22 List.186 List.187; - if List.709 then - let List.713 : {Str, I64} = CallByName List.66 List.183 List.186; - inc List.713; - let List.188 : List {U32, U32} = CallByName Dict.407 List.184 List.713 List.186 List.185; - let List.712 : U64 = 1i64; - let List.711 : U64 = CallByName Num.51 List.186 List.712; - jump List.707 List.183 List.188 List.185 List.711 List.187; +procedure List.102 (#Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27): + joinpoint List.717 List.184 List.185 List.186 List.187 List.188: + let List.719 : Int1 = CallByName Num.22 List.187 List.188; + if List.719 then + let List.723 : {Str, I64} = CallByName List.66 List.184 List.187; + inc List.723; + let List.189 : List {U32, U32} = CallByName Dict.407 List.185 List.723 List.187 List.186; + let List.722 : U64 = 1i64; + let List.721 : U64 = CallByName Num.51 List.187 List.722; + jump List.717 List.184 List.189 List.186 List.721 List.188; else - dec List.183; - ret List.184; + dec List.184; + ret List.185; in - inc #Derived_gen.15; - jump List.707 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19; + inc #Derived_gen.23; + jump List.717 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27; -procedure List.11 (List.149, List.150): - let List.727 : List {U32, U32} = CallByName List.68 List.150; - let List.726 : List {U32, U32} = CallByName List.98 List.149 List.150 List.727; - ret List.726; +procedure List.11 (List.150, List.151): + let List.737 : List {U32, U32} = CallByName List.68 List.151; + let List.736 : List {U32, U32} = CallByName List.99 List.150 List.151 List.737; + ret List.736; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : {List {U32, U32}, List {Str, I64}, U64, Float32, U8} = CallByName List.101 List.172 List.173 List.174 List.676 List.677; + ret List.675; -procedure List.18 (List.171, List.172, List.173): - let List.730 : U64 = 0i64; - let List.731 : U64 = CallByName List.6 List.171; - let List.729 : {Str, Int1} = CallByName List.100 List.171 List.172 List.173 List.730 List.731; - ret List.729; - -procedure List.3 (List.127, List.128, List.129): - let List.691 : {List {U32, U32}, {U32, U32}} = CallByName List.64 List.127 List.128 List.129; - let List.690 : List {U32, U32} = StructAtIndex 0 List.691; - ret List.690; - -procedure List.3 (List.127, List.128, List.129): - let List.693 : {List {Str, I64}, {Str, I64}} = CallByName List.64 List.127 List.128 List.129; - let List.692 : List {Str, I64} = StructAtIndex 0 List.693; - let #Derived_gen.74 : {Str, I64} = StructAtIndex 1 List.693; - dec #Derived_gen.74; - ret List.692; - -procedure List.4 (List.135, List.136): - let List.702 : U64 = 1i64; - let List.700 : List {Str, I64} = CallByName List.70 List.135 List.702; - let List.699 : List {Str, I64} = CallByName List.71 List.700 List.136; - ret List.699; - -procedure List.6 (#Attr.2): - let List.681 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.681; - -procedure List.6 (#Attr.2): - let List.728 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.728; - -procedure List.6 (#Attr.2): - let List.740 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.740; - -procedure List.64 (List.124, List.125, List.126): - let List.689 : U64 = CallByName List.6 List.124; - let List.686 : Int1 = CallByName Num.22 List.125 List.689; - if List.686 then - let List.687 : {List {U32, U32}, {U32, U32}} = CallByName List.67 List.124 List.125 List.126; - ret List.687; - else - let List.685 : {List {U32, U32}, {U32, U32}} = Struct {List.124, List.126}; - ret List.685; - -procedure List.64 (List.124, List.125, List.126): - let List.698 : U64 = CallByName List.6 List.124; - let List.695 : Int1 = CallByName Num.22 List.125 List.698; - if List.695 then - let List.696 : {List {Str, I64}, {Str, I64}} = CallByName List.67 List.124 List.125 List.126; - ret List.696; - else - let List.694 : {List {Str, I64}, {Str, I64}} = Struct {List.124, List.126}; - ret List.694; - -procedure List.66 (#Attr.2, #Attr.3): - let List.739 : {Str, I64} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.740 : U64 = 0i64; + let List.741 : U64 = CallByName List.6 List.172; + let List.739 : {Str, Int1} = CallByName List.101 List.172 List.173 List.174 List.740 List.741; ret List.739; -procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.688 : {List {U32, U32}, {U32, U32}} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.688; +procedure List.3 (List.128, List.129, List.130): + let List.701 : {List {U32, U32}, {U32, U32}} = CallByName List.64 List.128 List.129 List.130; + let List.700 : List {U32, U32} = StructAtIndex 0 List.701; + ret List.700; + +procedure List.3 (List.128, List.129, List.130): + let List.703 : {List {Str, I64}, {Str, I64}} = CallByName List.64 List.128 List.129 List.130; + let List.702 : List {Str, I64} = StructAtIndex 0 List.703; + let #Derived_gen.74 : {Str, I64} = StructAtIndex 1 List.703; + dec #Derived_gen.74; + ret List.702; + +procedure List.4 (List.136, List.137): + let List.712 : U64 = 1i64; + let List.710 : List {Str, I64} = CallByName List.70 List.136 List.712; + let List.709 : List {Str, I64} = CallByName List.71 List.710 List.137; + ret List.709; + +procedure List.6 (#Attr.2): + let List.691 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.691; + +procedure List.6 (#Attr.2): + let List.738 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.738; + +procedure List.6 (#Attr.2): + let List.750 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.750; + +procedure List.64 (List.125, List.126, List.127): + let List.699 : U64 = CallByName List.6 List.125; + let List.696 : Int1 = CallByName Num.22 List.126 List.699; + if List.696 then + let List.697 : {List {U32, U32}, {U32, U32}} = CallByName List.67 List.125 List.126 List.127; + ret List.697; + else + let List.695 : {List {U32, U32}, {U32, U32}} = Struct {List.125, List.127}; + ret List.695; + +procedure List.64 (List.125, List.126, List.127): + let List.708 : U64 = CallByName List.6 List.125; + let List.705 : Int1 = CallByName Num.22 List.126 List.708; + if List.705 then + let List.706 : {List {Str, I64}, {Str, I64}} = CallByName List.67 List.125 List.126 List.127; + ret List.706; + else + let List.704 : {List {Str, I64}, {Str, I64}} = Struct {List.125, List.127}; + ret List.704; + +procedure List.66 (#Attr.2, #Attr.3): + let List.749 : {Str, I64} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.749; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.697 : {List {Str, I64}, {Str, I64}} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.697; + let List.698 : {List {U32, U32}, {U32, U32}} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.698; + +procedure List.67 (#Attr.2, #Attr.3, #Attr.4): + let List.707 : {List {Str, I64}, {Str, I64}} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.707; procedure List.68 (#Attr.2): - let List.725 : List {U32, U32} = lowlevel ListWithCapacity #Attr.2; - ret List.725; + let List.735 : List {U32, U32} = lowlevel ListWithCapacity #Attr.2; + ret List.735; procedure List.70 (#Attr.2, #Attr.3): - let List.703 : List {Str, I64} = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.703; + let List.713 : List {Str, I64} = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.713; procedure List.71 (#Attr.2, #Attr.3): - let List.701 : List {Str, I64} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.701; + let List.711 : List {Str, I64} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.711; procedure List.71 (#Attr.2, #Attr.3): - let List.722 : List {U32, U32} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.722; + let List.732 : List {U32, U32} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.732; -procedure List.83 (List.180, List.181, List.182): - let List.705 : U64 = 0i64; - let List.706 : U64 = CallByName List.6 List.180; - let List.704 : List {U32, U32} = CallByName List.101 List.180 List.181 List.182 List.705 List.706; - ret List.704; +procedure List.83 (List.181, List.182, List.183): + let List.715 : U64 = 0i64; + let List.716 : U64 = CallByName List.6 List.181; + let List.714 : List {U32, U32} = CallByName List.102 List.181 List.182 List.183 List.715 List.716; + ret List.714; -procedure List.98 (#Derived_gen.22, #Derived_gen.23, #Derived_gen.24): - joinpoint List.716 List.151 List.152 List.153: - let List.724 : U64 = 0i64; - let List.718 : Int1 = CallByName Num.24 List.152 List.724; - if List.718 then - let List.723 : U64 = 1i64; - let List.720 : U64 = CallByName Num.75 List.152 List.723; - let List.721 : List {U32, U32} = CallByName List.71 List.153 List.151; - jump List.716 List.151 List.720 List.721; +procedure List.99 (#Derived_gen.20, #Derived_gen.21, #Derived_gen.22): + joinpoint List.726 List.152 List.153 List.154: + let List.734 : U64 = 0i64; + let List.728 : Int1 = CallByName Num.24 List.153 List.734; + if List.728 then + let List.733 : U64 = 1i64; + let List.730 : U64 = CallByName Num.75 List.153 List.733; + let List.731 : List {U32, U32} = CallByName List.71 List.154 List.152; + jump List.726 List.152 List.730 List.731; else - ret List.153; + ret List.154; in - jump List.716 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24; + jump List.726 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; procedure Num.131 (#Attr.2): let Num.291 : U32 = lowlevel NumIntCast #Attr.2; @@ -1279,7 +1279,7 @@ procedure Str.45 (Str.91, Str.92, Str.93): dec Str.344; ret Str.91; -procedure Str.56 (#Derived_gen.51, #Derived_gen.52, #Derived_gen.53, #Derived_gen.54): +procedure Str.56 (#Derived_gen.56, #Derived_gen.57, #Derived_gen.58, #Derived_gen.59): joinpoint Str.253 Str.96 Str.97 Str.98 Str.99: inc Str.97; let Str.254 : [C {}, C {Str, Str}] = CallByName Str.38 Str.97 Str.98; @@ -1303,9 +1303,9 @@ procedure Str.56 (#Derived_gen.51, #Derived_gen.52, #Derived_gen.53, #Derived_ge dec Str.97; ret Str.258; in - inc #Derived_gen.54; - inc #Derived_gen.53; - jump Str.253 #Derived_gen.51 #Derived_gen.52 #Derived_gen.53 #Derived_gen.54; + inc #Derived_gen.58; + inc #Derived_gen.59; + jump Str.253 #Derived_gen.56 #Derived_gen.57 #Derived_gen.58 #Derived_gen.59; procedure Str.57 (Str.121, Str.122): let Str.123 : U64 = CallByName Str.36 Str.121; @@ -1315,7 +1315,7 @@ procedure Str.57 (Str.121, Str.122): let Str.279 : [C , C U64] = CallByName Str.58 Str.121 Str.122 Str.280 Str.125; ret Str.279; -procedure Str.58 (#Derived_gen.28, #Derived_gen.29, #Derived_gen.30, #Derived_gen.31): +procedure Str.58 (#Derived_gen.33, #Derived_gen.34, #Derived_gen.35, #Derived_gen.36): joinpoint Str.281 Str.126 Str.127 Str.128 Str.129: let Str.283 : Int1 = CallByName Num.23 Str.128 Str.129; if Str.283 then @@ -1335,9 +1335,9 @@ procedure Str.58 (#Derived_gen.28, #Derived_gen.29, #Derived_gen.30, #Derived_ge let Str.282 : [C , C U64] = TagId(0) ; ret Str.282; in - inc #Derived_gen.29; - inc #Derived_gen.28; - jump Str.281 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31; + inc #Derived_gen.34; + inc #Derived_gen.33; + jump Str.281 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35 #Derived_gen.36; procedure Str.61 (Str.152, Str.153): let Str.311 : Int1 = CallByName Num.22 Str.152 Str.153; diff --git a/crates/compiler/test_mono/generated/inspect_derived_list.txt b/crates/compiler/test_mono/generated/inspect_derived_list.txt index 6ca8c75892..8fc98930c4 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_list.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_list.txt @@ -120,35 +120,35 @@ procedure Inspect.63 (Inspect.295, Inspect.291): procedure Inspect.64 (Inspect.297): ret Inspect.297; -procedure List.100 (#Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : I64 = CallByName List.66 List.174 List.177; - let List.179 : {Str, Int1} = CallByName Inspect.160 List.175 List.674 List.176; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : I64 = CallByName List.66 List.175 List.178; + let List.180 : {Str, Int1} = CallByName Inspect.160 List.176 List.684 List.177; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.8; - jump List.668 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; + inc #Derived_gen.11; + jump List.678 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : {Str, Int1} = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : {Str, Int1} = CallByName List.101 List.172 List.173 List.174 List.676 List.677; + ret List.675; procedure List.6 (#Attr.2): - let List.676 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.676; + let List.686 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.686; procedure List.66 (#Attr.2, #Attr.3): - let List.675 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.675; + let List.685 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; procedure Num.22 (#Attr.2, #Attr.3): let Num.285 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/inspect_derived_nested_record_string.txt b/crates/compiler/test_mono/generated/inspect_derived_nested_record_string.txt index a01894af3c..25343efbcc 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_nested_record_string.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_nested_record_string.txt @@ -235,68 +235,68 @@ procedure Inspect.63 (Inspect.295, Inspect.291): procedure Inspect.64 (Inspect.297): ret Inspect.297; -procedure List.100 (#Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : {Str, Str} = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : {Str, Int1} = CallByName Inspect.229 List.175 List.674; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : {Str, Str} = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : {Str, Int1} = CallByName Inspect.229 List.176 List.684; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in inc #Derived_gen.20; - jump List.668 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24; + jump List.678 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24; -procedure List.100 (#Derived_gen.42, #Derived_gen.43, #Derived_gen.44, #Derived_gen.45, #Derived_gen.46): - joinpoint List.680 List.174 List.175 List.176 List.177 List.178: - let List.682 : Int1 = CallByName Num.22 List.177 List.178; - if List.682 then - let List.686 : {Str, Str} = CallByName List.66 List.174 List.177; - inc List.686; - let List.179 : {Str, Int1} = CallByName Inspect.229 List.175 List.686; - let List.685 : U64 = 1i64; - let List.684 : U64 = CallByName Num.51 List.177 List.685; - jump List.680 List.174 List.179 List.176 List.684 List.178; +procedure List.101 (#Derived_gen.39, #Derived_gen.40, #Derived_gen.41, #Derived_gen.42, #Derived_gen.43): + joinpoint List.690 List.175 List.176 List.177 List.178 List.179: + let List.692 : Int1 = CallByName Num.22 List.178 List.179; + if List.692 then + let List.696 : {Str, Str} = CallByName List.66 List.175 List.178; + inc List.696; + let List.180 : {Str, Int1} = CallByName Inspect.229 List.176 List.696; + let List.695 : U64 = 1i64; + let List.694 : U64 = CallByName Num.51 List.178 List.695; + jump List.690 List.175 List.180 List.177 List.694 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.42; - jump List.680 #Derived_gen.42 #Derived_gen.43 #Derived_gen.44 #Derived_gen.45 #Derived_gen.46; + inc #Derived_gen.39; + jump List.690 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42 #Derived_gen.43; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : {Str, Int1} = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; - -procedure List.18 (List.171, List.172, List.173): - let List.678 : U64 = 0i64; - let List.679 : U64 = CallByName List.6 List.171; - let List.677 : {Str, Int1} = CallByName List.100 List.171 List.172 List.173 List.678 List.679; - ret List.677; - -procedure List.6 (#Attr.2): - let List.676 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.676; - -procedure List.6 (#Attr.2): - let List.688 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.688; - -procedure List.66 (#Attr.2, #Attr.3): - let List.675 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : {Str, Int1} = CallByName List.101 List.172 List.173 List.174 List.676 List.677; ret List.675; -procedure List.66 (#Attr.2, #Attr.3): - let List.687 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.688 : U64 = 0i64; + let List.689 : U64 = CallByName List.6 List.172; + let List.687 : {Str, Int1} = CallByName List.101 List.172 List.173 List.174 List.688 List.689; ret List.687; +procedure List.6 (#Attr.2): + let List.686 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.686; + +procedure List.6 (#Attr.2): + let List.698 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.698; + +procedure List.66 (#Attr.2, #Attr.3): + let List.685 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; + +procedure List.66 (#Attr.2, #Attr.3): + let List.697 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.697; + procedure Num.20 (#Attr.2, #Attr.3): let Num.290 : U64 = lowlevel NumSub #Attr.2 #Attr.3; ret Num.290; diff --git a/crates/compiler/test_mono/generated/inspect_derived_record.txt b/crates/compiler/test_mono/generated/inspect_derived_record.txt index 565021f790..0c7d6db97f 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_record.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_record.txt @@ -150,36 +150,36 @@ procedure Inspect.63 (Inspect.295, Inspect.291): procedure Inspect.64 (Inspect.297): ret Inspect.297; -procedure List.100 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : {[C I64, C Decimal], Str} = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : {Str, Int1} = CallByName Inspect.229 List.175 List.674; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : {[C I64, C Decimal], Str} = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : {Str, Int1} = CallByName Inspect.229 List.176 List.684; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.16; - jump List.668 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; + inc #Derived_gen.18; + jump List.678 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : {Str, Int1} = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : {Str, Int1} = CallByName List.101 List.172 List.173 List.174 List.676 List.677; + ret List.675; procedure List.6 (#Attr.2): - let List.676 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.676; + let List.686 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.686; procedure List.66 (#Attr.2, #Attr.3): - let List.675 : {[C I64, C Decimal], Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.675; + let List.685 : {[C I64, C Decimal], Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; procedure Num.22 (#Attr.2, #Attr.3): let Num.286 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/inspect_derived_record_one_field_string.txt b/crates/compiler/test_mono/generated/inspect_derived_record_one_field_string.txt index 5ef69a0c67..8fa307c5a9 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_record_one_field_string.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_record_one_field_string.txt @@ -160,36 +160,36 @@ procedure Inspect.63 (Inspect.295, Inspect.291): procedure Inspect.64 (Inspect.297): ret Inspect.297; -procedure List.100 (#Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : {Str, Str} = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : {Str, Int1} = CallByName Inspect.229 List.175 List.674; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : {Str, Str} = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : {Str, Int1} = CallByName Inspect.229 List.176 List.684; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.12; - jump List.668 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16; + inc #Derived_gen.10; + jump List.678 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : {Str, Int1} = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : {Str, Int1} = CallByName List.101 List.172 List.173 List.174 List.676 List.677; + ret List.675; procedure List.6 (#Attr.2): - let List.676 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.676; + let List.686 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.686; procedure List.66 (#Attr.2, #Attr.3): - let List.675 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.675; + let List.685 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; procedure Num.20 (#Attr.2, #Attr.3): let Num.288 : U64 = lowlevel NumSub #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/inspect_derived_record_two_field_strings.txt b/crates/compiler/test_mono/generated/inspect_derived_record_two_field_strings.txt index 35d10ac89a..a872fbd68a 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_record_two_field_strings.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_record_two_field_strings.txt @@ -167,36 +167,36 @@ procedure Inspect.63 (Inspect.295, Inspect.291): procedure Inspect.64 (Inspect.297): ret Inspect.297; -procedure List.100 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : {Str, Str} = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : {Str, Int1} = CallByName Inspect.229 List.175 List.674; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : {Str, Str} = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : {Str, Int1} = CallByName Inspect.229 List.176 List.684; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.16; - jump List.668 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; + inc #Derived_gen.14; + jump List.678 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : {Str, Int1} = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : {Str, Int1} = CallByName List.101 List.172 List.173 List.174 List.676 List.677; + ret List.675; procedure List.6 (#Attr.2): - let List.676 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.676; + let List.686 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.686; procedure List.66 (#Attr.2, #Attr.3): - let List.675 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.675; + let List.685 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; procedure Num.20 (#Attr.2, #Attr.3): let Num.288 : U64 = lowlevel NumSub #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/inspect_derived_tag_one_field_string.txt b/crates/compiler/test_mono/generated/inspect_derived_tag_one_field_string.txt index 13c9fae8db..8cb8571757 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_tag_one_field_string.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_tag_one_field_string.txt @@ -156,43 +156,43 @@ procedure Inspect.63 (Inspect.295, Inspect.291): procedure Inspect.64 (Inspect.297): ret Inspect.297; -procedure List.1 (List.118): - let List.678 : U64 = CallByName List.6 List.118; - let List.679 : U64 = 0i64; - let List.677 : Int1 = CallByName Bool.11 List.678 List.679; - ret List.677; +procedure List.1 (List.119): + let List.688 : U64 = CallByName List.6 List.119; + let List.689 : U64 = 0i64; + let List.687 : Int1 = CallByName Bool.11 List.688 List.689; + ret List.687; -procedure List.100 (#Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : Str = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : Str = CallByName Inspect.207 List.175 List.674; - dec List.674; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : Str = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : Str = CallByName Inspect.207 List.176 List.684; + dec List.684; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.23; - jump List.668 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27; + inc #Derived_gen.11; + jump List.678 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : Str = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : Str = CallByName List.101 List.172 List.173 List.174 List.676 List.677; + ret List.675; procedure List.6 (#Attr.2): - let List.676 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.676; + let List.686 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.686; procedure List.66 (#Attr.2, #Attr.3): - let List.675 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.675; + let List.685 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; procedure Num.20 (#Attr.2, #Attr.3): let Num.288 : U64 = lowlevel NumSub #Attr.2 #Attr.3; @@ -290,7 +290,7 @@ procedure Str.45 (Str.91, Str.92, Str.93): dec Str.341; ret Str.91; -procedure Str.56 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): +procedure Str.56 (#Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27): joinpoint Str.250 Str.96 Str.97 Str.98 Str.99: inc Str.97; let Str.251 : [C {}, C {Str, Str}] = CallByName Str.38 Str.97 Str.98; @@ -314,9 +314,9 @@ procedure Str.56 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_ge dec Str.97; ret Str.255; in - inc #Derived_gen.21; - inc #Derived_gen.22; - jump Str.250 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; + inc #Derived_gen.27; + inc #Derived_gen.26; + jump Str.250 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27; procedure Str.57 (Str.121, Str.122): let Str.123 : U64 = CallByName Str.36 Str.121; @@ -326,7 +326,7 @@ procedure Str.57 (Str.121, Str.122): let Str.276 : [C , C U64] = CallByName Str.58 Str.121 Str.122 Str.277 Str.125; ret Str.276; -procedure Str.58 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16): +procedure Str.58 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21): joinpoint Str.278 Str.126 Str.127 Str.128 Str.129: let Str.280 : Int1 = CallByName Num.23 Str.128 Str.129; if Str.280 then @@ -346,9 +346,9 @@ procedure Str.58 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_ge let Str.279 : [C , C U64] = TagId(0) ; ret Str.279; in - inc #Derived_gen.14; - inc #Derived_gen.13; - jump Str.278 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16; + inc #Derived_gen.18; + inc #Derived_gen.19; + jump Str.278 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21; procedure Str.61 (Str.152, Str.153): let Str.308 : Int1 = CallByName Num.22 Str.152 Str.153; diff --git a/crates/compiler/test_mono/generated/inspect_derived_tag_two_payloads_string.txt b/crates/compiler/test_mono/generated/inspect_derived_tag_two_payloads_string.txt index 0f01f412d7..b5d821a158 100644 --- a/crates/compiler/test_mono/generated/inspect_derived_tag_two_payloads_string.txt +++ b/crates/compiler/test_mono/generated/inspect_derived_tag_two_payloads_string.txt @@ -159,43 +159,43 @@ procedure Inspect.63 (Inspect.295, Inspect.291): procedure Inspect.64 (Inspect.297): ret Inspect.297; -procedure List.1 (List.118): - let List.678 : U64 = CallByName List.6 List.118; - let List.679 : U64 = 0i64; - let List.677 : Int1 = CallByName Bool.11 List.678 List.679; - ret List.677; +procedure List.1 (List.119): + let List.688 : U64 = CallByName List.6 List.119; + let List.689 : U64 = 0i64; + let List.687 : Int1 = CallByName Bool.11 List.688 List.689; + ret List.687; -procedure List.100 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : Str = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : Str = CallByName Inspect.207 List.175 List.674; - dec List.674; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : Str = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : Str = CallByName Inspect.207 List.176 List.684; + dec List.684; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.18; - jump List.668 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; + inc #Derived_gen.26; + jump List.678 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : Str = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : Str = CallByName List.101 List.172 List.173 List.174 List.676 List.677; + ret List.675; procedure List.6 (#Attr.2): - let List.676 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.676; + let List.686 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.686; procedure List.66 (#Attr.2, #Attr.3): - let List.675 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.675; + let List.685 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; procedure Num.20 (#Attr.2, #Attr.3): let Num.288 : U64 = lowlevel NumSub #Attr.2 #Attr.3; @@ -293,7 +293,7 @@ procedure Str.45 (Str.91, Str.92, Str.93): dec Str.385; ret Str.91; -procedure Str.56 (#Derived_gen.25, #Derived_gen.26, #Derived_gen.27, #Derived_gen.28): +procedure Str.56 (#Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): joinpoint Str.250 Str.96 Str.97 Str.98 Str.99: inc Str.97; let Str.251 : [C {}, C {Str, Str}] = CallByName Str.38 Str.97 Str.98; @@ -317,9 +317,9 @@ procedure Str.56 (#Derived_gen.25, #Derived_gen.26, #Derived_gen.27, #Derived_ge dec Str.97; ret Str.255; in - inc #Derived_gen.28; - inc #Derived_gen.27; - jump Str.250 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28; + inc #Derived_gen.23; + inc #Derived_gen.22; + jump Str.250 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; procedure Str.57 (Str.121, Str.122): let Str.123 : U64 = CallByName Str.36 Str.121; diff --git a/crates/compiler/test_mono/generated/ir_int_add.txt b/crates/compiler/test_mono/generated/ir_int_add.txt index 3fbaf57ab4..47d8f5b00c 100644 --- a/crates/compiler/test_mono/generated/ir_int_add.txt +++ b/crates/compiler/test_mono/generated/ir_int_add.txt @@ -1,6 +1,6 @@ procedure List.6 (#Attr.2): - let List.665 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.665; + let List.675 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.675; procedure Num.19 (#Attr.2, #Attr.3): let Num.285 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt index d62ad02bc3..d987197ab8 100644 --- a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt +++ b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt @@ -6,40 +6,40 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure List.2 (List.119, List.120): - let List.679 : U64 = CallByName List.6 List.119; - let List.675 : Int1 = CallByName Num.22 List.120 List.679; - if List.675 then - let List.677 : I64 = CallByName List.66 List.119 List.120; - let List.676 : [C {}, C I64] = TagId(1) List.677; - ret List.676; +procedure List.2 (List.120, List.121): + let List.689 : U64 = CallByName List.6 List.120; + let List.685 : Int1 = CallByName Num.22 List.121 List.689; + if List.685 then + let List.687 : I64 = CallByName List.66 List.120 List.121; + let List.686 : [C {}, C I64] = TagId(1) List.687; + ret List.686; else - let List.674 : {} = Struct {}; - let List.673 : [C {}, C I64] = TagId(0) List.674; - ret List.673; + let List.684 : {} = Struct {}; + let List.683 : [C {}, C I64] = TagId(0) List.684; + ret List.683; procedure List.6 (#Attr.2): - let List.680 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.680; + let List.690 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.690; procedure List.66 (#Attr.2, #Attr.3): - let List.678 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.678; + let List.688 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.688; -procedure List.9 (List.391): - let List.672 : U64 = 0i64; - let List.665 : [C {}, C I64] = CallByName List.2 List.391 List.672; - let List.669 : U8 = 1i64; - let List.670 : U8 = GetTagId List.665; - let List.671 : Int1 = lowlevel Eq List.669 List.670; - if List.671 then - let List.392 : I64 = UnionAtIndex (Id 1) (Index 0) List.665; - let List.666 : [C Int1, C I64] = TagId(1) List.392; - ret List.666; +procedure List.9 (List.392): + let List.682 : U64 = 0i64; + let List.675 : [C {}, C I64] = CallByName List.2 List.392 List.682; + let List.679 : U8 = 1i64; + let List.680 : U8 = GetTagId List.675; + let List.681 : Int1 = lowlevel Eq List.679 List.680; + if List.681 then + let List.393 : I64 = UnionAtIndex (Id 1) (Index 0) List.675; + let List.676 : [C Int1, C I64] = TagId(1) List.393; + ret List.676; else - let List.668 : Int1 = true; - let List.667 : [C Int1, C I64] = TagId(0) List.668; - ret List.667; + let List.678 : Int1 = true; + let List.677 : [C Int1, C I64] = TagId(0) List.678; + ret List.677; procedure Num.22 (#Attr.2, #Attr.3): let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/issue_4770.txt b/crates/compiler/test_mono/generated/issue_4770.txt index 9106e10f4f..d97ce3d233 100644 --- a/crates/compiler/test_mono/generated/issue_4770.txt +++ b/crates/compiler/test_mono/generated/issue_4770.txt @@ -6,118 +6,118 @@ procedure Bool.2 (): let Bool.24 : Int1 = true; ret Bool.24; -procedure List.105 (#Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11): - joinpoint List.703 List.290 List.291 List.292 List.293 List.294 List.295: - let List.705 : Int1 = CallByName Num.22 List.294 List.295; - if List.705 then - let List.711 : [C I64, C List *self] = CallByName List.66 List.290 List.294; - inc List.711; - let List.712 : [C I64, C List *self] = CallByName List.66 List.291 List.294; - inc List.712; - let List.296 : {[C I64, C List *self], [C I64, C List *self]} = CallByName Test.15 List.711 List.712; - let List.707 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.71 List.292 List.296; - let List.709 : U64 = 1i64; - let List.708 : U64 = CallByName Num.51 List.294 List.709; - jump List.703 List.290 List.291 List.707 List.293 List.708 List.295; +procedure List.106 (#Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6): + joinpoint List.713 List.291 List.292 List.293 List.294 List.295 List.296: + let List.715 : Int1 = CallByName Num.22 List.295 List.296; + if List.715 then + let List.721 : [C I64, C List *self] = CallByName List.66 List.291 List.295; + inc List.721; + let List.722 : [C I64, C List *self] = CallByName List.66 List.292 List.295; + inc List.722; + let List.297 : {[C I64, C List *self], [C I64, C List *self]} = CallByName Test.15 List.721 List.722; + let List.717 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.71 List.293 List.297; + let List.719 : U64 = 1i64; + let List.718 : U64 = CallByName Num.51 List.295 List.719; + jump List.713 List.291 List.292 List.717 List.294 List.718 List.296; else dec List.291; - dec List.290; - ret List.292; + dec List.292; + ret List.293; in - inc #Derived_gen.6; - inc #Derived_gen.7; - jump List.703 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11; + inc #Derived_gen.1; + inc #Derived_gen.2; + jump List.713 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6; -procedure List.115 (List.562, List.563, List.564): - let List.679 : U64 = 0i64; - let List.680 : U64 = CallByName List.6 List.562; - let List.678 : [C {}, C {}] = CallByName List.80 List.562 List.563 List.564 List.679 List.680; - ret List.678; +procedure List.116 (List.563, List.564, List.565): + let List.689 : U64 = 0i64; + let List.690 : U64 = CallByName List.6 List.563; + let List.688 : [C {}, C {}] = CallByName List.80 List.563 List.564 List.565 List.689 List.690; + ret List.688; -procedure List.23 (List.286, List.287, List.288): - let List.715 : U64 = CallByName List.6 List.286; - let List.716 : U64 = CallByName List.6 List.287; - let List.289 : U64 = CallByName Num.148 List.715 List.716; - let List.701 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.68 List.289; - let List.702 : U64 = 0i64; - let List.700 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.105 List.286 List.287 List.701 List.288 List.702 List.289; - ret List.700; - -procedure List.247 (List.667, List.248, List.246): - let List.697 : Int1 = CallByName Test.1 List.248; - if List.697 then - let List.699 : {} = Struct {}; - let List.698 : [C {}, C {}] = TagId(1) List.699; - ret List.698; - else - let List.696 : {} = Struct {}; - let List.695 : [C {}, C {}] = TagId(0) List.696; - ret List.695; - -procedure List.56 (List.245, List.246): - let List.676 : {} = Struct {}; - let List.668 : [C {}, C {}] = CallByName List.115 List.245 List.676 List.246; - let List.673 : U8 = 1i64; - let List.674 : U8 = GetTagId List.668; - let List.675 : Int1 = lowlevel Eq List.673 List.674; - if List.675 then - let List.669 : Int1 = CallByName Bool.2; - ret List.669; - else - let List.670 : Int1 = CallByName Bool.1; - ret List.670; - -procedure List.6 (#Attr.2): - let List.666 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.666; - -procedure List.6 (#Attr.2): - let List.694 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.694; - -procedure List.66 (#Attr.2, #Attr.3): - let List.693 : {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.693; - -procedure List.66 (#Attr.2, #Attr.3): - let List.713 : [C I64, C List *self] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.713; - -procedure List.68 (#Attr.2): - let List.714 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListWithCapacity #Attr.2; - ret List.714; - -procedure List.71 (#Attr.2, #Attr.3): - let List.710 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; +procedure List.23 (List.287, List.288, List.289): + let List.725 : U64 = CallByName List.6 List.287; + let List.726 : U64 = CallByName List.6 List.288; + let List.290 : U64 = CallByName Num.148 List.725 List.726; + let List.711 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.68 List.290; + let List.712 : U64 = 0i64; + let List.710 : List {[C I64, C List *self], [C I64, C List *self]} = CallByName List.106 List.287 List.288 List.711 List.289 List.712 List.290; ret List.710; -procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.681 List.565 List.566 List.567 List.568 List.569: - let List.683 : Int1 = CallByName Num.22 List.568 List.569; - if List.683 then - let List.692 : {[C I64, C List *self], [C I64, C List *self]} = CallByName List.66 List.565 List.568; - inc List.692; - let List.684 : [C {}, C {}] = CallByName List.247 List.566 List.692 List.567; - let List.689 : U8 = 1i64; - let List.690 : U8 = GetTagId List.684; - let List.691 : Int1 = lowlevel Eq List.689 List.690; - if List.691 then - let List.570 : {} = UnionAtIndex (Id 1) (Index 0) List.684; - let List.687 : U64 = 1i64; - let List.686 : U64 = CallByName Num.51 List.568 List.687; - jump List.681 List.565 List.570 List.567 List.686 List.569; +procedure List.248 (List.677, List.249, List.247): + let List.707 : Int1 = CallByName Test.1 List.249; + if List.707 then + let List.709 : {} = Struct {}; + let List.708 : [C {}, C {}] = TagId(1) List.709; + ret List.708; + else + let List.706 : {} = Struct {}; + let List.705 : [C {}, C {}] = TagId(0) List.706; + ret List.705; + +procedure List.56 (List.246, List.247): + let List.686 : {} = Struct {}; + let List.678 : [C {}, C {}] = CallByName List.116 List.246 List.686 List.247; + let List.683 : U8 = 1i64; + let List.684 : U8 = GetTagId List.678; + let List.685 : Int1 = lowlevel Eq List.683 List.684; + if List.685 then + let List.679 : Int1 = CallByName Bool.2; + ret List.679; + else + let List.680 : Int1 = CallByName Bool.1; + ret List.680; + +procedure List.6 (#Attr.2): + let List.676 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.676; + +procedure List.6 (#Attr.2): + let List.704 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.704; + +procedure List.66 (#Attr.2, #Attr.3): + let List.703 : {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.703; + +procedure List.66 (#Attr.2, #Attr.3): + let List.723 : [C I64, C List *self] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.723; + +procedure List.68 (#Attr.2): + let List.724 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListWithCapacity #Attr.2; + ret List.724; + +procedure List.71 (#Attr.2, #Attr.3): + let List.720 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.720; + +procedure List.80 (#Derived_gen.7, #Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11): + joinpoint List.691 List.566 List.567 List.568 List.569 List.570: + let List.693 : Int1 = CallByName Num.22 List.569 List.570; + if List.693 then + let List.702 : {[C I64, C List *self], [C I64, C List *self]} = CallByName List.66 List.566 List.569; + inc List.702; + let List.694 : [C {}, C {}] = CallByName List.248 List.567 List.702 List.568; + let List.699 : U8 = 1i64; + let List.700 : U8 = GetTagId List.694; + let List.701 : Int1 = lowlevel Eq List.699 List.700; + if List.701 then + let List.571 : {} = UnionAtIndex (Id 1) (Index 0) List.694; + let List.697 : U64 = 1i64; + let List.696 : U64 = CallByName Num.51 List.569 List.697; + jump List.691 List.566 List.571 List.568 List.696 List.570; else - dec List.565; - let List.571 : {} = UnionAtIndex (Id 0) (Index 0) List.684; - let List.688 : [C {}, C {}] = TagId(0) List.571; - ret List.688; + dec List.566; + let List.572 : {} = UnionAtIndex (Id 0) (Index 0) List.694; + let List.698 : [C {}, C {}] = TagId(0) List.572; + ret List.698; else - dec List.565; - let List.682 : [C {}, C {}] = TagId(1) List.566; - ret List.682; + dec List.566; + let List.692 : [C {}, C {}] = TagId(1) List.567; + ret List.692; in - inc #Derived_gen.0; - jump List.681 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + inc #Derived_gen.7; + jump List.691 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11; procedure Num.148 (Num.226, Num.227): let Num.290 : Int1 = CallByName Num.22 Num.226 Num.227; @@ -138,7 +138,7 @@ procedure Num.51 (#Attr.2, #Attr.3): let Num.286 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; ret Num.286; -procedure Test.1 (#Derived_gen.5): +procedure Test.1 (#Derived_gen.0): joinpoint Test.26 Test.6: let Test.65 : [C I64, C List *self] = StructAtIndex 1 Test.6; let Test.66 : U8 = 0i64; @@ -220,7 +220,7 @@ procedure Test.1 (#Derived_gen.5): let Test.44 : {[C I64, C List *self], [C I64, C List *self]} = Struct {Test.45, Test.46}; jump Test.26 Test.44; in - jump Test.26 #Derived_gen.5; + jump Test.26 #Derived_gen.0; procedure Test.15 (Test.16, Test.17): let Test.36 : {[C I64, C List *self], [C I64, C List *self]} = Struct {Test.16, Test.17}; diff --git a/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt b/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt index 671993f128..179e13022d 100644 --- a/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt +++ b/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt @@ -1,33 +1,33 @@ -procedure List.100 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : [C *self, ] = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : [, C {[C *self, ], *self}] = CallByName Test.7 List.175 List.674; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : [C *self, ] = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : [, C {[C *self, ], *self}] = CallByName Test.7 List.176 List.684; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in inc #Derived_gen.0; - jump List.668 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.678 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : [, C {[C *self, ], *self}] = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : [, C {[C *self, ], *self}] = CallByName List.101 List.172 List.173 List.174 List.676 List.677; + ret List.675; procedure List.6 (#Attr.2): - let List.676 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.676; + let List.686 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.686; procedure List.66 (#Attr.2, #Attr.3): - let List.675 : [C *self, ] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.675; + let List.685 : [C *self, ] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; procedure Num.22 (#Attr.2, #Attr.3): let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_append.txt b/crates/compiler/test_mono/generated/list_append.txt index 43dd147f54..04e1ddc8d0 100644 --- a/crates/compiler/test_mono/generated/list_append.txt +++ b/crates/compiler/test_mono/generated/list_append.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.135, List.136): - let List.668 : U64 = 1i64; - let List.666 : List I64 = CallByName List.70 List.135 List.668; - let List.665 : List I64 = CallByName List.71 List.666 List.136; - ret List.665; +procedure List.4 (List.136, List.137): + let List.678 : U64 = 1i64; + let List.676 : List I64 = CallByName List.70 List.136 List.678; + let List.675 : List I64 = CallByName List.71 List.676 List.137; + ret List.675; procedure List.70 (#Attr.2, #Attr.3): - let List.669 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.669; + let List.679 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.679; procedure List.71 (#Attr.2, #Attr.3): - let List.667 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.667; + let List.677 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.677; procedure Test.0 (): let Test.2 : List I64 = Array [1i64]; diff --git a/crates/compiler/test_mono/generated/list_append_closure.txt b/crates/compiler/test_mono/generated/list_append_closure.txt index ba3983e362..b134771140 100644 --- a/crates/compiler/test_mono/generated/list_append_closure.txt +++ b/crates/compiler/test_mono/generated/list_append_closure.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.135, List.136): - let List.668 : U64 = 1i64; - let List.666 : List I64 = CallByName List.70 List.135 List.668; - let List.665 : List I64 = CallByName List.71 List.666 List.136; - ret List.665; +procedure List.4 (List.136, List.137): + let List.678 : U64 = 1i64; + let List.676 : List I64 = CallByName List.70 List.136 List.678; + let List.675 : List I64 = CallByName List.71 List.676 List.137; + ret List.675; procedure List.70 (#Attr.2, #Attr.3): - let List.669 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.669; + let List.679 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.679; procedure List.71 (#Attr.2, #Attr.3): - let List.667 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.667; + let List.677 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.677; procedure Test.1 (Test.2): let Test.6 : I64 = 42i64; diff --git a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt index 59f9355977..95a6278854 100644 --- a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt +++ b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.127, List.128, List.129): - let List.668 : {List I64, I64} = CallByName List.64 List.127 List.128 List.129; - let List.667 : List I64 = StructAtIndex 0 List.668; - ret List.667; +procedure List.3 (List.128, List.129, List.130): + let List.678 : {List I64, I64} = CallByName List.64 List.128 List.129 List.130; + let List.677 : List I64 = StructAtIndex 0 List.678; + ret List.677; procedure List.6 (#Attr.2): - let List.666 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.666; + let List.676 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.676; -procedure List.64 (List.124, List.125, List.126): - let List.673 : U64 = CallByName List.6 List.124; - let List.670 : Int1 = CallByName Num.22 List.125 List.673; - if List.670 then - let List.671 : {List I64, I64} = CallByName List.67 List.124 List.125 List.126; - ret List.671; +procedure List.64 (List.125, List.126, List.127): + let List.683 : U64 = CallByName List.6 List.125; + let List.680 : Int1 = CallByName Num.22 List.126 List.683; + if List.680 then + let List.681 : {List I64, I64} = CallByName List.67 List.125 List.126 List.127; + ret List.681; else - let List.669 : {List I64, I64} = Struct {List.124, List.126}; - ret List.669; + let List.679 : {List I64, I64} = Struct {List.125, List.127}; + ret List.679; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.672 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.672; + let List.682 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.682; procedure Num.19 (#Attr.2, #Attr.3): let Num.283 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_get.txt b/crates/compiler/test_mono/generated/list_get.txt index 3de2d201b2..fcc7192896 100644 --- a/crates/compiler/test_mono/generated/list_get.txt +++ b/crates/compiler/test_mono/generated/list_get.txt @@ -1,22 +1,22 @@ -procedure List.2 (List.119, List.120): - let List.671 : U64 = CallByName List.6 List.119; - let List.667 : Int1 = CallByName Num.22 List.120 List.671; - if List.667 then - let List.669 : I64 = CallByName List.66 List.119 List.120; - let List.668 : [C {}, C I64] = TagId(1) List.669; - ret List.668; +procedure List.2 (List.120, List.121): + let List.681 : U64 = CallByName List.6 List.120; + let List.677 : Int1 = CallByName Num.22 List.121 List.681; + if List.677 then + let List.679 : I64 = CallByName List.66 List.120 List.121; + let List.678 : [C {}, C I64] = TagId(1) List.679; + ret List.678; else - let List.666 : {} = Struct {}; - let List.665 : [C {}, C I64] = TagId(0) List.666; - ret List.665; + let List.676 : {} = Struct {}; + let List.675 : [C {}, C I64] = TagId(0) List.676; + ret List.675; procedure List.6 (#Attr.2): - let List.672 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.672; + let List.682 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.682; procedure List.66 (#Attr.2, #Attr.3): - let List.670 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.670; + let List.680 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.680; procedure Num.22 (#Attr.2, #Attr.3): let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_len.txt b/crates/compiler/test_mono/generated/list_len.txt index 5fa13af048..17aadbfced 100644 --- a/crates/compiler/test_mono/generated/list_len.txt +++ b/crates/compiler/test_mono/generated/list_len.txt @@ -1,10 +1,10 @@ procedure List.6 (#Attr.2): - let List.665 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.665; + let List.675 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.675; procedure List.6 (#Attr.2): - let List.666 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.666; + let List.676 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.676; procedure Num.19 (#Attr.2, #Attr.3): let Num.283 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt index 8205852849..223650051b 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt @@ -1,66 +1,66 @@ -procedure List.100 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.679 List.174 List.175 List.176 List.177 List.178: - let List.681 : Int1 = CallByName Num.22 List.177 List.178; - if List.681 then - let List.685 : Str = CallByName List.66 List.174 List.177; - inc List.685; - let List.179 : List Str = CallByName List.283 List.175 List.685 List.176; - dec List.685; - let List.684 : U64 = 1i64; - let List.683 : U64 = CallByName Num.51 List.177 List.684; - jump List.679 List.174 List.179 List.176 List.683 List.178; +procedure List.101 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): + joinpoint List.689 List.175 List.176 List.177 List.178 List.179: + let List.691 : Int1 = CallByName Num.22 List.178 List.179; + if List.691 then + let List.695 : Str = CallByName List.66 List.175 List.178; + inc List.695; + let List.180 : List Str = CallByName List.284 List.176 List.695 List.177; + dec List.695; + let List.694 : U64 = 1i64; + let List.693 : U64 = CallByName Num.51 List.178 List.694; + jump List.689 List.175 List.180 List.177 List.693 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in inc #Derived_gen.3; - jump List.679 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + jump List.689 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; -procedure List.18 (List.171, List.172, List.173): - let List.677 : U64 = 0i64; - let List.678 : U64 = CallByName List.6 List.171; - let List.676 : List Str = CallByName List.100 List.171 List.172 List.173 List.677 List.678; - ret List.676; +procedure List.18 (List.172, List.173, List.174): + let List.687 : U64 = 0i64; + let List.688 : U64 = CallByName List.6 List.172; + let List.686 : List Str = CallByName List.101 List.172 List.173 List.174 List.687 List.688; + ret List.686; -procedure List.2 (List.119, List.120): - let List.671 : U64 = CallByName List.6 List.119; - let List.667 : Int1 = CallByName Num.22 List.120 List.671; - if List.667 then - let List.669 : Str = CallByName List.66 List.119 List.120; - inc List.669; - let List.668 : [C {}, C Str] = TagId(1) List.669; - ret List.668; +procedure List.2 (List.120, List.121): + let List.681 : U64 = CallByName List.6 List.120; + let List.677 : Int1 = CallByName Num.22 List.121 List.681; + if List.677 then + let List.679 : Str = CallByName List.66 List.120 List.121; + inc List.679; + let List.678 : [C {}, C Str] = TagId(1) List.679; + ret List.678; else - let List.666 : {} = Struct {}; - let List.665 : [C {}, C Str] = TagId(0) List.666; - ret List.665; + let List.676 : {} = Struct {}; + let List.675 : [C {}, C Str] = TagId(0) List.676; + ret List.675; -procedure List.283 (List.284, List.285, List.281): - let List.688 : Str = CallByName Test.3 List.285; - let List.687 : List Str = CallByName List.71 List.284 List.688; - ret List.687; +procedure List.284 (List.285, List.286, List.282): + let List.698 : Str = CallByName Test.3 List.286; + let List.697 : List Str = CallByName List.71 List.285 List.698; + ret List.697; -procedure List.5 (List.280, List.281): - let List.282 : U64 = CallByName List.6 List.280; - let List.674 : List Str = CallByName List.68 List.282; - let List.673 : List Str = CallByName List.18 List.280 List.674 List.281; - ret List.673; +procedure List.5 (List.281, List.282): + let List.283 : U64 = CallByName List.6 List.281; + let List.684 : List Str = CallByName List.68 List.283; + let List.683 : List Str = CallByName List.18 List.281 List.684 List.282; + ret List.683; procedure List.6 (#Attr.2): - let List.672 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.672; + let List.682 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.682; procedure List.66 (#Attr.2, #Attr.3): - let List.670 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.670; + let List.680 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.680; procedure List.68 (#Attr.2): - let List.690 : List Str = lowlevel ListWithCapacity #Attr.2; - ret List.690; + let List.700 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.700; procedure List.71 (#Attr.2, #Attr.3): - let List.689 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.689; + let List.699 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.699; procedure Num.22 (#Attr.2, #Attr.3): let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_map_closure_owns.txt b/crates/compiler/test_mono/generated/list_map_closure_owns.txt index b40b7c1f59..ce02924c29 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_owns.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_owns.txt @@ -1,65 +1,65 @@ -procedure List.100 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.679 List.174 List.175 List.176 List.177 List.178: - let List.681 : Int1 = CallByName Num.22 List.177 List.178; - if List.681 then - let List.685 : Str = CallByName List.66 List.174 List.177; - inc List.685; - let List.179 : List Str = CallByName List.283 List.175 List.685 List.176; - let List.684 : U64 = 1i64; - let List.683 : U64 = CallByName Num.51 List.177 List.684; - jump List.679 List.174 List.179 List.176 List.683 List.178; +procedure List.101 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): + joinpoint List.689 List.175 List.176 List.177 List.178 List.179: + let List.691 : Int1 = CallByName Num.22 List.178 List.179; + if List.691 then + let List.695 : Str = CallByName List.66 List.175 List.178; + inc List.695; + let List.180 : List Str = CallByName List.284 List.176 List.695 List.177; + let List.694 : U64 = 1i64; + let List.693 : U64 = CallByName Num.51 List.178 List.694; + jump List.689 List.175 List.180 List.177 List.693 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.0; - jump List.679 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + inc #Derived_gen.3; + jump List.689 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; -procedure List.18 (List.171, List.172, List.173): - let List.677 : U64 = 0i64; - let List.678 : U64 = CallByName List.6 List.171; - let List.676 : List Str = CallByName List.100 List.171 List.172 List.173 List.677 List.678; - ret List.676; +procedure List.18 (List.172, List.173, List.174): + let List.687 : U64 = 0i64; + let List.688 : U64 = CallByName List.6 List.172; + let List.686 : List Str = CallByName List.101 List.172 List.173 List.174 List.687 List.688; + ret List.686; -procedure List.2 (List.119, List.120): - let List.671 : U64 = CallByName List.6 List.119; - let List.667 : Int1 = CallByName Num.22 List.120 List.671; - if List.667 then - let List.669 : Str = CallByName List.66 List.119 List.120; - inc List.669; - let List.668 : [C {}, C Str] = TagId(1) List.669; - ret List.668; +procedure List.2 (List.120, List.121): + let List.681 : U64 = CallByName List.6 List.120; + let List.677 : Int1 = CallByName Num.22 List.121 List.681; + if List.677 then + let List.679 : Str = CallByName List.66 List.120 List.121; + inc List.679; + let List.678 : [C {}, C Str] = TagId(1) List.679; + ret List.678; else - let List.666 : {} = Struct {}; - let List.665 : [C {}, C Str] = TagId(0) List.666; - ret List.665; + let List.676 : {} = Struct {}; + let List.675 : [C {}, C Str] = TagId(0) List.676; + ret List.675; -procedure List.283 (List.284, List.285, List.281): - let List.688 : Str = CallByName Test.3 List.285; - let List.687 : List Str = CallByName List.71 List.284 List.688; - ret List.687; +procedure List.284 (List.285, List.286, List.282): + let List.698 : Str = CallByName Test.3 List.286; + let List.697 : List Str = CallByName List.71 List.285 List.698; + ret List.697; -procedure List.5 (List.280, List.281): - let List.282 : U64 = CallByName List.6 List.280; - let List.674 : List Str = CallByName List.68 List.282; - let List.673 : List Str = CallByName List.18 List.280 List.674 List.281; - ret List.673; +procedure List.5 (List.281, List.282): + let List.283 : U64 = CallByName List.6 List.281; + let List.684 : List Str = CallByName List.68 List.283; + let List.683 : List Str = CallByName List.18 List.281 List.684 List.282; + ret List.683; procedure List.6 (#Attr.2): - let List.672 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.672; + let List.682 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.682; procedure List.66 (#Attr.2, #Attr.3): - let List.670 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.670; + let List.680 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.680; procedure List.68 (#Attr.2): - let List.690 : List Str = lowlevel ListWithCapacity #Attr.2; - ret List.690; + let List.700 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.700; procedure List.71 (#Attr.2, #Attr.3): - let List.689 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.689; + let List.699 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.699; procedure Num.22 (#Attr.2, #Attr.3): let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; 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 bc7ae93e6b..a2fd6b6055 100644 --- a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt +++ b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt @@ -1,66 +1,66 @@ -procedure List.100 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.671 List.174 List.175 List.176 List.177 List.178: - let List.673 : Int1 = CallByName Num.22 List.177 List.178; - if List.673 then - let List.677 : U8 = CallByName List.66 List.174 List.177; - let List.179 : List U8 = CallByName List.283 List.175 List.677 List.176; - let List.676 : U64 = 1i64; - let List.675 : U64 = CallByName Num.51 List.177 List.676; - jump List.671 List.174 List.179 List.176 List.675 List.178; +procedure List.101 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.681 List.175 List.176 List.177 List.178 List.179: + let List.683 : Int1 = CallByName Num.22 List.178 List.179; + if List.683 then + let List.687 : U8 = CallByName List.66 List.175 List.178; + let List.180 : List U8 = CallByName List.284 List.176 List.687 List.177; + let List.686 : U64 = 1i64; + let List.685 : U64 = CallByName Num.51 List.178 List.686; + jump List.681 List.175 List.180 List.177 List.685 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.3; - jump List.671 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + inc #Derived_gen.0; + jump List.681 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.18 (List.171, List.172, List.173): - let List.669 : U64 = 0i64; - let List.670 : U64 = CallByName List.6 List.171; - let List.668 : List U8 = CallByName List.100 List.171 List.172 List.173 List.669 List.670; - ret List.668; - -procedure List.283 (List.284, List.285, List.281): - let List.684 : U8 = GetTagId List.281; - joinpoint List.685 List.682: - let List.681 : List U8 = CallByName List.71 List.284 List.682; - ret List.681; - in - switch List.684: - case 0: - let List.686 : U8 = CallByName Test.4 List.285 List.281; - jump List.685 List.686; - - case 1: - let List.686 : U8 = CallByName Test.6 List.285 List.281; - jump List.685 List.686; - - default: - let List.686 : U8 = CallByName Test.8 List.285; - jump List.685 List.686; - - -procedure List.5 (List.280, List.281): - let List.282 : U64 = CallByName List.6 List.280; - let List.666 : List U8 = CallByName List.68 List.282; - let List.665 : List U8 = CallByName List.18 List.280 List.666 List.281; - ret List.665; - -procedure List.6 (#Attr.2): - let List.679 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.679; - -procedure List.66 (#Attr.2, #Attr.3): - let List.678 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.679 : U64 = 0i64; + let List.680 : U64 = CallByName List.6 List.172; + let List.678 : List U8 = CallByName List.101 List.172 List.173 List.174 List.679 List.680; ret List.678; +procedure List.284 (List.285, List.286, List.282): + let List.694 : U8 = GetTagId List.282; + joinpoint List.695 List.692: + let List.691 : List U8 = CallByName List.71 List.285 List.692; + ret List.691; + in + switch List.694: + case 0: + let List.696 : U8 = CallByName Test.4 List.286 List.282; + jump List.695 List.696; + + case 1: + let List.696 : U8 = CallByName Test.6 List.286 List.282; + jump List.695 List.696; + + default: + let List.696 : U8 = CallByName Test.8 List.286; + jump List.695 List.696; + + +procedure List.5 (List.281, List.282): + let List.283 : U64 = CallByName List.6 List.281; + let List.676 : List U8 = CallByName List.68 List.283; + let List.675 : List U8 = CallByName List.18 List.281 List.676 List.282; + ret List.675; + +procedure List.6 (#Attr.2): + let List.689 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.689; + +procedure List.66 (#Attr.2, #Attr.3): + let List.688 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.688; + procedure List.68 (#Attr.2): - let List.687 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.687; + let List.697 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.697; procedure List.71 (#Attr.2, #Attr.3): - let List.683 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.683; + let List.693 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.693; procedure Num.19 (#Attr.2, #Attr.3): let Num.285 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_pass_to_function.txt b/crates/compiler/test_mono/generated/list_pass_to_function.txt index 81d1d76c24..714f1ff97d 100644 --- a/crates/compiler/test_mono/generated/list_pass_to_function.txt +++ b/crates/compiler/test_mono/generated/list_pass_to_function.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.127, List.128, List.129): - let List.666 : {List I64, I64} = CallByName List.64 List.127 List.128 List.129; - let List.665 : List I64 = StructAtIndex 0 List.666; - ret List.665; +procedure List.3 (List.128, List.129, List.130): + let List.676 : {List I64, I64} = CallByName List.64 List.128 List.129 List.130; + let List.675 : List I64 = StructAtIndex 0 List.676; + ret List.675; procedure List.6 (#Attr.2): - let List.672 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.672; + let List.682 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.682; -procedure List.64 (List.124, List.125, List.126): - let List.671 : U64 = CallByName List.6 List.124; - let List.668 : Int1 = CallByName Num.22 List.125 List.671; - if List.668 then - let List.669 : {List I64, I64} = CallByName List.67 List.124 List.125 List.126; - ret List.669; +procedure List.64 (List.125, List.126, List.127): + let List.681 : U64 = CallByName List.6 List.125; + let List.678 : Int1 = CallByName Num.22 List.126 List.681; + if List.678 then + let List.679 : {List I64, I64} = CallByName List.67 List.125 List.126 List.127; + ret List.679; else - let List.667 : {List I64, I64} = Struct {List.124, List.126}; - ret List.667; + let List.677 : {List I64, I64} = Struct {List.125, List.127}; + ret List.677; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.670 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.670; + let List.680 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.680; procedure Num.22 (#Attr.2, #Attr.3): let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_sort_asc.txt b/crates/compiler/test_mono/generated/list_sort_asc.txt index fb4bd333af..69deb96e46 100644 --- a/crates/compiler/test_mono/generated/list_sort_asc.txt +++ b/crates/compiler/test_mono/generated/list_sort_asc.txt @@ -1,11 +1,11 @@ procedure List.28 (#Attr.2, #Attr.3): - let List.667 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; - ret List.667; + let List.677 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; + ret List.677; -procedure List.59 (List.386): - let List.666 : {} = Struct {}; - let List.665 : List I64 = CallByName List.28 List.386 List.666; - ret List.665; +procedure List.59 (List.387): + let List.676 : {} = Struct {}; + let List.675 : List I64 = CallByName List.28 List.387 List.676; + ret List.675; procedure Num.46 (#Attr.2, #Attr.3): let Num.283 : U8 = lowlevel NumCompare #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/quicksort_swap.txt b/crates/compiler/test_mono/generated/quicksort_swap.txt index 9f84320505..4f023813fd 100644 --- a/crates/compiler/test_mono/generated/quicksort_swap.txt +++ b/crates/compiler/test_mono/generated/quicksort_swap.txt @@ -1,41 +1,41 @@ -procedure List.2 (List.119, List.120): - let List.687 : U64 = CallByName List.6 List.119; - let List.684 : Int1 = CallByName Num.22 List.120 List.687; - if List.684 then - let List.686 : I64 = CallByName List.66 List.119 List.120; - let List.685 : [C {}, C I64] = TagId(1) List.686; - ret List.685; +procedure List.2 (List.120, List.121): + let List.697 : U64 = CallByName List.6 List.120; + let List.694 : Int1 = CallByName Num.22 List.121 List.697; + if List.694 then + let List.696 : I64 = CallByName List.66 List.120 List.121; + let List.695 : [C {}, C I64] = TagId(1) List.696; + ret List.695; else - let List.683 : {} = Struct {}; - let List.682 : [C {}, C I64] = TagId(0) List.683; - ret List.682; + let List.693 : {} = Struct {}; + let List.692 : [C {}, C I64] = TagId(0) List.693; + ret List.692; -procedure List.3 (List.127, List.128, List.129): - let List.674 : {List I64, I64} = CallByName List.64 List.127 List.128 List.129; - let List.673 : List I64 = StructAtIndex 0 List.674; - ret List.673; +procedure List.3 (List.128, List.129, List.130): + let List.684 : {List I64, I64} = CallByName List.64 List.128 List.129 List.130; + let List.683 : List I64 = StructAtIndex 0 List.684; + ret List.683; procedure List.6 (#Attr.2): - let List.672 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.672; + let List.682 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.682; -procedure List.64 (List.124, List.125, List.126): - let List.671 : U64 = CallByName List.6 List.124; - let List.668 : Int1 = CallByName Num.22 List.125 List.671; - if List.668 then - let List.669 : {List I64, I64} = CallByName List.67 List.124 List.125 List.126; - ret List.669; +procedure List.64 (List.125, List.126, List.127): + let List.681 : U64 = CallByName List.6 List.125; + let List.678 : Int1 = CallByName Num.22 List.126 List.681; + if List.678 then + let List.679 : {List I64, I64} = CallByName List.67 List.125 List.126 List.127; + ret List.679; else - let List.667 : {List I64, I64} = Struct {List.124, List.126}; - ret List.667; + let List.677 : {List I64, I64} = Struct {List.125, List.127}; + ret List.677; procedure List.66 (#Attr.2, #Attr.3): - let List.680 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.680; + let List.690 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.690; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.670 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.670; + let List.680 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.680; procedure Num.22 (#Attr.2, #Attr.3): let Num.285 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/record_update.txt b/crates/compiler/test_mono/generated/record_update.txt index 42d08fa11f..20b2ab3278 100644 --- a/crates/compiler/test_mono/generated/record_update.txt +++ b/crates/compiler/test_mono/generated/record_update.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.127, List.128, List.129): - let List.674 : {List U64, U64} = CallByName List.64 List.127 List.128 List.129; - let List.673 : List U64 = StructAtIndex 0 List.674; - ret List.673; +procedure List.3 (List.128, List.129, List.130): + let List.684 : {List U64, U64} = CallByName List.64 List.128 List.129 List.130; + let List.683 : List U64 = StructAtIndex 0 List.684; + ret List.683; procedure List.6 (#Attr.2): - let List.672 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.672; + let List.682 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.682; -procedure List.64 (List.124, List.125, List.126): - let List.671 : U64 = CallByName List.6 List.124; - let List.668 : Int1 = CallByName Num.22 List.125 List.671; - if List.668 then - let List.669 : {List U64, U64} = CallByName List.67 List.124 List.125 List.126; - ret List.669; +procedure List.64 (List.125, List.126, List.127): + let List.681 : U64 = CallByName List.6 List.125; + let List.678 : Int1 = CallByName Num.22 List.126 List.681; + if List.678 then + let List.679 : {List U64, U64} = CallByName List.67 List.125 List.126 List.127; + ret List.679; else - let List.667 : {List U64, U64} = Struct {List.124, List.126}; - ret List.667; + let List.677 : {List U64, U64} = Struct {List.125, List.127}; + ret List.677; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.670 : {List U64, U64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.670; + let List.680 : {List U64, U64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.680; procedure Num.22 (#Attr.2, #Attr.3): let Num.283 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; 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 33fa7a2b6b..7eb948ec2f 100644 --- a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt +++ b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt @@ -1,52 +1,52 @@ -procedure List.100 (#Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8): - joinpoint List.671 List.174 List.175 List.176 List.177 List.178: - let List.673 : Int1 = CallByName Num.22 List.177 List.178; - if List.673 then - let List.677 : [C List *self] = CallByName List.66 List.174 List.177; - inc List.677; - let List.179 : List [C List *self] = CallByName List.283 List.175 List.677 List.176; - let List.676 : U64 = 1i64; - let List.675 : U64 = CallByName Num.51 List.177 List.676; - jump List.671 List.174 List.179 List.176 List.675 List.178; +procedure List.101 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.681 List.175 List.176 List.177 List.178 List.179: + let List.683 : Int1 = CallByName Num.22 List.178 List.179; + if List.683 then + let List.687 : [C List *self] = CallByName List.66 List.175 List.178; + inc List.687; + let List.180 : List [C List *self] = CallByName List.284 List.176 List.687 List.177; + let List.686 : U64 = 1i64; + let List.685 : U64 = CallByName Num.51 List.178 List.686; + jump List.681 List.175 List.180 List.177 List.685 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.4; - jump List.671 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8; + inc #Derived_gen.0; + jump List.681 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.18 (List.171, List.172, List.173): - let List.669 : U64 = 0i64; - let List.670 : U64 = CallByName List.6 List.171; - let List.668 : List [C List *self] = CallByName List.100 List.171 List.172 List.173 List.669 List.670; - ret List.668; - -procedure List.283 (List.284, List.285, List.281): - let List.682 : [C List *self] = CallByName Test.2 List.285; - let List.681 : List [C List *self] = CallByName List.71 List.284 List.682; - ret List.681; - -procedure List.5 (List.280, List.281): - let List.282 : U64 = CallByName List.6 List.280; - let List.666 : List [C List *self] = CallByName List.68 List.282; - let List.665 : List [C List *self] = CallByName List.18 List.280 List.666 List.281; - ret List.665; - -procedure List.6 (#Attr.2): - let List.679 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.679; - -procedure List.66 (#Attr.2, #Attr.3): - let List.678 : [C List *self] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.679 : U64 = 0i64; + let List.680 : U64 = CallByName List.6 List.172; + let List.678 : List [C List *self] = CallByName List.101 List.172 List.173 List.174 List.679 List.680; ret List.678; +procedure List.284 (List.285, List.286, List.282): + let List.692 : [C List *self] = CallByName Test.2 List.286; + let List.691 : List [C List *self] = CallByName List.71 List.285 List.692; + ret List.691; + +procedure List.5 (List.281, List.282): + let List.283 : U64 = CallByName List.6 List.281; + let List.676 : List [C List *self] = CallByName List.68 List.283; + let List.675 : List [C List *self] = CallByName List.18 List.281 List.676 List.282; + ret List.675; + +procedure List.6 (#Attr.2): + let List.689 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.689; + +procedure List.66 (#Attr.2, #Attr.3): + let List.688 : [C List *self] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.688; + procedure List.68 (#Attr.2): - let List.684 : List [C List *self] = lowlevel ListWithCapacity #Attr.2; - ret List.684; + let List.694 : List [C List *self] = lowlevel ListWithCapacity #Attr.2; + ret List.694; procedure List.71 (#Attr.2, #Attr.3): - let List.683 : List [C List *self] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.683; + let List.693 : List [C List *self] = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.693; procedure Num.22 (#Attr.2, #Attr.3): let Num.284 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/rigids.txt b/crates/compiler/test_mono/generated/rigids.txt index 74121885bd..2bd7204567 100644 --- a/crates/compiler/test_mono/generated/rigids.txt +++ b/crates/compiler/test_mono/generated/rigids.txt @@ -1,41 +1,41 @@ -procedure List.2 (List.119, List.120): - let List.687 : U64 = CallByName List.6 List.119; - let List.684 : Int1 = CallByName Num.22 List.120 List.687; - if List.684 then - let List.686 : I64 = CallByName List.66 List.119 List.120; - let List.685 : [C {}, C I64] = TagId(1) List.686; - ret List.685; +procedure List.2 (List.120, List.121): + let List.697 : U64 = CallByName List.6 List.120; + let List.694 : Int1 = CallByName Num.22 List.121 List.697; + if List.694 then + let List.696 : I64 = CallByName List.66 List.120 List.121; + let List.695 : [C {}, C I64] = TagId(1) List.696; + ret List.695; else - let List.683 : {} = Struct {}; - let List.682 : [C {}, C I64] = TagId(0) List.683; - ret List.682; + let List.693 : {} = Struct {}; + let List.692 : [C {}, C I64] = TagId(0) List.693; + ret List.692; -procedure List.3 (List.127, List.128, List.129): - let List.674 : {List I64, I64} = CallByName List.64 List.127 List.128 List.129; - let List.673 : List I64 = StructAtIndex 0 List.674; - ret List.673; +procedure List.3 (List.128, List.129, List.130): + let List.684 : {List I64, I64} = CallByName List.64 List.128 List.129 List.130; + let List.683 : List I64 = StructAtIndex 0 List.684; + ret List.683; procedure List.6 (#Attr.2): - let List.672 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.672; + let List.682 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.682; -procedure List.64 (List.124, List.125, List.126): - let List.671 : U64 = CallByName List.6 List.124; - let List.668 : Int1 = CallByName Num.22 List.125 List.671; - if List.668 then - let List.669 : {List I64, I64} = CallByName List.67 List.124 List.125 List.126; - ret List.669; +procedure List.64 (List.125, List.126, List.127): + let List.681 : U64 = CallByName List.6 List.125; + let List.678 : Int1 = CallByName Num.22 List.126 List.681; + if List.678 then + let List.679 : {List I64, I64} = CallByName List.67 List.125 List.126 List.127; + ret List.679; else - let List.667 : {List I64, I64} = Struct {List.124, List.126}; - ret List.667; + let List.677 : {List I64, I64} = Struct {List.125, List.127}; + ret List.677; procedure List.66 (#Attr.2, #Attr.3): - let List.680 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.680; + let List.690 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.690; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.670 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.670; + let List.680 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.680; procedure Num.22 (#Attr.2, #Attr.3): let Num.285 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt index b977714063..0d803f15bd 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 @@ -29,58 +29,58 @@ procedure Encode.26 (Encode.107, Encode.108): let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; ret Encode.110; -procedure List.100 (#Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9, #Derived_gen.10): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : Str = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : List U8 = CallByName Test.66 List.175 List.674 List.176; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : Str = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : List U8 = CallByName Test.66 List.176 List.684 List.177; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.6; - jump List.668 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10; + inc #Derived_gen.12; + jump List.678 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16; procedure List.13 (#Attr.2, #Attr.3): - let List.691 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.691; + let List.701 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.701; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : List U8 = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; - -procedure List.4 (List.135, List.136): - let List.687 : U64 = 1i64; - let List.686 : List U8 = CallByName List.70 List.135 List.687; - let List.685 : List U8 = CallByName List.71 List.686 List.136; - ret List.685; - -procedure List.6 (#Attr.2): - let List.690 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.690; - -procedure List.66 (#Attr.2, #Attr.3): - let List.675 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : List U8 = CallByName List.101 List.172 List.173 List.174 List.676 List.677; ret List.675; +procedure List.4 (List.136, List.137): + let List.697 : U64 = 1i64; + let List.696 : List U8 = CallByName List.70 List.136 List.697; + let List.695 : List U8 = CallByName List.71 List.696 List.137; + ret List.695; + +procedure List.6 (#Attr.2): + let List.700 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.700; + +procedure List.66 (#Attr.2, #Attr.3): + let List.685 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; + procedure List.70 (#Attr.2, #Attr.3): - let List.681 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.681; + let List.691 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.691; procedure List.71 (#Attr.2, #Attr.3): - let List.679 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.679; + let List.689 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.689; procedure List.8 (#Attr.2, #Attr.3): - let List.689 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.689; + let List.699 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.699; procedure Num.127 (#Attr.2): let Num.284 : U8 = lowlevel NumIntCast #Attr.2; 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 974cea5e21..6744f9ca1b 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 @@ -87,93 +87,93 @@ procedure Encode.26 (Encode.107, Encode.108): let Encode.110 : List U8 = CallByName Encode.24 Encode.111 Encode.112 Encode.108; ret Encode.110; -procedure List.100 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): - joinpoint List.695 List.174 List.175 List.176 List.177 List.178: - let List.697 : Int1 = CallByName Num.22 List.177 List.178; - if List.697 then - let List.701 : Str = CallByName List.66 List.174 List.177; - inc List.701; - let List.179 : List U8 = CallByName Test.66 List.175 List.701 List.176; - let List.700 : U64 = 1i64; - let List.699 : U64 = CallByName Num.51 List.177 List.700; - jump List.695 List.174 List.179 List.176 List.699 List.178; +procedure List.101 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): + joinpoint List.678 List.175 List.176 List.177 List.178 List.179: + let List.680 : Int1 = CallByName Num.22 List.178 List.179; + if List.680 then + let List.684 : [C {}, C {}, C Str] = CallByName List.66 List.175 List.178; + inc List.684; + let List.180 : List U8 = CallByName Test.66 List.176 List.684 List.177; + let List.683 : U64 = 1i64; + let List.682 : U64 = CallByName Num.51 List.178 List.683; + jump List.678 List.175 List.180 List.177 List.682 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in - inc #Derived_gen.29; - jump List.695 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; + inc #Derived_gen.26; + jump List.678 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; -procedure List.100 (#Derived_gen.49, #Derived_gen.50, #Derived_gen.51, #Derived_gen.52, #Derived_gen.53): - joinpoint List.668 List.174 List.175 List.176 List.177 List.178: - let List.670 : Int1 = CallByName Num.22 List.177 List.178; - if List.670 then - let List.674 : [C {}, C {}, C Str] = CallByName List.66 List.174 List.177; - inc List.674; - let List.179 : List U8 = CallByName Test.66 List.175 List.674 List.176; - let List.673 : U64 = 1i64; - let List.672 : U64 = CallByName Num.51 List.177 List.673; - jump List.668 List.174 List.179 List.176 List.672 List.178; +procedure List.101 (#Derived_gen.49, #Derived_gen.50, #Derived_gen.51, #Derived_gen.52, #Derived_gen.53): + joinpoint List.705 List.175 List.176 List.177 List.178 List.179: + let List.707 : Int1 = CallByName Num.22 List.178 List.179; + if List.707 then + let List.711 : Str = CallByName List.66 List.175 List.178; + inc List.711; + let List.180 : List U8 = CallByName Test.66 List.176 List.711 List.177; + let List.710 : U64 = 1i64; + let List.709 : U64 = CallByName Num.51 List.178 List.710; + jump List.705 List.175 List.180 List.177 List.709 List.179; else - dec List.174; - ret List.175; + dec List.175; + ret List.176; in inc #Derived_gen.49; - jump List.668 #Derived_gen.49 #Derived_gen.50 #Derived_gen.51 #Derived_gen.52 #Derived_gen.53; + jump List.705 #Derived_gen.49 #Derived_gen.50 #Derived_gen.51 #Derived_gen.52 #Derived_gen.53; procedure List.13 (#Attr.2, #Attr.3): - let List.691 : List [C {}, C {}, C Str] = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.691; + let List.701 : List [C {}, C {}, C Str] = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.701; procedure List.13 (#Attr.2, #Attr.3): - let List.719 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.719; + let List.729 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.729; -procedure List.18 (List.171, List.172, List.173): - let List.666 : U64 = 0i64; - let List.667 : U64 = CallByName List.6 List.171; - let List.665 : List U8 = CallByName List.100 List.171 List.172 List.173 List.666 List.667; - ret List.665; - -procedure List.18 (List.171, List.172, List.173): - let List.693 : U64 = 0i64; - let List.694 : U64 = CallByName List.6 List.171; - let List.692 : List U8 = CallByName List.100 List.171 List.172 List.173 List.693 List.694; - ret List.692; - -procedure List.4 (List.135, List.136): - let List.714 : U64 = 1i64; - let List.713 : List U8 = CallByName List.70 List.135 List.714; - let List.712 : List U8 = CallByName List.71 List.713 List.136; - ret List.712; - -procedure List.6 (#Attr.2): - let List.690 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.690; - -procedure List.6 (#Attr.2): - let List.717 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.717; - -procedure List.66 (#Attr.2, #Attr.3): - let List.675 : [C {}, C {}, C Str] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.676 : U64 = 0i64; + let List.677 : U64 = CallByName List.6 List.172; + let List.675 : List U8 = CallByName List.101 List.172 List.173 List.174 List.676 List.677; ret List.675; -procedure List.66 (#Attr.2, #Attr.3): - let List.702 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; +procedure List.18 (List.172, List.173, List.174): + let List.703 : U64 = 0i64; + let List.704 : U64 = CallByName List.6 List.172; + let List.702 : List U8 = CallByName List.101 List.172 List.173 List.174 List.703 List.704; ret List.702; +procedure List.4 (List.136, List.137): + let List.724 : U64 = 1i64; + let List.723 : List U8 = CallByName List.70 List.136 List.724; + let List.722 : List U8 = CallByName List.71 List.723 List.137; + ret List.722; + +procedure List.6 (#Attr.2): + let List.700 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.700; + +procedure List.6 (#Attr.2): + let List.727 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.727; + +procedure List.66 (#Attr.2, #Attr.3): + let List.685 : [C {}, C {}, C Str] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.685; + +procedure List.66 (#Attr.2, #Attr.3): + let List.712 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.712; + procedure List.70 (#Attr.2, #Attr.3): - let List.708 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.708; + let List.718 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.718; procedure List.71 (#Attr.2, #Attr.3): - let List.706 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.706; + let List.716 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.716; procedure List.8 (#Attr.2, #Attr.3): - let List.716 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.716; + let List.726 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.726; procedure Num.127 (#Attr.2): let Num.288 : U8 = lowlevel NumIntCast #Attr.2; diff --git a/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt b/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt index e5499da3ef..476c9b0343 100644 --- a/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt +++ b/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt @@ -2,81 +2,81 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.23; -procedure List.115 (List.562, List.563, List.564): - let List.683 : U64 = 0i64; - let List.684 : U64 = CallByName List.6 List.562; - let List.682 : [C U64, C U64] = CallByName List.80 List.562 List.563 List.564 List.683 List.684; - ret List.682; +procedure List.116 (List.563, List.564, List.565): + let List.693 : U64 = 0i64; + let List.694 : U64 = CallByName List.6 List.563; + let List.692 : [C U64, C U64] = CallByName List.80 List.563 List.564 List.565 List.693 List.694; + ret List.692; -procedure List.26 (List.212, List.213, List.214): - let List.676 : [C U64, C U64] = CallByName List.115 List.212 List.213 List.214; - let List.679 : U8 = 1i64; - let List.680 : U8 = GetTagId List.676; - let List.681 : Int1 = lowlevel Eq List.679 List.680; - if List.681 then - let List.215 : U64 = UnionAtIndex (Id 1) (Index 0) List.676; - ret List.215; - else - let List.216 : U64 = UnionAtIndex (Id 0) (Index 0) List.676; +procedure List.26 (List.213, List.214, List.215): + let List.686 : [C U64, C U64] = CallByName List.116 List.213 List.214 List.215; + let List.689 : U8 = 1i64; + let List.690 : U8 = GetTagId List.686; + let List.691 : Int1 = lowlevel Eq List.689 List.690; + if List.691 then + let List.216 : U64 = UnionAtIndex (Id 1) (Index 0) List.686; ret List.216; + else + let List.217 : U64 = UnionAtIndex (Id 0) (Index 0) List.686; + ret List.217; -procedure List.38 (List.400, List.401): - let List.675 : U64 = CallByName List.6 List.400; - let List.402 : U64 = CallByName Num.77 List.675 List.401; - let List.665 : List U8 = CallByName List.43 List.400 List.402; - ret List.665; +procedure List.38 (List.401, List.402): + let List.685 : U64 = CallByName List.6 List.401; + let List.403 : U64 = CallByName Num.77 List.685 List.402; + let List.675 : List U8 = CallByName List.43 List.401 List.403; + ret List.675; -procedure List.43 (List.398, List.399): - let List.673 : U64 = CallByName List.6 List.398; - let List.672 : U64 = CallByName Num.77 List.673 List.399; - let List.667 : {U64, U64} = Struct {List.399, List.672}; - let List.666 : List U8 = CallByName List.49 List.398 List.667; - ret List.666; +procedure List.43 (List.399, List.400): + let List.683 : U64 = CallByName List.6 List.399; + let List.682 : U64 = CallByName Num.77 List.683 List.400; + let List.677 : {U64, U64} = Struct {List.400, List.682}; + let List.676 : List U8 = CallByName List.49 List.399 List.677; + ret List.676; -procedure List.49 (List.476, List.477): - let List.669 : U64 = StructAtIndex 1 List.477; - let List.670 : U64 = StructAtIndex 0 List.477; - let List.668 : List U8 = CallByName List.72 List.476 List.669 List.670; - ret List.668; +procedure List.49 (List.477, List.478): + let List.679 : U64 = StructAtIndex 1 List.478; + let List.680 : U64 = StructAtIndex 0 List.478; + let List.678 : List U8 = CallByName List.72 List.477 List.679 List.680; + ret List.678; procedure List.6 (#Attr.2): - let List.674 : U64 = lowlevel ListLenU64 #Attr.2; - ret List.674; + let List.684 : U64 = lowlevel ListLenU64 #Attr.2; + ret List.684; procedure List.66 (#Attr.2, #Attr.3): - let List.697 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.697; + let List.707 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.707; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.671 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.671; + let List.681 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.681; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.685 List.565 List.566 List.567 List.568 List.569: - let List.687 : Int1 = CallByName Num.22 List.568 List.569; - if List.687 then - let List.696 : U8 = CallByName List.66 List.565 List.568; - let List.688 : [C U64, C U64] = CallByName Test.3 List.566 List.696; - let List.693 : U8 = 1i64; - let List.694 : U8 = GetTagId List.688; - let List.695 : Int1 = lowlevel Eq List.693 List.694; - if List.695 then - let List.570 : U64 = UnionAtIndex (Id 1) (Index 0) List.688; - let List.691 : U64 = 1i64; - let List.690 : U64 = CallByName Num.51 List.568 List.691; - jump List.685 List.565 List.570 List.567 List.690 List.569; + joinpoint List.695 List.566 List.567 List.568 List.569 List.570: + let List.697 : Int1 = CallByName Num.22 List.569 List.570; + if List.697 then + let List.706 : U8 = CallByName List.66 List.566 List.569; + let List.698 : [C U64, C U64] = CallByName Test.3 List.567 List.706; + let List.703 : U8 = 1i64; + let List.704 : U8 = GetTagId List.698; + let List.705 : Int1 = lowlevel Eq List.703 List.704; + if List.705 then + let List.571 : U64 = UnionAtIndex (Id 1) (Index 0) List.698; + let List.701 : U64 = 1i64; + let List.700 : U64 = CallByName Num.51 List.569 List.701; + jump List.695 List.566 List.571 List.568 List.700 List.570; else - dec List.565; - let List.571 : U64 = UnionAtIndex (Id 0) (Index 0) List.688; - let List.692 : [C U64, C U64] = TagId(0) List.571; - ret List.692; + dec List.566; + let List.572 : U64 = UnionAtIndex (Id 0) (Index 0) List.698; + let List.702 : [C U64, C U64] = TagId(0) List.572; + ret List.702; else - dec List.565; - let List.686 : [C U64, C U64] = TagId(1) List.566; - ret List.686; + dec List.566; + let List.696 : [C U64, C U64] = TagId(1) List.567; + ret List.696; in inc #Derived_gen.0; - jump List.685 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.695 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.22 (#Attr.2, #Attr.3): let Num.286 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; From 8deca25c5e335cde8b0828dfa5e5c2425c96a297 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Thu, 9 Jan 2025 18:36:00 -0800 Subject: [PATCH 18/24] Make sure to add parens if a PncApply dbg stmt becomes a space-separated Apply --- crates/compiler/fmt/src/expr.rs | 9 +++++- .../pass/dbg_pnc_a_over_a.expr.formatted.roc | 2 ++ .../pass/dbg_pnc_a_over_a.expr.result-ast | 32 +++++++++++++++++++ .../snapshots/pass/dbg_pnc_a_over_a.expr.roc | 2 ++ .../test_syntax/tests/test_snapshots.rs | 1 + 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.formatted.roc create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.result-ast create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.roc diff --git a/crates/compiler/fmt/src/expr.rs b/crates/compiler/fmt/src/expr.rs index ae91cad16b..2f9b1cbc69 100644 --- a/crates/compiler/fmt/src/expr.rs +++ b/crates/compiler/fmt/src/expr.rs @@ -1340,9 +1340,16 @@ pub fn expr_lift_spaces<'a, 'b: 'a>( let right_lifted = expr_lift_spaces_after(Parens::InOperator, arena, &right.value); + let mut item = + Expr::BinOps(lefts, arena.alloc(Loc::at(right.region, right_lifted.item))); + + if parens == Parens::InApply || parens == Parens::InApplyLastArg { + item = Expr::ParensAround(arena.alloc(item)); + } + Spaces { before, - item: Expr::BinOps(lefts, arena.alloc(Loc::at(right.region, right_lifted.item))), + item, after: right_lifted.after, } } diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.formatted.roc new file mode 100644 index 0000000000..d863928740 --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.formatted.roc @@ -0,0 +1,2 @@ +dbg (a / a) +d \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.result-ast new file mode 100644 index 0000000000..ca43e9a2fe --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.result-ast @@ -0,0 +1,32 @@ +@0-8 SpaceAfter( + DbgStmt { + first: @4-7 BinOps( + [ + ( + @4-5 Var { + module_name: "", + ident: "a", + }, + @5-6 Slash, + ), + ], + @6-7 Var { + module_name: "", + ident: "a", + }, + ), + extra_args: [], + continuation: @9-10 SpaceBefore( + Var { + module_name: "", + ident: "d", + }, + [ + Newline, + ], + ), + }, + [ + Newline, + ], +) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.roc new file mode 100644 index 0000000000..321064db20 --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_a_over_a.expr.roc @@ -0,0 +1,2 @@ +dbg(a/a) +d diff --git a/crates/compiler/test_syntax/tests/test_snapshots.rs b/crates/compiler/test_syntax/tests/test_snapshots.rs index 4b17513e28..b85cffc909 100644 --- a/crates/compiler/test_syntax/tests/test_snapshots.rs +++ b/crates/compiler/test_syntax/tests/test_snapshots.rs @@ -397,6 +397,7 @@ mod test_snapshots { pass/dbg_double_newline.expr, pass/dbg_extra_parens.expr, pass/dbg_newline_apply.expr, + pass/dbg_pnc_a_over_a.expr, pass/dbg_stmt.expr, pass/dbg_stmt_in_parens.expr, pass/dbg_stmt_multiline.expr, From 7acf9c5e5d485689e3be35574f8a65a7c0f8e7fd Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Thu, 9 Jan 2025 20:25:20 -0800 Subject: [PATCH 19/24] Fix zero-length dbg arg list --- crates/compiler/fmt/src/expr.rs | 29 +++--- crates/compiler/parse/src/expr.rs | 90 ++++++++++--------- crates/compiler/parse/src/normalize.rs | 56 +++++++----- .../pass/dbg_pnc_zero_args.expr.formatted.roc | 2 + .../pass/dbg_pnc_zero_args.expr.result-ast | 40 +++++++++ .../snapshots/pass/dbg_pnc_zero_args.expr.roc | 2 + .../test_syntax/tests/test_snapshots.rs | 1 + 7 files changed, 141 insertions(+), 79 deletions(-) create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.formatted.roc create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.result-ast create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.roc diff --git a/crates/compiler/fmt/src/expr.rs b/crates/compiler/fmt/src/expr.rs index 2f9b1cbc69..2f087af08d 100644 --- a/crates/compiler/fmt/src/expr.rs +++ b/crates/compiler/fmt/src/expr.rs @@ -91,14 +91,6 @@ fn format_expr_only( buf.indent(indent); buf.push_str("try"); } - Expr::PncApply( - loc_expr @ Loc { - value: Expr::Dbg, .. - }, - loc_args, - ) => { - fmt_apply(loc_expr, loc_args.items, indent, buf); - } Expr::PncApply(loc_expr, loc_args) => { fmt_pnc_apply(loc_expr, loc_args, indent, buf); } @@ -1763,12 +1755,21 @@ fn fmt_dbg_stmt<'a>( args.push(condition); args.extend_from_slice(extra_args); - Expr::Apply( - &Loc::at_zero(Expr::Dbg), - args.into_bump_slice(), - called_via::CalledVia::Space, - ) - .format_with_options(buf, parens, Newlines::Yes, indent); + if args.is_empty() { + Expr::PncApply(&Loc::at_zero(Expr::Dbg), Collection::empty()).format_with_options( + buf, + parens, + Newlines::Yes, + indent, + ); + } else { + Expr::Apply( + &Loc::at_zero(Expr::Dbg), + args.into_bump_slice(), + called_via::CalledVia::Space, + ) + .format_with_options(buf, parens, Newlines::Yes, indent); + } let cont_lifted = expr_lift_spaces(Parens::NotNeeded, buf.text.bump(), &continuation.value); diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index a9ac3cbe7d..fc0c2422bd 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -242,15 +242,7 @@ fn loc_term<'a>() -> impl Parser<'a, Loc>, EExpr<'a>> { let mut e = expr; let orig_region = e.region; for (args_loc, maybe_suffixes) in arg_locs_with_suffixes_vec.iter() { - let value = if matches!( - e, - Loc { - value: Expr::Dbg, - .. - } - ) { - Expr::Apply(arena.alloc(e), args_loc.value.items, CalledVia::Space) - } else if let Some(suffixes) = maybe_suffixes { + let value = if let Some(suffixes) = maybe_suffixes { apply_expr_access_chain( arena, Expr::PncApply(arena.alloc(e), args_loc.value), @@ -3150,24 +3142,32 @@ fn stmts_to_defs<'a>( _, ) = e { - let condition = &args[0]; - let rest = stmts_to_expr(&stmts[i + 1..], arena)?; - let e = Expr::DbgStmt { - first: condition, - extra_args: &args[1..], - continuation: arena.alloc(rest), - }; + if let Some((first, extra_args)) = args.split_first() { + let rest = stmts_to_expr(&stmts[i + 1..], arena)?; + let e = Expr::DbgStmt { + first, + extra_args, + continuation: arena.alloc(rest), + }; - let e = if sp_stmt.before.is_empty() { - e + let e = if sp_stmt.before.is_empty() { + e + } else { + arena.alloc(e).before(sp_stmt.before) + }; + + last_expr = Some(Loc::at(sp_stmt.item.region, e)); + + // don't re-process the rest of the statements; they got consumed by the dbg expr + break; } else { - arena.alloc(e).before(sp_stmt.before) - }; - - last_expr = Some(Loc::at(sp_stmt.item.region, e)); - - // don't re-process the rest of the statements; they got consumed by the dbg expr - break; + defs.push_value_def( + ValueDef::Stmt(arena.alloc(Loc::at(sp_stmt.item.region, e))), + sp_stmt.item.region, + sp_stmt.before, + &[], + ); + } } else if let Expr::PncApply( Loc { value: Expr::Dbg, .. @@ -3175,24 +3175,32 @@ fn stmts_to_defs<'a>( args, ) = e { - let condition = &args.items[0]; - let rest = stmts_to_expr(&stmts[i + 1..], arena)?; - let e = Expr::DbgStmt { - first: condition, - extra_args: &args.items[1..], - continuation: arena.alloc(rest), - }; + if let Some((first, extra_args)) = args.items.split_first() { + let rest = stmts_to_expr(&stmts[i + 1..], arena)?; + let e = Expr::DbgStmt { + first, + extra_args, + continuation: arena.alloc(rest), + }; - let e = if sp_stmt.before.is_empty() { - e + let e = if sp_stmt.before.is_empty() { + e + } else { + arena.alloc(e).before(sp_stmt.before) + }; + + last_expr = Some(Loc::at(sp_stmt.item.region, e)); + + // don't re-process the rest of the statements; they got consumed by the dbg expr + break; } else { - arena.alloc(e).before(sp_stmt.before) - }; - - last_expr = Some(Loc::at(sp_stmt.item.region, e)); - - // don't re-process the rest of the statements; they got consumed by the dbg expr - break; + defs.push_value_def( + ValueDef::Stmt(arena.alloc(Loc::at(sp_stmt.item.region, e))), + sp_stmt.item.region, + sp_stmt.before, + &[], + ); + } } else { defs.push_value_def( ValueDef::Stmt(arena.alloc(Loc::at(sp_stmt.item.region, e))), diff --git a/crates/compiler/parse/src/normalize.rs b/crates/compiler/parse/src/normalize.rs index e95844104c..d9530dc12b 100644 --- a/crates/compiler/parse/src/normalize.rs +++ b/crates/compiler/parse/src/normalize.rs @@ -822,19 +822,23 @@ fn fold_defs<'a>( ), .. }) => { - let rest = fold_defs(arena, defs, final_expr); - let new_final = Expr::DbgStmt { - first: args[0], - extra_args: &args[1..], - continuation: arena.alloc(Loc::at_zero(rest)), - }; - if new_defs.is_empty() { - return new_final; + if let Some((first, extra_args)) = args.split_first() { + let rest = fold_defs(arena, defs, final_expr); + let new_final = Expr::DbgStmt { + first, + extra_args, + continuation: arena.alloc(Loc::at_zero(rest)), + }; + if new_defs.is_empty() { + return new_final; + } + return Expr::Defs( + arena.alloc(new_defs), + arena.alloc(Loc::at_zero(new_final)), + ); + } else { + new_defs.push_value_def(vd, Region::zero(), &[], &[]); } - return Expr::Defs( - arena.alloc(new_defs), - arena.alloc(Loc::at_zero(new_final)), - ); } ValueDef::Stmt(&Loc { value: @@ -846,19 +850,23 @@ fn fold_defs<'a>( ), .. }) => { - let rest = fold_defs(arena, defs, final_expr); - let new_final = Expr::DbgStmt { - first: args.items[0], - extra_args: &args.items[1..], - continuation: arena.alloc(Loc::at_zero(rest)), - }; - if new_defs.is_empty() { - return new_final; + if let Some((first, extra_args)) = args.items.split_first() { + let rest = fold_defs(arena, defs, final_expr); + let new_final = Expr::DbgStmt { + first, + extra_args, + continuation: arena.alloc(Loc::at_zero(rest)), + }; + if new_defs.is_empty() { + return new_final; + } + return Expr::Defs( + arena.alloc(new_defs), + arena.alloc(Loc::at_zero(new_final)), + ); + } else { + new_defs.push_value_def(vd, Region::zero(), &[], &[]); } - return Expr::Defs( - arena.alloc(new_defs), - arena.alloc(Loc::at_zero(new_final)), - ); } _ => { new_defs.push_value_def(vd, Region::zero(), &[], &[]); diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.formatted.roc new file mode 100644 index 0000000000..4b17254eed --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.formatted.roc @@ -0,0 +1,2 @@ +dbg() +d \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.result-ast new file mode 100644 index 0000000000..576283bc8f --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.result-ast @@ -0,0 +1,40 @@ +@0-7 SpaceAfter( + Defs( + Defs { + tags: [ + EitherIndex(2147483648), + ], + regions: [ + @0-5, + ], + space_before: [ + Slice { start: 0, length: 0 }, + ], + space_after: [ + Slice { start: 0, length: 0 }, + ], + spaces: [], + type_defs: [], + value_defs: [ + Stmt( + @0-5 PncApply( + @0-3 Dbg, + [], + ), + ), + ], + }, + @6-7 SpaceBefore( + Var { + module_name: "", + ident: "d", + }, + [ + Newline, + ], + ), + ), + [ + Newline, + ], +) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.roc new file mode 100644 index 0000000000..a9c0e31c98 --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/dbg_pnc_zero_args.expr.roc @@ -0,0 +1,2 @@ +dbg() +d diff --git a/crates/compiler/test_syntax/tests/test_snapshots.rs b/crates/compiler/test_syntax/tests/test_snapshots.rs index b85cffc909..819af4d221 100644 --- a/crates/compiler/test_syntax/tests/test_snapshots.rs +++ b/crates/compiler/test_syntax/tests/test_snapshots.rs @@ -398,6 +398,7 @@ mod test_snapshots { pass/dbg_extra_parens.expr, pass/dbg_newline_apply.expr, pass/dbg_pnc_a_over_a.expr, + pass/dbg_pnc_zero_args.expr, pass/dbg_stmt.expr, pass/dbg_stmt_in_parens.expr, pass/dbg_stmt_multiline.expr, From 9f395e033dfb9ade5c0642567f0dda8bbd1f2e5a Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Thu, 9 Jan 2025 21:06:08 -0800 Subject: [PATCH 20/24] Fix pnc apply pattern lift spaces --- crates/compiler/fmt/src/pattern.rs | 2 +- .../pnc_parens_apply_etc.expr.formatted.roc | 2 + .../pass/pnc_parens_apply_etc.expr.result-ast | 54 +++++++++++++++++++ .../pass/pnc_parens_apply_etc.expr.roc | 3 ++ .../test_syntax/tests/test_snapshots.rs | 1 + 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.formatted.roc create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.result-ast create mode 100644 crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.roc diff --git a/crates/compiler/fmt/src/pattern.rs b/crates/compiler/fmt/src/pattern.rs index 025bbc8bfb..7356c2965b 100644 --- a/crates/compiler/fmt/src/pattern.rs +++ b/crates/compiler/fmt/src/pattern.rs @@ -722,7 +722,7 @@ pub fn pattern_lift_spaces<'a, 'b: 'a>( Spaces { before: func_lifted.before, - item: Pattern::PncApply(arena.alloc(func), *args), + item: Pattern::PncApply(arena.alloc(Loc::at_zero(func_lifted.item)), *args), after: &[], } } diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.formatted.roc new file mode 100644 index 0000000000..c5963bb609 --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.formatted.roc @@ -0,0 +1,2 @@ +3() : B +z \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.result-ast new file mode 100644 index 0000000000..2929161772 --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.result-ast @@ -0,0 +1,54 @@ +@0-12 SpaceAfter( + Defs( + Defs { + tags: [ + EitherIndex(2147483648), + ], + regions: [ + @0-8, + ], + space_before: [ + Slice { start: 0, length: 0 }, + ], + space_after: [ + Slice { start: 0, length: 0 }, + ], + spaces: [], + type_defs: [], + value_defs: [ + Annotation( + @2-6 PncApply( + @2-3 SpaceBefore( + NumLiteral( + "3", + ), + [ + Newline, + ], + ), + [], + ), + @7-8 Apply( + "", + "B", + [], + ), + ), + ], + }, + @9-12 SpaceBefore( + ParensAround( + Var { + module_name: "", + ident: "z", + }, + ), + [ + Newline, + ], + ), + ), + [ + Newline, + ], +) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.roc new file mode 100644 index 0000000000..82429530af --- /dev/null +++ b/crates/compiler/test_syntax/tests/snapshots/pass/pnc_parens_apply_etc.expr.roc @@ -0,0 +1,3 @@ +( +3)():B +(z) diff --git a/crates/compiler/test_syntax/tests/test_snapshots.rs b/crates/compiler/test_syntax/tests/test_snapshots.rs index 819af4d221..385c9ad9be 100644 --- a/crates/compiler/test_syntax/tests/test_snapshots.rs +++ b/crates/compiler/test_syntax/tests/test_snapshots.rs @@ -634,6 +634,7 @@ mod test_snapshots { pass/plus_if.expr, pass/plus_when.expr, pass/pnc_apply_comment_after_newline.expr, + pass/pnc_parens_apply_etc.expr, pass/pos_inf_float.expr, pass/positive_float.expr, pass/positive_int.expr, From eb1b5ffa267fd2cbe707ed49aa596215fe9c2e0a Mon Sep 17 00:00:00 2001 From: Sam Mohr Date: Fri, 10 Jan 2025 10:18:15 -0800 Subject: [PATCH 21/24] Move to new interpolation syntax --- crates/cli/src/format.rs | 4 +- crates/cli/tests/benchmarks/Quicksort.roc | 2 +- crates/cli/tests/benchmarks/rBTreeInsert.roc | 4 +- ...ple_zig__module_params_arity_mismatch.snap | 6 +- ...orm_simple_zig__module_params_bad_ann.snap | 4 +- ...mple_zig__module_params_unexpected_fn.snap | 2 +- .../test-projects/effectful/combine-tasks.roc | 2 +- .../test-projects/effectful/for_each_try.roc | 4 +- .../tests/test-projects/effectful/form.roc | 4 +- .../test-projects/effectful/print-line.roc | 2 +- .../effectful/suffixed_record_field.roc | 4 +- .../effectful/untyped_passed_fx.roc | 4 +- .../false-interpreter/Context.roc | 2 +- .../test-projects/false-interpreter/main.roc | 4 +- .../test-projects/fixtures/packages/main.roc | 2 +- .../transitive-deps/direct-one-and-two.roc | 2 +- .../fixtures/transitive-deps/one/One.roc | 2 +- .../fixtures/transitive-deps/zero/Zero.roc | 2 +- .../tests/test-projects/module_params/Api.roc | 14 +- .../test-projects/module_params/BadAnn.roc | 4 +- .../module_params/ImportInExpect.roc | 2 +- .../test-projects/module_params/Menu.roc | 2 +- .../tests/test-projects/module_params/app.roc | 62 +- .../module_params/arity_mismatch.roc | 8 +- .../module_params/effect_module.roc | 2 +- .../module_params/unexpected_fn.roc | 4 +- .../platform_requires_pkg/platform/main.roc | 2 +- crates/compiler/builtins/roc/Dict.roc | 2 +- crates/compiler/builtins/roc/List.roc | 13 +- crates/compiler/builtins/roc/Result.roc | 11 +- crates/compiler/builtins/roc/Str.roc | 8 +- crates/compiler/can/tests/test_can.rs | 4 +- crates/compiler/fmt/src/expr.rs | 6 +- crates/compiler/load/tests/test_reporting.rs | 16 +- .../compiler/load_internal/tests/test_load.rs | 14 +- crates/compiler/module/src/called_via.rs | 2 +- crates/compiler/parse/src/string_literal.rs | 26 +- crates/compiler/parse/tests/test_parse.rs | 36 +- crates/compiler/solve/tests/solve_expr.rs | 8 +- crates/compiler/test_gen/src/gen_list.rs | 6 +- .../compiler/test_gen/src/gen_primitives.rs | 20 +- crates/compiler/test_gen/src/gen_return.rs | 4 +- crates/compiler/test_mono/src/tests.rs | 14 +- .../pass/block_string_ann.expr.formatted.roc | 2 +- .../pass/block_string_ann.expr.result-ast | 11 +- .../snapshots/pass/block_string_ann.expr.roc | 2 +- ...multiline_str_crazyness.expr.formatted.roc | 4 +- .../multiline_str_crazyness.expr.result-ast | 61 +- .../pass/multiline_str_crazyness.expr.roc | 2 +- ...r_interpolation_records.expr.formatted.roc | 8 +- ...ltiline_str_interpolation_records.expr.roc | 8 +- ...nt_in_str_interpolation.expr.formatted.roc | 4 +- ...rens_comment_in_str_interpolation.expr.roc | 4 +- .../pass/pizza_question.moduledefs.roc | 2 +- crates/compiler/test_syntax/tests/test_fmt.rs | 8 +- .../test_syntax/tests/test_snapshots.rs | 8 +- crates/glue/platform/Types.roc | 6 +- crates/glue/src/RustGlue.roc | 642 +++++++++--------- crates/repl_test/src/tests.rs | 18 +- crates/reporting/src/error/parse.rs | 4 +- crates/valgrind_tests/src/lib.rs | 12 +- www/InteractiveExample.roc | 24 +- www/content/friendly.md | 2 +- www/content/functional.md | 6 +- www/content/index.md | 2 +- www/content/tutorial.md | 98 +-- www/main.roc | 8 +- www/public/site.js | 6 +- 68 files changed, 665 insertions(+), 633 deletions(-) diff --git a/crates/cli/src/format.rs b/crates/cli/src/format.rs index 3e82628f84..b1cbf5b2b9 100644 --- a/crates/cli/src/format.rs +++ b/crates/cli/src/format.rs @@ -278,14 +278,14 @@ import pf.Stdin main = Stdout.line! "What's your name?" name = Stdin.line! - Stdout.line! "Hi $(name)!""#; + Stdout.line! "Hi ${name}!""#; const UNFORMATTED_ROC: &str = r#"app [main] { pf: platform "platform/main.roc" } main = Stdout.line! "What's your name?" name = Stdin.line! - Stdout.line! "Hi $(name)!" + Stdout.line! "Hi ${name}!" "#; fn setup_test_file(dir: &Path, file_name: &str, contents: &str) -> PathBuf { diff --git a/crates/cli/tests/benchmarks/Quicksort.roc b/crates/cli/tests/benchmarks/Quicksort.roc index 3b03df6dfb..4149f4bbdf 100644 --- a/crates/cli/tests/benchmarks/Quicksort.roc +++ b/crates/cli/tests/benchmarks/Quicksort.roc @@ -10,7 +10,7 @@ show = \list -> |> List.map(Num.to_str) |> Str.join_with(", ") - "[$(content)]" + "[${content}]" sort_by : List a, (a -> Num *) -> List a sort_by = \list, to_comparable -> diff --git a/crates/cli/tests/benchmarks/rBTreeInsert.roc b/crates/cli/tests/benchmarks/rBTreeInsert.roc index 05b62ccee7..a017501bd5 100644 --- a/crates/cli/tests/benchmarks/rBTreeInsert.roc +++ b/crates/cli/tests/benchmarks/rBTreeInsert.roc @@ -25,7 +25,7 @@ show_rb_tree = \tree, show_key, show_value -> s_l = node_in_parens(left, show_key, show_value) s_r = node_in_parens(right, show_key, show_value) - "Node $(s_color) $(s_key) $(s_value) $(s_l) $(s_r)" + "Node ${s_color} ${s_key} ${s_value} ${s_l} ${s_r}" node_in_parens : RedBlackTree k v, (k -> Str), (v -> Str) -> Str node_in_parens = \tree, show_key, show_value -> @@ -36,7 +36,7 @@ node_in_parens = \tree, show_key, show_value -> Node(_, _, _, _, _) -> inner = show_rb_tree(tree, show_key, show_value) - "($(inner))" + "(${inner})" show_color : NodeColor -> Str show_color = \color -> diff --git a/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_arity_mismatch.snap b/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_arity_mismatch.snap index f3bc460c4d..6f6291694f 100644 --- a/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_arity_mismatch.snap +++ b/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_arity_mismatch.snap @@ -8,7 +8,7 @@ snapshot_kind: text The get_user function expects 1 argument, but it got 2 instead: -12│ $(Api.get_user(1, 2)) +12│ ${Api.get_user(1, 2)} ^^^^^^^^^^^^ Are there any missing commas? Or missing parentheses? @@ -18,7 +18,7 @@ Are there any missing commas? Or missing parentheses? This value is not a function, but it was given 1 argument: -13│ $(Api.base_url(1)) +13│ ${Api.base_url(1)} ^^^^^^^^^^^^ Are there any missing commas? Or missing parentheses? @@ -28,7 +28,7 @@ Are there any missing commas? Or missing parentheses? The get_post_comment function expects 2 arguments, but it got only 1: -16│ $(Api.get_post_comment(1)) +16│ ${Api.get_post_comment(1)} ^^^^^^^^^^^^^^^^^^^^ Roc does not allow functions to be partially applied. Use a closure to diff --git a/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_bad_ann.snap b/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_bad_ann.snap index 70259aade4..f6b7220c94 100644 --- a/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_bad_ann.snap +++ b/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_bad_ann.snap @@ -11,7 +11,7 @@ fn_annotated_as_value definition: 3│ fn_annotated_as_value : Str 4│> fn_annotated_as_value = \post_id, comment_id -> -5│> "/posts/$(post_id)/comments/$(Num.to_str(comment_id))" +5│> "/posts/${post_id}/comments/${Num.to_str(comment_id)}" The body is an anonymous function of type: @@ -28,7 +28,7 @@ Something is off with the body of the missing_arg definition: 7│ missing_arg : Str -> Str 8│> missing_arg = \post_id, _ -> -9│> "/posts/$(post_id)/comments" +9│> "/posts/${post_id}/comments" The body is an anonymous function of type: diff --git a/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_unexpected_fn.snap b/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_unexpected_fn.snap index 61baf2e53e..614c13c669 100644 --- a/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_unexpected_fn.snap +++ b/crates/cli/tests/snapshots/cli_tests__cli_tests__test_platform_simple_zig__module_params_unexpected_fn.snap @@ -8,7 +8,7 @@ snapshot_kind: text This argument to this string interpolation has an unexpected type: -10│ "$(Api.get_post)" +10│ "${Api.get_post}" ^^^^^^^^^^^^ The argument is an anonymous function of type: diff --git a/crates/cli/tests/test-projects/effectful/combine-tasks.roc b/crates/cli/tests/test-projects/effectful/combine-tasks.roc index 576275e925..3433e8f7ab 100644 --- a/crates/cli/tests/test-projects/effectful/combine-tasks.roc +++ b/crates/cli/tests/test-projects/effectful/combine-tasks.roc @@ -12,7 +12,7 @@ main = _: Task.ok(Dict.single("a", "b")), }! - Stdout.line!("For multiple tasks: $(Inspect.to_str(multiple_in))") + Stdout.line!("For multiple tasks: ${Inspect.to_str(multiple_in)}") sequential : Task a err, Task b err, (a, b -> c) -> Task c err sequential = \first_task, second_task, mapper -> diff --git a/crates/cli/tests/test-projects/effectful/for_each_try.roc b/crates/cli/tests/test-projects/effectful/for_each_try.roc index e7f6709163..6431c4d2a5 100644 --- a/crates/cli/tests/test-projects/effectful/for_each_try.roc +++ b/crates/cli/tests/test-projects/effectful/for_each_try.roc @@ -15,8 +15,8 @@ main! = \{} -> validate! : U32 => Result {} U32 validate! = \x -> if Num.is_even(x) then - Effect.put_line!("✅ $(Num.to_str(x))") + Effect.put_line!("✅ ${Num.to_str(x)}") Ok({}) else - Effect.put_line!("$(Num.to_str(x)) is not even! ABORT!") + Effect.put_line!("${Num.to_str(x)} is not even! ABORT!") Err(x) diff --git a/crates/cli/tests/test-projects/effectful/form.roc b/crates/cli/tests/test-projects/effectful/form.roc index 0f57f2a82b..55d4fe95fc 100644 --- a/crates/cli/tests/test-projects/effectful/form.roc +++ b/crates/cli/tests/test-projects/effectful/form.roc @@ -7,7 +7,7 @@ main! = \{} -> first = ask!("What's your first name?") last = ask!("What's your last name?") - Effect.put_line!("\nHi, $(first) $(last)!\n") + Effect.put_line!("\nHi, ${first} ${last}!\n") when Str.to_u8(ask!("How old are you?")) is Err(InvalidNumStr) -> @@ -17,7 +17,7 @@ main! = \{} -> Effect.put_line!("\nNice! You can vote!") Ok(age) -> - Effect.put_line!("\nYou'll be able to vote in $(Num.to_str((18 - age))) years") + Effect.put_line!("\nYou'll be able to vote in ${Num.to_str(18 - age)} years") Effect.put_line!("\nBye! 👋") diff --git a/crates/cli/tests/test-projects/effectful/print-line.roc b/crates/cli/tests/test-projects/effectful/print-line.roc index 64a5570934..3f6e049e60 100644 --- a/crates/cli/tests/test-projects/effectful/print-line.roc +++ b/crates/cli/tests/test-projects/effectful/print-line.roc @@ -15,5 +15,5 @@ main! = \{} -> else {} - Effect.put_line!("You entered: $(line)") + Effect.put_line!("You entered: ${line}") Effect.put_line!("It is known") diff --git a/crates/cli/tests/test-projects/effectful/suffixed_record_field.roc b/crates/cli/tests/test-projects/effectful/suffixed_record_field.roc index c417a2388c..e8acfe39f1 100644 --- a/crates/cli/tests/test-projects/effectful/suffixed_record_field.roc +++ b/crates/cli/tests/test-projects/effectful/suffixed_record_field.roc @@ -18,5 +18,5 @@ main! = \{} -> get_line!: Effect.get_line!, } - Effect.put_line!("not_effectful: $(not_effectful.get_line!({}))") - Effect.put_line!("effectful: $(effectful.get_line!({}))") + Effect.put_line!("not_effectful: ${not_effectful.get_line!({})}") + Effect.put_line!("effectful: ${effectful.get_line!({})}") diff --git a/crates/cli/tests/test-projects/effectful/untyped_passed_fx.roc b/crates/cli/tests/test-projects/effectful/untyped_passed_fx.roc index 5e2ef0f030..707883a98b 100644 --- a/crates/cli/tests/test-projects/effectful/untyped_passed_fx.roc +++ b/crates/cli/tests/test-projects/effectful/untyped_passed_fx.roc @@ -7,6 +7,6 @@ main! = \{} -> logged!("hello", \{} -> Effect.put_line!("Hello, World!")) logged! = \name, fx! -> - Effect.put_line!("Before $(name)") + Effect.put_line!("Before ${name}") fx!({}) - Effect.put_line!("After $(name)") + Effect.put_line!("After ${name}") diff --git a/crates/cli/tests/test-projects/false-interpreter/Context.roc b/crates/cli/tests/test-projects/false-interpreter/Context.roc index f0525deba2..bc129a7dd7 100644 --- a/crates/cli/tests/test-projects/false-interpreter/Context.roc +++ b/crates/cli/tests/test-projects/false-interpreter/Context.roc @@ -56,7 +56,7 @@ to_str = \{ scopes, stack, state, vars } -> stack_str = Str.join_with(List.map(stack, to_str_data), " ") vars_str = Str.join_with(List.map(vars, to_str_data), " ") - "\n============\nDepth: $(depth)\nState: $(state_str)\nStack: [$(stack_str)]\nVars: [$(vars_str)]\n============\n" + "\n============\nDepth: ${depth}\nState: ${state_str}\nStack: [${stack_str}]\nVars: [${vars_str}]\n============\n" with! : Str, (Context => a) => a with! = \path, callback! -> diff --git a/crates/cli/tests/test-projects/false-interpreter/main.roc b/crates/cli/tests/test-projects/false-interpreter/main.roc index 5553f4011b..a3527d4bc8 100644 --- a/crates/cli/tests/test-projects/false-interpreter/main.roc +++ b/crates/cli/tests/test-projects/false-interpreter/main.roc @@ -21,7 +21,7 @@ main! = \filename -> {} Err(StringErr(e)) -> - Stdout.line!("Ran into problem:\n$(e)\n") + Stdout.line!("Ran into problem:\n${e}\n") interpret_file! : Str => Result {} [StringErr Str] interpret_file! = \filename -> @@ -44,7 +44,7 @@ interpret_file! = \filename -> Err(StringErr("Ran into an invalid boolean that was neither false (0) or true (-1)")) Err(InvalidChar(char)) -> - Err(StringErr("Ran into an invalid character with ascii code: $(char)")) + Err(StringErr("Ran into an invalid character with ascii code: ${char}")) Err(MaxInputNumber) -> Err(StringErr("Like the original false compiler, the max input number is 320,000")) diff --git a/crates/cli/tests/test-projects/fixtures/packages/main.roc b/crates/cli/tests/test-projects/fixtures/packages/main.roc index 12487fb128..457a17891c 100644 --- a/crates/cli/tests/test-projects/fixtures/packages/main.roc +++ b/crates/cli/tests/test-projects/fixtures/packages/main.roc @@ -7,4 +7,4 @@ app [main] { import json.JsonParser import csv.Csv -main = "Hello, World! $(JsonParser.example) $(Csv.example)" +main = "Hello, World! ${JsonParser.example} ${Csv.example}" diff --git a/crates/cli/tests/test-projects/fixtures/transitive-deps/direct-one-and-two.roc b/crates/cli/tests/test-projects/fixtures/transitive-deps/direct-one-and-two.roc index 1dd3064256..a643e14468 100644 --- a/crates/cli/tests/test-projects/fixtures/transitive-deps/direct-one-and-two.roc +++ b/crates/cli/tests/test-projects/fixtures/transitive-deps/direct-one-and-two.roc @@ -7,4 +7,4 @@ app [main] { import one.One import two.Two -main = "$(One.example) | $(Two.example)" +main = "${One.example} | ${Two.example}" diff --git a/crates/cli/tests/test-projects/fixtures/transitive-deps/one/One.roc b/crates/cli/tests/test-projects/fixtures/transitive-deps/one/One.roc index 2fda762fc2..8adb413a2a 100644 --- a/crates/cli/tests/test-projects/fixtures/transitive-deps/one/One.roc +++ b/crates/cli/tests/test-projects/fixtures/transitive-deps/one/One.roc @@ -2,4 +2,4 @@ module [example] import two.Two -example = "[One imports Two: $(Two.example)]" +example = "[One imports Two: ${Two.example}]" diff --git a/crates/cli/tests/test-projects/fixtures/transitive-deps/zero/Zero.roc b/crates/cli/tests/test-projects/fixtures/transitive-deps/zero/Zero.roc index 96f16afe97..c1bc93aef6 100644 --- a/crates/cli/tests/test-projects/fixtures/transitive-deps/zero/Zero.roc +++ b/crates/cli/tests/test-projects/fixtures/transitive-deps/zero/Zero.roc @@ -2,4 +2,4 @@ module [example] import one.One -example = "[Zero imports One: $(One.example)]" +example = "[Zero imports One: ${One.example}]" diff --git a/crates/cli/tests/test-projects/module_params/Api.roc b/crates/cli/tests/test-projects/module_params/Api.roc index cd407b7122..f8db617be8 100644 --- a/crates/cli/tests/test-projects/module_params/Api.roc +++ b/crates/cli/tests/test-projects/module_params/Api.roc @@ -14,18 +14,18 @@ module { app_id, protocol } -> [ ## value def referencing params base_url : Str base_url = - protocol("api.example.com/$(app_id)") + protocol("api.example.com/${app_id}") ## function def referencing params get_user : U32 -> Str get_user = \user_id -> # purposefully not using baseUrl to test top-level fn referencing param - protocol("api.example.com/$(app_id)/users/$(Num.to_str(user_id))") + protocol("api.example.com/${app_id}/users/${Num.to_str(user_id)}") ## function def referencing top-level value get_post : U32 -> Str get_post = \post_id -> - "$(base_url)/posts/$(Num.to_str(post_id))" + "${base_url}/posts/${Num.to_str(post_id)}" ## function def passing top-level function get_posts : List U32 -> List Str @@ -35,13 +35,13 @@ get_posts = \ids -> ## function def calling top-level function get_post_comments : U32 -> Str get_post_comments = \post_id -> - "$(get_post(post_id))/comments" + "${get_post(post_id)}/comments" ## function def passing nested function get_companies : List U32 -> List Str get_companies = \ids -> get_company = \id -> - protocol("api.example.com/$(app_id)/companies/$(Num.to_str(id))") + protocol("api.example.com/${app_id}/companies/${Num.to_str(id)}") List.map(ids, get_company) @@ -59,11 +59,11 @@ get_post_aliased = get_user_safe : U32 -> Str get_user_safe = if Str.starts_with(app_id, "prod_") then - \id -> "$(get_user(id))?safe=true" + \id -> "${get_user(id)}?safe=true" else get_user ## two-argument function get_post_comment : U32, U32 -> Str get_post_comment = \post_id, comment_id -> - "$(get_post(post_id))/comments/$(Num.to_str(comment_id))" + "${get_post(post_id)}/comments/${Num.to_str(comment_id)}" diff --git a/crates/cli/tests/test-projects/module_params/BadAnn.roc b/crates/cli/tests/test-projects/module_params/BadAnn.roc index 1c67aef608..5c0cb09c5f 100644 --- a/crates/cli/tests/test-projects/module_params/BadAnn.roc +++ b/crates/cli/tests/test-projects/module_params/BadAnn.roc @@ -2,8 +2,8 @@ module { app_id } -> [fn_annotated_as_value, missing_arg] fn_annotated_as_value : Str fn_annotated_as_value = \post_id, comment_id -> - "/posts/$(post_id)/comments/$(Num.to_str(comment_id))" + "/posts/${post_id}/comments/${Num.to_str(comment_id)}" missing_arg : Str -> Str missing_arg = \post_id, _ -> - "/posts/$(post_id)/comments" + "/posts/${post_id}/comments" diff --git a/crates/cli/tests/test-projects/module_params/ImportInExpect.roc b/crates/cli/tests/test-projects/module_params/ImportInExpect.roc index 02bc3a38e6..6ed3e1bd33 100644 --- a/crates/cli/tests/test-projects/module_params/ImportInExpect.roc +++ b/crates/cli/tests/test-projects/module_params/ImportInExpect.roc @@ -1,6 +1,6 @@ module [] -https = \url -> "https://$(url)" +https = \url -> "https://${url}" expect import Api { app_id: "one", protocol: https } diff --git a/crates/cli/tests/test-projects/module_params/Menu.roc b/crates/cli/tests/test-projects/module_params/Menu.roc index 52afd5dd11..b56dc857be 100644 --- a/crates/cli/tests/test-projects/module_params/Menu.roc +++ b/crates/cli/tests/test-projects/module_params/Menu.roc @@ -4,4 +4,4 @@ menu = \name -> indirect(name) indirect = \name -> - echo("Hi, $(name)!") + echo("Hi, ${name}!") diff --git a/crates/cli/tests/test-projects/module_params/app.roc b/crates/cli/tests/test-projects/module_params/app.roc index 692fee536a..763ccd6abc 100644 --- a/crates/cli/tests/test-projects/module_params/app.roc +++ b/crates/cli/tests/test-projects/module_params/app.roc @@ -6,8 +6,8 @@ import Api { app_id: "one", protocol: https } as App1 import Api { app_id: "two", protocol: http } as App2 import Api { app_id: "prod_1", protocol: http } as Prod -https = \url -> "https://$(url)" -http = \url -> "http://$(url)" +https = \url -> "https://${url}" +http = \url -> "http://${url}" users_app1 = # pass top-level fn in a module with params @@ -27,33 +27,33 @@ main = List.map([1, 2, 3], App3.get_user) """ - App1.baseUrl: $(App1.base_url) - App2.baseUrl: $(App2.base_url) - App3.baseUrl: $(App3.base_url) - App1.getUser 1: $(App1.get_user(1)) - App2.getUser 2: $(App2.get_user(2)) - App3.getUser 3: $(App3.get_user(3)) - App1.getPost 1: $(App1.get_post(1)) - App2.getPost 2: $(App2.get_post(2)) - App3.getPost 3: $(App3.get_post(3)) - App1.getPosts [1, 2]: $(Inspect.to_str(App1.get_posts([1, 2]))) - App2.getPosts [3, 4]: $(Inspect.to_str(App2.get_posts([3, 4]))) - App2.getPosts [5, 6]: $(Inspect.to_str(App2.get_posts([5, 6]))) - App1.getPostComments 1: $(App1.get_post_comments(1)) - App2.getPostComments 2: $(App2.get_post_comments(2)) - App2.getPostComments 3: $(App2.get_post_comments(3)) - App1.getCompanies [1, 2]: $(Inspect.to_str(App1.get_companies([1, 2]))) - App2.getCompanies [3, 4]: $(Inspect.to_str(App2.get_companies([3, 4]))) - App2.getCompanies [5, 6]: $(Inspect.to_str(App2.get_companies([5, 6]))) - App1.getPostAliased 1: $(App1.get_post_aliased(1)) - App2.getPostAliased 2: $(App2.get_post_aliased(2)) - App3.getPostAliased 3: $(App3.get_post_aliased(3)) - App1.baseUrlAliased: $(App1.base_url_aliased) - App2.baseUrlAliased: $(App2.base_url_aliased) - App3.baseUrlAliased: $(App3.base_url_aliased) - App1.getUserSafe 1: $(App1.get_user_safe(1)) - Prod.getUserSafe 2: $(Prod.get_user_safe(2)) - usersApp1: $(Inspect.to_str(users_app1)) - getUserApp3Nested 3: $(get_user_app3_nested(3)) - usersApp3Passed: $(Inspect.to_str(users_app3_passed)) + App1.baseUrl: ${App1.base_url} + App2.baseUrl: ${App2.base_url} + App3.baseUrl: ${App3.base_url} + App1.getUser 1: ${App1.get_user(1)} + App2.getUser 2: ${App2.get_user(2)} + App3.getUser 3: ${App3.get_user(3)} + App1.getPost 1: ${App1.get_post(1)} + App2.getPost 2: ${App2.get_post(2)} + App3.getPost 3: ${App3.get_post(3)} + App1.getPosts [1, 2]: ${Inspect.to_str(App1.get_posts([1, 2]))} + App2.getPosts [3, 4]: ${Inspect.to_str(App2.get_posts([3, 4]))} + App2.getPosts [5, 6]: ${Inspect.to_str(App2.get_posts([5, 6]))} + App1.getPostComments 1: ${App1.get_post_comments(1)} + App2.getPostComments 2: ${App2.get_post_comments(2)} + App2.getPostComments 3: ${App2.get_post_comments(3)} + App1.getCompanies [1, 2]: ${Inspect.to_str(App1.get_companies([1, 2]))} + App2.getCompanies [3, 4]: ${Inspect.to_str(App2.get_companies([3, 4]))} + App2.getCompanies [5, 6]: ${Inspect.to_str(App2.get_companies([5, 6]))} + App1.getPostAliased 1: ${App1.get_post_aliased(1)} + App2.getPostAliased 2: ${App2.get_post_aliased(2)} + App3.getPostAliased 3: ${App3.get_post_aliased(3)} + App1.baseUrlAliased: ${App1.base_url_aliased} + App2.baseUrlAliased: ${App2.base_url_aliased} + App3.baseUrlAliased: ${App3.base_url_aliased} + App1.getUserSafe 1: ${App1.get_user_safe(1)} + Prod.getUserSafe 2: ${Prod.get_user_safe(2)} + usersApp1: ${Inspect.to_str(users_app1)} + getUserApp3Nested 3: ${get_user_app3_nested(3)} + usersApp3Passed: ${Inspect.to_str(users_app3_passed)} """ diff --git a/crates/cli/tests/test-projects/module_params/arity_mismatch.roc b/crates/cli/tests/test-projects/module_params/arity_mismatch.roc index a2f600ed34..6199c42662 100644 --- a/crates/cli/tests/test-projects/module_params/arity_mismatch.roc +++ b/crates/cli/tests/test-projects/module_params/arity_mismatch.roc @@ -4,14 +4,14 @@ app [main] { import Api { app_id: "one", protocol: https } -https = \url -> "https://$(url)" +https = \url -> "https://${url}" main = """ # too many args - $(Api.get_user(1, 2)) - $(Api.base_url(1)) + ${Api.get_user(1, 2)} + ${Api.base_url(1)} # too few args - $(Api.get_post_comment(1)) + ${Api.get_post_comment(1)} """ diff --git a/crates/cli/tests/test-projects/module_params/effect_module.roc b/crates/cli/tests/test-projects/module_params/effect_module.roc index 9e745eb553..f816c248d0 100644 --- a/crates/cli/tests/test-projects/module_params/effect_module.roc +++ b/crates/cli/tests/test-projects/module_params/effect_module.roc @@ -1,3 +1,3 @@ module { stdout! } -> [log!] -log! = \msg, level -> stdout!("$(level):$(msg)") +log! = \msg, level -> stdout!("${level}:${msg}") diff --git a/crates/cli/tests/test-projects/module_params/unexpected_fn.roc b/crates/cli/tests/test-projects/module_params/unexpected_fn.roc index 6c3a49a5d9..0f19a2c495 100644 --- a/crates/cli/tests/test-projects/module_params/unexpected_fn.roc +++ b/crates/cli/tests/test-projects/module_params/unexpected_fn.roc @@ -4,7 +4,7 @@ app [main] { import Api { app_id: "one", protocol: https } -https = \url -> "https://$(url)" +https = \url -> "https://${url}" main = - "$(Api.get_post)" + "${Api.get_post}" diff --git a/crates/cli/tests/test-projects/platform_requires_pkg/platform/main.roc b/crates/cli/tests/test-projects/platform_requires_pkg/platform/main.roc index 56565e7ec6..e5c0251616 100644 --- a/crates/cli/tests/test-projects/platform_requires_pkg/platform/main.roc +++ b/crates/cli/tests/test-projects/platform_requires_pkg/platform/main.roc @@ -11,4 +11,4 @@ import foo.Foo main_for_host : Str main_for_host = - "$(main) $(Foo.foo)" + "${main} ${Foo.foo}" diff --git a/crates/compiler/builtins/roc/Dict.roc b/crates/compiler/builtins/roc/Dict.roc index 585b02c504..a061291e78 100644 --- a/crates/compiler/builtins/roc/Dict.roc +++ b/crates/compiler/builtins/roc/Dict.roc @@ -887,7 +887,7 @@ increase_size = \@Dict({ data, max_bucket_capacity, max_load_factor, shifts }) - }, ) else - crash("Dict hit limit of $(Num.to_str(max_bucket_count)) elements. Unable to grow more.") + crash("Dict hit limit of ${Num.to_str(max_bucket_count)} elements. Unable to grow more.") alloc_buckets_from_shift : U8, F32 -> (List Bucket, U64) alloc_buckets_from_shift = \shifts, max_load_factor -> diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index 320cc42532..c7aa005c5b 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -1485,7 +1485,7 @@ for_each! = \list, func! -> ## List.for_each_try!(files_to_delete, \path -> ## File.delete!(path)? ## -## Stdout.line!("$(path) deleted") +## Stdout.line!("${path} deleted") ## ) ## ``` for_each_try! : List a, (a => Result {} err) => Result {} err @@ -1527,14 +1527,15 @@ walk! = \list, state, func! -> ## If the function returns `Err`, the iteration stops and the error is returned. ## ## ``` -## names = try List.walk_try!( +## names = +## List.walk_try!( ## ["First", "Middle", "Last"], ## [], ## \accumulator, which -> -## try Stdout.write! ("$(which) name: ") -## name = try Stdin.line! ({}) -## Ok (List.append accumulator name), -## ) +## Stdout.write!("${which} name: ")? +## name = Stdin.line!({})? +## Ok(List.append(accumulator, name)), +## )? ## ``` ## ## This is the same as [walk_try], except that the step function can have effects. diff --git a/crates/compiler/builtins/roc/Result.roc b/crates/compiler/builtins/roc/Result.roc index eedec3b693..ff7cfec885 100644 --- a/crates/compiler/builtins/roc/Result.roc +++ b/crates/compiler/builtins/roc/Result.roc @@ -124,11 +124,12 @@ on_err = \result, transform -> ## Like [on_err], but it allows the transformation function to produce effects. ## ## ```roc -## Result.on_err(Err("missing user"), (\msg -> -## Stdout.line!("ERROR: $(msg)")? -## -## Err(msg) -## )) +## Result.on_err( +## Err("missing user"), +## \msg -> +## Stdout.line!("ERROR: ${msg}")? +## Err(msg), +## ) ## ``` on_err! : Result a err, (err => Result a other_err) => Result a other_err on_err! = \result, transform! -> diff --git a/crates/compiler/builtins/roc/Str.roc b/crates/compiler/builtins/roc/Str.roc index 9304559dd3..b8196a4244 100644 --- a/crates/compiler/builtins/roc/Str.roc +++ b/crates/compiler/builtins/roc/Str.roc @@ -34,7 +34,7 @@ ## ``` ## name = "Sam" ## -## "Hi, my name is $(name)!" +## "Hi, my name is ${name}!" ## ``` ## ## This will evaluate to the string `"Hi, my name is Sam!"` @@ -44,7 +44,7 @@ ## ``` ## colors = ["red", "green", "blue"] ## -## "The colors are $(colors |> Str.join_with(", "))!" +## "The colors are ${colors |> Str.join_with(", ")}!" ## ``` ## ## Interpolation can be used in multiline strings, but the part inside the parentheses must still be on one line. @@ -800,7 +800,7 @@ replace_first : Str, Str, Str -> Str replace_first = \haystack, needle, flower -> when split_first(haystack, needle) is Ok({ before, after }) -> - "$(before)$(flower)$(after)" + "${before}${flower}${after}" Err(NotFound) -> haystack @@ -818,7 +818,7 @@ replace_last : Str, Str, Str -> Str replace_last = \haystack, needle, flower -> when split_last(haystack, needle) is Ok({ before, after }) -> - "$(before)$(flower)$(after)" + "${before}${flower}${after}" Err(NotFound) -> haystack diff --git a/crates/compiler/can/tests/test_can.rs b/crates/compiler/can/tests/test_can.rs index 92cbc21be2..b42c2afab6 100644 --- a/crates/compiler/can/tests/test_can.rs +++ b/crates/compiler/can/tests/test_can.rs @@ -2157,10 +2157,10 @@ mod test_can { // // This should NOT be string interpolation, because of the \\ // indoc!( // r#" - // "abcd\$(efg)hij" + // "abcd\${efg}hij" // "# // ), - // Str(r"abcd$(efg)hij".into()), + // Str(r"abcd${efg}hij".into()), // ); // } diff --git a/crates/compiler/fmt/src/expr.rs b/crates/compiler/fmt/src/expr.rs index 0e1101fab0..ec9520628a 100644 --- a/crates/compiler/fmt/src/expr.rs +++ b/crates/compiler/fmt/src/expr.rs @@ -922,8 +922,8 @@ fn format_str_segment(seg: &StrSegment, buf: &mut Buf) { buf.push(escaped.to_parsed_char()); } Interpolated(loc_expr) => { - buf.push_str("$("); - // e.g. (name) in "Hi, $(name)!" + buf.push_str("${"); + // e.g. {name} in "Hi, ${name}!" let min_indent = buf.cur_line_indent() + INDENT; loc_expr.value.format_with_options( buf, @@ -932,7 +932,7 @@ fn format_str_segment(seg: &StrSegment, buf: &mut Buf) { min_indent, ); buf.indent(min_indent); - buf.push(')'); + buf.push('}'); } } } diff --git a/crates/compiler/load/tests/test_reporting.rs b/crates/compiler/load/tests/test_reporting.rs index 472aac6243..84ba1a0646 100644 --- a/crates/compiler/load/tests/test_reporting.rs +++ b/crates/compiler/load/tests/test_reporting.rs @@ -5864,7 +5864,7 @@ mod test_reporting { r#" greeting = "Privet" - if Bool.true then 1 else "$(greeting), World!" + if Bool.true then 1 else "${greeting}, World!" "#, ), @r#" @@ -5872,7 +5872,7 @@ mod test_reporting { This `if` has an `else` branch with a different type from its `then` branch: - 6│ if Bool.true then 1 else "$(greeting), World!" + 6│ if Bool.true then 1 else "${greeting}, World!" ^^^^^^^^^^^^^^^^^^^^^ The `else` branch is a string of type: @@ -15052,7 +15052,7 @@ All branches in an `if` must have the same type! u64_nums = parse_items_with Str.to_u64 u8_nums = parse_items_with Str.to_u8 - "$(Inspect.to_str u64_nums) $(Inspect.to_str u8_nums)" + "${Inspect.to_str(u64_nums)} ${Inspect.to_str(u8_nums)}" "# ), @"" // no errors @@ -15304,7 +15304,7 @@ All branches in an `if` must have the same type! get_cheer = \msg -> name = Effect.get_line! {} - "$(msg), $(name)!" + "${msg}, ${name}!" "# ), @r" @@ -15340,7 +15340,7 @@ All branches in an `if` must have the same type! trim : Str -> Str trim = \msg -> - Effect.put_line! "Trimming $(msg)" + Effect.put_line!("Trimming ${msg}") Str.trim msg "# ), @@ -15349,7 +15349,7 @@ All branches in an `if` must have the same type! This call to `Effect.put_line!` might produce an effect: - 10│ Effect.put_line! "Trimming $(msg)" + 10│ Effect.put_line!("Trimming ${msg}") ^^^^^^^^^^^^^^^^ However, the type of the enclosing function requires that it's pure: @@ -15736,7 +15736,7 @@ All branches in an `if` must have the same type! (get, put) = (Effect.get_line!, Effect.put_line!) name = get {} - put "Hi, $(name)" + put "Hi, ${name}" "# ), @r###" @@ -15808,7 +15808,7 @@ All branches in an `if` must have the same type! Tag get put = Tag Effect.get_line! Effect.put_line! name = get {} - put "Hi, $(name)" + put "Hi, ${name}" "# ), @r###" diff --git a/crates/compiler/load_internal/tests/test_load.rs b/crates/compiler/load_internal/tests/test_load.rs index deef83c187..133a473231 100644 --- a/crates/compiler/load_internal/tests/test_load.rs +++ b/crates/compiler/load_internal/tests/test_load.rs @@ -1574,7 +1574,7 @@ fn module_params_checks() { r#" module { key } -> [url] - url = "example.com/$(key)" + url = "example.com/${key}" "# ), ), @@ -1605,7 +1605,7 @@ fn module_params_optional() { r#" module { key, exp ? "default" } -> [url] - url = "example.com/$(key)?exp=$(exp)" + url = "example.com/${key}?exp=${exp}" "# ), ), @@ -1636,7 +1636,7 @@ fn module_params_typecheck_fail() { r#" module { key } -> [url] - url = "example.com/$(key)" + url = "example.com/${key}" "# ), ), @@ -1687,7 +1687,7 @@ fn module_params_missing_fields() { r#" module { key } -> [url] - url = "example.com/$(key)" + url = "example.com/${key}" "# ), ), @@ -1740,7 +1740,7 @@ fn module_params_extra_fields() { r#" module { key } -> [url] - url = "example.com/$(key)" + url = "example.com/${key}" "# ), ), @@ -1839,7 +1839,7 @@ fn module_params_missing() { r#" module { key, exp } -> [url] - url = "example.com/$(key)?exp=$(Num.to_str exp)" + url = "example.com/${key}?exp=${Num.to_str(exp)}" "# ), ), @@ -2169,7 +2169,7 @@ fn roc_package_depends_on_other_package() { r#" module [say] - say = \msg -> "$(msg), world!" + say = \msg -> "${msg}, world!" "# ), ), diff --git a/crates/compiler/module/src/called_via.rs b/crates/compiler/module/src/called_via.rs index 0fac0c3f7c..831e63c0bb 100644 --- a/crates/compiler/module/src/called_via.rs +++ b/crates/compiler/module/src/called_via.rs @@ -75,7 +75,7 @@ pub enum CalledVia { UnaryOp(UnaryOp), /// This call is the result of desugaring string interpolation, - /// e.g. "$(first) $(last)" is transformed into Str.concat (Str.concat first " ") last. + /// e.g. "${first} ${last}" is transformed into `Str.concat(Str.concat(first, " "))` last. StringInterpolation, /// This call is the result of desugaring a map2-based Record Builder field. e.g. diff --git a/crates/compiler/parse/src/string_literal.rs b/crates/compiler/parse/src/string_literal.rs index 2f7e18066e..ae20275cae 100644 --- a/crates/compiler/parse/src/string_literal.rs +++ b/crates/compiler/parse/src/string_literal.rs @@ -425,16 +425,18 @@ pub fn parse_str_like_literal<'a>() -> impl Parser<'a, StrLikeLiteral<'a>, EStri } } } - b'(' if preceded_by_dollar && !is_single_quote => { + b'(' | b'{' if preceded_by_dollar && !is_single_quote => { + let old_style_interpolation_block = one_byte == b'('; + // We're about to begin string interpolation! // // End the previous segment so we can begin a new one. // Retroactively end it right before the `$` char we parsed. // (We can't use end_segment! here because it ends it right after - // the just-parsed character, which here would be '(' rather than '$') + // the just-parsed character, which here would be '{' rather than '$') // Don't push anything if the string would be empty. if segment_parsed_bytes > 2 { - // exclude the 2 chars we just parsed, namely '$' and '(' + // exclude the 2 chars we just parsed, namely '$' and '{' let string_bytes = &state.bytes()[0..(segment_parsed_bytes - 2)]; match std::str::from_utf8(string_bytes) { @@ -452,19 +454,27 @@ pub fn parse_str_like_literal<'a>() -> impl Parser<'a, StrLikeLiteral<'a>, EStri } } - // Advance past the `$(` + // Advance past the `${` state.advance_mut(2); let original_byte_count = state.bytes().len(); - // Parse an arbitrary expression, followed by ')' + // Parse an arbitrary expression, followed by '}' or ')' + let terminating_char = if old_style_interpolation_block { + b')' + } else { + b'}' + }; let (_progress, (mut loc_expr, sp), new_state) = and( specialize_err_ref( EString::Format, loc(allocated(reset_min_indent(expr::expr_help()))) .trace("str_interpolation"), ), - skip_second(space0_e(EString::FormatEnd), byte(b')', EString::FormatEnd)), + skip_second( + space0_e(EString::FormatEnd), + byte(terminating_char, EString::FormatEnd), + ), ) .parse(arena, state, min_indent)?; @@ -488,8 +498,8 @@ pub fn parse_str_like_literal<'a>() -> impl Parser<'a, StrLikeLiteral<'a>, EStri } } - // iff the '$' is followed by '(', this is string interpolation. - // We'll check for the '(' on the next iteration of the loop. + // iff the '$' is followed by '{', this is string interpolation. + // We'll check for the '{' on the next iteration of the loop. preceded_by_dollar = one_byte == b'$'; } diff --git a/crates/compiler/parse/tests/test_parse.rs b/crates/compiler/parse/tests/test_parse.rs index e73ee85f98..c9ceaf8814 100644 --- a/crates/compiler/parse/tests/test_parse.rs +++ b/crates/compiler/parse/tests/test_parse.rs @@ -160,17 +160,17 @@ mod test_parse { #[test] fn escaped_interpolation() { - assert_segments(r#""Hi, \$(name)!""#, |arena| { + assert_segments(r#""Hi, \${name}!""#, |arena| { bumpalo::vec![in arena; Plaintext("Hi, "), EscapedChar(EscapedChar::Dollar), - Plaintext("(name)!"), + Plaintext("{name}!"), ] }); } #[test] - fn string_with_interpolation_in_middle() { + fn string_with_old_interpolation_still_works_for_now() { assert_segments(r#""Hi, $(name)!""#, |arena| { let expr = arena.alloc(Var { module_name: "", @@ -185,9 +185,31 @@ mod test_parse { }); } + #[test] + fn string_with_mixed_new_and_old_interpolation_braces_fails() { + assert_parsing_fails(r#""${foo)""#, SyntaxError::Unexpected(Region::zero())); + assert_parsing_fails(r#""$(foo}""#, SyntaxError::Unexpected(Region::zero())); + } + + #[test] + fn string_with_interpolation_in_middle() { + assert_segments(r#""Hi, ${name}!""#, |arena| { + let expr = arena.alloc(Var { + module_name: "", + ident: "name", + }); + + bumpalo::vec![in arena; + Plaintext("Hi, "), + Interpolated(Loc::new(7, 11, expr)), + Plaintext("!") + ] + }); + } + #[test] fn string_with_interpolation_in_front() { - assert_segments(r#""$(name), hi!""#, |arena| { + assert_segments(r#""${name}, hi!""#, |arena| { let expr = arena.alloc(Var { module_name: "", ident: "name", @@ -232,7 +254,7 @@ mod test_parse { #[test] fn string_with_interpolation_in_back() { - assert_segments(r#""Hello $(name)""#, |arena| { + assert_segments(r#""Hello ${name}""#, |arena| { let expr = arena.alloc(Var { module_name: "", ident: "name", @@ -247,7 +269,7 @@ mod test_parse { #[test] fn string_with_multiple_interpolations() { - assert_segments(r#""Hi, $(name)! How is $(project) going?""#, |arena| { + assert_segments(r#""Hi, ${name}! How is ${project} going?""#, |arena| { let expr1 = arena.alloc(Var { module_name: "", ident: "name", @@ -271,7 +293,7 @@ mod test_parse { #[test] fn string_with_non_interpolation_dollar_signs() { assert_segments( - r#""$a Hi, $(name)! $b How is $(project) going? $c""#, + r#""$a Hi, ${name}! $b How is ${project} going? $c""#, |arena| { let expr1 = arena.alloc(Var { module_name: "", diff --git a/crates/compiler/solve/tests/solve_expr.rs b/crates/compiler/solve/tests/solve_expr.rs index 8c6e02c6e5..cbb8ef592e 100644 --- a/crates/compiler/solve/tests/solve_expr.rs +++ b/crates/compiler/solve/tests/solve_expr.rs @@ -324,7 +324,7 @@ mod solve_expr { r#" what_it_is = "great" - "type inference is $(what_it_is)!" + "type inference is ${what_it_is}!" "# ), "Str", @@ -338,7 +338,7 @@ mod solve_expr { r#" what_it_is = "great" - str = "type inference is $(what_it_is)!" + str = "type inference is ${what_it_is}!" what_it_is "# @@ -354,7 +354,7 @@ mod solve_expr { r#" rec = { what_it_is: "great" } - str = "type inference is $(rec.what_it_is)!" + str = "type inference is ${rec.what_it_is}!" rec "# @@ -4751,7 +4751,7 @@ mod solve_expr { r#" set_roc_email : _ -> { name: Str, email: Str }_ set_roc_email = \person -> - { person & email: "$(person.name)@roclang.com" } + { person & email: "${person.name}@roclang.com" } set_roc_email "# ), diff --git a/crates/compiler/test_gen/src/gen_list.rs b/crates/compiler/test_gen/src/gen_list.rs index cea420c42d..22bfceed2c 100644 --- a/crates/compiler/test_gen/src/gen_list.rs +++ b/crates/compiler/test_gen/src/gen_list.rs @@ -330,7 +330,7 @@ fn list_map_try_ok() { List.map_try [1, 2, 3] \num -> str = Num.to_str (num * 2) - Ok "$(str)!" + Ok "${str}!" "#, // Result Str [] is unwrapped to just Str RocList::::from_slice(&[ @@ -3870,10 +3870,10 @@ fn issue_3571_lowlevel_call_function_with_bool_lambda_set() { List.concat state mapped_vals add2 : Str -> Str - add2 = \x -> "added $(x)" + add2 = \x -> "added ${x}" mul2 : Str -> Str - mul2 = \x -> "multiplied $(x)" + mul2 = \x -> "multiplied ${x}" foo = [add2, mul2] bar = ["1", "2", "3", "4"] diff --git a/crates/compiler/test_gen/src/gen_primitives.rs b/crates/compiler/test_gen/src/gen_primitives.rs index 24e21ca97c..d4334138f0 100644 --- a/crates/compiler/test_gen/src/gen_primitives.rs +++ b/crates/compiler/test_gen/src/gen_primitives.rs @@ -3120,7 +3120,7 @@ fn recursively_build_effect() { hi = "Hello" name = "World" - "$(hi), $(name)!" + "${hi}, ${name}!" main = when nest_help 4 is @@ -3876,8 +3876,8 @@ fn compose_recursive_lambda_set_productive_toplevel() { compose = \f, g -> \x -> g (f x) identity = \x -> x - exclaim = \s -> "$(s)!" - whisper = \s -> "($(s))" + exclaim = \s -> "${s}!" + whisper = \s -> "(${s})" main = res: Str -> Str @@ -3899,8 +3899,8 @@ fn compose_recursive_lambda_set_productive_nested() { compose = \f, g -> \x -> g (f x) identity = \x -> x - exclaim = \s -> "$(s)!" - whisper = \s -> "($(s))" + exclaim = \s -> "${s}!" + whisper = \s -> "(${s})" res: Str -> Str res = List.walk [ exclaim, whisper ] identity compose @@ -3921,8 +3921,8 @@ fn compose_recursive_lambda_set_productive_inferred() { compose = \f, g -> \x -> g (f x) identity = \x -> x - exclaim = \s -> "$(s)!" - whisper = \s -> "($(s))" + exclaim = \s -> "${s}!" + whisper = \s -> "(${s})" res = List.walk [ exclaim, whisper ] identity compose res "hello" @@ -3947,8 +3947,8 @@ fn compose_recursive_lambda_set_productive_nullable_wrapped() { else \x -> f (g x) identity = \x -> x - exclame = \s -> "$(s)!" - whisper = \s -> "($(s))" + exclame = \s -> "${s}!" + whisper = \s -> "(${s})" main = res: Str -> Str @@ -4475,7 +4475,7 @@ fn reset_recursive_type_wraps_in_named_type() { Cons x xs -> str_x = f x str_xs = print_linked_list xs f - "Cons $(str_x) ($(str_xs))" + "Cons ${str_x} (${str_xs})" "# ), RocStr::from("Cons 2 (Cons 3 (Cons 4 (Nil)))"), diff --git a/crates/compiler/test_gen/src/gen_return.rs b/crates/compiler/test_gen/src/gen_return.rs index 9b62fa45e2..4a25db3a68 100644 --- a/crates/compiler/test_gen/src/gen_return.rs +++ b/crates/compiler/test_gen/src/gen_return.rs @@ -37,7 +37,7 @@ fn early_return_nested_ifs() { else third - "$(first), $(second)" + "${first}, ${second}" main : List Str main = List.map [1, 2, 3] display_n @@ -76,7 +76,7 @@ fn early_return_nested_whens() { _ -> third - "$(first), $(second)" + "${first}, ${second}" main : List Str main = List.map [1, 2, 3] display_n diff --git a/crates/compiler/test_mono/src/tests.rs b/crates/compiler/test_mono/src/tests.rs index c59eddaff0..a7e48c8cde 100644 --- a/crates/compiler/test_mono/src/tests.rs +++ b/crates/compiler/test_mono/src/tests.rs @@ -1759,7 +1759,7 @@ fn lambda_capture_niches_with_other_lambda_capture() { when val is _ -> "" - capture2 = \val -> \{} -> "$(val)" + capture2 = \val -> \{} -> "${val}" x : [A, B, C] x = A @@ -2072,7 +2072,7 @@ fn polymorphic_expression_unification() { ] parse_function : Str -> RenderTree parse_function = \name -> - last = Indent [Text ".trace(\"$(name)\")" ] + last = Indent [Text ".trace(\"${name}\")" ] Indent [last] values = parse_function "interface_header" @@ -2636,7 +2636,7 @@ fn recursively_build_effect() { hi = "Hello" name = "World" - "$(hi), $(name)!" + "${hi}, ${name}!" main = when nest_help 4 is @@ -2956,8 +2956,8 @@ fn compose_recursive_lambda_set_productive_nullable_wrapped() { else \x -> f (g x) identity = \x -> x - exclaim = \s -> "$(s)!" - whisper = \s -> "($(s))" + exclaim = \s -> "${s}!" + whisper = \s -> "(${s})" main = res: Str -> Str @@ -3291,7 +3291,7 @@ fn dbg_nested_expr() { fn dbg_inside_string() { indoc!( r#" - "Hello $(dbg "world")!" + "Hello ${dbg "world"}!" "# ) } @@ -3690,7 +3690,7 @@ fn dec_refcount_for_usage_after_early_return_in_if() { else third - "$(first), $(second)" + "${first}, ${second}" display_n 3 "# diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.formatted.roc index 6dcec3e360..80a7b24b8e 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.formatted.roc @@ -1,2 +1,2 @@ -"$(g)" : q +"{(g)" : q f \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.result-ast index e0c51eb4d8..7b63402fbc 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.result-ast @@ -18,15 +18,8 @@ value_defs: [ Annotation( @0-10 StrLiteral( - Line( - [ - Interpolated( - @5-6 Var { - module_name: "", - ident: "g", - }, - ), - ], + PlainLine( + "{(g)", ), ), @11-12 BoundVariable( diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.roc index d02c902bc9..dbe3f487a5 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.roc @@ -1,2 +1,2 @@ -"""$(g)""":q +"""{(g)""":q f diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.formatted.roc index 478e76fed0..79832d1b34 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.formatted.roc @@ -1,5 +1,5 @@ """ """ - "$(i + "${i """ - """)" \ No newline at end of file + """}" \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.result-ast index dfd4fdcbe4..45d1b3eb6d 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.result-ast @@ -1,32 +1,37 @@ -@0-18 Apply( - @0-6 Str( - Block( - [], - ), - ), - [ - @6-18 Str( - Line( - [ - Interpolated( - @9-16 Apply( - @9-10 Var { - module_name: "", - ident: "i", - }, - [ - @10-16 Str( - Block( - [], - ), - ), - ], - Space, - ), - ), - ], +@0-18 SpaceAfter( + Apply( + @0-6 Str( + Block( + [], ), ), + [ + @6-18 Str( + Line( + [ + Interpolated( + @9-16 Apply( + @9-10 Var { + module_name: "", + ident: "i", + }, + [ + @10-16 Str( + Block( + [], + ), + ), + ], + Space, + ), + ), + ], + ), + ), + ], + Space, + ), + [ + Newline, ], - Space, ) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.roc index ffccdc7a55..c479285481 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.roc @@ -1 +1 @@ -"""""""$(i"""""")" \ No newline at end of file +"""""""${i""""""}" diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_interpolation_records.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_interpolation_records.expr.formatted.roc index b50635ea3e..da99e84b09 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_interpolation_records.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_interpolation_records.expr.formatted.roc @@ -1,8 +1,8 @@ """ -$({ +${{ } - i) -$({ + i} +${{ } - i) + i} """ \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_interpolation_records.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_interpolation_records.expr.roc index 86ff6c30c3..35e02f4acf 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_interpolation_records.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_interpolation_records.expr.roc @@ -1,4 +1,4 @@ -"""$({ -}i) -$({ -}i)""" +"""${{ +}i} +${{ +}i}""" diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/parens_comment_in_str_interpolation.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/parens_comment_in_str_interpolation.expr.formatted.roc index f4f394444b..7d310dbca7 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/parens_comment_in_str_interpolation.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/parens_comment_in_str_interpolation.expr.formatted.roc @@ -1,2 +1,2 @@ -"$(S # - )" \ No newline at end of file +"${S # + }" \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/parens_comment_in_str_interpolation.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/parens_comment_in_str_interpolation.expr.roc index f22d10d9b0..e640e8ab6a 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/parens_comment_in_str_interpolation.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/parens_comment_in_str_interpolation.expr.roc @@ -1,2 +1,2 @@ -"$((S# -))" +"${(S# +)}" diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/pizza_question.moduledefs.roc b/crates/compiler/test_syntax/tests/snapshots/pass/pizza_question.moduledefs.roc index 646c9f1d80..0b332d3b7d 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/pizza_question.moduledefs.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/pizza_question.moduledefs.roc @@ -3,5 +3,5 @@ main = |> List.dropFirst 1 |> List.mapTry? Str.toU8 |> List.sum - |> \total -> "Sum of numbers: $(Num.to_str total)" + |> \total -> "Sum of numbers: ${Num.to_str total}" |> Str.toUpper diff --git a/crates/compiler/test_syntax/tests/test_fmt.rs b/crates/compiler/test_syntax/tests/test_fmt.rs index a472237a89..1fa7503bbd 100644 --- a/crates/compiler/test_syntax/tests/test_fmt.rs +++ b/crates/compiler/test_syntax/tests/test_fmt.rs @@ -6575,13 +6575,13 @@ mod test_fmt { expr_formats_to( indoc!( " - x = \"foo:\u{200B} $(bar).\" + x = \"foo:\u{200B} ${bar}.\" x " ), indoc!( r#" - x = "foo:\u(200b) $(bar)." + x = "foo:\u(200b) ${bar}." x "# ), @@ -6595,7 +6595,7 @@ mod test_fmt { " x = \"\"\" - foo:\u{200B} $(bar). + foo:\u{200B} ${bar}. \"\"\" x " @@ -6604,7 +6604,7 @@ mod test_fmt { r#" x = """ - foo:\u(200b) $(bar). + foo:\u(200b) ${bar}. """ x "# diff --git a/crates/compiler/test_syntax/tests/test_snapshots.rs b/crates/compiler/test_syntax/tests/test_snapshots.rs index 4d9c44565d..34088dc997 100644 --- a/crates/compiler/test_syntax/tests/test_snapshots.rs +++ b/crates/compiler/test_syntax/tests/test_snapshots.rs @@ -1032,7 +1032,7 @@ mod test_snapshots { #[test] fn string_with_interpolation_in_middle() { - assert_segments(r#""Hi, $(name)!""#, |arena| { + assert_segments(r#""Hi, ${name}!""#, |arena| { let expr = arena.alloc(Var { module_name: "", ident: "name", @@ -1048,7 +1048,7 @@ mod test_snapshots { #[test] fn string_with_interpolation_in_front() { - assert_segments(r#""$(name), hi!""#, |arena| { + assert_segments(r#""${name}, hi!""#, |arena| { let expr = arena.alloc(Var { module_name: "", ident: "name", @@ -1063,7 +1063,7 @@ mod test_snapshots { #[test] fn string_with_interpolation_in_back() { - assert_segments(r#""Hello $(name)""#, |arena| { + assert_segments(r#""Hello ${name}""#, |arena| { let expr = arena.alloc(Var { module_name: "", ident: "name", @@ -1078,7 +1078,7 @@ mod test_snapshots { #[test] fn string_with_multiple_interpolations() { - assert_segments(r#""Hi, $(name)! How is $(project) going?""#, |arena| { + assert_segments(r#""Hi, ${name}! How is ${project} going?""#, |arena| { let expr1 = arena.alloc(Var { module_name: "", ident: "name", diff --git a/crates/glue/platform/Types.roc b/crates/glue/platform/Types.roc index 1f7146d74e..5b6cdab825 100644 --- a/crates/glue/platform/Types.roc +++ b/crates/glue/platform/Types.roc @@ -48,7 +48,7 @@ shape = \@Types(types), id -> Err(OutOfBounds) -> id_str = Num.to_str(type_id_to_u64(id)) - crash("TypeId #$(id_str) was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at ") + crash("TypeId #${id_str} was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at ") alignment : Types, TypeId -> U32 alignment = \@Types(types), id -> @@ -57,7 +57,7 @@ alignment = \@Types(types), id -> Err(OutOfBounds) -> id_str = Num.to_str(type_id_to_u64(id)) - crash("TypeId #$(id_str) was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at ") + crash("TypeId #${id_str} was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at ") size : Types, TypeId -> U32 size = \@Types(types), id -> @@ -66,4 +66,4 @@ size = \@Types(types), id -> Err(OutOfBounds) -> id_str = Num.to_str(type_id_to_u64(id)) - crash("TypeId #$(id_str) was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at ") + crash("TypeId #${id_str} was not found in Types. This should never happen, and means there was a bug in `roc glue`. If you have time, please open an issue at ") diff --git a/crates/glue/src/RustGlue.roc b/crates/glue/src/RustGlue.roc index acc4fdd4ef..fa717deb61 100644 --- a/crates/glue/src/RustGlue.roc +++ b/crates/glue/src/RustGlue.roc @@ -22,10 +22,10 @@ make_glue = \types_by_arch -> Str.concat( content, """ - #[cfg(target_arch = "$(arch_str)")] - mod $(arch_str); - #[cfg(target_arch = "$(arch_str)")] - pub use $(arch_str)::*; + #[cfg(target_arch = "${arch_str}")] + mod ${arch_str}; + #[cfg(target_arch = "${arch_str}")] + pub use ${arch_str}::*; """, )) @@ -117,7 +117,7 @@ convert_types_to_file = \types -> arch_str = arch_name(arch) { - name: "roc_app/src/$(arch_str).rs", + name: "roc_app/src/${arch_str}.rs", content: content |> generate_entry_points(types), } @@ -135,15 +135,15 @@ generate_entry_point = \buf, types, name, id -> type = type_name(types, arg_id) index_str = Num.to_str(index) - "arg$(index_str): $(type)") + "arg${index_str}: ${type}") ret = type_name(types, roc_fn.ret) - "($(arguments)) -> $(ret)" + "(${arguments}) -> ${ret}" _ -> ret = type_name(types, id) - "() -> $(ret)" + "() -> ${ret}" (extern_signature, return_type_name, returns_fn) = when Types.shape(types, id) is @@ -153,21 +153,21 @@ generate_entry_point = \buf, types, name, id -> type = type_name(types, arg_id) if can_derive_copy(types, shape) then - "_: $(type)" + "_: ${type}" else - "_: &mut core::mem::ManuallyDrop<$(type)>") + "_: &mut core::mem::ManuallyDrop<${type}>") ret = type_name(types, roc_fn.ret) when Types.shape(types, roc_fn.ret) is Function(_) -> - ("(_: *mut u8, $(arguments))", ret, Bool.true) + ("(_: *mut u8, ${arguments})", ret, Bool.true) _ -> - ("(_: *mut $(ret), $(arguments))", ret, Bool.false) + ("(_: *mut ${ret}, ${arguments})", ret, Bool.false) _ -> ret = type_name(types, id) - ("(_: *mut $(ret))", ret, Bool.false) + ("(_: *mut ${ret})", ret, Bool.false) extern_arguments = when Types.shape(types, id) is @@ -176,32 +176,32 @@ generate_entry_point = \buf, types, name, id -> index_str = Num.to_str(index) if can_derive_copy(types, shape) then - "arg$(index_str)" + "arg${index_str}" else - "&mut core::mem::ManuallyDrop::new(arg$(index_str))") + "&mut core::mem::ManuallyDrop::new(arg${index_str})") _ -> "" if returns_fn then """ - $(buf) + ${buf} - pub fn $(name)$(public_signature) { + pub fn ${name}${public_signature} { extern "C" { - fn roc__$(name)_1_exposed_generic$(extern_signature); - fn roc__$(name)_1_exposed_size() -> i64; + fn roc__${name}_1_exposed_generic${extern_signature}; + fn roc__${name}_1_exposed_size() -> i64; } unsafe { - let capacity = roc__$(name)_1_exposed_size() as usize; + let capacity = roc__${name}_1_exposed_size() as usize; - let mut ret = $(return_type_name) { + let mut ret = ${return_type_name} { closure_data: Vec::with_capacity(capacity), }; ret.closure_data.resize(capacity, 0); - roc__$(name)_1_exposed_generic(ret.closure_data.as_mut_ptr(), $(extern_arguments)); + roc__${name}_1_exposed_generic(ret.closure_data.as_mut_ptr(), ${extern_arguments}); ret } @@ -209,17 +209,17 @@ generate_entry_point = \buf, types, name, id -> """ else """ - $(buf) + ${buf} - pub fn $(name)$(public_signature) { + pub fn ${name}${public_signature} { extern "C" { - fn roc__$(name)_1_exposed_generic$(extern_signature); + fn roc__${name}_1_exposed_generic${extern_signature}; } let mut ret = core::mem::MaybeUninit::uninit(); unsafe { - roc__$(name)_1_exposed_generic(ret.as_mut_ptr(), $(extern_arguments)); + roc__${name}_1_exposed_generic(ret.as_mut_ptr(), ${extern_arguments}); ret.assume_init() } @@ -236,7 +236,7 @@ generate_function = \buf, types, roc_fn -> type = type_name(types, arg_id) index_str = Num.to_str(index) - "arg$(index_str): $(type)") + "arg${index_str}: ${type}") extern_def_arguments = without_unit = @@ -244,7 +244,7 @@ generate_function = \buf, types, roc_fn -> type = type_name(types, arg_id) index_str = Num.to_str(index) - "arg$(index_str): *const $(type)") + "arg${index_str}: *const ${type}") if Str.is_empty(without_unit) then # These always have a first argument that's a pointer, even if it's to nothing. @@ -257,7 +257,7 @@ generate_function = \buf, types, roc_fn -> to_arg_str(roc_fn.args, types, \_argId, _shape, index -> index_str = Num.to_str(index) - "&arg$(index_str)") + "&arg${index_str}") if Str.is_empty(without_unit) then # These always have a first argument that's a pointer, even if it's to nothing. @@ -270,24 +270,24 @@ generate_function = \buf, types, roc_fn -> ret = type_name(types, roc_fn.ret) """ - $(buf) + ${buf} #[repr(C)] #[derive(Debug)] - pub struct $(name) { + pub struct ${name} { closure_data: Vec, } - impl $(name) { - pub fn force_thunk(mut self$(public_comma)$(public_arguments)) -> $(ret) { + impl ${name} { + pub fn force_thunk(mut self${public_comma}${public_arguments}) -> ${ret} { extern "C" { - fn $(extern_name)($(extern_def_arguments), closure_data: *mut u8, output: *mut $(ret)); + fn ${extern_name}(${extern_def_arguments}, closure_data: *mut u8, output: *mut ${ret}); } let mut output = core::mem::MaybeUninit::uninit(); unsafe { - $(extern_name)($(extern_call_arguments), self.closure_data.as_mut_ptr(), output.as_mut_ptr()); + ${extern_name}(${extern_call_arguments}, self.closure_data.as_mut_ptr(), output.as_mut_ptr()); output.assume_init() } @@ -318,7 +318,7 @@ generate_struct = \buf, types, id, name, struct_fields, visibility -> buf |> generate_derive_str(types, struct_type, IncludeDebug) - |> Str.concat("#[repr($(repr))]\n$(pub)struct $(escaped_name) {\n") + |> Str.concat("#[repr(${repr})]\n${pub}struct ${escaped_name} {\n") |> generate_struct_fields(types, Public, struct_fields) |> Str.concat("}\n\n") |> generate_roc_refcounted(types, struct_type, escaped_name) @@ -341,18 +341,18 @@ generate_struct_field_without_closure = \types, visibility -> Public -> "pub" Private -> "" - Str.concat(accum, "$(indent)$(pub) $(escaped_field_name): $(type_str),\n") + Str.concat(accum, "${indent}${pub} ${escaped_field_name}: ${type_str},\n") name_tag_union_payload_fields = \payload_fields -> # Tag union payloads have numbered fields, so we prefix them # with an "f" because Rust doesn't allow struct fields to be numbers. when payload_fields is HasNoClosure(fields) -> - renamed_fields = List.map(fields, \{ name, id } -> { name: "f$(name)", id }) + renamed_fields = List.map(fields, \{ name, id } -> { name: "f${name}", id }) HasNoClosure(renamed_fields) HasClosure(fields) -> - renamed_fields = List.map(fields, \{ name, id, accessors } -> { name: "f$(name)", id, accessors }) + renamed_fields = List.map(fields, \{ name, id, accessors } -> { name: "f${name}", id, accessors }) HasClosure(renamed_fields) generate_enumeration = \buf, types, enum_type, name, tags, tag_bytes -> @@ -362,7 +362,7 @@ generate_enumeration = \buf, types, enum_type, name, tags, tag_bytes -> buf |> generate_derive_str(types, enum_type, ExcludeDebug) - |> Str.concat("#[repr(u$(repr_bits))]\npub enum $(escaped_name) {\n") + |> Str.concat("#[repr(u${repr_bits})]\npub enum ${escaped_name} {\n") |> \b -> List.walk_with_index(tags, b, generate_enum_tags) |> # Enums require a custom debug impl to ensure naming is identical on all platforms. @@ -370,45 +370,45 @@ generate_enumeration = \buf, types, enum_type, name, tags, tag_bytes -> """ } - impl core::fmt::Debug for $(escaped_name) { + impl core::fmt::Debug for ${escaped_name} { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { """, ) |> \b -> List.walk(tags, b, generate_enum_tags_debug(name)) - |> Str.concat("$(indent)$(indent)}\n$(indent)}\n}\n\n") + |> Str.concat("${indent}${indent}}\n${indent}}\n}\n\n") |> generate_roc_refcounted(types, enum_type, escaped_name) generate_enum_tags = \accum, name, index -> index_str = Num.to_str(index) - Str.concat(accum, "$(indent)$(name) = $(index_str),\n") + Str.concat(accum, "${indent}${name} = ${index_str},\n") generate_enum_tags_debug = \name -> \accum, tag_name -> - Str.concat(accum, "$(indent)$(indent)$(indent)Self::$(tag_name) => f.write_str(\"$(name)::$(tag_name)\"),\n") + Str.concat(accum, "${indent}${indent}${indent}Self::${tag_name} => f.write_str(\"${name}::${tag_name}\"),\n") derive_clone_tag_union : Str, Str, List { name : Str, payload : [Some TypeId, None] } -> Str derive_clone_tag_union = \buf, tag_union_type, tags -> clones = List.walk(tags, "", \accum, { name: tag_name } -> """ - $(accum) - $(tag_name) => union_$(tag_union_type) { - $(tag_name): self.payload.$(tag_name).clone(), + ${accum} + ${tag_name} => union_${tag_union_type} { + ${tag_name}: self.payload.${tag_name}.clone(), }, """) """ - $(buf) + ${buf} - impl Clone for $(tag_union_type) { + impl Clone for ${tag_union_type} { fn clone(&self) -> Self { - use discriminant_$(tag_union_type)::*; + use discriminant_${tag_union_type}::*; let payload = unsafe { - match self.discriminant {$(clones) + match self.discriminant {${clones} } }; @@ -430,22 +430,22 @@ derive_debug_tag_union = \buf, types, tag_union_type, tags -> None -> "()" """ - $(accum) - $(tag_name) => { - let field: &$(type) = &self.payload.$(tag_name); - f.debug_tuple("$(tag_union_type)::$(tag_name)").field(field).finish() + ${accum} + ${tag_name} => { + let field: &${type} = &self.payload.${tag_name}; + f.debug_tuple("${tag_union_type}::${tag_name}").field(field).finish() }, """) """ - $(buf) + ${buf} - impl core::fmt::Debug for $(tag_union_type) { + impl core::fmt::Debug for ${tag_union_type} { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - use discriminant_$(tag_union_type)::*; + use discriminant_${tag_union_type}::*; unsafe { - match self.discriminant {$(checks) + match self.discriminant {${checks} } } } @@ -456,9 +456,9 @@ derive_eq_tag_union : Str, Types, Shape, Str -> Str derive_eq_tag_union = \buf, types, shape, tag_union_type -> if can_support_eq_hash_ord(types, shape) then """ - $(buf) + ${buf} - impl Eq for $(tag_union_type) {} + impl Eq for ${tag_union_type} {} """ else buf @@ -469,23 +469,23 @@ derive_partial_eq_tag_union = \buf, types, shape, tag_union_type, tags -> checks = List.walk(tags, "", \accum, { name: tag_name } -> """ - $(accum) - $(tag_name) => self.payload.$(tag_name) == other.payload.$(tag_name), + ${accum} + ${tag_name} => self.payload.${tag_name} == other.payload.${tag_name}, """) """ - $(buf) + ${buf} - impl PartialEq for $(tag_union_type) { + impl PartialEq for ${tag_union_type} { fn eq(&self, other: &Self) -> bool { - use discriminant_$(tag_union_type)::*; + use discriminant_${tag_union_type}::*; if self.discriminant != other.discriminant { return false; } unsafe { - match self.discriminant {$(checks) + match self.discriminant {${checks} } } } @@ -498,9 +498,9 @@ derive_ord_tag_union : Str, Types, Shape, Str -> Str derive_ord_tag_union = \buf, types, shape, tag_union_type -> if can_support_eq_hash_ord(types, shape) then """ - $(buf) + ${buf} - impl Ord for $(tag_union_type) { + impl Ord for ${tag_union_type} { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.partial_cmp(other).unwrap() } @@ -515,16 +515,16 @@ derive_partial_ord_tag_union = \buf, types, shape, tag_union_type, tags -> checks = List.walk(tags, "", \accum, { name: tag_name } -> """ - $(accum) - $(tag_name) => self.payload.$(tag_name).partial_cmp(&other.payload.$(tag_name)), + ${accum} + ${tag_name} => self.payload.${tag_name}.partial_cmp(&other.payload.${tag_name}), """) """ - $(buf) + ${buf} - impl PartialOrd for $(tag_union_type) { + impl PartialOrd for ${tag_union_type} { fn partial_cmp(&self, other: &Self) -> Option { - use discriminant_$(tag_union_type)::*; + use discriminant_${tag_union_type}::*; use std::cmp::Ordering::*; @@ -532,7 +532,7 @@ derive_partial_ord_tag_union = \buf, types, shape, tag_union_type, tags -> Less => Option::Some(Less), Greater => Option::Some(Greater), Equal => unsafe { - match self.discriminant {$(checks) + match self.discriminant {${checks} } }, } @@ -548,19 +548,19 @@ derive_hash_tag_union = \buf, types, shape, tag_union_type, tags -> checks = List.walk(tags, "", \accum, { name: tag_name } -> """ - $(accum) - $(tag_name) => self.payload.$(tag_name).hash(state), + ${accum} + ${tag_name} => self.payload.${tag_name}.hash(state), """) """ - $(buf) + ${buf} - impl core::hash::Hash for $(tag_union_type) { + impl core::hash::Hash for ${tag_union_type} { fn hash(&self, state: &mut H) { - use discriminant_$(tag_union_type)::*; + use discriminant_${tag_union_type}::*; unsafe { - match self.discriminant {$(checks) + match self.discriminant {${checks} } } } @@ -572,7 +572,7 @@ derive_hash_tag_union = \buf, types, shape, tag_union_type, tags -> generate_constructor_functions : Str, Types, Str, List { name : Str, payload : [Some TypeId, None] } -> Str generate_constructor_functions = \buf, types, tag_union_type, tags -> buf - |> Str.concat("\n\nimpl $(tag_union_type) {") + |> Str.concat("\n\nimpl ${tag_union_type} {") |> \b -> List.walk(tags, b, \accum, r -> generate_constructor_function(accum, types, tag_union_type, r.name, r.payload)) |> Str.concat("\n}\n\n") @@ -581,13 +581,13 @@ generate_constructor_function = \buf, types, tag_union_type, name, opt_payload - when opt_payload is None -> """ - $(buf) + ${buf} - pub fn $(name)() -> Self { + pub fn ${name}() -> Self { Self { - discriminant: discriminant_$(tag_union_type)::$(name), - payload: union_$(tag_union_type) { - $(name): (), + discriminant: discriminant_${tag_union_type}::${name}, + payload: union_${tag_union_type} { + ${name}: (), } } } @@ -604,13 +604,13 @@ generate_constructor_function = \buf, types, tag_union_type, name, opt_payload - "core::mem::ManuallyDrop::new(payload)" """ - $(buf) + ${buf} - pub fn $(name)(payload: $(payload_type)) -> Self { + pub fn ${name}(payload: ${payload_type}) -> Self { Self { - discriminant: discriminant_$(tag_union_type)::$(name), - payload: union_$(tag_union_type) { - $(name): $(new), + discriminant: discriminant_${tag_union_type}::${name}, + payload: union_${tag_union_type} { + ${name}: ${new}, } } } @@ -619,7 +619,7 @@ generate_constructor_function = \buf, types, tag_union_type, name, opt_payload - generate_destructor_functions : Str, Types, Str, List { name : Str, payload : [Some TypeId, None] } -> Str generate_destructor_functions = \buf, types, tag_union_type, tags -> buf - |> Str.concat("\n\nimpl $(tag_union_type) {") + |> Str.concat("\n\nimpl ${tag_union_type} {") |> \b -> List.walk(tags, b, \accum, r -> generate_destructor_function(accum, types, tag_union_type, r.name, r.payload)) |> Str.concat("\n}\n\n") @@ -628,10 +628,10 @@ generate_destructor_function = \buf, types, tag_union_type, name, opt_payload -> when opt_payload is None -> """ - $(buf) + ${buf} - pub fn is_$(name)(&self) -> bool { - matches!(self.discriminant, discriminant_$(tag_union_type)::$(name)) + pub fn is_${name}(&self) -> bool { + matches!(self.discriminant, discriminant_${tag_union_type}::${name}) } """ @@ -641,62 +641,62 @@ generate_destructor_function = \buf, types, tag_union_type, name, opt_payload -> take = if can_derive_copy(types, shape) then - "unsafe { self.payload.$(name) }" + "unsafe { self.payload.${name} }" else - "unsafe { core::mem::ManuallyDrop::take(&mut self.payload.$(name)) }" + "unsafe { core::mem::ManuallyDrop::take(&mut self.payload.${name}) }" (borrow, borrow_type) = if can_derive_copy(types, shape) then - ("unsafe { self.payload.$(name) }", payload_type) + ("unsafe { self.payload.${name} }", payload_type) else ( """ use core::borrow::Borrow; - unsafe { self.payload.$(name).borrow() } + unsafe { self.payload.${name}.borrow() } """, - "&$(payload_type)", + "&${payload_type}", ) (borrow_mut, borrow_mut_type) = if can_derive_copy(types, shape) then - ("unsafe { &mut self.payload.$(name) }", "&mut $(payload_type)") + ("unsafe { &mut self.payload.${name} }", "&mut ${payload_type}") else ( """ use core::borrow::BorrowMut; - unsafe { self.payload.$(name).borrow_mut() } + unsafe { self.payload.${name}.borrow_mut() } """, - "&mut $(payload_type)", + "&mut ${payload_type}", ) """ - $(buf) + ${buf} - pub fn unwrap_$(name)(mut self) -> $(payload_type) { - debug_assert_eq!(self.discriminant, discriminant_$(tag_union_type)::$(name)); - $(take) + pub fn unwrap_${name}(mut self) -> ${payload_type} { + debug_assert_eq!(self.discriminant, discriminant_${tag_union_type}::${name}); + ${take} } - pub fn borrow_$(name)(&self) -> $(borrow_type) { - debug_assert_eq!(self.discriminant, discriminant_$(tag_union_type)::$(name)); - $(borrow) + pub fn borrow_${name}(&self) -> ${borrow_type} { + debug_assert_eq!(self.discriminant, discriminant_${tag_union_type}::${name}); + ${borrow} } - pub fn borrow_mut_$(name)(&mut self) -> $(borrow_mut_type) { - debug_assert_eq!(self.discriminant, discriminant_$(tag_union_type)::$(name)); - $(borrow_mut) + pub fn borrow_mut_${name}(&mut self) -> ${borrow_mut_type} { + debug_assert_eq!(self.discriminant, discriminant_${tag_union_type}::${name}); + ${borrow_mut} } - pub fn is_$(name)(&self) -> bool { - matches!(self.discriminant, discriminant_$(tag_union_type)::$(name)) + pub fn is_${name}(&self) -> bool { + matches!(self.discriminant, discriminant_${tag_union_type}::${name}) } """ generate_non_recursive_tag_union : Str, Types, TypeId, Str, List { name : Str, payload : [Some TypeId, None] }, U32, U32 -> Str generate_non_recursive_tag_union = \buf, types, id, name, tags, discriminant_size, discriminant_offset -> escaped_name = escape_kw(name) - discriminant_name = "discriminant_$(escaped_name)" - union_name = "union_$(escaped_name)" + discriminant_name = "discriminant_${escaped_name}" + union_name = "union_${escaped_name}" discriminant_offset_str = Num.to_str(discriminant_offset) tag_names = List.map(tags, \{ name: n } -> n) self_mut = "self" @@ -735,35 +735,35 @@ generate_non_recursive_tag_union = \buf, types, id, name, tags, discriminant_siz buf |> generate_discriminant(types, discriminant_name, tag_names, discriminant_size) - |> Str.concat("#[repr(C, align($(align)))]\npub union $(union_name) {\n") + |> Str.concat("#[repr(C, align(${align}))]\npub union ${union_name} {\n") |> \b -> List.walk(tags, b, generate_union_field(types)) |> Str.concat( """ } // TODO(@roc-lang): See https://github.com/roc-lang/roc/issues/6012 - // const _SIZE_CHECK_$(union_name): () = assert!(core::mem::size_of::<$(union_name)>() == $(size_of_union_str)); - const _ALIGN_CHECK_$(union_name): () = assert!(core::mem::align_of::<$(union_name)>() == $(align_of_union_str)); + // const _SIZE_CHECK_${union_name}: () = assert!(core::mem::size_of::<${union_name}>() == ${size_of_union_str}); + const _ALIGN_CHECK_${union_name}: () = assert!(core::mem::align_of::<${union_name}>() == ${align_of_union_str}); - const _SIZE_CHECK_$(escaped_name): () = assert!(core::mem::size_of::<$(escaped_name)>() == $(size_of_self)); - const _ALIGN_CHECK_$(escaped_name): () = assert!(core::mem::align_of::<$(escaped_name)>() == $(align_of_self)); + const _SIZE_CHECK_${escaped_name}: () = assert!(core::mem::size_of::<${escaped_name}>() == ${size_of_self}); + const _ALIGN_CHECK_${escaped_name}: () = assert!(core::mem::align_of::<${escaped_name}>() == ${align_of_self}); - impl $(escaped_name) { - $(discriminant_doc_comment) - pub fn discriminant(&self) -> $(discriminant_name) { + impl ${escaped_name} { + ${discriminant_doc_comment} + pub fn discriminant(&self) -> ${discriminant_name} { unsafe { let bytes = core::mem::transmute::<&Self, &[u8; core::mem::size_of::()]>(self); - core::mem::transmute::(*bytes.as_ptr().add($(discriminant_offset_str))) + core::mem::transmute::(*bytes.as_ptr().add(${discriminant_offset_str})) } } /// Internal helper - fn set_discriminant(&mut self, discriminant: $(discriminant_name)) { - let discriminant_ptr: *mut $(discriminant_name) = (self as *mut $(escaped_name)).cast(); + fn set_discriminant(&mut self, discriminant: ${discriminant_name}) { + let discriminant_ptr: *mut ${discriminant_name} = (self as *mut ${escaped_name}).cast(); unsafe { - *(discriminant_ptr.add($(discriminant_offset_str))) = discriminant; + *(discriminant_ptr.add(${discriminant_offset_str})) = discriminant; } } } @@ -774,9 +774,9 @@ generate_non_recursive_tag_union = \buf, types, id, name, tags, discriminant_siz |> Str.concat( """ #[repr(C)] - pub struct $(escaped_name) { - payload: union_$(escaped_name), - discriminant: discriminant_$(escaped_name), + pub struct ${escaped_name} { + payload: union_${escaped_name}, + discriminant: discriminant_${escaped_name}, } """, ) @@ -795,7 +795,7 @@ generate_non_recursive_tag_union = \buf, types, id, name, tags, discriminant_siz b |> Str.concat( """ - impl Drop for $(escaped_name) { + impl Drop for ${escaped_name} { fn drop(&mut self) { // Drop the payloads @@ -816,7 +816,7 @@ generate_non_recursive_tag_union = \buf, types, id, name, tags, discriminant_siz generate_non_nullable_unwrapped = \buf, types, name, tag_name, payload, discriminant_size, _discriminant_offset, _null_tagIndex -> escaped_name = escape_kw(name) - discriminant_name = "discriminant_$(escaped_name)" + discriminant_name = "discriminant_${escaped_name}" payload_fields = when Types.shape(types, payload) is @@ -831,19 +831,19 @@ generate_non_nullable_unwrapped = \buf, types, name, tag_name, payload, discrimi payload_field_names = comma_separated("", payload_fields, \_, i -> n = Num.to_str(i) - "f$(n)") + "f${n}") constructor_arguments = comma_separated("", payload_fields, \id, i -> n = Num.to_str(i) type = type_name(types, id) - "f$(n): $(type)") + "f${n}: ${type}") debug_fields = payload_fields |> List.map_with_index(\_, i -> n = Num.to_str(i) - ".field(&node.f$(n))") + ".field(&node.f${n})") |> Str.join_with("") buf1 = buf |> generate_discriminant(types, discriminant_name, [tag_name], discriminant_size) @@ -851,24 +851,24 @@ generate_non_nullable_unwrapped = \buf, types, name, tag_name, payload, discrimi union_type = TagUnion(NonNullableUnwrapped({ name, tag_name, payload })) """ - $(buf1) + ${buf1} #[repr(transparent)] #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash)] - pub struct $(escaped_name)(roc_std::RocBox<$(name)_$(tag_name)>); + pub struct ${escaped_name}(roc_std::RocBox<${name}_${tag_name}>); - impl $(escaped_name) { - pub fn $(tag_name)($(constructor_arguments)) -> Self { - let payload = $(name)_$(tag_name) { $(payload_field_names) }; + impl ${escaped_name} { + pub fn ${tag_name)(${constructor_arguments}) -> Self { + let payload = ${name}_${tag_name} { ${payload_field_names} }; Self(roc_std::RocBox::new(payload)) } } - impl core::fmt::Debug for $(escaped_name) { + impl core::fmt::Debug for ${escaped_name} { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let node = &self.0; - f.debug_tuple("$(escaped_name)::$(tag_name)")$(debug_fields).finish() + f.debug_tuple("${escaped_name}::${tag_name}")${debug_fields}.finish() } } """ @@ -876,23 +876,23 @@ generate_non_nullable_unwrapped = \buf, types, name, tag_name, payload, discrimi generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discriminant_size, _discriminant_offset, null_tag_index -> escaped_name = escape_kw(tag_union_name) - discriminant_name = "discriminant_$(escaped_name)" + discriminant_name = "discriminant_${escaped_name}" tag_names = List.map(tags, \{ name: n } -> n) # self = "(&*self.union_pointer())" # selfMut = "(&mut *self.union_pointer())" # other = "(&*other.union_pointer())" - union_name = "union_$(escaped_name)" + union_name = "union_${escaped_name}" discriminants = tag_names |> Str.join_with(", ") - |> \b -> "[ $(b) ]" + |> \b -> "[ ${b} ]" null_tag_id = when null_tag_index is Some(index) -> n = Num.to_str(index) - "discriminants[$(n)]" + "discriminants[${n}]" None -> """ @@ -924,15 +924,15 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina i: i + 1, accum: """ - $(accum) - pub fn get_$(tag_name)_f$(field_index)(&self) -> &$(field_type_name) { - debug_assert!(self.is_$(tag_name)()); + ${accum} + pub fn get_${tag_name}_f${field_index}(&self) -> &${field_type_name} { + debug_assert!(self.is_${tag_name}()); // extern "C" { // fn foobar(tag_id: u16, field_index: usize) -> usize; // } - // let offset = unsafe { foobar($(field_index)) }; + // let offset = unsafe { foobar(${field_index}) }; let offset = 0; unsafe { &*self.unmasked_pointer().add(offset).cast() } } @@ -944,13 +944,13 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina payload_field_names = comma_separated("", payload_fields, \_, i -> n = Num.to_str(i) - "f$(n)") + "f${n}") constructor_arguments = comma_separated("", payload_fields, \payload_id, i -> n = Num.to_str(i) type = type_name(types, payload_id) - "f$(n): $(type)") + "f${n}: ${type}") fix_manually_drop = when opt_payload is @@ -967,37 +967,37 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina if Some(Num.int_cast(index)) == null_tag_index then """ - pub fn is_$(tag_name)(&self) -> bool { - matches!(self.discriminant(), discriminant_$(escaped_name)::$(tag_name)) + pub fn is_${tag_name}(&self) -> bool { + matches!(self.discriminant(), discriminant_${escaped_name}::${tag_name}) } - pub fn $(tag_name)($(constructor_arguments)) -> Self { + pub fn ${tag_name}(${constructor_arguments}) -> Self { Self(std::ptr::null_mut()) } """ else """ - pub fn is_$(tag_name)(&self) -> bool { - matches!(self.discriminant(), discriminant_$(escaped_name)::$(tag_name)) + pub fn is_${tag_name}(&self) -> bool { + matches!(self.discriminant(), discriminant_${escaped_name}::${tag_name}) } - pub fn $(tag_name)($(constructor_arguments)) -> Self { - let tag_id = discriminant_$(escaped_name)::$(tag_name); + pub fn ${tag_name}(${constructor_arguments}) -> Self { + let tag_id = discriminant_${escaped_name}::${tag_name}; - let payload = $(escaped_name)_$(tag_name) { $(payload_field_names) } ; + let payload = ${escaped_name}_${tag_name} { ${payload_field_names} } ; - let union_payload = union_$(escaped_name) { $(tag_name): $(fix_manually_drop) }; + let union_payload = union_${escaped_name} { ${tag_name}: ${fix_manually_drop} }; let ptr = unsafe { roc_std::RocBox::leak(roc_std::RocBox::new(union_payload)) }; Self((ptr as usize | tag_id as usize) as *mut _) } - $(field_getters) + ${field_getters} - pub fn get_$(tag_name)(mut self) -> $(escaped_name)_$(tag_name) { - debug_assert!(self.is_$(tag_name)()); + pub fn get_${tag_name}(mut self) -> ${escaped_name}_${tag_name} { + debug_assert!(self.is_${tag_name}()); - unsafe { core::mem::ManuallyDrop::take(&mut self.ptr_read_union().$(tag_name)) } + unsafe { core::mem::ManuallyDrop::take(&mut self.ptr_read_union().{dtag_name}) } } """ @@ -1009,16 +1009,16 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina clone_case = \{ name: tag_name }, index -> if Some(Num.int_cast(index)) == null_tag_index then """ - $(tag_name) => Self::$(tag_name)(), + ${tag_name} => Self::${tag_name}(), """ else """ - $(tag_name) => { - let tag_id = discriminant_$(escaped_name)::$(tag_name); + ${tag_name} => { + let tag_id = discriminant_${escaped_name}::${tag_name}; let payload_union = unsafe { self.ptr_read_union() }; - let payload = union_$(escaped_name) { - $(tag_name): unsafe { payload_union.$(tag_name).clone() }, + let payload = union_${escaped_name} { + ${tag_name}: unsafe { payload_union.${tag_name}.clone() }, }; let ptr = unsafe { roc_std::RocBox::leak(roc_std::RocBox::new(payload)) }; @@ -1035,16 +1035,16 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina partial_eq_case = \{ name: tag_name }, index -> if Some(Num.int_cast(index)) == null_tag_index then """ - $(tag_name) => true, + ${tag_name} => true, """ else """ - $(tag_name) => { + ${tag_name} => { let payload_union1 = unsafe { self.ptr_read_union() }; let payload_union2 = unsafe { other.ptr_read_union() }; unsafe { - payload_union1.$(tag_name) == payload_union2.$(tag_name) + payload_union1.${tag_name} == payload_union2.${tag_name} } }, """ @@ -1057,21 +1057,21 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina partial_eq_impl = if can_support_partial_eq_ord(types, Types.shape(types, id)) then """ - impl PartialEq for $(escaped_name) { + impl PartialEq for ${escaped_name} { fn eq(&self, other: &Self) -> bool { - use discriminant_$(escaped_name)::*; + use discriminant_${escaped_name}::*; if self.discriminant() != other.discriminant() { return false; } match self.discriminant() { - $(partial_eq_cases) + ${partial_eq_cases} } } } - impl Eq for $(escaped_name) {} + impl Eq for ${escaped_name} {} """ else "" @@ -1079,7 +1079,7 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina debug_case = \{ name: tag_name, payload: opt_payload }, index -> if Some(Num.int_cast(index)) == null_tag_index then """ - $(tag_name) => f.debug_tuple("$(escaped_name)::$(tag_name)").finish(), + ${tag_name} => f.debug_tuple("${escaped_name}::${tag_name}").finish(), """ else payload_fields = @@ -1101,15 +1101,15 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina payload_fields |> List.map_with_index(\_, i -> n = Num.to_str(i) - ".field(&payload_union.$(tag_name).f$(n))") + ".field(&payload_union.${tag_name}.f${n})") |> Str.join_with("") """ - $(tag_name) => { + ${tag_name} => { let payload_union = unsafe { self.ptr_read_union() }; unsafe { - f.debug_tuple("$(escaped_name)::$(tag_name)")$(debug_fields).finish() + f.debug_tuple("${escaped_name}::${tag_name}")${debug_fields}.finish() } }, """ @@ -1122,13 +1122,13 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina hash_case = \{ name: tag_name }, index -> if Some(Num.int_cast(index)) == null_tag_index then """ - $(tag_name) => {} + ${tag_name} => {} """ else """ - $(tag_name) => { + ${tag_name} => { let payload_union = unsafe { self.ptr_read_union() }; - unsafe { payload_union.$(tag_name).hash(state) }; + unsafe { payload_union.${tag_name}.hash(state) }; }, """ @@ -1141,14 +1141,14 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina hash_impl = if can_support_partial_eq_ord(types, union_type) then """ - impl core::hash::Hash for $(escaped_name) { + impl core::hash::Hash for ${escaped_name} { fn hash(&self, state: &mut H) { - use discriminant_$(escaped_name)::*; + use discriminant_${escaped_name}::*; self.discriminant().hash(state); match self.discriminant() { - $(hash_cases) + ${hash_cases} } } } @@ -1159,16 +1159,16 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina partial_ord_case = \{ name: tag_name }, index -> if Some(Num.int_cast(index)) == null_tag_index then """ - $(tag_name) => std::cmp::Ordering::Equal, + ${tag_name} => std::cmp::Ordering::Equal, """ else """ - $(tag_name) => { + ${tag_name} => { let payload_union1 = unsafe { self.ptr_read_union() }; let payload_union2 = unsafe { other.ptr_read_union() }; unsafe { - payload_union1.$(tag_name).cmp(&payload_union2.$(tag_name)) + payload_union1.${tag_name}.cmp(&payload_union2.${tag_name}) } }, """ @@ -1181,15 +1181,15 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina partial_ord_impl = if can_support_partial_eq_ord(types, Types.shape(types, id)) then """ - impl PartialOrd for $(escaped_name) { + impl PartialOrd for ${escaped_name} { fn partial_cmp(&self, other: &Self) -> Option { Some(::cmp(self, other)) } } - impl Ord for $(escaped_name) { + impl Ord for ${escaped_name} { fn cmp(&self, other: &Self) -> std::cmp::Ordering { - use discriminant_$(escaped_name)::*; + use discriminant_${escaped_name}::*; use std::cmp::Ordering::*; @@ -1198,7 +1198,7 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina Greater => Greater, Equal => unsafe { match self.discriminant() { - $(partial_ord_cases) + ${partial_ord_cases} } }, } @@ -1216,21 +1216,21 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina |> Str.concat( """ #[repr(transparent)] - pub struct $(escaped_name)(*mut $(union_name)); + pub struct ${escaped_name}(*mut ${union_name}); - const _SIZE_CHECK_$(escaped_name): () = assert!(core::mem::size_of::<$(escaped_name)>() == $(size_of_self)); - const _ALIGN_CHECK_$(escaped_name): () = assert!(core::mem::align_of::<$(escaped_name)>() == $(align_of_self)); + const _SIZE_CHECK_${escaped_name}: () = assert!(core::mem::size_of::<${escaped_name}>() == ${size_of_self}); + const _ALIGN_CHECK_${escaped_name}: () = assert!(core::mem::align_of::<${escaped_name}>() == ${align_of_self}); - impl $(escaped_name) { - pub fn discriminant(&self) -> discriminant_$(escaped_name) { + impl ${escaped_name} { + pub fn discriminant(&self) -> discriminant_${escaped_name} { let discriminants = { - use $(discriminant_name)::*; + use ${discriminant_name}::*; - $(discriminants) + ${discriminants} }; if self.0.is_null() { - $(null_tag_id) + ${null_tag_id} } else { match std::mem::size_of::() { 4 => discriminants[self.0 as usize & 0b011], @@ -1240,7 +1240,7 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina } } - fn unmasked_pointer(&self) -> *mut union_$(escaped_name) { + fn unmasked_pointer(&self) -> *mut union_${escaped_name} { debug_assert!(!self.0.is_null()); let mask = match std::mem::size_of::() { @@ -1249,50 +1249,50 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina _ => unreachable!(), }; - ((self.0 as usize) & mask) as *mut union_$(escaped_name) + ((self.0 as usize) & mask) as *mut union_${escaped_name} } - unsafe fn ptr_read_union(&self) -> core::mem::ManuallyDrop { + unsafe fn ptr_read_union(&self) -> core::mem::ManuallyDrop { let ptr = self.unmasked_pointer(); core::mem::ManuallyDrop::new(unsafe { std::ptr::read(ptr) }) } - $(constructors) + ${constructors} } - impl Clone for $(escaped_name) { + impl Clone for ${escaped_name} { fn clone(&self) -> Self { - use discriminant_$(escaped_name)::*; + use discriminant_${escaped_name}::*; let discriminant = self.discriminant(); match discriminant { - $(clone_cases) + ${clone_cases} } } } - $(partial_eq_impl) + ${partial_eq_impl} - $(hash_impl) + ${hash_impl} - $(partial_ord_impl) + ${partial_ord_impl} - impl core::fmt::Debug for $(escaped_name) { + impl core::fmt::Debug for ${escaped_name} { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - use discriminant_$(escaped_name)::*; + use discriminant_${escaped_name}::*; match self.discriminant() { - $(debug_cases) + ${debug_cases} } } } #[repr(C)] - union $(union_name) { + union ${union_name} { """, ) |> \b -> List.walk(tags, b, generate_union_field(types)) @@ -1307,7 +1307,7 @@ generate_tag_union_drop_payload = \buf, types, self_mut, tags, discriminant_name # just drop the pointer. buf |> write_indents(indents) - |> Str.concat("unsafe { core::mem::ManuallyDrop::drop(&mut core::ptr::read(self.pointer).$(name)); }") + |> Str.concat("unsafe { core::mem::ManuallyDrop::drop(&mut core::ptr::read(self.pointer).${name}); }") Err(ListWasEmpty) -> crash("unreachable") @@ -1316,7 +1316,7 @@ generate_tag_union_drop_payload = \buf, types, self_mut, tags, discriminant_name |> write_tag_impls(tags, discriminant_name, indents, \name, payload -> when payload is Some(id) if cannot_support_copy(types, Types.shape(types, id)) -> - "unsafe { core::mem::ManuallyDrop::drop(&mut $(self_mut).payload.$(name)) }," + "unsafe { core::mem::ManuallyDrop::drop(&mut ${self_mut}.payload.${name}) }," _ -> # If it had no payload, or if the payload had no pointers, @@ -1341,7 +1341,7 @@ write_tag_impls = \buf, tags, discriminant_name, indents, f -> branch_str = f(name, payload) accum |> write_indents((indents + 1)) - |> Str.concat("$(discriminant_name)::$(name) => $(branch_str)\n")) + |> Str.concat("${discriminant_name}::${name} => ${branch_str}\n")) |> write_indents(indents) |> Str.concat("}\n") @@ -1375,15 +1375,15 @@ generate_union_field = \types -> # types with pointers need ManuallyDrop # because rust unions don't (and can't) # know how to drop them automatically! - "core::mem::ManuallyDrop<$(type_str)>" + "core::mem::ManuallyDrop<${type_str}>" else type_str - Str.concat(accum, "$(indent)$(escaped_field_name): $(full_type_str),\n") + Str.concat(accum, "${indent}${escaped_field_name}: ${full_type_str},\n") None -> # use unit as the payload - Str.concat(accum, "$(indent)$(escaped_field_name): (),\n") + Str.concat(accum, "${indent}${escaped_field_name}: (),\n") comma_separated : Str, List a, (a, U64 -> Str) -> Str comma_separated = \buf, items, step -> @@ -1416,19 +1416,19 @@ generate_nullable_unwrapped = \buf, types, tag_unionid, name, null_tag, non_null payload_field_names = comma_separated("", payload_fields, \_, i -> n = Num.to_str(i) - "f$(n)") + "f${n}") constructor_arguments = comma_separated("", payload_fields, \id, i -> n = Num.to_str(i) type = type_name(types, id) - "f$(n): $(type)") + "f${n}: ${type}") debug_fields = payload_fields |> List.map_with_index(\_, i -> n = Num.to_str(i) - ".field(&node.f$(n))") + ".field(&node.f${n})") |> Str.join_with("") union_type = TagUnion(NullableUnwrapped({ name, null_tag, non_null_tag, non_null_payload, which_tag_is_null })) @@ -1437,18 +1437,18 @@ generate_nullable_unwrapped = \buf, types, tag_unionid, name, null_tag, non_null FirstTagIsNull -> """ #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub enum discriminant_$(name) { - $(null_tag) = 0, - $(non_null_tag) = 1, + pub enum discriminant_${name} { + ${null_tag} = 0, + ${non_null_tag} = 1, } """ SecondTagIsNull -> """ #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub enum discriminant_$(name) { - $(non_null_tag) = 0, - $(null_tag) = 1, + pub enum discriminant_${name} { + ${non_null_tag} = 0, + ${null_tag} = 1, } """ @@ -1456,67 +1456,67 @@ generate_nullable_unwrapped = \buf, types, tag_unionid, name, null_tag, non_null align_of_self = Num.to_str(Types.alignment(types, tag_unionid)) """ - $(buf) + ${buf} #[derive(PartialOrd, Ord)] #[repr(C)] - pub struct $(name)(*mut $(name)_$(non_null_tag)); + pub struct ${name}(*mut ${name}_${non_null_tag}); - $(discriminant) + ${discriminant} - const _SIZE_CHECK_$(name): () = assert!(core::mem::size_of::<$(name)>() == $(size_of_self)); - const _ALIGN_CHECK_$(name): () = assert!(core::mem::align_of::<$(name)>() == $(align_of_self)); + const _SIZE_CHECK_${name}: () = assert!(core::mem::size_of::<${name}>() == ${size_of_self}); + const _ALIGN_CHECK_${name}: () = assert!(core::mem::align_of::<${name}>() == ${align_of_self}); - impl $(name) { - pub fn $(null_tag)() -> Self { + impl ${name} { + pub fn ${null_tag}() -> Self { Self(core::ptr::null_mut()) } - pub fn $(non_null_tag)($(constructor_arguments)) -> Self { - let payload = $(name)_$(non_null_tag) { $(payload_field_names) }; + pub fn ${non_null_tag}(${constructor_arguments}) -> Self { + let payload = ${name}_${non_null_tag} { ${payload_field_names} }; let ptr = unsafe { roc_std::RocBox::leak(roc_std::RocBox::new(payload)) }; Self(ptr) } - pub fn discriminant(&self) -> discriminant_$(name) { - if self.is_$(null_tag)() { - discriminant_$(name)::$(null_tag) + pub fn discriminant(&self) -> discriminant_${name} { + if self.is_${null_tag}() { + discriminant_${name}::${null_tag} } else { - discriminant_$(name)::$(non_null_tag) + discriminant_${name}::${non_null_tag} } } - pub fn is_$(null_tag)(&self) -> bool { + pub fn is_${null_tag}(&self) -> bool { self.0.is_null() } - pub fn is_$(non_null_tag)(&self) -> bool { + pub fn is_${non_null_tag}(&self) -> bool { !self.0.is_null() } } - impl core::fmt::Debug for $(name) { + impl core::fmt::Debug for ${name} { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - if self.is_$(null_tag)() { - f.debug_tuple("$(name)::$(null_tag)").finish() + if self.is_${null_tag}() { + f.debug_tuple("${name}::${null_tag}").finish() } else { let node = core::mem::ManuallyDrop::new(unsafe { std::ptr::read(self.0) }); - f.debug_tuple("$(name)::$(non_null_tag)")$(debug_fields).finish() + f.debug_tuple("${name}::${non_null_tag}")${debug_fields}.finish() } } } - impl Clone for $(name) { + impl Clone for ${name} { fn clone(&self) -> Self { - if self.is_$(null_tag)() { - Self::$(null_tag)() + if self.is_${null_tag}() { + Self::${null_tag}() } else { use std::ops::Deref; let node_ref = core::mem::ManuallyDrop::new(unsafe { std::ptr::read(self.0) }); - let payload : $(name)_$(non_null_tag) = (node_ref.deref()).clone(); + let payload : ${name}_${non_null_tag} = (node_ref.deref()).clone(); let ptr = unsafe { roc_std::RocBox::leak(roc_std::RocBox::new(payload)) }; @@ -1525,13 +1525,13 @@ generate_nullable_unwrapped = \buf, types, tag_unionid, name, null_tag, non_null } } - impl PartialEq for $(name) { + impl PartialEq for ${name} { fn eq(&self, other: &Self) -> bool { if self.discriminant() != other.discriminant() { return false; } - if self.is_$(null_tag)() { + if self.is_${null_tag}() { return true; } @@ -1542,13 +1542,13 @@ generate_nullable_unwrapped = \buf, types, tag_unionid, name, null_tag, non_null } } - impl Eq for $(name) {} + impl Eq for ${name} {} - impl core::hash::Hash for $(name) { + impl core::hash::Hash for ${name} { fn hash(&self, state: &mut H) { self.discriminant().hash(state); - if self.is_$(non_null_tag)() { + if self.is_${non_null_tag}() { let payload = core::mem::ManuallyDrop::new(unsafe { std::ptr::read(self.0) }); payload.hash(state); } @@ -1578,7 +1578,7 @@ generate_single_tag_struct = \buf, types, name, tag_name, payload -> List.map_with_index(fields, \{ id }, index -> index_str = Num.to_str(index) - { name: "f$(index_str)", id }) + { name: "f${index_str}", id }) |> HasNoClosure as_struct_type = Struct({ @@ -1588,7 +1588,7 @@ generate_single_tag_struct = \buf, types, name, tag_name, payload -> buf |> generate_derive_str(types, as_struct_type, ExcludeDebug) - |> Str.concat("#[repr($(repr))]\npub struct $(escaped_name) ") + |> Str.concat("#[repr(${repr})]\npub struct ${escaped_name} ") |> \b -> if List.is_empty(fields) then generate_zero_element_single_tag_struct(b, escaped_name, tag_name) @@ -1606,7 +1606,7 @@ generate_multi_element_single_tag_struct = \buf, types, name, tag_name, payload_ |> Str.concat("}\n\n") |> Str.concat( """ - impl $(name) { + impl ${name} { """, ) @@ -1620,18 +1620,18 @@ generate_multi_element_single_tag_struct = \buf, types, name, tag_name, payload_ |> List.map_with_index(\field_type_name, index -> index_str = Num.to_str(index) - "f$(index_str): $(field_type_name)") + "f${index_str}: ${field_type_name}") fields = payload_fields |> List.map_with_index(\_, index -> index_str = Num.to_str(index) - "f$(index_str)") + "f${index_str}") field_accesses = fields |> List.map(\field -> - "self.$(field)") + "self.${field}") { b, @@ -1642,18 +1642,18 @@ generate_multi_element_single_tag_struct = \buf, types, name, tag_name, payload_ } |> \{ b, args, fields, field_types, field_accesses } -> args_str = Str.join_with(args, ", ") - fields_str = Str.join_with(fields, ",\n$(indent)$(indent)$(indent)") + fields_str = Str.join_with(fields, ",\n${indent}${indent}${indent}") { b: Str.concat( b, """ - $(indent)/// A tag named ``$(tag_name)``, with the given payload. - $(indent)pub fn $(tag_name)($(args_str)) -> Self { - $(indent) Self { - $(indent) $(fields_str) - $(indent) } - $(indent)} + ${indent}/// A tag named ``${tag_name}``, with the given payload. + ${indent}pub fn ${tag_name}(${args_str}) -> Self { + ${indent} Self { + ${indent} ${fields_str} + ${indent} } + ${indent}} """, @@ -1669,11 +1669,11 @@ generate_multi_element_single_tag_struct = \buf, types, name, tag_name, payload_ b: Str.concat( b, """ - $(indent)/// Since `$(name)` only has one tag (namely, `$(tag_name)`), - $(indent)/// convert it to `$(tag_name)`'s payload. - $(indent)pub fn into_$(tag_name)(self) -> $(ret_type) { - $(indent) $(ret_expr) - $(indent)} + ${indent}/// Since `${name}` only has one tag (namely, `${tag_name}`), + ${indent}/// convert it to `${tag_name}`'s payload. + ${indent}pub fn into_${tag_name}(self) -> ${ret_type} { + ${indent} ${ret_expr} + ${indent}} """, @@ -1684,21 +1684,21 @@ generate_multi_element_single_tag_struct = \buf, types, name, tag_name, payload_ |> \{ b, field_types, field_accesses } -> ret_type = field_types - |> List.map(\ft -> "&$(ft)") + |> List.map(\ft -> "&${ft}") |> as_rust_tuple ret_expr = field_accesses - |> List.map(\fa -> "&$(fa)") + |> List.map(\fa -> "&${fa}") |> as_rust_tuple Str.concat( b, """ - $(indent)/// Since `$(name)` only has one tag (namely, `$(tag_name)`), - $(indent)/// convert it to `$(tag_name)`'s payload. - $(indent)pub fn as_$(tag_name)(&self) -> $(ret_type) { - $(indent) $(ret_expr) - $(indent)} + ${indent}/// Since `${name}` only has one tag (namely, `${tag_name}`), + ${indent}/// convert it to `${tag_name}`'s payload. + ${indent}pub fn as_${tag_name}(&self) -> ${ret_type} { + ${indent} ${ret_expr} + ${indent}} """, ) @@ -1707,9 +1707,9 @@ generate_multi_element_single_tag_struct = \buf, types, name, tag_name, payload_ } - impl core::fmt::Debug for $(name) { + impl core::fmt::Debug for ${name} { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_tuple("$(name)::$(tag_name)") + f.debug_tuple("${name}::${tag_name}") """, ) @@ -1718,7 +1718,7 @@ generate_multi_element_single_tag_struct = \buf, types, name, tag_name, payload_ |> List.map_with_index(\_, index -> index_str = Num.to_str(index) - "$(indent)$(indent)$(indent)$(indent).field(&self.f$(index_str))\n") + "${indent}${indent}${indent}${indent}.field(&self.f${index_str})\n") |> List.walk(b, Str.concat) |> Str.concat( """ @@ -1738,7 +1738,7 @@ as_rust_tuple = \list -> if List.len(list) == 1 then joined else - "($(joined))" + "(${joined})" generate_zero_element_single_tag_struct = \buf, name, tag_name -> # A single tag with no payload is a zero-sized unit type, so @@ -1747,26 +1747,26 @@ generate_zero_element_single_tag_struct = \buf, name, tag_name -> |> Str.concat("();\n\n") |> Str.concat( """ - impl $(name) { - /// A tag named $(tag_name), which has no payload. - pub const $(tag_name): Self = Self(); + impl ${name} { + /// A tag named ${tag_name}, which has no payload. + pub const ${tag_name}: Self = Self(); - /// Other `into_` methods return a payload, but since $(tag_name) tag + /// Other `into_` methods return a payload, but since ${tag_name} tag /// has no payload, this does nothing and is only here for completeness. - pub fn into_$(tag_name)(self) { + pub fn into_${tag_name}(self) { () } - /// Other `as_` methods return a payload, but since $(tag_name) tag + /// Other `as_` methods return a payload, but since ${tag_name} tag /// has no payload, this does nothing and is only here for completeness. - pub fn as_$(tag_name)(&self) { + pub fn as_${tag_name}(&self) { () } } - impl core::fmt::Debug for $(name) { + impl core::fmt::Debug for ${name} { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.write_str("$(name)::$(tag_name)") + f.write_str("${name}::${tag_name}") } } @@ -1996,7 +1996,7 @@ generate_roc_refcounted = \buf, types, type, escaped_name -> when type is TagUnion(NonNullableUnwrapped(_)) -> """ - impl roc_std::RocRefcounted for $(escaped_name) { + impl roc_std::RocRefcounted for ${escaped_name} { fn inc(&mut self) { self.0.inc(); } @@ -2011,7 +2011,7 @@ generate_roc_refcounted = \buf, types, type, escaped_name -> TagUnion(Recursive(_)) -> """ - impl roc_std::RocRefcounted for $(escaped_name) { + impl roc_std::RocRefcounted for ${escaped_name} { fn inc(&mut self) { unimplemented!(); } @@ -2022,7 +2022,7 @@ generate_roc_refcounted = \buf, types, type, escaped_name -> true } }\n\n - impl roc_std::RocRefcounted for union_$(escaped_name) { + impl roc_std::RocRefcounted for union_${escaped_name} { fn inc(&mut self) { unimplemented!(); } @@ -2037,7 +2037,7 @@ generate_roc_refcounted = \buf, types, type, escaped_name -> TagUnion(NullableWrapped(_)) -> """ - impl roc_std::RocRefcounted for $(escaped_name) { + impl roc_std::RocRefcounted for ${escaped_name} { fn inc(&mut self) { unimplemented!(); } @@ -2048,7 +2048,7 @@ generate_roc_refcounted = \buf, types, type, escaped_name -> true } }\n\n - impl roc_std::RocRefcounted for union_$(escaped_name) { + impl roc_std::RocRefcounted for union_${escaped_name} { fn inc(&mut self) { unimplemented!(); } @@ -2065,12 +2065,12 @@ generate_roc_refcounted = \buf, types, type, escaped_name -> inc_fields = generate_roc_refcounted_named_fields(types, fields, Inc, Struct) dec_fields = generate_roc_refcounted_named_fields(types, fields, Dec, Struct) """ - impl roc_std::RocRefcounted for $(escaped_name) { + impl roc_std::RocRefcounted for ${escaped_name} { fn inc(&mut self) { - $(inc_fields) + ${inc_fields} } fn dec(&mut self) { - $(dec_fields) + ${dec_fields} } fn is_refcounted() -> bool { true @@ -2082,12 +2082,12 @@ generate_roc_refcounted = \buf, types, type, escaped_name -> inc_fields = generate_roc_refcounted_named_fields(types, fields, Inc, Tag) dec_fields = generate_roc_refcounted_named_fields(types, fields, Dec, Tag) """ - impl roc_std::RocRefcounted for $(escaped_name) { + impl roc_std::RocRefcounted for ${escaped_name} { fn inc(&mut self) { - $(inc_fields) + ${inc_fields} } fn dec(&mut self) { - $(dec_fields) + ${dec_fields} } fn is_refcounted() -> bool { true @@ -2097,7 +2097,7 @@ generate_roc_refcounted = \buf, types, type, escaped_name -> _ -> """ - impl roc_std::RocRefcounted for $(escaped_name) { + impl roc_std::RocRefcounted for ${escaped_name} { fn inc(&mut self) { unimplemented!(); } @@ -2114,14 +2114,14 @@ generate_roc_refcounted = \buf, types, type, escaped_name -> impl, ) else - Str.concat(buf, "roc_refcounted_noop_impl!($(escaped_name));\n\n") + Str.concat(buf, "roc_refcounted_noop_impl!(${escaped_name});\n\n") generate_roc_refcounted_named_fields = \types, fields, mode, wrapper -> field_name = \name -> escaped_name = escape_kw(name) when wrapper is Struct -> escaped_name - Tag -> "f$(escaped_name)" + Tag -> "f${escaped_name}" method_name = when mode is @@ -2133,7 +2133,7 @@ generate_roc_refcounted_named_fields = \types, fields, mode, wrapper -> if contains_refcounted(types, Types.shape(types, id)) then Str.concat( accum, - "$(indent) self.$(field_name(name)).$(method_name)();\n", + "${indent} self.${field_name(name)}.${method_name}();\n", ) else accum @@ -2207,29 +2207,29 @@ type_name = \types, id -> RocDict(_key, _value) -> # key_name = type_name(types, key) # value_name = type_name(types, value) - # "roc_std::RocDict<$(key_name), $(value_name)>" + # "roc_std::RocDict<${key_name}, ${value_name}>" crash("RocDict is not yet supported in rust") RocSet(_elem) -> # elem_name = type_name(types, elem) - # "roc_std::RocSet<$(elem_name)>" + # "roc_std::RocSet<${elem_name}>" crash("RocSet is not yet supported in rust") RocList(elem) -> elem_name = type_name(types, elem) - "roc_std::RocList<$(elem_name)>" + "roc_std::RocList<{delem_name}>" RocBox(elem) -> elem_name = type_name(types, elem) - "roc_std::RocBox<$(elem_name)>" + "roc_std::RocBox<${elem_name}>" RocResult(ok, err) -> ok_name = type_name(types, ok) err_name = type_name(types, err) - "roc_std::RocResult<$(ok_name), $(err_name)>" + "roc_std::RocResult<${ok_name}, ${err_name}>" RecursivePointer(content) -> type_name(types, content) @@ -2351,7 +2351,7 @@ escape_kw = \input -> # https://doc.rust-lang.org/rust-by-example/compatibility/raw_identifiers.html # another design would be to add an underscore after it; this is an experiment! if Set.contains(reserved_keywords, input) then - "r#$(input)" + "r#${input}" else input diff --git a/crates/repl_test/src/tests.rs b/crates/repl_test/src/tests.rs index c1ff65330b..37dcdc8d71 100644 --- a/crates/repl_test/src/tests.rs +++ b/crates/repl_test/src/tests.rs @@ -755,14 +755,14 @@ fn type_problem_unary_operator() { #[test] fn type_problem_string_interpolation() { expect_failure( - "\"This is not a string -> $(1)\"", + "\"This is not a string -> ${1}\"", indoc!( r#" ── TYPE MISMATCH ─────────────────────────────────────────────────────────────── This argument to this string interpolation has an unexpected type: - 4│ "This is not a string -> $(1)" + 4│ "This is not a string -> ${1}" ^ The argument is a number of type: @@ -833,14 +833,14 @@ fn list_get_negative_index() { #[test] fn invalid_string_interpolation() { expect_failure( - "\"$(123)\"", + "\"${123}\"", indoc!( r#" ── TYPE MISMATCH ─────────────────────────────────────────────────────────────── This argument to this string interpolation has an unexpected type: - 4│ "$(123)" + 4│ "${123}" ^^^ The argument is a number of type: @@ -1537,7 +1537,7 @@ fn interpolation_with_nested_strings() { expect_success( indoc!( r#" - "foo $(Str.join_with ["a", "b", "c"] ", ") bar" + "foo ${Str.join_with ["a", "b", "c"] ", "} bar" "# ), r#""foo a, b, c bar" : Str"#, @@ -1549,7 +1549,7 @@ fn interpolation_with_num_to_str() { expect_success( indoc!( r#" - "foo $(Num.to_str Num.max_i8) bar" + "foo ${Num.to_str Num.max_i8} bar" "# ), r#""foo 127 bar" : Str"#, @@ -1561,7 +1561,7 @@ fn interpolation_with_operator_desugaring() { expect_success( indoc!( r#" - "foo $(Num.to_str (1 + 2)) bar" + "foo ${Num.to_str (1 + 2)} bar" "# ), r#""foo 3 bar" : Str"#, @@ -1576,7 +1576,7 @@ fn interpolation_with_nested_interpolation() { expect_failure( indoc!( r#" - "foo $(Str.join_with ["a$(Num.to_str 5)", "b"] "c")" + "foo ${Str.join_with ["a${Num.to_str 5}", "b"] "c"}" "# ), indoc!( @@ -1585,7 +1585,7 @@ fn interpolation_with_nested_interpolation() { This string interpolation is invalid: - 4│ "foo $(Str.join_with ["a$(Num.to_str 5)", "b"] "c")" + 4│ "foo ${Str.join_with ["a${Num.to_str 5}", "b"] "c"}" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String interpolations cannot contain newlines or other interpolations. diff --git a/crates/reporting/src/error/parse.rs b/crates/reporting/src/error/parse.rs index 13e01addd8..e8b2fabe9b 100644 --- a/crates/reporting/src/error/parse.rs +++ b/crates/reporting/src/error/parse.rs @@ -1098,7 +1098,7 @@ fn to_str_report<'a>( alloc.region_with_subregion(lines.convert_region(surroundings), region, severity), alloc.concat([ alloc.reflow(r"You could change it to something like "), - alloc.parser_suggestion("\"The count is $(count)\""), + alloc.parser_suggestion("\"The count is ${count}\""), alloc.reflow("."), ]), ]); @@ -1176,7 +1176,7 @@ fn to_str_report<'a>( alloc.stack([ alloc.concat([ alloc.reflow("I am part way through parsing this single-quote literal, "), - alloc.reflow("but I encountered a string interpolation like \"$(this)\","), + alloc.reflow("but I encountered a string interpolation like \"${this}\","), alloc.reflow("which is not allowed in single-quote literals."), ]), alloc.region_with_subregion(lines.convert_region(surroundings), region, severity), diff --git a/crates/valgrind_tests/src/lib.rs b/crates/valgrind_tests/src/lib.rs index 6f909b0c79..b83b9aa0c4 100644 --- a/crates/valgrind_tests/src/lib.rs +++ b/crates/valgrind_tests/src/lib.rs @@ -341,7 +341,7 @@ fn joinpoint_with_closure() { cat_sound = make_sound Cat dog_sound = make_sound Dog goose_sound = make_sound Goose - "Cat: $(cat_sound), Dog: $(dog_sound), Goose: $(goose_sound)" + "Cat: ${cat_sound}, Dog: ${dog_sound}, Goose: ${goose_sound}" test ) @@ -370,7 +370,7 @@ fn joinpoint_with_reuse() { Cons x xs -> str_x = f x str_xs = print_linked_list xs f - "Cons $(str_x) ($(str_xs))" + "Cons ${str_x} (${str_xs})" test = new_list = map_linked_list (Cons 1 (Cons 2 (Cons 3 Nil))) (\x -> x + 1) @@ -457,7 +457,7 @@ fn tree_rebalance() { s_l = node_in_parens left show_key show_value s_r = node_in_parens right show_key show_value - "Node $(s_color) $(s_key) $(s_value) $(s_l) $(s_r)" + "Node ${s_color} ${s_key} ${s_value} ${s_l} ${s_r}" node_in_parens : RedBlackTree k v, (k -> Str), (v -> Str) -> Str node_in_parens = \tree, show_key, show_value -> @@ -468,7 +468,7 @@ fn tree_rebalance() { Node _ _ _ _ _ -> inner = show_rb_tree tree show_key show_value - "($(inner))" + "(${inner})" show_color : NodeColor -> Str show_color = \color -> @@ -516,7 +516,7 @@ fn joinpoint_nullpointer() { Nil -> "Nil" Cons x xs -> str_xs = print_linked_list xs - "Cons $(x) ($(str_xs))" + "Cons ${x} (${str_xs})" linked_list_head : LinkedList Str -> LinkedList Str linked_list_head = \linked_list -> @@ -528,7 +528,7 @@ fn joinpoint_nullpointer() { test = cons = print_linked_list (linked_list_head (Cons "foo" Nil)) nil = print_linked_list (linked_list_head (Nil)) - "$(cons) - $(nil)" + "${cons} - ${nil}" test ) diff --git a/www/InteractiveExample.roc b/www/InteractiveExample.roc index 2043eaacf5..6ca95f9754 100644 --- a/www/InteractiveExample.roc +++ b/www/InteractiveExample.roc @@ -37,7 +37,7 @@ view = Newline, Desc([Ident("user"), Kw("="), Ident("Http.get!"), Ident("url"), Ident("Json.utf8")], "

This fetches the contents of the URL and decodes them as JSON.

If the shape of the JSON isn't compatible with the type of user (based on type inference), this will give a decoding error immediately.

As with all the other function calls involving the ! operator, if there's an error, nothing else in storeEmail will be run, and handleErr will run.

"), Newline, - Desc([Ident("dest"), Kw("="), Ident("Path.fromStr"), StrInterpolation("\"", "user.name", ".txt\"")], "

The \$(user.name) in this string literal will be replaced with the value stored in the user record's name field. This is string interpolation.

Note that this function call doesn't involve the ! operator. That's because Path.fromStr doesn't involve any Tasks, so there's no need to use ! to wait for it to finish.

"), + Desc([Ident("dest"), Kw("="), Ident("Path.fromStr"), StrInterpolation("\"", "user.name", ".txt\"")], "

The \${user.name} in this string literal will be replaced with the value stored in the user record's name field. This is string interpolation.

Note that this function call doesn't involve the ! operator. That's because Path.fromStr doesn't involve any Tasks, so there's no need to use ! to wait for it to finish.

"), Newline, Desc([Ident("File.writeUtf8!"), Ident("dest"), Ident("user.email")], "

This writes user.email to the file, encoded as UTF-8.

Since File.writeUtf8 doesn't produce any information on success, we don't bother using = like we did on the other lines.

"), Newline, @@ -90,7 +90,7 @@ tokens_to_str = \tokens -> # Don't put spaces after opening parens or before closing parens args_with_commas = args - |> List.map(\ident -> "$(ident)") + |> List.map(\ident -> "${ident}") |> Str.join_with(", ") buf_with_space @@ -99,22 +99,22 @@ tokens_to_str = \tokens -> |> Str.concat(" ->") Kw(str) -> - Str.concat(buf_with_space, "$(str)") + Str.concat(buf_with_space, "${str}") Num(str) | Str(str) | Literal(str) -> # We may render these differently in the future - Str.concat(buf_with_space, "$(str)") + Str.concat(buf_with_space, "${str}") Comment(str) -> - Str.concat(buf_with_space, "# $(str)") + Str.concat(buf_with_space, "# ${str}") Ident(str) -> Str.concat(buf_with_space, ident_to_html(str)) StrInterpolation(before, interp, after) -> buf_with_space - |> Str.concat((if Str.is_empty(before) then "" else "$(before)")) - |> Str.concat("\$($(ident_to_html(interp)))") - |> Str.concat((if Str.is_empty(after) then "" else "$(after)"))) + |> Str.concat((if Str.is_empty(before) then "" else "${before}")) + |> Str.concat("\${${ident_to_html(interp)}}") + |> Str.concat((if Str.is_empty(after) then "" else "${after}"))) ident_to_html : Str -> Str ident_to_html = \str -> @@ -122,18 +122,18 @@ ident_to_html = \str -> len = Str.count_utf8_bytes(ident) without_suffix = ident |> Str.replace_last("!", "") - ident_html = "$(without_suffix)" + ident_html = "${without_suffix}" html = # If removing a trailing "!" changed the length, then there must have been a trailing "!" if len > Str.count_utf8_bytes(without_suffix) then - "$(ident_html)!" + "${ident_html}!" else ident_html if Str.is_empty(accum) then html else - "$(accum).$(html)") + "${accum}.${html}") sections_to_str : List Section -> Str sections_to_str = \sections -> @@ -178,5 +178,5 @@ radio = \index, label_html, desc_html -> checked_html = if index == 0 then " checked" else "" """ - $(desc_html) + ${desc_html} """ diff --git a/www/content/friendly.md b/www/content/friendly.md index 2b31d03e78..c23f098173 100644 --- a/www/content/friendly.md +++ b/www/content/friendly.md @@ -9,7 +9,7 @@ Roc's syntax isn't trivial, but there also isn't much of it to learn. It's desig - `user.email` always accesses the `email` field of a record named `user`. (Roc has no inheritance, subclassing, or proxying.) - `Email.isValid` always refers to something named `isValid` exported by a module named `Email`. (Module names are always capitalized, and variables/constants never are.) Modules are always defined statically and can't be modified at runtime; there's no [monkey patching](https://en.wikipedia.org/wiki/Monkey_patch) to consider either. - `x = doSomething y z` always declares a new constant `x` (Roc has [no mutable variables, reassignment, or shadowing](/functional)) to be whatever the `doSomething` function returns when passed the arguments `y` and `z`. (Function calls in Roc don't need parentheses or commas.) -- `"Name: $(Str.trim name)"` uses *string interpolation* syntax: a dollar sign inside a string literal, followed by an expression in parentheses. +- `"Name: ${Str.trim(name)}"` uses *string interpolation* syntax: a dollar sign inside a string literal, followed by an expression in parentheses. Roc also ships with a source code formatter that helps you maintain a consistent style with little effort. The `roc format` command neatly formats your source code according to a common style, and it's designed with the time-saving feature of having no configuration options. This feature saves teams all the time they would otherwise spend debating which stylistic tweaks to settle on! diff --git a/www/content/functional.md b/www/content/functional.md index 31fe8b5b8f..5004f2463f 100644 --- a/www/content/functional.md +++ b/www/content/functional.md @@ -65,7 +65,7 @@ A benefit of this design is that it makes Roc code easier to rearrange without c
func = \arg ->
     greeting = "Hello"
-    welcome = \name -> "$(greeting), $(name)!"
+    welcome = \name -> "${greeting}, ${name}!"
 
     # …
 
@@ -82,7 +82,7 @@ Suppose I decide to extract the `welcome` function to the top level, so I can re
 
     # …
 
-welcome = \prefix, name -> "$(prefix), $(name)!"
+welcome = \prefix, name -> "${prefix}, ${name}!" Even without knowing the rest of `func`, we can be confident this change will not alter the code's behavior. @@ -90,7 +90,7 @@ In contrast, suppose Roc allowed reassignment. Then it's possible something in t
func = \arg ->
     greeting = "Hello"
-    welcome = \name -> "$(greeting), $(name)!"
+    welcome = \name -> "${greeting}, ${name}!"
 
     # …
 
diff --git a/www/content/index.md b/www/content/index.md
index 6607a05af2..753c6c08d8 100644
--- a/www/content/index.md
+++ b/www/content/index.md
@@ -6,7 +6,7 @@
 
 

A fast, friendly, functional language.

credits = List.map songs \song ->
-    "Performed by $(song.artist)"
+ "Performed by ${song.artist}"
diff --git a/www/content/tutorial.md b/www/content/tutorial.md index 7bece3abb6..b05f5bcab7 100644 --- a/www/content/tutorial.md +++ b/www/content/tutorial.md @@ -109,16 +109,16 @@ Note that in Roc, we don't need parentheses or commas to call functions. We don' That said, just like in the arithmetic example above, we can use parentheses to specify how nested function calls should work. For example, we could write this: -
Str.concat "Birds: " (Num.toStr 42)
+
Str.concat "Birds: " (Num.to_str 42)
 
 "Birds: 42" : Str
 
-This calls `Num.toStr` on the number `42`, which converts it into the string `"42"`, and then passes that string as the second argument to `Str.concat`. +This calls `Num.to_str` on the number `42`, which converts it into the string `"42"`, and then passes that string as the second argument to `Str.concat`. The parentheses are important here to specify how the function calls nest. Try removing them, and see what happens: -
Str.concat "Birds: " Num.toStr 42
+
Str.concat "Birds: " Num.to_str 42
 
 <error>
 
@@ -126,12 +126,12 @@ The parentheses are important here to specify how the function calls nest. Try r The error tells us that we've given `Str.concat` too many arguments. Indeed we have! We've passed it three arguments: 1. The string `"Birds"` -2. The function `Num.toStr` +2. The function `Num.to_str` 3. The number `42` -That's not what we intended to do. Putting parentheses around the `Num.toStr 42` call clarifies that we want it to be evaluated as its own expression, rather than being two arguments to `Str.concat`. +That's not what we intended to do. Putting parentheses around the `Num.to_str 42` call clarifies that we want it to be evaluated as its own expression, rather than being two arguments to `Str.concat`. -Both the `Str.concat` function and the `Num.toStr` function have a dot in their names. In `Str.concat`, `Str` is the name of a _module_, and `concat` is the name of a function inside that module. Similarly, `Num` is a module, and `toStr` is a function inside that module. +Both the `Str.concat` function and the `Num.to_str` function have a dot in their names. In `Str.concat`, `Str` is the name of a _module_, and `concat` is the name of a function inside that module. Similarly, `Num` is a module, and `to_str` is a function inside that module. We'll get into more depth about modules later, but for now you can think of a module as a named collection of functions. Eventually we'll discuss how to use them for more than that. @@ -139,7 +139,7 @@ We'll get into more depth about modules later, but for now you can think of a mo An alternative syntax for `Str.concat` is _string interpolation_, which looks like this: -
"$(greeting) there, $(audience)."
+
"${greeting} there, ${audience}."
This is syntax sugar for calling `Str.concat` several times, like so: @@ -149,7 +149,7 @@ Str.concat greeting (Str.concat " there, " (Str.concat audience ".")) You can put entire single-line expressions inside the parentheses in string interpolation. For example: -
"Two plus three is: $(Num.toStr (2 + 3))"
+
"Two plus three is: ${Num.to_str(2 + 3)}"
By the way, there are many other ways to put strings together! Check out the [documentation](https://www.roc-lang.org/builtins/Str) for the `Str` module for more. @@ -187,10 +187,10 @@ birds = 3 iguanas = 2 -total = Num.toStr (birds + iguanas) +total = Num.to_str (birds + iguanas) main! = \_args -> - Stdout.line! "There are $(total) animals." + Stdout.line! "There are ${total} animals." ``` Now run `roc main.roc` again. This time the "Downloading ..." message won't appear; the file has been cached from last time, and won't need to be downloaded again. @@ -204,9 +204,9 @@ You should see this: A definition names an expression. - The first two defs assign the names `birds` and `iguanas` to the expressions `3` and `2`. -- The next def assigns the name `total` to the expression `Num.toStr (birds + iguanas)`. +- The next def assigns the name `total` to the expression `Num.to_str (birds + iguanas)`. -Once we have a def, we can use its name in other expressions. For example, the `total` expression refers to `birds` and `iguanas`, and `Stdout.line! "There are $(total) animals."` refers to `total`. +Once we have a def, we can use its name in other expressions. For example, the `total` expression refers to `birds` and `iguanas`, and `Stdout.line! "There are ${total} animals."` refers to `total`. You can name a def using any combination of letters and numbers, but they have to start with a lowercase letter. @@ -219,7 +219,7 @@ birds = 2 ### [Defining Functions](#defining-functions) {#defining-functions} -So far we've called functions like `Num.toStr`, `Str.concat`, and `Stdout.line`. Next let's try defining a function of our own. +So far we've called functions like `Num.to_str`, `Str.concat`, and `Stdout.line`. Next let's try defining a function of our own. ```roc birds = 3 @@ -229,13 +229,13 @@ iguanas = 2 total = add_and_stringify birds iguanas main! = \_args -> - Stdout.line! "There are $(total) animals." + Stdout.line! "There are ${total} animals." add_and_stringify = \num1, num2 -> - Num.toStr (num1 + num2) + Num.to_str (num1 + num2) ``` -This new `add_and_stringify` function we've defined accepts two numbers, adds them, calls `Num.toStr` on the result, and returns that. +This new `add_and_stringify` function we've defined accepts two numbers, adds them, calls `Num.to_str` on the result, and returns that. The `\num1, num2 ->` syntax defines a function's arguments, and the expression after the `->` is the body of the function. Whenever a function gets called, its body expression gets evaluated and returned. @@ -250,13 +250,13 @@ add_and_stringify = \num1, num2 -> if sum == 0 then "" else - Num.toStr sum + Num.to_str sum ``` We did two things here: - We introduced a _local def_ named `sum`, and set it equal to `num1 + num2`. Because we defined `sum` inside `add_and_stringify`, it's _local_ to that scope and can't be accessed outside that function. -- We added an `if`\-`then`\-`else` conditional to return either `""` or `Num.toStr sum` depending on whether `sum == 0`. +- We added an `if`\-`then`\-`else` conditional to return either `""` or `Num.to_str sum` depending on whether `sum == 0`. Every `if` must be accompanied by both `then` and also `else`. Having an `if` without an `else` is an error, because `if` is an expression, and all expressions must evaluate to a value. If there were ever an `if` without an `else`, that would be an expression that might not evaluate to a value! @@ -273,7 +273,7 @@ add_and_stringify = \num1, num2 -> else if sum < 0 then "negative" else - Num.toStr sum + Num.to_str sum ``` Note that `else if` is not a separate language keyword! It's just an `if`/`else` where the `else` branch contains another `if`/`else`. This is easier to see with different indentation: @@ -288,7 +288,7 @@ add_and_stringify = \num1, num2 -> if sum < 0 then "negative" else - Num.toStr sum + Num.to_str sum ``` This differently-indented version is equivalent to writing `else if sum < 0 then` on the same line, although the convention is to use the original version's style. @@ -325,7 +325,7 @@ Currently our `add_and_stringify` function takes two arguments. We can instead m total = add_and_stringify { birds: 5, iguanas: 7 } add_and_stringify = \counts -> - Num.toStr (counts.birds + counts.iguanas) + Num.to_str (counts.birds + counts.iguanas) ``` The function now takes a _record_, which is a group of named values. Records are not [objects](); they don't have methods or inheritance, they just store information. @@ -349,7 +349,7 @@ total = add_and_stringify { birds: 5, iguanas: 7 } total_with_note = add_and_stringify { birds: 4, iguanas: 3, note: "Whee!" } add_and_stringify = \counts -> - Num.toStr (counts.birds + counts.iguanas) + Num.to_str (counts.birds + counts.iguanas) ``` This works because `add_and_stringify` only uses `counts.birds` and `counts.iguanas`. If we were to use `counts.note` inside `add_and_stringify`, then we would get an error because `total` is calling `add_and_stringify` passing a record that doesn't have a `note` field. @@ -383,14 +383,14 @@ We can use _destructuring_ to avoid naming a record in a function argument, inst ```roc add_and_stringify = \{ birds, iguanas } -> - Num.toStr (birds + iguanas) + Num.to_str (birds + iguanas) ``` Here, we've _destructured_ the record to create a `birds` def that's assigned to its `birds` field, and an `iguanas` def that's assigned to its `iguanas` field. We can customize this if we like: ```roc add_and_stringify = \{ birds, iguanas: lizards } -> - Num.toStr (birds + lizards) + Num.to_str (birds + lizards) ``` In this version, we created a `lizards` def that's assigned to the record's `iguanas` field. (We could also do something similar with the `birds` field if we like.) @@ -810,7 +810,7 @@ Here's how calling `List.get` can look in practice: ```roc when List.get ["a", "b", "c"] index is - Ok str -> "I got this string: $(str)" + Ok str -> "I got this string: ${str}" Err OutOfBounds -> "That index was out of bounds, sorry!" ``` @@ -1017,7 +1017,7 @@ Sometimes you may want to document the type of a definition. For example, you mi ```roc # Takes a first_name string and a last_name string, and returns a string full_name = \first_name, last_name -> - "$(first_name) $(last_name)" + "${first_name) ${last_name}" ``` Comments can be valuable documentation, but they can also get out of date and become misleading. If someone changes this function and forgets to update the comment, it will no longer be accurate. @@ -1029,7 +1029,7 @@ Here's another way to document this function's type, which doesn't have that pro ```roc full_name : Str, Str -> Str full_name = \first_name, last_name -> - "$(first_name) $(last_name)" + "${first_name} ${last_name}" ``` The `full_name :` line is a _type annotation_. It's a strictly optional piece of metadata we can add above a def to describe its type. Unlike a comment, the Roc compiler will check type annotations for accuracy. If the annotation ever doesn't fit with the implementation, we'll get a compile-time error. @@ -1410,12 +1410,12 @@ You can write automated tests for your Roc code like so: ```roc pluralize = \singular, plural, count -> - count_str = Num.toStr count + count_str = Num.to_str count if count == 1 then - "$(count_str) $(singular)" + "${count_str} ${singular}" else - "$(count_str) $(plural)" + "${count_str} ${plural}" expect pluralize "cactus" "cacti" 1 == "1 cactus" @@ -1439,14 +1439,14 @@ Expects do not have to be at the top level: ```roc pluralize = \singular, plural, count -> - count_str = Num.toStr count + count_str = Num.to_str count if count == 1 then - "$(count_str) $(singular)" + "${count_str} ${singular}" else expect count > 0 - "$(count_str) $(plural)" + "${count_str} ${plural}" ``` This `expect` will fail if you call `pluralize` passing a count of 0. @@ -1625,7 +1625,7 @@ There are two types of functions in roc, "pure" and "effectful". Consider these ```roc with_extension : Str -> Str with_extension = \filename -> - "$(filename).roc" + "${filename}.roc" read_file! : Str => Str read_file! = \path -> @@ -1690,7 +1690,7 @@ import pf.Stdin main! = \_args -> try Stdout.line! "Type in something and press Enter:" input = try Stdin.line! {} - try Stdout.line! "Your input was: $(input)" + try Stdout.line! "Your input was: ${input}" Ok {} ``` @@ -1766,7 +1766,7 @@ main! : List Arg => Result {} [Exit I32 Str] main! = \_args -> try Stdout.line! "Type in something and press Enter:" input = try Stdin.line! {} - try Stdout.line! "Your input was: $(input)" + try Stdout.line! "Your input was: ${input}" Ok {} ``` @@ -1798,7 +1798,7 @@ my_function! : {} => Result {} [EndOfFile, StdinErr _, StdoutErr _] my_function! = \{} -> try Stdout.line! "Type in something and press Enter:" input = try Stdin.line! {} - try Stdout.line! "Your input was: $(input)" + try Stdout.line! "Your input was: ${input}" Ok {} ``` @@ -1841,7 +1841,7 @@ import pf.Stdin main! = \_args -> try Stdout.line! "Type in something and press Enter:" input = try Stdin.line! {} - try Stdout.line! "Your input was: $(input)" + try Stdout.line! "Your input was: ${input}" Ok {} ``` @@ -1856,7 +1856,7 @@ main! = \_args -> _ = Stdout.line! "Type in something and press Enter:" when Stdin.line! {} is Ok input -> - _ = Stdout.line! "Your input was: $(input)" + _ = Stdout.line! "Your input was: ${input}" Ok {} Err _ -> Ok {} @@ -1870,7 +1870,7 @@ Although it's rare, it is possible that either of the `Stdout.line!` operations main! = \_args -> try Stdout.line! "Type something and press Enter." input = try Stdin.line! {} - try Stdout.line! "You entered: $(input)" + try Stdout.line! "You entered: ${input}" Ok {} ``` @@ -1897,7 +1897,7 @@ main! = \_args -> |> Result.mapErr UnableToReadInput |> try - Stdout.line! "You entered: $(input)" + Stdout.line! "You entered: ${input}" |> Result.mapErr UnableToPrintInput |> try @@ -1920,14 +1920,14 @@ This code is doing three things: See the [Error Handling example](https://www.roc-lang.org/examples/ErrorHandling/README.html) for a more detailed explanation of error handling in a larger program. -### [Displaying Roc values with `Inspect.toStr`](#inspect) {#inspect} +### [Displaying Roc values with `Inspect.to_str`](#inspect) {#inspect} -The [`Inspect.toStr`](https://www.roc-lang.org/builtins/Inspect#toStr) function returns a `Str` representation of any Roc value using its [`Inspect` ability](/abilities#inspect-ability). It's useful for things like debugging and logging (although [`dbg`](https://www.roc-lang.org/tutorial#debugging) is often nicer for debugging in particular), but its output is almost never something that should be shown to end users! In this case we're just using it for our own learning, but it would be better to run a `when` on `e` and display a more helpful message. +The [`Inspect.to_str`](https://www.roc-lang.org/builtins/Inspect#to_str) function returns a `Str` representation of any Roc value using its [`Inspect` ability](/abilities#inspect-ability). It's useful for things like debugging and logging (although [`dbg`](https://www.roc-lang.org/tutorial#debugging) is often nicer for debugging in particular), but its output is almost never something that should be shown to end users! In this case we're just using it for our own learning, but it would be better to run a `when` on `e` and display a more helpful message. ```roc when err is - StdoutErr e -> Exit 1 "Error writing to stdout: $(Inspect.toStr e)" - StdinErr e -> Exit 2 "Error writing to stdin: $(Inspect.toStr e)" + StdoutErr e -> Exit 1 "Error writing to stdout: ${Inspect.to_str e}" + StdinErr e -> Exit 2 "Error writing to stdin: ${Inspect.to_str e}" ``` ### [The early `return` keyword](#the-early-return-keyword) {#the-early-return-keyword} @@ -1988,7 +1988,7 @@ Let's say I write a function which takes a record with a `first_name` and `last_ ```roc full_name = \user -> - "$(user.first_name) $(user.last_name)" + "${user.first_name} ${user.last_name}" ``` I can pass this function a record that has more fields than just `first_name` and `last_name`, as long as it has _at least_ both of those fields (and both of them are strings). So any of these calls would work: @@ -2007,14 +2007,14 @@ If we add a type annotation to this `full_name` function, we can choose to have # Closed record full_name : { first_name : Str, last_name : Str } -> Str full_name = \user -> - "$(user.first_name) $(user.last_name)" + "${user.first_name} ${user.last_name}" ``` ```roc # Open record (because of the `*`) full_name : { first_name : Str, last_name : Str }* -> Str full_name = \user -> - "$(user.first_name) $(user.last_name)" + "${user.first_name} ${user.last_name}" ``` The `*` in the type `{ first_name : Str, last_name : Str }*` is what makes it an open record type. This `*` is the _wildcard type_ we saw earlier with empty lists. (An empty list has the type `List *`, in contrast to something like `List Str` which is a list of strings.) @@ -2030,7 +2030,7 @@ The type variable can also be a named type variable, like so: ```roc add_https : { url : Str }a -> { url : Str }a add_https = \record -> - { record & url: "https://$(record.url)" } + { record & url: "https://${record.url}" } ``` This function uses _constrained records_ in its type. The annotation is saying: diff --git a/www/main.roc b/www/main.roc index d23068bd23..6b171ce124 100644 --- a/www/main.roc +++ b/www/main.roc @@ -64,11 +64,11 @@ get_page_info = \page_path_str -> Str.split_on(page_path_str, "/") |> List.take_last(2) |> List.first # we use the folder for name for the page title, e.g. Json from examples/Json/README.html - |> unwrap_or_crash("This List.first should never fail. pagePathStr ($(page_path_str)) did not contain any `/`.") + |> unwrap_or_crash("This List.first should never fail. page_path_str (${page_path_str}) did not contain any `/`.") |> (\page_title -> - { title: "$(page_title) | Roc", description: "$(page_title) example in the Roc programming language." }) + { title: "${page_title} | Roc", description: "${page_title} example in the Roc programming language." }) else - crash("Web page $(page_path_str) did not have a title and description specified in the pageData Dict. Please add one.") + crash("Web page ${page_path_str} did not have a title and description specified in the pageData Dict. Please add one.") unwrap_or_crash : Result a b, Str -> a where b implements Inspect unwrap_or_crash = \result, error_msg -> @@ -77,7 +77,7 @@ unwrap_or_crash = \result, error_msg -> val Err(err) -> - crash("$(Inspect.to_str(err)): $(error_msg)") + crash("${Inspect.to_str(err)}: ${error_msg}") transform : Str, Str -> Str transform = \page_path_str, html_content -> diff --git a/www/public/site.js b/www/public/site.js index 88dd1cb467..2aa8199f45 100644 --- a/www/public/site.js +++ b/www/public/site.js @@ -40,7 +40,7 @@ const repl = { }, { match: (input) => input.replace(/ /g, "").match(/^name="/i), - show: '

This created a new definitionname is now defined to be equal to the string you entered.

Try using this definition by entering "Hi, \$(name)!"

', + show: '

This created a new definitionname is now defined to be equal to the string you entered.

Try using this definition by entering "Hi, \${name}!"

', }, { match: (input) => input.match(/^"[^\$]+\$\(name\)/i), @@ -388,9 +388,9 @@ function updateHistoryEntry(index, ok, outputText) { bounds.top >= 0 && bounds.left >= 0 && bounds.bottom <= - (window.innerHeight || document.documentElement.clientHeight) && + (window.innerHeight || document.documentElement.clientHeight) && bounds.right <= - (window.innerWidth || document.documentElement.clientWidth); + (window.innerWidth || document.documentElement.clientWidth); if (!isInView) { repl.elemSourceInput.scrollIntoView({ From b0a5b1c3d57c9e89b761f8a65c9f5bff7b5a8307 Mon Sep 17 00:00:00 2001 From: Sam Mohr Date: Fri, 10 Jan 2025 10:55:40 -0800 Subject: [PATCH 22/24] Fix broken RustGlue.roc interpolation --- .../snapshots/pass/block_string_ann.expr.formatted.roc | 2 +- .../tests/snapshots/pass/block_string_ann.expr.roc | 2 +- .../tests/snapshots/pass/multiline_str_crazyness.expr.roc | 2 +- crates/glue/src/RustGlue.roc | 6 +++--- www/content/tutorial.md | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.formatted.roc index 80a7b24b8e..89aa5ea89b 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.formatted.roc @@ -1,2 +1,2 @@ -"{(g)" : q +"${g}" : q f \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.roc index dbe3f487a5..809a11a8a8 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.roc @@ -1,2 +1,2 @@ -"""{(g)""":q +"""${g}""":q f diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.roc index c479285481..3f48e3217e 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.roc @@ -1 +1 @@ -"""""""${i""""""}" +"""""""${i""""""}" \ No newline at end of file diff --git a/crates/glue/src/RustGlue.roc b/crates/glue/src/RustGlue.roc index fa717deb61..a3761dcfcf 100644 --- a/crates/glue/src/RustGlue.roc +++ b/crates/glue/src/RustGlue.roc @@ -858,7 +858,7 @@ generate_non_nullable_unwrapped = \buf, types, name, tag_name, payload, discrimi pub struct ${escaped_name}(roc_std::RocBox<${name}_${tag_name}>); impl ${escaped_name} { - pub fn ${tag_name)(${constructor_arguments}) -> Self { + pub fn ${tag_name}(${constructor_arguments}) -> Self { let payload = ${name}_${tag_name} { ${payload_field_names} }; Self(roc_std::RocBox::new(payload)) @@ -997,7 +997,7 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina pub fn get_${tag_name}(mut self) -> ${escaped_name}_${tag_name} { debug_assert!(self.is_${tag_name}()); - unsafe { core::mem::ManuallyDrop::take(&mut self.ptr_read_union().{dtag_name}) } + unsafe { core::mem::ManuallyDrop::take(&mut self.ptr_read_union().${tag_name}) } } """ @@ -2218,7 +2218,7 @@ type_name = \types, id -> RocList(elem) -> elem_name = type_name(types, elem) - "roc_std::RocList<{delem_name}>" + "roc_std::RocList<${elem_name}>" RocBox(elem) -> elem_name = type_name(types, elem) diff --git a/www/content/tutorial.md b/www/content/tutorial.md index b05f5bcab7..344616cd1d 100644 --- a/www/content/tutorial.md +++ b/www/content/tutorial.md @@ -1017,7 +1017,7 @@ Sometimes you may want to document the type of a definition. For example, you mi ```roc # Takes a first_name string and a last_name string, and returns a string full_name = \first_name, last_name -> - "${first_name) ${last_name}" + "${first_name} ${last_name}" ``` Comments can be valuable documentation, but they can also get out of date and become misleading. If someone changes this function and forgets to update the comment, it will no longer be accurate. From 9689656845834fccfde99f029e8e700c664fad04 Mon Sep 17 00:00:00 2001 From: Norbert Hajagos Date: Fri, 10 Jan 2025 21:34:11 +0100 Subject: [PATCH 23/24] remove unused var causing errors in debug tests. --- crates/compiler/builtins/bitcode/src/utils.zig | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/compiler/builtins/bitcode/src/utils.zig b/crates/compiler/builtins/bitcode/src/utils.zig index bc415329f1..76443ce899 100644 --- a/crates/compiler/builtins/bitcode/src/utils.zig +++ b/crates/compiler/builtins/bitcode/src/utils.zig @@ -224,10 +224,7 @@ pub fn increfRcPtrC(ptr_to_refcount: *isize, amount: isize) callconv(.C) void { const old = @as(usize, @bitCast(refcount)); const new = old + @as(usize, @intCast(amount)); - const oldH = old - REFCOUNT_ONE + 1; - const newH = new - REFCOUNT_ONE + 1; - - std.debug.print("{} + {} = {}!\n", .{ oldH, amount, newH }); + std.debug.print("{} + {} = {}!\n", .{ old, amount, new }); } ptr_to_refcount.* = refcount + amount; @@ -390,10 +387,7 @@ inline fn decref_ptr_to_refcount( const new = @as(usize, @bitCast(refcount -% 1)); if (DEBUG_INCDEC and builtin.target.cpu.arch != .wasm32) { - const oldH = old - REFCOUNT_ONE + 1; - const newH = new - REFCOUNT_ONE + 1; - - std.debug.print("{} - 1 = {}!\n", .{ oldH, newH }); + std.debug.print("{} - 1 = {}!\n", .{ old, new }); } if (refcount == REFCOUNT_ONE_ISIZE) { From 0984732854a793057f2158a7fee44dc273ecedf7 Mon Sep 17 00:00:00 2001 From: Sam Mohr Date: Fri, 10 Jan 2025 13:08:13 -0800 Subject: [PATCH 24/24] Fix out-of-date syntax snapshots --- .../pass/block_string_ann.expr.result-ast | 11 +++- .../multiline_str_crazyness.expr.result-ast | 59 +++++++++---------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.result-ast index 7b63402fbc..e0c51eb4d8 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/block_string_ann.expr.result-ast @@ -18,8 +18,15 @@ value_defs: [ Annotation( @0-10 StrLiteral( - PlainLine( - "{(g)", + Line( + [ + Interpolated( + @5-6 Var { + module_name: "", + ident: "g", + }, + ), + ], ), ), @11-12 BoundVariable( diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.result-ast index 45d1b3eb6d..dfd4fdcbe4 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/multiline_str_crazyness.expr.result-ast @@ -1,37 +1,32 @@ -@0-18 SpaceAfter( - Apply( - @0-6 Str( - Block( - [], - ), +@0-18 Apply( + @0-6 Str( + Block( + [], ), - [ - @6-18 Str( - Line( - [ - Interpolated( - @9-16 Apply( - @9-10 Var { - module_name: "", - ident: "i", - }, - [ - @10-16 Str( - Block( - [], - ), - ), - ], - Space, - ), - ), - ], - ), - ), - ], - Space, ), [ - Newline, + @6-18 Str( + Line( + [ + Interpolated( + @9-16 Apply( + @9-10 Var { + module_name: "", + ident: "i", + }, + [ + @10-16 Str( + Block( + [], + ), + ), + ], + Space, + ), + ), + ], + ), + ), ], + Space, )