Propagate more failures upwards

Fixes #4112
master
LemonBoy 2020-01-08 21:32:53 +01:00 committed by Andrew Kelley
parent 02ace4569e
commit 27b290f312
2 changed files with 13 additions and 3 deletions

View File

@ -4787,11 +4787,16 @@ static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry) {
ZigType *fn_type = fn_table_entry->type_entry;
assert(!fn_type->data.fn.is_generic);
ir_gen_fn(g, fn_table_entry);
if (!ir_gen_fn(g, fn_table_entry)) {
fn_table_entry->anal_state = FnAnalStateInvalid;
return;
}
if (fn_table_entry->ir_executable->first_err_trace_msg != nullptr) {
fn_table_entry->anal_state = FnAnalStateInvalid;
return;
}
if (g->verbose_ir) {
fprintf(stderr, "\n");
ast_render(stderr, fn_table_entry->body_node, 4);

View File

@ -9164,7 +9164,10 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
ir_ref_bb(irb->current_basic_block);
IrInstruction *result = ir_gen_node_extra(irb, node, scope, LValNone, nullptr);
assert(result);
if (result == irb->codegen->invalid_instruction)
return false;
if (irb->exec->first_err_trace_msg != nullptr) {
codegen->trace_err = irb->exec->first_err_trace_msg;
return false;
@ -12029,7 +12032,9 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
ir_executable->fn_entry = fn_entry;
ir_executable->c_import_buf = c_import_buf;
ir_executable->begin_scope = scope;
ir_gen(codegen, node, scope, ir_executable);
if (!ir_gen(codegen, node, scope, ir_executable))
return codegen->invalid_instruction->value;
if (ir_executable->first_err_trace_msg != nullptr) {
codegen->trace_err = ir_executable->first_err_trace_msg;