Browse Source

Fix proc literal bug not finding the associated `DeclInfo`

gingerBill 4 years ago
parent
commit
2d99a348b8
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/ir.cpp

+ 7 - 1
src/ir.cpp

@@ -132,6 +132,7 @@ struct irProcedure {
 	irModule *            module;
 	irModule *            module;
 	String                name;
 	String                name;
 	Type *                type;
 	Type *                type;
+	Ast *                 proc_lit; // only for actual anonymous procedure literals
 	Ast *                 type_expr;
 	Ast *                 type_expr;
 	Ast *                 body;
 	Ast *                 body;
 	u64                   tags;
 	u64                   tags;
@@ -6894,7 +6895,7 @@ irTargetList *ir_push_target_list(irProcedure *proc, Ast *label, irBlock *break_
 			}
 			}
 		}
 		}
 
 
-		GB_PANIC("ir_set_label_blocks: Unreachable");
+		GB_PANIC("ir_set_label_blocks: Unreachable; Unable to find label: %s", expr_to_string(label->Label.name));
 	}
 	}
 
 
 	return tl;
 	return tl;
@@ -6927,6 +6928,7 @@ irValue *ir_gen_anonymous_proc_lit(irModule *m, String prefix_name, Ast *expr, i
 	set_procedure_abi_types(type);
 	set_procedure_abi_types(type);
 	irValue *value = ir_value_procedure(m, nullptr, type, pl->type, pl->body, name);
 	irValue *value = ir_value_procedure(m, nullptr, type, pl->type, pl->body, name);
 
 
+	value->Proc.proc_lit = expr;
 	value->Proc.tags = pl->tags;
 	value->Proc.tags = pl->tags;
 	value->Proc.inlining = pl->inlining;
 	value->Proc.inlining = pl->inlining;
 	value->Proc.parent = proc;
 	value->Proc.parent = proc;
@@ -11390,6 +11392,10 @@ void ir_begin_procedure_body(irProcedure *proc) {
 	array_init(&proc->context_stack,    heap_allocator());
 	array_init(&proc->context_stack,    heap_allocator());
 
 
 	DeclInfo *decl = decl_info_of_entity(proc->entity);
 	DeclInfo *decl = decl_info_of_entity(proc->entity);
+	if (decl == nullptr && proc->proc_lit != nullptr) {
+		GB_ASSERT(proc->proc_lit->kind == Ast_ProcLit);
+		decl = proc->proc_lit->ProcLit.decl;
+	}
 	if (decl != nullptr) {
 	if (decl != nullptr) {
 		for_array(i, decl->labels) {
 		for_array(i, decl->labels) {
 			BlockLabel bl = decl->labels[i];
 			BlockLabel bl = decl->labels[i];