| ... | ... | @@ -78,6 +78,9 @@ post_hoc_blocks: std.AutoHashMapUnmanaged(Air.Inst.Index, *LabeledBlock) = .{}, |
| 78 | 78 | err: ?*Module.ErrorMsg = null, |
| 79 | 79 | /// True when analyzing a generic instantiation. Used to suppress some errors. |
| 80 | 80 | is_generic_instantiation: bool = false, |
| 81 | /// Set to true when analyzing a func type instruction so that nested generic |
| 82 | /// function types will emit generic poison instead of a partial type. |
| 83 | no_partial_func_ty: bool = false, |
| 81 | 84 | |
| 82 | 85 | const std = @import("std"); |
| 83 | 86 | const math = std.math; |
| ... | ... | @@ -7917,6 +7920,7 @@ fn funcCommon( |
| 7917 | 7920 | if (cc_workaround == .Inline and is_noinline) { |
| 7918 | 7921 | return sema.fail(block, cc_src, "'noinline' function cannot have callconv 'Inline'", .{}); |
| 7919 | 7922 | } |
| 7923 | if (is_generic and sema.no_partial_func_ty) return error.GenericPoison; |
| 7920 | 7924 | |
| 7921 | 7925 | break :fn_ty try Type.Tag.function.create(sema.arena, .{ |
| 7922 | 7926 | .param_types = param_types, |
| ... | ... | @@ -8097,25 +8101,19 @@ fn zirParam( |
| 8097 | 8101 | // Make sure any nested param instructions don't clobber our work. |
| 8098 | 8102 | const prev_params = block.params; |
| 8099 | 8103 | const prev_preallocated_new_func = sema.preallocated_new_func; |
| 8104 | const prev_no_partial_func_type = sema.no_partial_func_ty; |
| 8100 | 8105 | block.params = .{}; |
| 8101 | 8106 | sema.preallocated_new_func = null; |
| 8107 | sema.no_partial_func_ty = true; |
| 8102 | 8108 | defer { |
| 8103 | 8109 | block.params.deinit(sema.gpa); |
| 8104 | 8110 | block.params = prev_params; |
| 8105 | 8111 | sema.preallocated_new_func = prev_preallocated_new_func; |
| 8112 | sema.no_partial_func_ty = prev_no_partial_func_type; |
| 8106 | 8113 | } |
| 8107 | 8114 | |
| 8108 | 8115 | if (sema.resolveBody(block, body, inst)) |param_ty_inst| { |
| 8109 | 8116 | if (sema.analyzeAsType(block, src, param_ty_inst)) |param_ty| { |
| 8110 | | if (param_ty.zigTypeTag() == .Fn and param_ty.fnInfo().is_generic) { |
| 8111 | | // zirFunc will not emit error.GenericPoison to build a |
| 8112 | | // partial type for generic functions but we still need to |
| 8113 | | // detect if a function parameter is a generic function |
| 8114 | | // to force the parent function to also be generic. |
| 8115 | | if (!sema.inst_map.contains(inst)) { |
| 8116 | | break :err error.GenericPoison; |
| 8117 | | } |
| 8118 | | } |
| 8119 | 8117 | break :param_ty param_ty; |
| 8120 | 8118 | } else |err| break :err err; |
| 8121 | 8119 | } else |err| break :err err; |