From 1bca8e693d42256d575c76fbab5c68d86c0c4bc3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 11 Nov 2019 13:18:16 -0500 Subject: fix anon literal used with return result loc --- src/ir.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index f1b31af582..e278193785 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -6151,7 +6151,11 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A init_array_type_source_node = container_type->source_node; } else { child_result_loc = parent_result_loc; - init_array_type_source_node = parent_result_loc->source_instruction->source_node; + if (parent_result_loc->source_instruction != nullptr) { + init_array_type_source_node = parent_result_loc->source_instruction->source_node; + } else { + init_array_type_source_node = node; + } } switch (kind) { @@ -15935,6 +15939,10 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, instruction->result_loc->source_instruction->child); if (type_is_invalid(implicit_elem_type)) return ira->codegen->invalid_instruction; + } else if (instruction->result_loc->id == ResultLocIdReturn) { + implicit_elem_type = ira->explicit_return_type; + if (type_is_invalid(implicit_elem_type)) + return ira->codegen->invalid_instruction; } else { Buf *bare_name = buf_alloc(); Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct), -- cgit v1.2.3