typecheck the panic function
this adds the prototype of panic to @import("builtin")
and then uses it to do an implicit cast of the panic
function to this prototype, rather than redoing all the
implicit cast logic.
closes #1894
closes #1895
This commit is contained in:
15
src/ir.cpp
15
src/ir.cpp
@@ -9949,7 +9949,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un
|
||||
ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
|
||||
ZigType *expected_type, size_t *backward_branch_count, size_t backward_branch_quota,
|
||||
ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
|
||||
IrExecutable *parent_exec)
|
||||
IrExecutable *parent_exec, AstNode *expected_type_source_node)
|
||||
{
|
||||
if (expected_type != nullptr && type_is_invalid(expected_type))
|
||||
return &codegen->invalid_instruction->value;
|
||||
@@ -9985,7 +9985,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod
|
||||
analyzed_executable->backward_branch_count = backward_branch_count;
|
||||
analyzed_executable->backward_branch_quota = backward_branch_quota;
|
||||
analyzed_executable->begin_scope = scope;
|
||||
ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, node);
|
||||
ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, expected_type_source_node);
|
||||
if (type_is_invalid(result_type))
|
||||
return &codegen->invalid_instruction->value;
|
||||
|
||||
@@ -10863,10 +10863,13 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ConstCastResultIdFnIsGeneric:
|
||||
add_error_note(ira->codegen, parent_msg, source_node,
|
||||
buf_sprintf("only one of the functions is generic"));
|
||||
break;
|
||||
case ConstCastResultIdFnAlign: // TODO
|
||||
case ConstCastResultIdFnCC: // TODO
|
||||
case ConstCastResultIdFnVarArgs: // TODO
|
||||
case ConstCastResultIdFnIsGeneric: // TODO
|
||||
case ConstCastResultIdFnReturnType: // TODO
|
||||
case ConstCastResultIdFnArgCount: // TODO
|
||||
case ConstCastResultIdFnGenericArgCount: // TODO
|
||||
@@ -13856,7 +13859,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call
|
||||
AstNode *body_node = fn_entry->body_node;
|
||||
result = ir_eval_const_value(ira->codegen, exec_scope, body_node, return_type,
|
||||
ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, fn_entry,
|
||||
nullptr, call_instruction->base.source_node, nullptr, ira->new_irb.exec);
|
||||
nullptr, call_instruction->base.source_node, nullptr, ira->new_irb.exec, return_type_node);
|
||||
|
||||
if (inferred_err_set_type != nullptr) {
|
||||
inferred_err_set_type->data.error_set.infer_fn = nullptr;
|
||||
@@ -14052,7 +14055,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call
|
||||
ConstExprValue *align_result = ir_eval_const_value(ira->codegen, impl_fn->child_scope,
|
||||
fn_proto_node->data.fn_proto.align_expr, get_align_amt_type(ira->codegen),
|
||||
ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota,
|
||||
nullptr, nullptr, fn_proto_node->data.fn_proto.align_expr, nullptr, ira->new_irb.exec);
|
||||
nullptr, nullptr, fn_proto_node->data.fn_proto.align_expr, nullptr, ira->new_irb.exec, nullptr);
|
||||
IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb,
|
||||
impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr);
|
||||
const_instruction->base.value = *align_result;
|
||||
@@ -18464,7 +18467,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct
|
||||
ZigType *void_type = ira->codegen->builtin_types.entry_void;
|
||||
ConstExprValue *cimport_result = ir_eval_const_value(ira->codegen, &cimport_scope->base, block_node, void_type,
|
||||
ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr,
|
||||
&cimport_scope->buf, block_node, nullptr, nullptr);
|
||||
&cimport_scope->buf, block_node, nullptr, nullptr, nullptr);
|
||||
if (type_is_invalid(cimport_result->type))
|
||||
return ira->codegen->invalid_instruction;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user