From 786e238a7f1034a09bc0471b3796051abb874e14 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 5 Aug 2021 23:20:10 -0700 Subject: [PATCH] AstGen: fix function declarations They were putting their return type expressions into the wrong ZIR block, resulting in a compiler crash. --- src/AstGen.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AstGen.zig b/src/AstGen.zig index febe581e35..1b6cbc6c3f 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -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: {