Files
c3c/test/test_suite/errors/else_with_void.c3t

55 lines
1.7 KiB
Plaintext

// #target: macos-x64
module func_point_test;
import std::io;
import std::collections;
alias FuncPoint = fn void(String text);
fn void test(String text = "test123")
{
io::printn(text);
}
fn void main()
{
HashMap{String, FuncPoint} map;
map.tinit();
map.set("test", &test);
String test_index = "index";
map[test_index]("Hello World") ?? test();
}
/* #expect: func_point_test.ll
define void @func_point_test.main() #0 {
entry:
%map = alloca %HashMap, align 8
%test_index = alloca %"char[]", align 8
%retparam = alloca ptr, align 8
call void @llvm.memset.p0.i64(ptr align 8 %map, i8 0, i64 48, i1 false)
%0 = call ptr @"std_collections_map$String$fn$void$String$$.HashMap.tinit"(ptr %map, i32 16, float 7.500000e-01)
%1 = call i8 @"std_collections_map$String$fn$void$String$$.HashMap.set"(ptr %map, ptr @.str, i64 4, ptr @func_point_test.test)
store %"char[]" { ptr @.str.1, i64 5 }, ptr %test_index, align 8
%lo = load ptr, ptr %test_index, align 8
%ptradd = getelementptr inbounds i8, ptr %test_index, i64 8
%hi = load i64, ptr %ptradd, align 8
%2 = call i64 @"std_collections_map$String$fn$void$String$$.HashMap.get"(ptr %retparam, ptr %map, ptr %lo, i64 %hi)
%not_err = icmp eq i64 %2, 0
%3 = call i1 @llvm.expect.i1(i1 %not_err, i1 true)
br i1 %3, label %after_check, label %else_block
after_check: ; preds = %entry
%4 = load ptr, ptr %retparam, align 8
call void %4(ptr @.str.2, i64 11)
br label %phi_block
else_block: ; preds = %entry
call void @func_point_test.test(ptr @.str.3, i64 7)
br label %phi_block
phi_block: ; preds = %else_block, %after_check
ret void
}