| ... | @@ -1156,16 +1156,6 @@ fn fnProtoExpr( | ... | @@ -1156,16 +1156,6 @@ fn fnProtoExpr( |
| 1156 | return astgen.failNode(fn_proto.ast.section_expr, "linksection not allowed on function prototypes", .{}); | 1156 | return astgen.failNode(fn_proto.ast.section_expr, "linksection not allowed on function prototypes", .{}); |
| 1157 | } | 1157 | } |
| 1158 | | 1158 | |
| 1159 | const maybe_bang = tree.firstToken(fn_proto.ast.return_type) - 1; | | |
| 1160 | const is_inferred_error = token_tags[maybe_bang] == .bang; | | |
| 1161 | if (is_inferred_error) { | | |
| 1162 | return astgen.failTok(maybe_bang, "function prototype may not have inferred error set", .{}); | | |
| 1163 | } | | |
| 1164 | var ret_gz = gz.makeSubBlock(scope); | | |
| 1165 | defer ret_gz.instructions.deinit(gpa); | | |
| 1166 | const ret_ty = try expr(&ret_gz, scope, coerced_type_rl, fn_proto.ast.return_type); | | |
| 1167 | const ret_br = try ret_gz.addBreak(.break_inline, 0, ret_ty); | | |
| 1168 | | | |
| 1169 | const cc: Zir.Inst.Ref = if (fn_proto.ast.callconv_expr != 0) | 1159 | const cc: Zir.Inst.Ref = if (fn_proto.ast.callconv_expr != 0) |
| 1170 | try expr( | 1160 | try expr( |
| 1171 | gz, | 1161 | gz, |
| ... | @@ -1176,6 +1166,16 @@ fn fnProtoExpr( | ... | @@ -1176,6 +1166,16 @@ fn fnProtoExpr( |
| 1176 | else | 1166 | else |
| 1177 | Zir.Inst.Ref.none; | 1167 | Zir.Inst.Ref.none; |
| 1178 | | 1168 | |
| | 1169 | const maybe_bang = tree.firstToken(fn_proto.ast.return_type) - 1; |
| | 1170 | const is_inferred_error = token_tags[maybe_bang] == .bang; |
| | 1171 | if (is_inferred_error) { |
| | 1172 | return astgen.failTok(maybe_bang, "function prototype may not have inferred error set", .{}); |
| | 1173 | } |
| | 1174 | var ret_gz = gz.makeSubBlock(scope); |
| | 1175 | defer ret_gz.instructions.deinit(gpa); |
| | 1176 | const ret_ty = try expr(&ret_gz, scope, coerced_type_rl, fn_proto.ast.return_type); |
| | 1177 | const ret_br = try ret_gz.addBreak(.break_inline, 0, ret_ty); |
| | 1178 | |
| 1179 | const result = try gz.addFunc(.{ | 1179 | const result = try gz.addFunc(.{ |
| 1180 | .src_node = fn_proto.ast.proto_node, | 1180 | .src_node = fn_proto.ast.proto_node, |
| 1181 | .param_block = 0, | 1181 | .param_block = 0, |
| ... | @@ -3182,11 +3182,6 @@ fn fnDecl( | ... | @@ -3182,11 +3182,6 @@ fn fnDecl( |
| 3182 | break :inst try comptimeExpr(&decl_gz, params_scope, .{ .ty = .const_slice_u8_type }, fn_proto.ast.section_expr); | 3182 | break :inst try comptimeExpr(&decl_gz, params_scope, .{ .ty = .const_slice_u8_type }, fn_proto.ast.section_expr); |
| 3183 | }; | 3183 | }; |
| 3184 | | 3184 | |
| 3185 | var ret_gz = decl_gz.makeSubBlock(params_scope); | | |
| 3186 | defer ret_gz.instructions.deinit(gpa); | | |
| 3187 | const ret_ty = try expr(&ret_gz, params_scope, coerced_type_rl, fn_proto.ast.return_type); | | |
| 3188 | const ret_br = try ret_gz.addBreak(.break_inline, 0, ret_ty); | | |
| 3189 | | | |
| 3190 | const cc: Zir.Inst.Ref = blk: { | 3185 | const cc: Zir.Inst.Ref = blk: { |
| 3191 | if (fn_proto.ast.callconv_expr != 0) { | 3186 | if (fn_proto.ast.callconv_expr != 0) { |
| 3192 | if (has_inline_keyword) { | 3187 | if (has_inline_keyword) { |
| ... | @@ -3212,6 +3207,11 @@ fn fnDecl( | ... | @@ -3212,6 +3207,11 @@ fn fnDecl( |
| 3212 | } | 3207 | } |
| 3213 | }; | 3208 | }; |
| 3214 | | 3209 | |
| | 3210 | var ret_gz = decl_gz.makeSubBlock(params_scope); |
| | 3211 | defer ret_gz.instructions.deinit(gpa); |
| | 3212 | const ret_ty = try expr(&ret_gz, params_scope, coerced_type_rl, fn_proto.ast.return_type); |
| | 3213 | const ret_br = try ret_gz.addBreak(.break_inline, 0, ret_ty); |
| | 3214 | |
| 3215 | const func_inst: Zir.Inst.Ref = if (body_node == 0) func: { | 3215 | const func_inst: Zir.Inst.Ref = if (body_node == 0) func: { |
| 3216 | if (!is_extern) { | 3216 | if (!is_extern) { |
| 3217 | return astgen.failTok(fn_proto.ast.fn_token, "non-extern function has no body", .{}); | 3217 | return astgen.failTok(fn_proto.ast.fn_token, "non-extern function has no body", .{}); |