diff --git a/compiler/builtins/bitcode/src/utils.zig b/compiler/builtins/bitcode/src/utils.zig index c7887509be..772b8ce41e 100644 --- a/compiler/builtins/bitcode/src/utils.zig +++ b/compiler/builtins/bitcode/src/utils.zig @@ -25,9 +25,6 @@ comptime { @export(testing_roc_realloc, .{ .name = "roc_realloc", .linkage = .Strong }); @export(testing_roc_dealloc, .{ .name = "roc_dealloc", .linkage = .Strong }); @export(testing_roc_panic, .{ .name = "roc_panic", .linkage = .Strong }); - @export(testing_roc_expect_failed, .{ .name = "roc_expect_failed", .linkage = .Strong }); - } else { - @export(expect_failed, .{ .name = "roc_expect_failed", .linkage = .Strong }); } } @@ -48,14 +45,9 @@ fn testing_roc_dealloc(c_ptr: *c_void, _: u32) callconv(.C) void { std.testing.allocator.destroy(ptr); } -fn testing_roc_expect_failed() callconv(.C) void { - const stderr = std.io.getStdErr().writer(); - stderr.print("Expect failed inside test\n", .{}) catch unreachable; -} - -fn expect_failed() callconv(.C) void { - const stderr = std.io.getStdErr().writer(); - stderr.print("Expect failed outside test\n", .{}) catch unreachable; +export fn roc_expect_failed(func_ptr: usize) callconv(.C) void { + const func = @intToPtr(fn () void, func_ptr); + func(); } fn testing_roc_panic(c_ptr: *c_void, tag_id: u32) callconv(.C) void { diff --git a/compiler/gen_llvm/src/llvm/build.rs b/compiler/gen_llvm/src/llvm/build.rs index 4e873c5ac9..c31decb014 100644 --- a/compiler/gen_llvm/src/llvm/build.rs +++ b/compiler/gen_llvm/src/llvm/build.rs @@ -5175,7 +5175,11 @@ fn run_low_level<'a, 'ctx, 'env>( bd.position_at_end(throw_block); - call_void_bitcode_fn(env, &[], bitcode::EXPECT_FAILED); + call_void_bitcode_fn( + env, + &[env.ptr_int().const_int(0 as u64, false).into()], + bitcode::EXPECT_FAILED, + ); bd.build_unconditional_branch(then_block); bd.position_at_end(then_block);