authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-18 21:15:40-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-18 21:15:40-05:00
log956ff8a7f98cad2f5f9b043e8a896609ea41f952
treee0dfd01974856834d7bec3946dc119a0b83187d3
parent132e2fa5d9cc17088082cf4797701214c20845f1

better error message generic instantiations


1 files changed, 9 insertions(+), 1 deletions(-)

src/ir.cpp+9-1
...@@ -4172,13 +4172,16 @@ IrInstruction *ir_gen_fn(CodeGen *codegen, FnTableEntry *fn_entry) {...@@ -4172,13 +4172,16 @@ IrInstruction *ir_gen_fn(CodeGen *codegen, FnTableEntry *fn_entry) {
4172static void add_call_stack_errors(CodeGen *codegen, IrExecutable *exec, ErrorMsg *err_msg, int limit) {4172static void add_call_stack_errors(CodeGen *codegen, IrExecutable *exec, ErrorMsg *err_msg, int limit) {
4173 if (!exec || !exec->source_node || limit < 0) return;4173 if (!exec || !exec->source_node || limit < 0) return;
4174 add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here"));4174 add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here"));
4175
4175 add_call_stack_errors(codegen, exec->parent_exec, err_msg, limit - 1);4176 add_call_stack_errors(codegen, exec->parent_exec, err_msg, limit - 1);
4176}4177}
41774178
4178static ErrorMsg *ir_add_error(IrAnalyze *ira, IrInstruction *source_instruction, Buf *msg) {4179static ErrorMsg *ir_add_error(IrAnalyze *ira, IrInstruction *source_instruction, Buf *msg) {
4179 ira->new_irb.exec->invalid = true;4180 ira->new_irb.exec->invalid = true;
4180 ErrorMsg *err_msg = add_node_error(ira->codegen, source_instruction->source_node, msg);4181 ErrorMsg *err_msg = add_node_error(ira->codegen, source_instruction->source_node, msg);
4181 add_call_stack_errors(ira->codegen, ira->new_irb.exec, err_msg, 10);4182 if (ira->new_irb.exec->parent_exec) {
4183 add_call_stack_errors(ira->codegen, ira->new_irb.exec, err_msg, 10);
4184 }
4182 return err_msg;4185 return err_msg;
4183}4186}
41844187
...@@ -6243,6 +6246,11 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -6243,6 +6246,11 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
6243 if (impl_fn->type_entry->id == TypeTableEntryIdInvalid)6246 if (impl_fn->type_entry->id == TypeTableEntryIdInvalid)
6244 return ira->codegen->builtin_types.entry_invalid;6247 return ira->codegen->builtin_types.entry_invalid;
62456248
6249 impl_fn->ir_executable.source_node = call_instruction->base.source_node;
6250 impl_fn->ir_executable.parent_exec = ira->new_irb.exec;
6251 impl_fn->analyzed_executable.source_node = call_instruction->base.source_node;
6252 impl_fn->analyzed_executable.parent_exec = ira->new_irb.exec;
6253
6246 ira->codegen->fn_protos.append(impl_fn);6254 ira->codegen->fn_protos.append(impl_fn);
6247 ira->codegen->fn_defs.append(impl_fn);6255 ira->codegen->fn_defs.append(impl_fn);
6248 }6256 }