| ... | @@ -5923,6 +5923,10 @@ fn funcCommon( | ... | @@ -5923,6 +5923,10 @@ fn funcCommon( |
| 5923 | break :ret_ty ret_ty; | 5923 | break :ret_ty ret_ty; |
| 5924 | } else |err| break :err err; | 5924 | } else |err| break :err err; |
| 5925 | } else |err| break :err err; | 5925 | } else |err| break :err err; |
| | 5926 | // Check for generic params. |
| | 5927 | for (block.params.items) |param| { |
| | 5928 | if (param.ty.tag() == .generic_poison) is_generic = true; |
| | 5929 | } |
| 5926 | }; | 5930 | }; |
| 5927 | switch (err) { | 5931 | switch (err) { |
| 5928 | error.GenericPoison => { | 5932 | error.GenericPoison => { |
| ... | @@ -6111,6 +6115,13 @@ fn zirParam( | ... | @@ -6111,6 +6115,13 @@ fn zirParam( |
| 6111 | | 6115 | |
| 6112 | if (sema.resolveBody(block, body, inst)) |param_ty_inst| { | 6116 | if (sema.resolveBody(block, body, inst)) |param_ty_inst| { |
| 6113 | if (sema.analyzeAsType(block, src, param_ty_inst)) |param_ty| { | 6117 | if (sema.analyzeAsType(block, src, param_ty_inst)) |param_ty| { |
| | 6118 | if (param_ty.zigTypeTag() == .Fn and param_ty.fnInfo().is_generic) { |
| | 6119 | // zirFunc will not emit error.GenericPoison to build a |
| | 6120 | // partial type for generic functions but we still need to |
| | 6121 | // detect if a function parameter is a generic function |
| | 6122 | // to force the parent function to also be generic. |
| | 6123 | break :err error.GenericPoison; |
| | 6124 | } |
| 6114 | break :param_ty param_ty; | 6125 | break :param_ty param_ty; |
| 6115 | } else |err| break :err err; | 6126 | } else |err| break :err err; |
| 6116 | } else |err| break :err err; | 6127 | } else |err| break :err err; |
| ... | @@ -10965,6 +10976,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -10965,6 +10976,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 10965 | | 10976 | |
| 10966 | const operand = try sema.resolveBody(&child_block, body, inst); | 10977 | const operand = try sema.resolveBody(&child_block, body, inst); |
| 10967 | const operand_ty = sema.typeOf(operand); | 10978 | const operand_ty = sema.typeOf(operand); |
| | 10979 | if (operand_ty.tag() == .generic_poison) return error.GenericPoison; |
| 10968 | return sema.addType(operand_ty); | 10980 | return sema.addType(operand_ty); |
| 10969 | } | 10981 | } |
| 10970 | | 10982 | |
| ... | @@ -11044,6 +11056,7 @@ fn zirTypeofPeer( | ... | @@ -11044,6 +11056,7 @@ fn zirTypeofPeer( |
| 11044 | | 11056 | |
| 11045 | for (args) |arg_ref, i| { | 11057 | for (args) |arg_ref, i| { |
| 11046 | inst_list[i] = sema.resolveInst(arg_ref); | 11058 | inst_list[i] = sema.resolveInst(arg_ref); |
| | 11059 | if (sema.typeOf(inst_list[i]).tag() == .generic_poison) return error.GenericPoison; |
| 11047 | } | 11060 | } |
| 11048 | | 11061 | |
| 11049 | const result_type = try sema.resolvePeerTypes(block, src, inst_list, .{ .typeof_builtin_call_node_offset = extra.data.src_node }); | 11062 | const result_type = try sema.resolvePeerTypes(block, src, inst_list, .{ .typeof_builtin_call_node_offset = extra.data.src_node }); |