From 737d76684125a95371702851cd99a523ef6ee057 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Mon, 20 Nov 2023 20:44:58 -0500 Subject: [PATCH 01/16] add node to dev inputs --- flake.nix | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index cfb5b92855..cf7a3c98ed 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,8 @@ description = "Roc flake"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs?rev=676fe5e01b9a41fa14aaa48d87685677664104b1"; + nixpkgs.url = + "github:nixos/nixpkgs?rev=676fe5e01b9a41fa14aaa48d87685677664104b1"; # rust from nixpkgs has some libc problems, this is patched in the rust-overlay rust-overlay = { @@ -27,7 +28,9 @@ }; outputs = { self, nixpkgs, rust-overlay, flake-utils, nixgl, ... }@inputs: - let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; + let + supportedSystems = + [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; in flake-utils.lib.eachSystem supportedSystems (system: let overlays = [ (import rust-overlay) ] @@ -37,8 +40,9 @@ 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; @@ -58,11 +62,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) + ]); # For debugging LLVM IR debugir = pkgs.stdenv.mkDerivation { @@ -116,6 +120,8 @@ wasm-pack # for repl_wasm jq # used in several bash scripts cargo-nextest # used to give more info for segfaults for gen tests + + nodejs_18 # for npx in `build-dev-local` ]); aliases = '' @@ -124,15 +130,15 @@ alias fmtc='cargo fmt --all -- --check' ''; - in - { + in { devShell = pkgs.mkShell { - buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs ++ darwinDevInputs ++ linuxDevInputs + buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs + ++ darwinDevInputs ++ linuxDevInputs ++ (if system == "x86_64-linux" then - [ pkgs.nixgl.nixVulkanIntel ] - else - [ ]); + [ pkgs.nixgl.nixVulkanIntel ] + else + [ ]); # nix does not store libs in /usr/lib or /lib # for libgcc_s.so.1 @@ -144,8 +150,8 @@ LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath - ([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ] - ++ linuxDevInputs); + ([ 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 @@ -160,7 +166,7 @@ # You can build this package (the roc CLI) with the `nix build` command. packages = { default = rocBuild.roc-cli; - + # all rust crates in workspace.members of Cargo.toml full = rocBuild.roc-full; # only the CLI crate = executable provided in nightly releases From 23e22693d4b110edb995474bd9b1dce51504ccf9 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:43:31 -0500 Subject: [PATCH 02/16] switch @panic to roc_panic to really throw panics for bad numeric ops --- crates/compiler/builtins/bitcode/src/dec.zig | 31 +++++++++++++------- crates/compiler/builtins/bitcode/src/num.zig | 7 ++++- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/crates/compiler/builtins/bitcode/src/dec.zig b/crates/compiler/builtins/bitcode/src/dec.zig index 75340094e7..7cb8d2825a 100644 --- a/crates/compiler/builtins/bitcode/src/dec.zig +++ b/crates/compiler/builtins/bitcode/src/dec.zig @@ -369,7 +369,7 @@ pub const RocDec = extern struct { // (n / 0) is an error if (denominator_i128 == 0) { - @panic("TODO runtime exception for dividing by 0!"); + roc_panic("Decimal divison by 0", 0); } // If they're both negative, or if neither is negative, the final answer @@ -397,7 +397,8 @@ pub const RocDec = extern struct { if (denominator_i128 == one_point_zero_i128) { return self; } else { - @panic("TODO runtime exception for overflow when dividing!"); + roc_panic("Decimal divison overflow in numerator", 0); + unreachable; } }; const numerator_u128 = @as(u128, @intCast(numerator_abs_i128)); @@ -410,7 +411,8 @@ pub const RocDec = extern struct { if (numerator_i128 == one_point_zero_i128) { return other; } else { - @panic("TODO runtime exception for overflow when dividing!"); + roc_panic("Decimal divison overflow in denominator", 0); + unreachable; } }; const denominator_u128 = @as(u128, @intCast(denominator_abs_i128)); @@ -422,7 +424,7 @@ pub const RocDec = extern struct { if (answer.hi == 0 and answer.lo <= math.maxInt(i128)) { unsigned_answer = @as(i128, @intCast(answer.lo)); } else { - @panic("TODO runtime exception for overflow when dividing!"); + roc_panic("Decimal divison overflow", 0); } return RocDec{ .num = if (is_answer_negative) -unsigned_answer else unsigned_answer }; @@ -632,7 +634,7 @@ fn mul_and_decimalize(a: u128, b: u128) i128 { const d = answer[0]; if (overflowed == 1) { - @panic("TODO runtime exception for overflow!"); + roc_panic("Decimal multiplication overflow", 0); } // Final 512bit value is d, c, b, a @@ -1208,7 +1210,8 @@ pub fn fromF64C(arg: f64) callconv(.C) i128 { if (@call(.always_inline, RocDec.fromF64, .{arg})) |dec| { return dec.num; } else { - @panic("TODO runtime exception failing convert f64 to RocDec"); + roc_panic("Decimal conversion from f64", 0); + unreachable; } } @@ -1217,7 +1220,8 @@ pub fn fromF32C(arg_f32: f32) callconv(.C) i128 { if (@call(.always_inline, RocDec.fromF64, .{arg_f64})) |dec| { return dec.num; } else { - @panic("TODO runtime exception failing convert f64 to RocDec"); + roc_panic("Decimal conversion from f32", 0); + unreachable; } } @@ -1232,7 +1236,8 @@ pub fn exportFromInt(comptime T: type, comptime name: []const u8) void { const answer = @mulWithOverflow(this, RocDec.one_point_zero_i128); if (answer[1] == 1) { - @panic("TODO runtime exception failing convert integer to RocDec"); + roc_panic("Decimal conversion from integer", 0); + unreachable; } else { return answer[0]; } @@ -1258,11 +1263,17 @@ pub fn neqC(arg1: RocDec, arg2: RocDec) callconv(.C) bool { } pub fn negateC(arg: RocDec) callconv(.C) i128 { - return if (@call(.always_inline, RocDec.negate, .{arg})) |dec| dec.num else @panic("TODO overflow for negating RocDec"); + return if (@call(.always_inline, RocDec.negate, .{arg})) |dec| dec.num else { + roc_panic("Decimal negation overflow", 0); + unreachable; + }; } pub fn absC(arg: RocDec) callconv(.C) i128 { - const result = @call(.always_inline, RocDec.abs, .{arg}) catch @panic("TODO overflow for calling absolute value on RocDec"); + const result = @call(.always_inline, RocDec.abs, .{arg}) catch { + roc_panic("Decimal absolute value overflow", 0); + unreachable; + }; return result.num; } diff --git a/crates/compiler/builtins/bitcode/src/num.zig b/crates/compiler/builtins/bitcode/src/num.zig index c978af99e1..8a148e5553 100644 --- a/crates/compiler/builtins/bitcode/src/num.zig +++ b/crates/compiler/builtins/bitcode/src/num.zig @@ -233,7 +233,12 @@ pub fn exportCeiling(comptime F: type, comptime T: type, comptime name: []const pub fn exportDivCeil(comptime T: type, comptime name: []const u8) void { comptime var f = struct { fn func(a: T, b: T) callconv(.C) T { - return math.divCeil(T, a, b) catch @panic("TODO runtime exception for dividing by 0!"); + return math.divCeil(T, a, b) catch { + roc_panic("integer divison by 0", 0); + unreachable; + }; + + // return math.divCeil(T, a, b) catch @panic("TODO runtime exception for dividing by 0!"); } }.func; @export(f, .{ .name = name ++ @typeName(T), .linkage = .Strong }); From 191752e9797b3424161d7adce2ed0d466ece4293 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:43:39 -0500 Subject: [PATCH 03/16] add zls to flake --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index cf7a3c98ed..cd58b4bafa 100644 --- a/flake.nix +++ b/flake.nix @@ -120,8 +120,8 @@ wasm-pack # for repl_wasm jq # used in several bash scripts cargo-nextest # used to give more info for segfaults for gen tests - nodejs_18 # for npx in `build-dev-local` + zls # zig language server ]); aliases = '' From 5df2199ef58941033b9ea367e789da16e5413488 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:45:56 -0500 Subject: [PATCH 04/16] add test for dec division --- crates/compiler/test_gen/src/gen_num.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/compiler/test_gen/src/gen_num.rs b/crates/compiler/test_gen/src/gen_num.rs index c6651b9416..54b27f5533 100644 --- a/crates/compiler/test_gen/src/gen_num.rs +++ b/crates/compiler/test_gen/src/gen_num.rs @@ -799,6 +799,13 @@ fn gen_div_checked_by_zero_dec() { ); } +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] +#[should_panic(expected = r#"Roc failed with message: "Decimal divison by 0"#)] +fn gen_div_dec_by_zero() { + assert_evals_to!("1dec / 0", RocDec::from_str_to_i128_unsafe("-1"), i128); +} + #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn gen_int_eq() { @@ -1175,6 +1182,22 @@ fn gen_div_checked_by_zero_i64() { ); } +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] +fn gen_div_by_zero_i64() { + assert_evals_to!( + indoc!( + r#" + when Num.divTruncChecked 1000 0 is + Err DivByZero -> 99 + _ -> -24 + "# + ), + 99, + i64 + ); +} + #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))] fn gen_rem_i64() { From 863ecd8da50c48a61eefa13fabe62a7cb993e962 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:53:42 -0500 Subject: [PATCH 05/16] be excited to panic... --- crates/compiler/builtins/bitcode/src/dec.zig | 20 ++++++++++---------- crates/compiler/builtins/bitcode/src/num.zig | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/compiler/builtins/bitcode/src/dec.zig b/crates/compiler/builtins/bitcode/src/dec.zig index 7cb8d2825a..6c72e8624d 100644 --- a/crates/compiler/builtins/bitcode/src/dec.zig +++ b/crates/compiler/builtins/bitcode/src/dec.zig @@ -369,7 +369,7 @@ pub const RocDec = extern struct { // (n / 0) is an error if (denominator_i128 == 0) { - roc_panic("Decimal divison by 0", 0); + roc_panic("Decimal divison by 0!", 0); } // If they're both negative, or if neither is negative, the final answer @@ -397,7 +397,7 @@ pub const RocDec = extern struct { if (denominator_i128 == one_point_zero_i128) { return self; } else { - roc_panic("Decimal divison overflow in numerator", 0); + roc_panic("Decimal divison overflow in numerator!", 0); unreachable; } }; @@ -411,7 +411,7 @@ pub const RocDec = extern struct { if (numerator_i128 == one_point_zero_i128) { return other; } else { - roc_panic("Decimal divison overflow in denominator", 0); + roc_panic("Decimal divison overflow in denominator!", 0); unreachable; } }; @@ -424,7 +424,7 @@ pub const RocDec = extern struct { if (answer.hi == 0 and answer.lo <= math.maxInt(i128)) { unsigned_answer = @as(i128, @intCast(answer.lo)); } else { - roc_panic("Decimal divison overflow", 0); + roc_panic("Decimal divison overflow!", 0); } return RocDec{ .num = if (is_answer_negative) -unsigned_answer else unsigned_answer }; @@ -634,7 +634,7 @@ fn mul_and_decimalize(a: u128, b: u128) i128 { const d = answer[0]; if (overflowed == 1) { - roc_panic("Decimal multiplication overflow", 0); + roc_panic("Decimal multiplication overflow!", 0); } // Final 512bit value is d, c, b, a @@ -1210,7 +1210,7 @@ pub fn fromF64C(arg: f64) callconv(.C) i128 { if (@call(.always_inline, RocDec.fromF64, .{arg})) |dec| { return dec.num; } else { - roc_panic("Decimal conversion from f64", 0); + roc_panic("Decimal conversion from f64!", 0); unreachable; } } @@ -1220,7 +1220,7 @@ pub fn fromF32C(arg_f32: f32) callconv(.C) i128 { if (@call(.always_inline, RocDec.fromF64, .{arg_f64})) |dec| { return dec.num; } else { - roc_panic("Decimal conversion from f32", 0); + roc_panic("Decimal conversion from f32!", 0); unreachable; } } @@ -1236,7 +1236,7 @@ pub fn exportFromInt(comptime T: type, comptime name: []const u8) void { const answer = @mulWithOverflow(this, RocDec.one_point_zero_i128); if (answer[1] == 1) { - roc_panic("Decimal conversion from integer", 0); + roc_panic("Decimal conversion from integer!", 0); unreachable; } else { return answer[0]; @@ -1264,14 +1264,14 @@ pub fn neqC(arg1: RocDec, arg2: RocDec) callconv(.C) bool { pub fn negateC(arg: RocDec) callconv(.C) i128 { return if (@call(.always_inline, RocDec.negate, .{arg})) |dec| dec.num else { - roc_panic("Decimal negation overflow", 0); + roc_panic("Decimal negation overflow!", 0); unreachable; }; } pub fn absC(arg: RocDec) callconv(.C) i128 { const result = @call(.always_inline, RocDec.abs, .{arg}) catch { - roc_panic("Decimal absolute value overflow", 0); + roc_panic("Decimal absolute value overflow!", 0); unreachable; }; return result.num; diff --git a/crates/compiler/builtins/bitcode/src/num.zig b/crates/compiler/builtins/bitcode/src/num.zig index 8a148e5553..7d0a61c8f5 100644 --- a/crates/compiler/builtins/bitcode/src/num.zig +++ b/crates/compiler/builtins/bitcode/src/num.zig @@ -234,7 +234,7 @@ pub fn exportDivCeil(comptime T: type, comptime name: []const u8) void { comptime var f = struct { fn func(a: T, b: T) callconv(.C) T { return math.divCeil(T, a, b) catch { - roc_panic("integer divison by 0", 0); + roc_panic("integer divison by 0!", 0); unreachable; }; From abc92ded95d318cce94b17ac03c752b91b9a7879 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Mon, 20 Nov 2023 23:27:24 -0500 Subject: [PATCH 06/16] add test for divCeil by 0 --- crates/compiler/builtins/bitcode/src/num.zig | 10 ++++------ crates/compiler/test_gen/src/gen_num.rs | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/crates/compiler/builtins/bitcode/src/num.zig b/crates/compiler/builtins/bitcode/src/num.zig index 7d0a61c8f5..ef14db0271 100644 --- a/crates/compiler/builtins/bitcode/src/num.zig +++ b/crates/compiler/builtins/bitcode/src/num.zig @@ -234,11 +234,9 @@ pub fn exportDivCeil(comptime T: type, comptime name: []const u8) void { comptime var f = struct { fn func(a: T, b: T) callconv(.C) T { return math.divCeil(T, a, b) catch { - roc_panic("integer divison by 0!", 0); + roc_panic("Integer divison by 0!", 0); unreachable; }; - - // return math.divCeil(T, a, b) catch @panic("TODO runtime exception for dividing by 0!"); } }.func; @export(f, .{ .name = name ++ @typeName(T), .linkage = .Strong }); @@ -384,7 +382,7 @@ pub fn exportAddOrPanic(comptime T: type, comptime name: []const u8) void { fn func(self: T, other: T) callconv(.C) T { const result = addWithOverflow(T, self, other); if (result.has_overflowed) { - roc_panic("integer addition overflowed!", 0); + roc_panic("Integer addition overflowed!", 0); unreachable; } else { return result.value; @@ -442,7 +440,7 @@ pub fn exportSubOrPanic(comptime T: type, comptime name: []const u8) void { fn func(self: T, other: T) callconv(.C) T { const result = subWithOverflow(T, self, other); if (result.has_overflowed) { - roc_panic("integer subtraction overflowed!", 0); + roc_panic("Integer subtraction overflowed!", 0); unreachable; } else { return result.value; @@ -627,7 +625,7 @@ pub fn exportMulOrPanic(comptime T: type, comptime W: type, comptime name: []con fn func(self: T, other: T) callconv(.C) T { const result = @call(.always_inline, mulWithOverflow, .{ T, W, self, other }); if (result.has_overflowed) { - roc_panic("integer multiplication overflowed!", 0); + roc_panic("Integer multiplication overflowed!", 0); unreachable; } else { return result.value; diff --git a/crates/compiler/test_gen/src/gen_num.rs b/crates/compiler/test_gen/src/gen_num.rs index 54b27f5533..83611970ee 100644 --- a/crates/compiler/test_gen/src/gen_num.rs +++ b/crates/compiler/test_gen/src/gen_num.rs @@ -801,11 +801,24 @@ fn gen_div_checked_by_zero_dec() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "Decimal divison by 0"#)] +#[should_panic(expected = r#"Roc failed with message: "Decimal divison by 0!"#)] fn gen_div_dec_by_zero() { assert_evals_to!("1dec / 0", RocDec::from_str_to_i128_unsafe("-1"), i128); } +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] +#[should_panic(expected = r#"Roc failed with message: "Integer divison by 0!"#)] +fn gen_div_ceil_by_zero() { + assert_evals_to!( + r#" + Num.divCeil 5 0 == 0 + "#, + false, + bool + ); +} + #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn gen_int_eq() { From 14478c888d648fa62b3699603a12fc3ac6f77d49 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Mon, 20 Nov 2023 23:41:08 -0500 Subject: [PATCH 07/16] remove bad copy paste --- crates/compiler/test_gen/src/gen_num.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/crates/compiler/test_gen/src/gen_num.rs b/crates/compiler/test_gen/src/gen_num.rs index 83611970ee..b268bf6147 100644 --- a/crates/compiler/test_gen/src/gen_num.rs +++ b/crates/compiler/test_gen/src/gen_num.rs @@ -1195,22 +1195,6 @@ fn gen_div_checked_by_zero_i64() { ); } -#[test] -#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -fn gen_div_by_zero_i64() { - assert_evals_to!( - indoc!( - r#" - when Num.divTruncChecked 1000 0 is - Err DivByZero -> 99 - _ -> -24 - "# - ), - 99, - i64 - ); -} - #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))] fn gen_rem_i64() { From c9e1456fc4a7c95ea3886349e447d0e3a0709388 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:11:41 -0500 Subject: [PATCH 08/16] fix formatting in flake --- flake.nix | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/flake.nix b/flake.nix index cd58b4bafa..769aaaf91b 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,7 @@ description = "Roc flake"; inputs = { - nixpkgs.url = - "github:nixos/nixpkgs?rev=676fe5e01b9a41fa14aaa48d87685677664104b1"; + nixpkgs.url = "github:nixos/nixpkgs?rev=676fe5e01b9a41fa14aaa48d87685677664104b1"; # rust from nixpkgs has some libc problems, this is patched in the rust-overlay rust-overlay = { @@ -28,9 +27,7 @@ }; outputs = { self, nixpkgs, rust-overlay, flake-utils, nixgl, ... }@inputs: - let - supportedSystems = - [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; + let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; in flake-utils.lib.eachSystem supportedSystems (system: let overlays = [ (import rust-overlay) ] @@ -40,9 +37,8 @@ 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; @@ -62,11 +58,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) + ]); # For debugging LLVM IR debugir = pkgs.stdenv.mkDerivation { @@ -130,15 +126,15 @@ alias fmtc='cargo fmt --all -- --check' ''; - in { + in + { devShell = pkgs.mkShell { - buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs - ++ darwinDevInputs ++ linuxDevInputs + buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs ++ darwinDevInputs ++ linuxDevInputs ++ (if system == "x86_64-linux" then - [ pkgs.nixgl.nixVulkanIntel ] - else - [ ]); + [ pkgs.nixgl.nixVulkanIntel ] + else + [ ]); # nix does not store libs in /usr/lib or /lib # for libgcc_s.so.1 @@ -150,8 +146,8 @@ LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath - ([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ] - ++ linuxDevInputs); + ([ 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 925cba48e149b1bd77d50b7294543d1a4a27002f Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Wed, 22 Nov 2023 11:06:16 -0500 Subject: [PATCH 09/16] update docs for wasm repl dev --- crates/lang_srv/debug_server.sh | 2 +- crates/repl_wasm/README.md | 5 +++-- www/.gitignore | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 www/.gitignore diff --git a/crates/lang_srv/debug_server.sh b/crates/lang_srv/debug_server.sh index 5510f3d8d7..b7a9100b89 100755 --- a/crates/lang_srv/debug_server.sh +++ b/crates/lang_srv/debug_server.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) ${SCRIPT_DIR}/../../target/debug/roc_ls "$@" 2> /tmp/roc_ls.err diff --git a/crates/repl_wasm/README.md b/crates/repl_wasm/README.md index be6731426c..5f4cd8fb58 100644 --- a/crates/repl_wasm/README.md +++ b/crates/repl_wasm/README.md @@ -14,13 +14,14 @@ crates/repl_wasm/build-www.sh ### 2. Make symlinks to the generated Wasm and JS ```bash -cd www/public +mkdir -p www/public/repl +cd www/public/repl ln -s ../../../crates/repl_wasm/build/roc_repl_wasm_bg.wasm ln -s ../../../crates/repl_wasm/build/roc_repl_wasm.js ``` These symlinks are ignored by Git. -> This is a bit different from the production build, where we copy all the files to `www/build/`. But for development, it's convenient to have just one copy of files like `www/public/repl.js`. You can make changes, reload your browser to see them, and commit them to Git, without getting mixed up between different copies of the same file. +> This is a bit different from the production build, where we copy all the files to `www/build/`. But for development, it's convenient to have just one copy of files like `www/public/repl/repl.js`. You can make changes, reload your browser to see them, and commit them to Git, without getting mixed up between different copies of the same file. ### 3. Run a local HTTP server diff --git a/www/.gitignore b/www/.gitignore new file mode 100644 index 0000000000..9bc9fa870c --- /dev/null +++ b/www/.gitignore @@ -0,0 +1,2 @@ +# ignore a symlink to the wasm repl code +public/repl \ No newline at end of file From 38207cff8a0d096ce934808e4e4eb5d18e993b92 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Wed, 22 Nov 2023 16:49:03 -0500 Subject: [PATCH 10/16] fix typo --- crates/compiler/builtins/bitcode/src/dec.zig | 8 ++++---- crates/compiler/builtins/bitcode/src/num.zig | 2 +- crates/compiler/test_gen/src/gen_num.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/compiler/builtins/bitcode/src/dec.zig b/crates/compiler/builtins/bitcode/src/dec.zig index 6c72e8624d..2507b81f15 100644 --- a/crates/compiler/builtins/bitcode/src/dec.zig +++ b/crates/compiler/builtins/bitcode/src/dec.zig @@ -369,7 +369,7 @@ pub const RocDec = extern struct { // (n / 0) is an error if (denominator_i128 == 0) { - roc_panic("Decimal divison by 0!", 0); + roc_panic("Decimal division by 0!", 0); } // If they're both negative, or if neither is negative, the final answer @@ -397,7 +397,7 @@ pub const RocDec = extern struct { if (denominator_i128 == one_point_zero_i128) { return self; } else { - roc_panic("Decimal divison overflow in numerator!", 0); + roc_panic("Decimal division overflow in numerator!", 0); unreachable; } }; @@ -411,7 +411,7 @@ pub const RocDec = extern struct { if (numerator_i128 == one_point_zero_i128) { return other; } else { - roc_panic("Decimal divison overflow in denominator!", 0); + roc_panic("Decimal division overflow in denominator!", 0); unreachable; } }; @@ -424,7 +424,7 @@ pub const RocDec = extern struct { if (answer.hi == 0 and answer.lo <= math.maxInt(i128)) { unsigned_answer = @as(i128, @intCast(answer.lo)); } else { - roc_panic("Decimal divison overflow!", 0); + roc_panic("Decimal division overflow!", 0); } return RocDec{ .num = if (is_answer_negative) -unsigned_answer else unsigned_answer }; diff --git a/crates/compiler/builtins/bitcode/src/num.zig b/crates/compiler/builtins/bitcode/src/num.zig index ef14db0271..594dfe6f4e 100644 --- a/crates/compiler/builtins/bitcode/src/num.zig +++ b/crates/compiler/builtins/bitcode/src/num.zig @@ -234,7 +234,7 @@ pub fn exportDivCeil(comptime T: type, comptime name: []const u8) void { comptime var f = struct { fn func(a: T, b: T) callconv(.C) T { return math.divCeil(T, a, b) catch { - roc_panic("Integer divison by 0!", 0); + roc_panic("Integer division by 0!", 0); unreachable; }; } diff --git a/crates/compiler/test_gen/src/gen_num.rs b/crates/compiler/test_gen/src/gen_num.rs index b268bf6147..4ca1152cc5 100644 --- a/crates/compiler/test_gen/src/gen_num.rs +++ b/crates/compiler/test_gen/src/gen_num.rs @@ -801,14 +801,14 @@ fn gen_div_checked_by_zero_dec() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "Decimal divison by 0!"#)] +#[should_panic(expected = r#"Roc failed with message: "Decimal division by 0!"#)] fn gen_div_dec_by_zero() { assert_evals_to!("1dec / 0", RocDec::from_str_to_i128_unsafe("-1"), i128); } #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "Integer divison by 0!"#)] +#[should_panic(expected = r#"Roc failed with message: "Integer division by 0!"#)] fn gen_div_ceil_by_zero() { assert_evals_to!( r#" From 4fe4041dc015b4ffeba8f56e3581fb601f775801 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:07:07 -0500 Subject: [PATCH 11/16] remove node from dev shell --- flake.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/flake.nix b/flake.nix index 769aaaf91b..f26a976097 100644 --- a/flake.nix +++ b/flake.nix @@ -116,7 +116,6 @@ wasm-pack # for repl_wasm jq # used in several bash scripts cargo-nextest # used to give more info for segfaults for gen tests - nodejs_18 # for npx in `build-dev-local` zls # zig language server ]); From 2a762f1379ea8cb45aaf646f86c1843ab1fa9dc3 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Mon, 27 Nov 2023 19:59:30 -0500 Subject: [PATCH 12/16] revert change of integer => Integer in panic messages --- crates/compiler/builtins/bitcode/src/num.zig | 8 ++++---- crates/compiler/test_gen/src/gen_num.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/compiler/builtins/bitcode/src/num.zig b/crates/compiler/builtins/bitcode/src/num.zig index 594dfe6f4e..614cf6ea0e 100644 --- a/crates/compiler/builtins/bitcode/src/num.zig +++ b/crates/compiler/builtins/bitcode/src/num.zig @@ -234,7 +234,7 @@ pub fn exportDivCeil(comptime T: type, comptime name: []const u8) void { comptime var f = struct { fn func(a: T, b: T) callconv(.C) T { return math.divCeil(T, a, b) catch { - roc_panic("Integer division by 0!", 0); + roc_panic("integer division by 0!", 0); unreachable; }; } @@ -382,7 +382,7 @@ pub fn exportAddOrPanic(comptime T: type, comptime name: []const u8) void { fn func(self: T, other: T) callconv(.C) T { const result = addWithOverflow(T, self, other); if (result.has_overflowed) { - roc_panic("Integer addition overflowed!", 0); + roc_panic("integer addition overflowed!", 0); unreachable; } else { return result.value; @@ -440,7 +440,7 @@ pub fn exportSubOrPanic(comptime T: type, comptime name: []const u8) void { fn func(self: T, other: T) callconv(.C) T { const result = subWithOverflow(T, self, other); if (result.has_overflowed) { - roc_panic("Integer subtraction overflowed!", 0); + roc_panic("integer subtraction overflowed!", 0); unreachable; } else { return result.value; @@ -625,7 +625,7 @@ pub fn exportMulOrPanic(comptime T: type, comptime W: type, comptime name: []con fn func(self: T, other: T) callconv(.C) T { const result = @call(.always_inline, mulWithOverflow, .{ T, W, self, other }); if (result.has_overflowed) { - roc_panic("Integer multiplication overflowed!", 0); + roc_panic("integer multiplication overflowed!", 0); unreachable; } else { return result.value; diff --git a/crates/compiler/test_gen/src/gen_num.rs b/crates/compiler/test_gen/src/gen_num.rs index 4ca1152cc5..8138235020 100644 --- a/crates/compiler/test_gen/src/gen_num.rs +++ b/crates/compiler/test_gen/src/gen_num.rs @@ -808,7 +808,7 @@ fn gen_div_dec_by_zero() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "Integer division by 0!"#)] +#[should_panic(expected = r#"Roc failed with message: "integer division by 0!"#)] fn gen_div_ceil_by_zero() { assert_evals_to!( r#" From a5180bed673478a9458c96be2c96e533e5e1295e Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Tue, 28 Nov 2023 00:00:54 -0500 Subject: [PATCH 13/16] make zig `roc_panic` return type be `noreturn` and remove some `unreachable` calls --- crates/compiler/builtins/bitcode/src/dec.zig | 12 +----------- crates/compiler/builtins/bitcode/src/num.zig | 4 ---- crates/compiler/builtins/bitcode/src/panic.zig | 6 +++--- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/crates/compiler/builtins/bitcode/src/dec.zig b/crates/compiler/builtins/bitcode/src/dec.zig index 2507b81f15..028f57a916 100644 --- a/crates/compiler/builtins/bitcode/src/dec.zig +++ b/crates/compiler/builtins/bitcode/src/dec.zig @@ -252,7 +252,6 @@ pub const RocDec = extern struct { if (answer.has_overflowed) { roc_panic("Decimal addition overflowed!", 0); - unreachable; } else { return answer.value; } @@ -283,7 +282,6 @@ pub const RocDec = extern struct { if (answer.has_overflowed) { roc_panic("Decimal subtraction overflowed!", 0); - unreachable; } else { return answer.value; } @@ -347,7 +345,6 @@ pub const RocDec = extern struct { if (answer.has_overflowed) { roc_panic("Decimal multiplication overflowed!", 0); - unreachable; } else { return answer.value; } @@ -398,7 +395,6 @@ pub const RocDec = extern struct { return self; } else { roc_panic("Decimal division overflow in numerator!", 0); - unreachable; } }; const numerator_u128 = @as(u128, @intCast(numerator_abs_i128)); @@ -412,7 +408,6 @@ pub const RocDec = extern struct { return other; } else { roc_panic("Decimal division overflow in denominator!", 0); - unreachable; } }; const denominator_u128 = @as(u128, @intCast(denominator_abs_i128)); @@ -634,7 +629,7 @@ fn mul_and_decimalize(a: u128, b: u128) i128 { const d = answer[0]; if (overflowed == 1) { - roc_panic("Decimal multiplication overflow!", 0); + roc_panic("Decimal multiplication overflow22!", 0); } // Final 512bit value is d, c, b, a @@ -1211,7 +1206,6 @@ pub fn fromF64C(arg: f64) callconv(.C) i128 { return dec.num; } else { roc_panic("Decimal conversion from f64!", 0); - unreachable; } } @@ -1221,7 +1215,6 @@ pub fn fromF32C(arg_f32: f32) callconv(.C) i128 { return dec.num; } else { roc_panic("Decimal conversion from f32!", 0); - unreachable; } } @@ -1237,7 +1230,6 @@ pub fn exportFromInt(comptime T: type, comptime name: []const u8) void { const answer = @mulWithOverflow(this, RocDec.one_point_zero_i128); if (answer[1] == 1) { roc_panic("Decimal conversion from integer!", 0); - unreachable; } else { return answer[0]; } @@ -1265,14 +1257,12 @@ pub fn neqC(arg1: RocDec, arg2: RocDec) callconv(.C) bool { pub fn negateC(arg: RocDec) callconv(.C) i128 { return if (@call(.always_inline, RocDec.negate, .{arg})) |dec| dec.num else { roc_panic("Decimal negation overflow!", 0); - unreachable; }; } pub fn absC(arg: RocDec) callconv(.C) i128 { const result = @call(.always_inline, RocDec.abs, .{arg}) catch { roc_panic("Decimal absolute value overflow!", 0); - unreachable; }; return result.num; } diff --git a/crates/compiler/builtins/bitcode/src/num.zig b/crates/compiler/builtins/bitcode/src/num.zig index 614cf6ea0e..845cf21aa3 100644 --- a/crates/compiler/builtins/bitcode/src/num.zig +++ b/crates/compiler/builtins/bitcode/src/num.zig @@ -235,7 +235,6 @@ pub fn exportDivCeil(comptime T: type, comptime name: []const u8) void { fn func(a: T, b: T) callconv(.C) T { return math.divCeil(T, a, b) catch { roc_panic("integer division by 0!", 0); - unreachable; }; } }.func; @@ -383,7 +382,6 @@ pub fn exportAddOrPanic(comptime T: type, comptime name: []const u8) void { const result = addWithOverflow(T, self, other); if (result.has_overflowed) { roc_panic("integer addition overflowed!", 0); - unreachable; } else { return result.value; } @@ -441,7 +439,6 @@ pub fn exportSubOrPanic(comptime T: type, comptime name: []const u8) void { const result = subWithOverflow(T, self, other); if (result.has_overflowed) { roc_panic("integer subtraction overflowed!", 0); - unreachable; } else { return result.value; } @@ -626,7 +623,6 @@ pub fn exportMulOrPanic(comptime T: type, comptime W: type, comptime name: []con const result = @call(.always_inline, mulWithOverflow, .{ T, W, self, other }); if (result.has_overflowed) { roc_panic("integer multiplication overflowed!", 0); - unreachable; } else { return result.value; } diff --git a/crates/compiler/builtins/bitcode/src/panic.zig b/crates/compiler/builtins/bitcode/src/panic.zig index 76ecd69e12..13224a67df 100644 --- a/crates/compiler/builtins/bitcode/src/panic.zig +++ b/crates/compiler/builtins/bitcode/src/panic.zig @@ -2,14 +2,14 @@ const std = @import("std"); const RocStr = @import("str.zig").RocStr; // Signals to the host that the program has panicked -extern fn roc_panic(msg: *const RocStr, tag_id: u32) callconv(.C) void; +extern fn roc_panic(msg: *const RocStr, tag_id: u32) callconv(.C) noreturn; -pub fn panic_help(msg: []const u8, tag_id: u32) void { +pub fn panic_help(msg: []const u8, tag_id: u32) noreturn { var str = RocStr.init(msg.ptr, msg.len); roc_panic(&str, tag_id); } // must export this explicitly because right now it is not used from zig code -pub fn panic(msg: *const RocStr, alignment: u32) callconv(.C) void { +pub fn panic(msg: *const RocStr, alignment: u32) callconv(.C) noreturn { return roc_panic(msg, alignment); } From d6f07092965d4c56a45c97643388607256b6e8bd Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Tue, 28 Nov 2023 20:21:56 -0500 Subject: [PATCH 14/16] feedback: update some panic messages --- crates/compiler/builtins/bitcode/src/dec.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/compiler/builtins/bitcode/src/dec.zig b/crates/compiler/builtins/bitcode/src/dec.zig index 028f57a916..177ed6c574 100644 --- a/crates/compiler/builtins/bitcode/src/dec.zig +++ b/crates/compiler/builtins/bitcode/src/dec.zig @@ -629,7 +629,7 @@ fn mul_and_decimalize(a: u128, b: u128) i128 { const d = answer[0]; if (overflowed == 1) { - roc_panic("Decimal multiplication overflow22!", 0); + roc_panic("Decimal multiplication overflow!", 0); } // Final 512bit value is d, c, b, a @@ -1205,7 +1205,7 @@ pub fn fromF64C(arg: f64) callconv(.C) i128 { if (@call(.always_inline, RocDec.fromF64, .{arg})) |dec| { return dec.num; } else { - roc_panic("Decimal conversion from f64!", 0); + roc_panic("Decimal conversion from f64 failed!", 0); } } @@ -1229,7 +1229,7 @@ pub fn exportFromInt(comptime T: type, comptime name: []const u8) void { const answer = @mulWithOverflow(this, RocDec.one_point_zero_i128); if (answer[1] == 1) { - roc_panic("Decimal conversion from integer!", 0); + roc_panic("Decimal conversion from integer failed!", 0); } else { return answer[0]; } From d37dd442f51f7e0507e0ccaa9052a34b5b89177a Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Tue, 28 Nov 2023 20:22:42 -0500 Subject: [PATCH 15/16] undo change in debug server --- crates/lang_srv/debug_server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/lang_srv/debug_server.sh b/crates/lang_srv/debug_server.sh index b7a9100b89..427c81be67 100755 --- a/crates/lang_srv/debug_server.sh +++ b/crates/lang_srv/debug_server.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/bash SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) ${SCRIPT_DIR}/../../target/debug/roc_ls "$@" 2> /tmp/roc_ls.err From 298f93d20cfd8ee37d6632b31359b2a9f7e2bc73 Mon Sep 17 00:00:00 2001 From: John Murray <5672686+JRMurr@users.noreply.github.com> Date: Tue, 28 Nov 2023 20:46:09 -0500 Subject: [PATCH 16/16] update a bunch of panic message to be capitalized --- crates/compiler/builtins/bitcode/src/dec.zig | 2 +- crates/compiler/builtins/bitcode/src/num.zig | 8 ++++---- crates/compiler/gen_llvm/src/llvm/lowlevel.rs | 16 +++++++-------- crates/compiler/gen_wasm/src/low_level.rs | 4 ++-- crates/compiler/test_gen/src/gen_list.rs | 2 +- crates/compiler/test_gen/src/gen_num.rs | 20 +++++++++---------- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/crates/compiler/builtins/bitcode/src/dec.zig b/crates/compiler/builtins/bitcode/src/dec.zig index 177ed6c574..7863548d34 100644 --- a/crates/compiler/builtins/bitcode/src/dec.zig +++ b/crates/compiler/builtins/bitcode/src/dec.zig @@ -1229,7 +1229,7 @@ pub fn exportFromInt(comptime T: type, comptime name: []const u8) void { const answer = @mulWithOverflow(this, RocDec.one_point_zero_i128); if (answer[1] == 1) { - roc_panic("Decimal conversion from integer failed!", 0); + roc_panic("Decimal conversion from Integer failed!", 0); } else { return answer[0]; } diff --git a/crates/compiler/builtins/bitcode/src/num.zig b/crates/compiler/builtins/bitcode/src/num.zig index 845cf21aa3..eb7c532dd4 100644 --- a/crates/compiler/builtins/bitcode/src/num.zig +++ b/crates/compiler/builtins/bitcode/src/num.zig @@ -234,7 +234,7 @@ pub fn exportDivCeil(comptime T: type, comptime name: []const u8) void { comptime var f = struct { fn func(a: T, b: T) callconv(.C) T { return math.divCeil(T, a, b) catch { - roc_panic("integer division by 0!", 0); + roc_panic("Integer division by 0!", 0); }; } }.func; @@ -381,7 +381,7 @@ pub fn exportAddOrPanic(comptime T: type, comptime name: []const u8) void { fn func(self: T, other: T) callconv(.C) T { const result = addWithOverflow(T, self, other); if (result.has_overflowed) { - roc_panic("integer addition overflowed!", 0); + roc_panic("Integer addition overflowed!", 0); } else { return result.value; } @@ -438,7 +438,7 @@ pub fn exportSubOrPanic(comptime T: type, comptime name: []const u8) void { fn func(self: T, other: T) callconv(.C) T { const result = subWithOverflow(T, self, other); if (result.has_overflowed) { - roc_panic("integer subtraction overflowed!", 0); + roc_panic("Integer subtraction overflowed!", 0); } else { return result.value; } @@ -622,7 +622,7 @@ pub fn exportMulOrPanic(comptime T: type, comptime W: type, comptime name: []con fn func(self: T, other: T) callconv(.C) T { const result = @call(.always_inline, mulWithOverflow, .{ T, W, self, other }); if (result.has_overflowed) { - roc_panic("integer multiplication overflowed!", 0); + roc_panic("Integer multiplication overflowed!", 0); } else { return result.value; } diff --git a/crates/compiler/gen_llvm/src/llvm/lowlevel.rs b/crates/compiler/gen_llvm/src/llvm/lowlevel.rs index ea9fbdecf3..8590762267 100644 --- a/crates/compiler/gen_llvm/src/llvm/lowlevel.rs +++ b/crates/compiler/gen_llvm/src/llvm/lowlevel.rs @@ -1535,7 +1535,7 @@ fn build_int_binop<'ctx>( ) .into_struct_value(); - throw_on_overflow(env, parent, result, "integer addition overflowed!") + throw_on_overflow(env, parent, result, "Integer addition overflowed!") } NumAddWrap => bd.new_build_int_add(lhs, rhs, "add_int_wrap").into(), NumAddChecked => { @@ -1566,7 +1566,7 @@ fn build_int_binop<'ctx>( ) .into_struct_value(); - throw_on_overflow(env, parent, result, "integer subtraction overflowed!") + throw_on_overflow(env, parent, result, "Integer subtraction overflowed!") } NumSubWrap => bd.new_build_int_sub(lhs, rhs, "sub_int").into(), NumSubChecked => { @@ -1597,7 +1597,7 @@ fn build_int_binop<'ctx>( ) .into_struct_value(); - throw_on_overflow(env, parent, result, "integer multiplication overflowed!") + throw_on_overflow(env, parent, result, "Integer multiplication overflowed!") } NumMulWrap => bd.new_build_int_mul(lhs, rhs, "mul_int").into(), NumMulSaturated => call_bitcode_fn( @@ -2350,7 +2350,7 @@ fn build_dec_binop<'a, 'ctx>( bitcode::DEC_ADD_WITH_OVERFLOW, lhs, rhs, - "decimal addition overflowed", + "Decimal addition overflowed", ), NumSub => build_dec_binop_throw_on_overflow( env, @@ -2358,7 +2358,7 @@ fn build_dec_binop<'a, 'ctx>( bitcode::DEC_SUB_WITH_OVERFLOW, lhs, rhs, - "decimal subtraction overflowed", + "Decimal subtraction overflowed", ), NumMul => build_dec_binop_throw_on_overflow( env, @@ -2366,7 +2366,7 @@ fn build_dec_binop<'a, 'ctx>( bitcode::DEC_MUL_WITH_OVERFLOW, lhs, rhs, - "decimal multiplication overflowed", + "Decimal multiplication overflowed", ), NumDivFrac => dec_binop_with_unchecked(env, bitcode::DEC_DIV, lhs, rhs), @@ -2659,7 +2659,7 @@ fn int_neg_raise_on_overflow<'ctx>( throw_internal_exception( env, parent, - "integer negation overflowed because its argument is the minimum value", + "Integer negation overflowed because its argument is the minimum value", ); builder.position_at_end(else_block); @@ -2690,7 +2690,7 @@ fn int_abs_raise_on_overflow<'ctx>( throw_internal_exception( env, parent, - "integer absolute overflowed because its argument is the minimum value", + "Integer absolute overflowed because its argument is the minimum value", ); builder.position_at_end(else_block); diff --git a/crates/compiler/gen_wasm/src/low_level.rs b/crates/compiler/gen_wasm/src/low_level.rs index 683fbd61c6..ae71c917b8 100644 --- a/crates/compiler/gen_wasm/src/low_level.rs +++ b/crates/compiler/gen_wasm/src/low_level.rs @@ -1382,7 +1382,7 @@ impl<'a> LowLevelCall<'a> { } NumAbs => { const PANIC_MSG: &str = - "integer absolute overflowed because its argument is the minimum value"; + "Integer absolute overflowed because its argument is the minimum value"; self.load_args(backend); @@ -1446,7 +1446,7 @@ impl<'a> LowLevelCall<'a> { } NumNeg => { const PANIC_MSG: &str = - "integer negation overflowed because its argument is the minimum value"; + "Integer negation overflowed because its argument is the minimum value"; self.load_args(backend); match CodeGenNumType::from(self.ret_layout) { diff --git a/crates/compiler/test_gen/src/gen_list.rs b/crates/compiler/test_gen/src/gen_list.rs index db6863b8da..fc7aa3736d 100644 --- a/crates/compiler/test_gen/src/gen_list.rs +++ b/crates/compiler/test_gen/src/gen_list.rs @@ -2934,7 +2934,7 @@ fn list_map_with_index() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "integer addition overflowed!"#)] +#[should_panic(expected = r#"Roc failed with message: "Integer addition overflowed!"#)] fn cleanup_because_exception() { assert_evals_to!( indoc!( diff --git a/crates/compiler/test_gen/src/gen_num.rs b/crates/compiler/test_gen/src/gen_num.rs index 8138235020..077f81ea97 100644 --- a/crates/compiler/test_gen/src/gen_num.rs +++ b/crates/compiler/test_gen/src/gen_num.rs @@ -575,7 +575,7 @@ fn various_sized_abs() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] #[should_panic( - expected = r#"Roc failed with message: "integer absolute overflowed because its argument is the minimum value"# + expected = r#"Roc failed with message: "Integer absolute overflowed because its argument is the minimum value"# )] fn abs_min_int_overflow() { assert_evals_to!( @@ -808,7 +808,7 @@ fn gen_div_dec_by_zero() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "integer division by 0!"#)] +#[should_panic(expected = r#"Roc failed with message: "Integer division by 0!"#)] fn gen_div_ceil_by_zero() { assert_evals_to!( r#" @@ -1601,7 +1601,7 @@ fn int_negate() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] #[should_panic( - expected = r#"Roc failed with message: "integer negation overflowed because its argument is the minimum value"# + expected = r#"Roc failed with message: "Integer negation overflowed because its argument is the minimum value"# )] fn neg_min_int_overflow() { assert_evals_to!( @@ -1829,7 +1829,7 @@ fn atan() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "integer addition overflowed!"#)] +#[should_panic(expected = r#"Roc failed with message: "Integer addition overflowed!"#)] fn int_add_overflow() { assert_evals_to!( indoc!( @@ -1904,7 +1904,7 @@ fn float_add_overflow() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "integer subtraction overflowed!"#)] +#[should_panic(expected = r#"Roc failed with message: "Integer subtraction overflowed!"#)] fn int_sub_overflow() { assert_evals_to!("-9_223_372_036_854_775_808 - 1", 0, i64); } @@ -1989,7 +1989,7 @@ fn float_sub_checked() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "integer multiplication overflowed!"#)] +#[should_panic(expected = r#"Roc failed with message: "Integer multiplication overflowed!"#)] fn int_positive_mul_overflow() { assert_evals_to!( indoc!( @@ -2004,7 +2004,7 @@ fn int_positive_mul_overflow() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "integer multiplication overflowed!"#)] +#[should_panic(expected = r#"Roc failed with message: "Integer multiplication overflowed!"#)] fn int_negative_mul_overflow() { assert_evals_to!( indoc!( @@ -3927,21 +3927,21 @@ fn num_abs_diff_float() { #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "integer subtraction overflowed!"#)] +#[should_panic(expected = r#"Roc failed with message: "Integer subtraction overflowed!"#)] fn num_abs_max_overflow() { assert_evals_to!(r#"Num.absDiff Num.maxI64 -1"#, 0, i64); } #[test] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] -#[should_panic(expected = r#"Roc failed with message: "integer subtraction overflowed!"#)] +#[should_panic(expected = r#"Roc failed with message: "Integer subtraction overflowed!"#)] fn num_abs_int_min_overflow() { assert_evals_to!(r#"Num.absDiff Num.minI64 0"#, 0, i64); } #[test] #[cfg(feature = "gen-llvm")] -#[should_panic(expected = r#"Roc failed with message: "integer subtraction overflowed!"#)] +#[should_panic(expected = r#"Roc failed with message: "Integer subtraction overflowed!"#)] fn num_abs_large_bits_min_overflow() { assert_evals_to!(r#"Num.absDiff Num.minI128 0"#, 0, i128); }