| ... | @@ -4764,12 +4764,20 @@ fn analyzeCall( | ... | @@ -4764,12 +4764,20 @@ fn analyzeCall( |
| 4764 | | 4764 | |
| 4765 | const gpa = sema.gpa; | 4765 | const gpa = sema.gpa; |
| 4766 | | 4766 | |
| 4767 | var is_comptime_call = block.is_comptime or modifier == .compile_time or | 4767 | var is_generic_call = func_ty_info.is_generic; |
| 4768 | try sema.typeRequiresComptime(block, func_src, func_ty_info.return_type); | 4768 | var is_comptime_call = block.is_comptime or modifier == .compile_time; |
| | 4769 | if (!is_comptime_call) { |
| | 4770 | if (sema.typeRequiresComptime(block, func_src, func_ty_info.return_type)) |ct| { |
| | 4771 | is_comptime_call = ct; |
| | 4772 | } else |err| switch (err) { |
| | 4773 | error.GenericPoison => is_generic_call = true, |
| | 4774 | else => |e| return e, |
| | 4775 | } |
| | 4776 | } |
| 4769 | var is_inline_call = is_comptime_call or modifier == .always_inline or | 4777 | var is_inline_call = is_comptime_call or modifier == .always_inline or |
| 4770 | func_ty_info.cc == .Inline; | 4778 | func_ty_info.cc == .Inline; |
| 4771 | | 4779 | |
| 4772 | if (!is_inline_call and func_ty_info.is_generic) { | 4780 | if (!is_inline_call and is_generic_call) { |
| 4773 | if (sema.instantiateGenericCall( | 4781 | if (sema.instantiateGenericCall( |
| 4774 | block, | 4782 | block, |
| 4775 | func, | 4783 | func, |
| ... | @@ -6410,10 +6418,20 @@ fn funcCommon( | ... | @@ -6410,10 +6418,20 @@ fn funcCommon( |
| 6410 | } | 6418 | } |
| 6411 | } | 6419 | } |
| 6412 | | 6420 | |
| 6413 | is_generic = is_generic or | 6421 | const ret_poison = if (!is_generic) rp: { |
| 6414 | try sema.typeRequiresComptime(block, ret_ty_src, bare_return_type); | 6422 | if (sema.typeRequiresComptime(block, ret_ty_src, bare_return_type)) |ret_comptime| { |
| | 6423 | is_generic = ret_comptime; |
| | 6424 | break :rp bare_return_type.tag() == .generic_poison; |
| | 6425 | } else |err| switch (err) { |
| | 6426 | error.GenericPoison => { |
| | 6427 | is_generic = true; |
| | 6428 | break :rp true; |
| | 6429 | }, |
| | 6430 | else => |e| return e, |
| | 6431 | } |
| | 6432 | } else bare_return_type.tag() == .generic_poison; |
| 6415 | | 6433 | |
| 6416 | const return_type = if (!inferred_error_set or bare_return_type.tag() == .generic_poison) | 6434 | const return_type = if (!inferred_error_set or ret_poison) |
| 6417 | bare_return_type | 6435 | bare_return_type |
| 6418 | else blk: { | 6436 | else blk: { |
| 6419 | const node = try sema.gpa.create(Module.Fn.InferredErrorSetListNode); | 6437 | const node = try sema.gpa.create(Module.Fn.InferredErrorSetListNode); |
| ... | @@ -13570,7 +13588,7 @@ fn reifyStruct( | ... | @@ -13570,7 +13588,7 @@ fn reifyStruct( |
| 13570 | .zir_index = inst, | 13588 | .zir_index = inst, |
| 13571 | .layout = layout_val.toEnum(std.builtin.Type.ContainerLayout), | 13589 | .layout = layout_val.toEnum(std.builtin.Type.ContainerLayout), |
| 13572 | .status = .have_field_types, | 13590 | .status = .have_field_types, |
| 13573 | .known_non_opv = undefined, | 13591 | .known_non_opv = false, |
| 13574 | .namespace = .{ | 13592 | .namespace = .{ |
| 13575 | .parent = block.namespace, | 13593 | .parent = block.namespace, |
| 13576 | .ty = struct_ty, | 13594 | .ty = struct_ty, |
| ... | @@ -21666,6 +21684,10 @@ fn semaStructFields( | ... | @@ -21666,6 +21684,10 @@ fn semaStructFields( |
| 21666 | // TODO emit compile errors for invalid field types | 21684 | // TODO emit compile errors for invalid field types |
| 21667 | // such as arrays and pointers inside packed structs. | 21685 | // such as arrays and pointers inside packed structs. |
| 21668 | | 21686 | |
| | 21687 | if (field_ty.tag() == .generic_poison) { |
| | 21688 | return error.GenericPoison; |
| | 21689 | } |
| | 21690 | |
| 21669 | const gop = struct_obj.fields.getOrPutAssumeCapacity(field_name); | 21691 | const gop = struct_obj.fields.getOrPutAssumeCapacity(field_name); |
| 21670 | assert(!gop.found_existing); | 21692 | assert(!gop.found_existing); |
| 21671 | gop.value_ptr.* = .{ | 21693 | gop.value_ptr.* = .{ |
| ... | @@ -21913,6 +21935,10 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { | ... | @@ -21913,6 +21935,10 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { |
| 21913 | // But only resolve the source location if we need to emit a compile error. | 21935 | // But only resolve the source location if we need to emit a compile error. |
| 21914 | try sema.resolveType(&block_scope, src, field_type_ref); | 21936 | try sema.resolveType(&block_scope, src, field_type_ref); |
| 21915 | | 21937 | |
| | 21938 | if (field_ty.tag() == .generic_poison) { |
| | 21939 | return error.GenericPoison; |
| | 21940 | } |
| | 21941 | |
| 21916 | const gop = union_obj.fields.getOrPutAssumeCapacity(field_name); | 21942 | const gop = union_obj.fields.getOrPutAssumeCapacity(field_name); |
| 21917 | assert(!gop.found_existing); | 21943 | assert(!gop.found_existing); |
| 21918 | gop.value_ptr.* = .{ | 21944 | gop.value_ptr.* = .{ |