AstGen: fix function declarations

They were putting their return type expressions into the wrong ZIR
block, resulting in a compiler crash.
This commit is contained in:
Andrew Kelley
2021-08-05 23:20:10 -07:00
parent 47f2463b5c
commit 786e238a7f

View File

@@ -3004,9 +3004,9 @@ fn fnDecl(
break :inst try comptimeExpr(&decl_gz, params_scope, .{ .ty = .const_slice_u8_type }, fn_proto.ast.section_expr);
};
var ret_gz = gz.makeSubBlock(params_scope);
var ret_gz = decl_gz.makeSubBlock(params_scope);
defer ret_gz.instructions.deinit(gpa);
const ret_ty = try expr(&decl_gz, params_scope, coerced_type_rl, fn_proto.ast.return_type);
const ret_ty = try expr(&ret_gz, params_scope, coerced_type_rl, fn_proto.ast.return_type);
const ret_br = try ret_gz.addBreak(.break_inline, 0, ret_ty);
const cc: Zir.Inst.Ref = blk: {