authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-02 20:01:32-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:40:03-07:00
log50f33734c6cec10a0132644c08ee443c2dd224e2
treed5192de4e7f849226b93cf03095a5ac7e54c3782
parent00f82f1c46126f1fc6655c6142ef16e8e5afbf4e

stage2: isGenericPoison InternPool awareness


4 files changed, 47 insertions(+), 31 deletions(-)

src/Module.zig+1-1
...@@ -5728,7 +5728,7 @@ pub fn analyzeFnBody(mod: *Module, func: *Fn, arena: Allocator) SemaError!Air {...@@ -5728,7 +5728,7 @@ pub fn analyzeFnBody(mod: *Module, func: *Fn, arena: Allocator) SemaError!Air {
5728 const param_ty = if (func.comptime_args) |comptime_args| t: {5728 const param_ty = if (func.comptime_args) |comptime_args| t: {
5729 const arg_tv = comptime_args[total_param_index];5729 const arg_tv = comptime_args[total_param_index];
57305730
5731 const arg_val = if (arg_tv.val.tag() != .generic_poison)5731 const arg_val = if (!arg_tv.val.isGenericPoison())
5732 arg_tv.val5732 arg_tv.val
5733 else if (arg_tv.ty.onePossibleValue(mod)) |opv|5733 else if (arg_tv.ty.onePossibleValue(mod)) |opv|
5734 opv5734 opv
src/Sema.zig+22-22
...@@ -300,7 +300,7 @@ pub const Block = struct {...@@ -300,7 +300,7 @@ pub const Block = struct {
300 const src_decl = sema.mod.declPtr(rt.block.src_decl);300 const src_decl = sema.mod.declPtr(rt.block.src_decl);
301 break :blk rt.func_src.toSrcLoc(src_decl);301 break :blk rt.func_src.toSrcLoc(src_decl);
302 };302 };
303 if (rt.return_ty.tag() == .generic_poison) {303 if (rt.return_ty.isGenericPoison()) {
304 return sema.mod.errNoteNonLazy(src_loc, parent, prefix ++ "the generic function was instantiated with a comptime-only return type", .{});304 return sema.mod.errNoteNonLazy(src_loc, parent, prefix ++ "the generic function was instantiated with a comptime-only return type", .{});
305 }305 }
306 try sema.mod.errNoteNonLazy(306 try sema.mod.errNoteNonLazy(
...@@ -1730,7 +1730,7 @@ pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {...@@ -1730,7 +1730,7 @@ pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {
1730 // The last section of indexes refers to the map of ZIR => AIR.1730 // The last section of indexes refers to the map of ZIR => AIR.
1731 const inst = sema.inst_map.get(i - InternPool.static_len).?;1731 const inst = sema.inst_map.get(i - InternPool.static_len).?;
1732 const ty = sema.typeOf(inst);1732 const ty = sema.typeOf(inst);
1733 if (ty.tag() == .generic_poison) return error.GenericPoison;1733 if (ty.isGenericPoison()) return error.GenericPoison;
1734 return inst;1734 return inst;
1735}1735}
17361736
...@@ -1766,7 +1766,7 @@ pub fn resolveType(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Ins...@@ -1766,7 +1766,7 @@ pub fn resolveType(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Ins
1766 const air_inst = try sema.resolveInst(zir_ref);1766 const air_inst = try sema.resolveInst(zir_ref);
1767 assert(air_inst != .var_args_param_type);1767 assert(air_inst != .var_args_param_type);
1768 const ty = try sema.analyzeAsType(block, src, air_inst);1768 const ty = try sema.analyzeAsType(block, src, air_inst);
1769 if (ty.tag() == .generic_poison) return error.GenericPoison;1769 if (ty.isGenericPoison()) return error.GenericPoison;
1770 return ty;1770 return ty;
1771}1771}
17721772
...@@ -1827,7 +1827,7 @@ fn resolveValue(...@@ -1827,7 +1827,7 @@ fn resolveValue(
1827 reason: []const u8,1827 reason: []const u8,
1828) CompileError!Value {1828) CompileError!Value {
1829 if (try sema.resolveMaybeUndefValAllowVariables(air_ref)) |val| {1829 if (try sema.resolveMaybeUndefValAllowVariables(air_ref)) |val| {
1830 if (val.tag() == .generic_poison) return error.GenericPoison;1830 if (val.isGenericPoison()) return error.GenericPoison;
1831 return val;1831 return val;
1832 }1832 }
1833 return sema.failWithNeededComptime(block, src, reason);1833 return sema.failWithNeededComptime(block, src, reason);
...@@ -6549,8 +6549,8 @@ const GenericCallAdapter = struct {...@@ -6549,8 +6549,8 @@ const GenericCallAdapter = struct {
6549 const other_comptime_args = other_key.comptime_args.?;6549 const other_comptime_args = other_key.comptime_args.?;
6550 for (other_comptime_args[0..ctx.func_ty_info.param_types.len], 0..) |other_arg, i| {6550 for (other_comptime_args[0..ctx.func_ty_info.param_types.len], 0..) |other_arg, i| {
6551 const this_arg = ctx.args[i];6551 const this_arg = ctx.args[i];
6552 const this_is_comptime = this_arg.val.tag() != .generic_poison;6552 const this_is_comptime = !this_arg.val.isGenericPoison();
6553 const other_is_comptime = other_arg.val.tag() != .generic_poison;6553 const other_is_comptime = !other_arg.val.isGenericPoison();
6554 const this_is_anytype = this_arg.is_anytype;6554 const this_is_anytype = this_arg.is_anytype;
6555 const other_is_anytype = other_key.isAnytypeParam(ctx.module, @intCast(u32, i));6555 const other_is_anytype = other_key.isAnytypeParam(ctx.module, @intCast(u32, i));
65566556
...@@ -7189,7 +7189,7 @@ fn analyzeInlineCallArg(...@@ -7189,7 +7189,7 @@ fn analyzeInlineCallArg(
7189 const param_body = sema.code.extra[extra.end..][0..extra.data.body_len];7189 const param_body = sema.code.extra[extra.end..][0..extra.data.body_len];
7190 const param_ty = param_ty: {7190 const param_ty = param_ty: {
7191 const raw_param_ty = raw_param_types[arg_i.*];7191 const raw_param_ty = raw_param_types[arg_i.*];
7192 if (raw_param_ty.tag() != .generic_poison) break :param_ty raw_param_ty;7192 if (!raw_param_ty.isGenericPoison()) break :param_ty raw_param_ty;
7193 const param_ty_inst = try sema.resolveBody(param_block, param_body, inst);7193 const param_ty_inst = try sema.resolveBody(param_block, param_body, inst);
7194 break :param_ty try sema.analyzeAsType(param_block, param_src, param_ty_inst);7194 break :param_ty try sema.analyzeAsType(param_block, param_src, param_ty_inst);
7195 };7195 };
...@@ -7317,7 +7317,7 @@ fn analyzeGenericCallArg(...@@ -7317,7 +7317,7 @@ fn analyzeGenericCallArg(
7317 runtime_i: *u32,7317 runtime_i: *u32,
7318) !void {7318) !void {
7319 const mod = sema.mod;7319 const mod = sema.mod;
7320 const is_runtime = comptime_arg.val.tag() == .generic_poison and7320 const is_runtime = comptime_arg.val.isGenericPoison() and
7321 comptime_arg.ty.hasRuntimeBits(mod) and7321 comptime_arg.ty.hasRuntimeBits(mod) and
7322 !(try sema.typeRequiresComptime(comptime_arg.ty));7322 !(try sema.typeRequiresComptime(comptime_arg.ty));
7323 if (is_runtime) {7323 if (is_runtime) {
...@@ -8882,7 +8882,7 @@ fn funcCommon(...@@ -8882,7 +8882,7 @@ fn funcCommon(
8882 const cc_src: LazySrcLoc = .{ .node_offset_fn_type_cc = src_node_offset };8882 const cc_src: LazySrcLoc = .{ .node_offset_fn_type_cc = src_node_offset };
8883 const func_src = LazySrcLoc.nodeOffset(src_node_offset);8883 const func_src = LazySrcLoc.nodeOffset(src_node_offset);
88848884
8885 var is_generic = bare_return_type.tag() == .generic_poison or8885 var is_generic = bare_return_type.isGenericPoison() or
8886 alignment == null or8886 alignment == null or
8887 address_space == null or8887 address_space == null or
8888 section == .generic or8888 section == .generic or
...@@ -8965,7 +8965,7 @@ fn funcCommon(...@@ -8965,7 +8965,7 @@ fn funcCommon(
8965 var ret_ty_requires_comptime = false;8965 var ret_ty_requires_comptime = false;
8966 const ret_poison = if (sema.typeRequiresComptime(bare_return_type)) |ret_comptime| rp: {8966 const ret_poison = if (sema.typeRequiresComptime(bare_return_type)) |ret_comptime| rp: {
8967 ret_ty_requires_comptime = ret_comptime;8967 ret_ty_requires_comptime = ret_comptime;
8968 break :rp bare_return_type.tag() == .generic_poison;8968 break :rp bare_return_type.isGenericPoison();
8969 } else |err| switch (err) {8969 } else |err| switch (err) {
8970 error.GenericPoison => rp: {8970 error.GenericPoison => rp: {
8971 is_generic = true;8971 is_generic = true;
...@@ -9208,7 +9208,7 @@ fn analyzeParameter(...@@ -9208,7 +9208,7 @@ fn analyzeParameter(
9208 const mod = sema.mod;9208 const mod = sema.mod;
9209 const requires_comptime = try sema.typeRequiresComptime(param.ty);9209 const requires_comptime = try sema.typeRequiresComptime(param.ty);
9210 comptime_params[i] = param.is_comptime or requires_comptime;9210 comptime_params[i] = param.is_comptime or requires_comptime;
9211 const this_generic = param.ty.tag() == .generic_poison;9211 const this_generic = param.ty.isGenericPoison();
9212 is_generic.* = is_generic.* or this_generic;9212 is_generic.* = is_generic.* or this_generic;
9213 const target = mod.getTarget();9213 const target = mod.getTarget();
9214 if (param.is_comptime and !Type.fnCallingConventionAllowsZigTypes(target, cc)) {9214 if (param.is_comptime and !Type.fnCallingConventionAllowsZigTypes(target, cc)) {
...@@ -15872,7 +15872,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15872,7 +15872,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15872 const param_vals = try params_anon_decl.arena().alloc(Value, info.param_types.len);15872 const param_vals = try params_anon_decl.arena().alloc(Value, info.param_types.len);
15873 for (param_vals, 0..) |*param_val, i| {15873 for (param_vals, 0..) |*param_val, i| {
15874 const param_ty = info.param_types[i];15874 const param_ty = info.param_types[i];
15875 const is_generic = param_ty.tag() == .generic_poison;15875 const is_generic = param_ty.isGenericPoison();
15876 const param_ty_val = if (is_generic)15876 const param_ty_val = if (is_generic)
15877 Value.null15877 Value.null
15878 else15878 else
...@@ -15936,7 +15936,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15936,7 +15936,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15936 });15936 });
15937 };15937 };
1593815938
15939 const ret_ty_opt = if (info.return_type.tag() != .generic_poison)15939 const ret_ty_opt = if (!info.return_type.isGenericPoison())
15940 try Value.Tag.opt_payload.create(15940 try Value.Tag.opt_payload.create(
15941 sema.arena,15941 sema.arena,
15942 try Value.Tag.ty.create(sema.arena, info.return_type),15942 try Value.Tag.ty.create(sema.arena, info.return_type),
...@@ -16713,7 +16713,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -16713,7 +16713,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
1671316713
16714 const operand = try sema.resolveBody(&child_block, body, inst);16714 const operand = try sema.resolveBody(&child_block, body, inst);
16715 const operand_ty = sema.typeOf(operand);16715 const operand_ty = sema.typeOf(operand);
16716 if (operand_ty.tag() == .generic_poison) return error.GenericPoison;16716 if (operand_ty.isGenericPoison()) return error.GenericPoison;
16717 return sema.addType(operand_ty);16717 return sema.addType(operand_ty);
16718}16718}
1671916719
...@@ -17589,7 +17589,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -17589,7 +17589,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
17589 }17589 }
17590 return err;17590 return err;
17591 };17591 };
17592 if (ty.tag() == .generic_poison) return error.GenericPoison;17592 if (ty.isGenericPoison()) return error.GenericPoison;
17593 break :blk ty;17593 break :blk ty;
17594 };17594 };
17595 const target = sema.mod.getTarget();17595 const target = sema.mod.getTarget();
...@@ -22575,7 +22575,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -22575,7 +22575,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
22575 extra_index += body.len;22575 extra_index += body.len;
2257622576
22577 const val = try sema.resolveGenericBody(block, align_src, body, inst, Type.u29, "alignment must be comptime-known");22577 const val = try sema.resolveGenericBody(block, align_src, body, inst, Type.u29, "alignment must be comptime-known");
22578 if (val.tag() == .generic_poison) {22578 if (val.isGenericPoison()) {
22579 break :blk null;22579 break :blk null;
22580 }22580 }
22581 const alignment = @intCast(u32, val.toUnsignedInt(mod));22581 const alignment = @intCast(u32, val.toUnsignedInt(mod));
...@@ -22611,7 +22611,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -22611,7 +22611,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2261122611
22612 const addrspace_ty = try sema.getBuiltinType("AddressSpace");22612 const addrspace_ty = try sema.getBuiltinType("AddressSpace");
22613 const val = try sema.resolveGenericBody(block, addrspace_src, body, inst, addrspace_ty, "addrespace must be comptime-known");22613 const val = try sema.resolveGenericBody(block, addrspace_src, body, inst, addrspace_ty, "addrespace must be comptime-known");
22614 if (val.tag() == .generic_poison) {22614 if (val.isGenericPoison()) {
22615 break :blk null;22615 break :blk null;
22616 }22616 }
22617 break :blk val.toEnum(std.builtin.AddressSpace);22617 break :blk val.toEnum(std.builtin.AddressSpace);
...@@ -22635,7 +22635,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -22635,7 +22635,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2263522635
22636 const ty = Type.initTag(.const_slice_u8);22636 const ty = Type.initTag(.const_slice_u8);
22637 const val = try sema.resolveGenericBody(block, section_src, body, inst, ty, "linksection must be comptime-known");22637 const val = try sema.resolveGenericBody(block, section_src, body, inst, ty, "linksection must be comptime-known");
22638 if (val.tag() == .generic_poison) {22638 if (val.isGenericPoison()) {
22639 break :blk FuncLinkSection{ .generic = {} };22639 break :blk FuncLinkSection{ .generic = {} };
22640 }22640 }
22641 break :blk FuncLinkSection{ .explicit = try val.toAllocatedBytes(ty, sema.arena, sema.mod) };22641 break :blk FuncLinkSection{ .explicit = try val.toAllocatedBytes(ty, sema.arena, sema.mod) };
...@@ -22659,7 +22659,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -22659,7 +22659,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2265922659
22660 const cc_ty = try sema.getBuiltinType("CallingConvention");22660 const cc_ty = try sema.getBuiltinType("CallingConvention");
22661 const val = try sema.resolveGenericBody(block, cc_src, body, inst, cc_ty, "calling convention must be comptime-known");22661 const val = try sema.resolveGenericBody(block, cc_src, body, inst, cc_ty, "calling convention must be comptime-known");
22662 if (val.tag() == .generic_poison) {22662 if (val.isGenericPoison()) {
22663 break :blk null;22663 break :blk null;
22664 }22664 }
22665 break :blk val.toEnum(std.builtin.CallingConvention);22665 break :blk val.toEnum(std.builtin.CallingConvention);
...@@ -31790,7 +31790,7 @@ fn resolveInferredErrorSet(...@@ -31790,7 +31790,7 @@ fn resolveInferredErrorSet(
31790 // if ies declared by a inline function with generic return type, the return_type should be generic_poison,31790 // if ies declared by a inline function with generic return type, the return_type should be generic_poison,
31791 // because inline function does not create a new declaration, and the ies has been filled with analyzeCall,31791 // because inline function does not create a new declaration, and the ies has been filled with analyzeCall,
31792 // so here we can simply skip this case.31792 // so here we can simply skip this case.
31793 if (ies_func_info.return_type.tag() == .generic_poison) {31793 if (ies_func_info.return_type.isGenericPoison()) {
31794 assert(ies_func_info.cc == .Inline);31794 assert(ies_func_info.cc == .Inline);
31795 } else if (ies_func_info.return_type.errorUnionSet().castTag(.error_set_inferred).?.data == ies) {31795 } else if (ies_func_info.return_type.errorUnionSet().castTag(.error_set_inferred).?.data == ies) {
31796 if (ies_func_info.is_generic) {31796 if (ies_func_info.is_generic) {
...@@ -32048,7 +32048,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void...@@ -32048,7 +32048,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
32048 else => |e| return e,32048 else => |e| return e,
32049 };32049 };
32050 };32050 };
32051 if (field_ty.tag() == .generic_poison) {32051 if (field_ty.isGenericPoison()) {
32052 return error.GenericPoison;32052 return error.GenericPoison;
32053 }32053 }
3205432054
...@@ -32442,7 +32442,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {...@@ -32442,7 +32442,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
32442 else => |e| return e,32442 else => |e| return e,
32443 };32443 };
3244432444
32445 if (field_ty.tag() == .generic_poison) {32445 if (field_ty.isGenericPoison()) {
32446 return error.GenericPoison;32446 return error.GenericPoison;
32447 }32447 }
3244832448
src/type.zig+16-8
...@@ -727,8 +727,8 @@ pub const Type = struct {...@@ -727,8 +727,8 @@ pub const Type = struct {
727 const a_info = a.fnInfo();727 const a_info = a.fnInfo();
728 const b_info = b.fnInfo();728 const b_info = b.fnInfo();
729729
730 if (a_info.return_type.tag() != .generic_poison and730 if (!a_info.return_type.isGenericPoison() and
731 b_info.return_type.tag() != .generic_poison and731 !b_info.return_type.isGenericPoison() and
732 !eql(a_info.return_type, b_info.return_type, mod))732 !eql(a_info.return_type, b_info.return_type, mod))
733 return false;733 return false;
734734
...@@ -758,8 +758,8 @@ pub const Type = struct {...@@ -758,8 +758,8 @@ pub const Type = struct {
758 if (a_info.comptime_params[i] != b_info.comptime_params[i])758 if (a_info.comptime_params[i] != b_info.comptime_params[i])
759 return false;759 return false;
760760
761 if (a_param_ty.tag() == .generic_poison) continue;761 if (a_param_ty.isGenericPoison()) continue;
762 if (b_param_ty.tag() == .generic_poison) continue;762 if (b_param_ty.isGenericPoison()) continue;
763763
764 if (!eql(a_param_ty, b_param_ty, mod))764 if (!eql(a_param_ty, b_param_ty, mod))
765 return false;765 return false;
...@@ -1131,7 +1131,7 @@ pub const Type = struct {...@@ -1131,7 +1131,7 @@ pub const Type = struct {
1131 std.hash.autoHash(hasher, std.builtin.TypeId.Fn);1131 std.hash.autoHash(hasher, std.builtin.TypeId.Fn);
11321132
1133 const fn_info = ty.fnInfo();1133 const fn_info = ty.fnInfo();
1134 if (fn_info.return_type.tag() != .generic_poison) {1134 if (!fn_info.return_type.isGenericPoison()) {
1135 hashWithHasher(fn_info.return_type, hasher, mod);1135 hashWithHasher(fn_info.return_type, hasher, mod);
1136 }1136 }
1137 if (!fn_info.align_is_generic) {1137 if (!fn_info.align_is_generic) {
...@@ -1148,7 +1148,7 @@ pub const Type = struct {...@@ -1148,7 +1148,7 @@ pub const Type = struct {
1148 std.hash.autoHash(hasher, fn_info.param_types.len);1148 std.hash.autoHash(hasher, fn_info.param_types.len);
1149 for (fn_info.param_types, 0..) |param_ty, i| {1149 for (fn_info.param_types, 0..) |param_ty, i| {
1150 std.hash.autoHash(hasher, fn_info.paramIsComptime(i));1150 std.hash.autoHash(hasher, fn_info.paramIsComptime(i));
1151 if (param_ty.tag() == .generic_poison) continue;1151 if (param_ty.isGenericPoison()) continue;
1152 hashWithHasher(param_ty, hasher, mod);1152 hashWithHasher(param_ty, hasher, mod);
1153 }1153 }
1154 },1154 },
...@@ -2154,7 +2154,7 @@ pub const Type = struct {...@@ -2154,7 +2154,7 @@ pub const Type = struct {
2154 if (std.math.cast(u5, i)) |index| if (@truncate(u1, fn_info.noalias_bits >> index) != 0) {2154 if (std.math.cast(u5, i)) |index| if (@truncate(u1, fn_info.noalias_bits >> index) != 0) {
2155 try writer.writeAll("noalias ");2155 try writer.writeAll("noalias ");
2156 };2156 };
2157 if (param_ty.tag() == .generic_poison) {2157 if (param_ty.isGenericPoison()) {
2158 try writer.writeAll("anytype");2158 try writer.writeAll("anytype");
2159 } else {2159 } else {
2160 try print(param_ty, writer, mod);2160 try print(param_ty, writer, mod);
...@@ -2175,7 +2175,7 @@ pub const Type = struct {...@@ -2175,7 +2175,7 @@ pub const Type = struct {
2175 try writer.writeAll(@tagName(fn_info.cc));2175 try writer.writeAll(@tagName(fn_info.cc));
2176 try writer.writeAll(") ");2176 try writer.writeAll(") ");
2177 }2177 }
2178 if (fn_info.return_type.tag() == .generic_poison) {2178 if (fn_info.return_type.isGenericPoison()) {
2179 try writer.writeAll("anytype");2179 try writer.writeAll("anytype");
2180 } else {2180 } else {
2181 try print(fn_info.return_type, writer, mod);2181 try print(fn_info.return_type, writer, mod);
...@@ -6075,6 +6075,14 @@ pub const Type = struct {...@@ -6075,6 +6075,14 @@ pub const Type = struct {
6075 }6075 }
6076 }6076 }
60776077
6078 pub fn isGenericPoison(ty: Type) bool {
6079 return switch (ty.ip_index) {
6080 .generic_poison_type => true,
6081 .none => ty.tag() == .generic_poison,
6082 else => false,
6083 };
6084 }
6085
6078 /// This enum does not directly correspond to `std.builtin.TypeId` because6086 /// This enum does not directly correspond to `std.builtin.TypeId` because
6079 /// it has extra enum tags in it, as a way of using less memory. For example,6087 /// it has extra enum tags in it, as a way of using less memory. For example,
6080 /// even though Zig recognizes `*align(10) i32` and `*i32` both as Pointer types6088 /// even though Zig recognizes `*align(10) i32` and `*i32` both as Pointer types
src/value.zig+8
...@@ -5416,6 +5416,14 @@ pub const Value = struct {...@@ -5416,6 +5416,14 @@ pub const Value = struct {
5416 return initPayload(&value_buffer.base);5416 return initPayload(&value_buffer.base);
5417 }5417 }
54185418
5419 pub fn isGenericPoison(val: Value) bool {
5420 return switch (val.ip_index) {
5421 .generic_poison => true,
5422 .none => val.tag() == .generic_poison,
5423 else => false,
5424 };
5425 }
5426
5419 /// This type is not copyable since it may contain pointers to its inner data.5427 /// This type is not copyable since it may contain pointers to its inner data.
5420 pub const Payload = struct {5428 pub const Payload = struct {
5421 tag: Tag,5429 tag: Tag,