| ... | ... | @@ -2584,17 +2584,16 @@ static bool scope_is_root_decls(Scope *scope) { |
| 2584 | 2584 | |
| 2585 | 2585 | static void wrong_panic_prototype(CodeGen *g, AstNode *proto_node, TypeTableEntry *fn_type) { |
| 2586 | 2586 | add_node_error(g, proto_node, |
| 2587 | | buf_sprintf("expected 'fn([]const u8) -> unreachable', found '%s'", |
| 2587 | buf_sprintf("expected 'fn([]const u8, ?&builtin.StackTrace) -> unreachable', found '%s'", |
| 2588 | 2588 | buf_ptr(&fn_type->name))); |
| 2589 | 2589 | } |
| 2590 | 2590 | |
| 2591 | 2591 | static void typecheck_panic_fn(CodeGen *g, FnTableEntry *panic_fn) { |
| 2592 | | return; // TODO |
| 2593 | 2592 | AstNode *proto_node = panic_fn->proto_node; |
| 2594 | 2593 | assert(proto_node->type == NodeTypeFnProto); |
| 2595 | 2594 | TypeTableEntry *fn_type = panic_fn->type_entry; |
| 2596 | 2595 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; |
| 2597 | | if (fn_type_id->param_count != 1) { |
| 2596 | if (fn_type_id->param_count != 2) { |
| 2598 | 2597 | return wrong_panic_prototype(g, proto_node, fn_type); |
| 2599 | 2598 | } |
| 2600 | 2599 | TypeTableEntry *const_u8_ptr = get_pointer_to_type(g, g->builtin_types.entry_u8, true); |
| ... | ... | @@ -2603,6 +2602,11 @@ static void typecheck_panic_fn(CodeGen *g, FnTableEntry *panic_fn) { |
| 2603 | 2602 | return wrong_panic_prototype(g, proto_node, fn_type); |
| 2604 | 2603 | } |
| 2605 | 2604 | |
| 2605 | TypeTableEntry *nullable_ptr_to_stack_trace_type = get_maybe_type(g, get_ptr_to_stack_trace_type(g)); |
| 2606 | if (fn_type_id->param_info[1].type != nullable_ptr_to_stack_trace_type) { |
| 2607 | return wrong_panic_prototype(g, proto_node, fn_type); |
| 2608 | } |
| 2609 | |
| 2606 | 2610 | TypeTableEntry *actual_return_type = fn_type_id->return_type; |
| 2607 | 2611 | if (actual_return_type != g->builtin_types.entry_unreachable) { |
| 2608 | 2612 | return wrong_panic_prototype(g, proto_node, fn_type); |