| ... | ... | @@ -7720,7 +7720,6 @@ fn funcCommon( |
| 7720 | 7720 | noalias_bits: u32, |
| 7721 | 7721 | is_noinline: bool, |
| 7722 | 7722 | ) CompileError!Air.Inst.Ref { |
| 7723 | | const fn_src = LazySrcLoc.nodeOffset(src_node_offset); |
| 7724 | 7723 | const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset }; |
| 7725 | 7724 | const cc_src: LazySrcLoc = .{ .node_offset_fn_type_cc = src_node_offset }; |
| 7726 | 7725 | |
| ... | ... | @@ -7791,13 +7790,11 @@ fn funcCommon( |
| 7791 | 7790 | param_types[i] = param.ty; |
| 7792 | 7791 | sema.analyzeParameter( |
| 7793 | 7792 | block, |
| 7794 | | fn_src, |
| 7795 | 7793 | .unneeded, |
| 7796 | 7794 | param, |
| 7797 | 7795 | comptime_params, |
| 7798 | 7796 | i, |
| 7799 | 7797 | &is_generic, |
| 7800 | | is_extern, |
| 7801 | 7798 | cc_workaround, |
| 7802 | 7799 | has_body, |
| 7803 | 7800 | ) catch |err| switch (err) { |
| ... | ... | @@ -7805,13 +7802,11 @@ fn funcCommon( |
| 7805 | 7802 | const decl = sema.mod.declPtr(block.src_decl); |
| 7806 | 7803 | try sema.analyzeParameter( |
| 7807 | 7804 | block, |
| 7808 | | fn_src, |
| 7809 | 7805 | Module.paramSrc(src_node_offset, sema.gpa, decl, i), |
| 7810 | 7806 | param, |
| 7811 | 7807 | comptime_params, |
| 7812 | 7808 | i, |
| 7813 | 7809 | &is_generic, |
| 7814 | | is_extern, |
| 7815 | 7810 | cc_workaround, |
| 7816 | 7811 | has_body, |
| 7817 | 7812 | ); |
| ... | ... | @@ -7821,9 +7816,10 @@ fn funcCommon( |
| 7821 | 7816 | }; |
| 7822 | 7817 | } |
| 7823 | 7818 | |
| 7819 | var is_comptime_ret = false; |
| 7824 | 7820 | const ret_poison = if (!is_generic) rp: { |
| 7825 | 7821 | if (sema.typeRequiresComptime(block, ret_ty_src, bare_return_type)) |ret_comptime| { |
| 7826 | | is_generic = ret_comptime; |
| 7822 | is_comptime_ret = ret_comptime; |
| 7827 | 7823 | break :rp bare_return_type.tag() == .generic_poison; |
| 7828 | 7824 | } else |err| switch (err) { |
| 7829 | 7825 | error.GenericPoison => { |
| ... | ... | @@ -7920,6 +7916,8 @@ fn funcCommon( |
| 7920 | 7916 | return sema.fail(block, cc_src, "'noinline' function cannot have callconv 'Inline'", .{}); |
| 7921 | 7917 | } |
| 7922 | 7918 | if (is_generic and sema.no_partial_func_ty) return error.GenericPoison; |
| 7919 | for (comptime_params) |ct| is_generic = is_generic or ct; |
| 7920 | is_generic = is_generic or is_comptime_ret; |
| 7923 | 7921 | |
| 7924 | 7922 | break :fn_ty try Type.Tag.function.create(sema.arena, .{ |
| 7925 | 7923 | .param_types = param_types, |
| ... | ... | @@ -8010,31 +8008,20 @@ fn funcCommon( |
| 8010 | 8008 | fn analyzeParameter( |
| 8011 | 8009 | sema: *Sema, |
| 8012 | 8010 | block: *Block, |
| 8013 | | func_src: LazySrcLoc, |
| 8014 | 8011 | param_src: LazySrcLoc, |
| 8015 | 8012 | param: Block.Param, |
| 8016 | 8013 | comptime_params: []bool, |
| 8017 | 8014 | i: usize, |
| 8018 | 8015 | is_generic: *bool, |
| 8019 | | is_extern: bool, |
| 8020 | 8016 | cc: std.builtin.CallingConvention, |
| 8021 | 8017 | has_body: bool, |
| 8022 | 8018 | ) !void { |
| 8023 | 8019 | const requires_comptime = try sema.typeRequiresComptime(block, param_src, param.ty); |
| 8024 | 8020 | comptime_params[i] = param.is_comptime or requires_comptime; |
| 8025 | | const this_generic = comptime_params[i] or param.ty.tag() == .generic_poison; |
| 8021 | const this_generic = param.ty.tag() == .generic_poison; |
| 8026 | 8022 | is_generic.* = is_generic.* or this_generic; |
| 8027 | | if (is_extern and this_generic) { |
| 8028 | | // TODO this check should exist somewhere for notes. |
| 8029 | | if (param_src == .unneeded) return error.NeededSourceLocation; |
| 8030 | | const msg = msg: { |
| 8031 | | const msg = try sema.errMsg(block, func_src, "extern function cannot be generic", .{}); |
| 8032 | | errdefer msg.destroy(sema.gpa); |
| 8033 | | |
| 8034 | | try sema.errNote(block, param_src, msg, "function is generic because of this parameter", .{}); |
| 8035 | | break :msg msg; |
| 8036 | | }; |
| 8037 | | return sema.failWithOwnedErrorMsg(msg); |
| 8023 | if (param.is_comptime and !Type.fnCallingConventionAllowsZigTypes(cc)) { |
| 8024 | return sema.fail(block, param_src, "comptime parameters not allowed in function with calling convention '{s}'", .{@tagName(cc)}); |
| 8038 | 8025 | } |
| 8039 | 8026 | if (this_generic and !Type.fnCallingConventionAllowsZigTypes(cc)) { |
| 8040 | 8027 | return sema.fail(block, param_src, "generic parameters not allowed in function with calling convention '{s}'", .{@tagName(cc)}); |