Use context.assertion_failure_proc with type assertions when the context is available, otherwise use a trivial trap.

This commit is contained in:
gingerBill
2026-01-26 18:23:29 +00:00
parent 467954bc7b
commit 3586bda6ae
5 changed files with 509 additions and 37 deletions

View File

@@ -803,7 +803,12 @@ gb_internal lbValue lb_emit_union_cast(lbProcedure *p, lbValue value, Type *type
args[5] = lb_typeid(m, dst_type);
args[6] = lb_emit_conv(p, value_, t_rawptr);
}
lb_emit_runtime_call(p, "type_assertion_check2", args);
char const *name = "type_assertion_check2_contextless";
if (p->context_stack.count > 0) {
name = "type_assertion_check2_with_context";
}
lb_emit_runtime_call(p, name, args);
}
return lb_emit_load(p, lb_emit_struct_ep(p, v.addr, 0));
@@ -877,7 +882,11 @@ gb_internal lbAddr lb_emit_any_cast_addr(lbProcedure *p, lbValue value, Type *ty
args[5] = dst_typeid;
args[6] = lb_emit_struct_ev(p, value, 0);
}
lb_emit_runtime_call(p, "type_assertion_check2", args);
char const *name = "type_assertion_check2_contextless";
if (p->context_stack.count > 0) {
name = "type_assertion_check2_with_context";
}
lb_emit_runtime_call(p, name, args);
}
return lb_addr(lb_emit_struct_ep(p, v.addr, 0));