| ... | @@ -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 | } |
| 1736 | | 1736 | |
| ... | @@ -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 | } |
| 1772 | | 1772 | |
| ... | @@ -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)); |
| 6556 | | 6556 | |
| ... | @@ -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 and | 7320 | const is_runtime = comptime_arg.val.isGenericPoison() and |
| 7321 | comptime_arg.ty.hasRuntimeBits(mod) and | 7321 | 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); |
| 8884 | | 8884 | |
| 8885 | var is_generic = bare_return_type.tag() == .generic_poison or | 8885 | var is_generic = bare_return_type.isGenericPoison() or |
| 8886 | alignment == null or | 8886 | alignment == null or |
| 8887 | address_space == null or | 8887 | address_space == null or |
| 8888 | section == .generic or | 8888 | 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.null | 15877 | Value.null |
| 15878 | else | 15878 | 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 | }; |
| 15938 | | 15938 | |
| 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 |
| 16713 | | 16713 | |
| 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 | } |
| 16719 | | 16719 | |
| ... | @@ -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; |
| 22576 | | 22576 | |
| 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 |
| 22611 | | 22611 | |
| 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 |
| 22635 | | 22635 | |
| 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 |
| 22659 | | 22659 | |
| 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 | } |
| 32054 | | 32054 | |
| ... | @@ -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 | }; |
| 32444 | | 32444 | |
| 32445 | if (field_ty.tag() == .generic_poison) { | 32445 | if (field_ty.isGenericPoison()) { |
| 32446 | return error.GenericPoison; | 32446 | return error.GenericPoison; |
| 32447 | } | 32447 | } |
| 32448 | | 32448 | |