authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-03 18:11:07-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:40:04-07:00
log836d8a1f64cb811641e621799429c54f222717eb
treebbcdd77b43cf4fa0bdd97abcfbe2457b57d9ae46
parentbcd4bb8afbea84d86fd8758b581b141e7086b16b

stage2: move most simple types to InternPool


14 files changed, 435 insertions(+), 985 deletions(-)

src/Air.zig+2-2
...@@ -1333,7 +1333,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: InternPool) Type {...@@ -1333,7 +1333,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: InternPool) Type {
1333 .ret_load,1333 .ret_load,
1334 .unreach,1334 .unreach,
1335 .trap,1335 .trap,
1336 => return Type.initTag(.noreturn),1336 => return Type.noreturn,
13371337
1338 .breakpoint,1338 .breakpoint,
1339 .dbg_stmt,1339 .dbg_stmt,
...@@ -1370,7 +1370,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: InternPool) Type {...@@ -1370,7 +1370,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: InternPool) Type {
1370 .wasm_memory_grow => return Type.i32,1370 .wasm_memory_grow => return Type.i32,
1371 .wasm_memory_size => return Type.u32,1371 .wasm_memory_size => return Type.u32,
13721372
1373 .bool_to_int => return Type.initTag(.u1),1373 .bool_to_int => return Type.u1,
13741374
1375 .tag_name, .error_name => return Type.initTag(.const_slice_u8_sentinel_0),1375 .tag_name, .error_name => return Type.initTag(.const_slice_u8_sentinel_0),
13761376
src/Module.zig+27-24
...@@ -1005,7 +1005,7 @@ pub const Struct = struct {...@@ -1005,7 +1005,7 @@ pub const Struct = struct {
1005 /// If the layout is packed, this is the backing integer type of the packed struct.1005 /// If the layout is packed, this is the backing integer type of the packed struct.
1006 /// Whether zig chooses this type or the user specifies it, it is stored here.1006 /// Whether zig chooses this type or the user specifies it, it is stored here.
1007 /// This will be set to the noreturn type until status is `have_layout`.1007 /// This will be set to the noreturn type until status is `have_layout`.
1008 backing_int_ty: Type = Type.initTag(.noreturn),1008 backing_int_ty: Type = Type.noreturn,
1009 status: enum {1009 status: enum {
1010 none,1010 none,
1011 field_types_wip,1011 field_types_wip,
...@@ -1705,31 +1705,34 @@ pub const Fn = struct {...@@ -1705,31 +1705,34 @@ pub const Fn = struct {
1705 is_resolved: bool = false,1705 is_resolved: bool = false,
17061706
1707 pub fn addErrorSet(self: *InferredErrorSet, gpa: Allocator, err_set_ty: Type) !void {1707 pub fn addErrorSet(self: *InferredErrorSet, gpa: Allocator, err_set_ty: Type) !void {
1708 switch (err_set_ty.tag()) {1708 switch (err_set_ty.ip_index) {
1709 .error_set => {1709 .anyerror_type => {
1710 const names = err_set_ty.castTag(.error_set).?.data.names.keys();1710 self.is_anyerror = true;
1711 for (names) |name| {
1712 try self.errors.put(gpa, name, {});
1713 }
1714 },
1715 .error_set_single => {
1716 const name = err_set_ty.castTag(.error_set_single).?.data;
1717 try self.errors.put(gpa, name, {});
1718 },
1719 .error_set_inferred => {
1720 const ies = err_set_ty.castTag(.error_set_inferred).?.data;
1721 try self.inferred_error_sets.put(gpa, ies, {});
1722 },1711 },
1723 .error_set_merged => {1712 .none => switch (err_set_ty.tag()) {
1724 const names = err_set_ty.castTag(.error_set_merged).?.data.keys();1713 .error_set => {
1725 for (names) |name| {1714 const names = err_set_ty.castTag(.error_set).?.data.names.keys();
1715 for (names) |name| {
1716 try self.errors.put(gpa, name, {});
1717 }
1718 },
1719 .error_set_single => {
1720 const name = err_set_ty.castTag(.error_set_single).?.data;
1726 try self.errors.put(gpa, name, {});1721 try self.errors.put(gpa, name, {});
1727 }1722 },
1728 },1723 .error_set_inferred => {
1729 .anyerror => {1724 const ies = err_set_ty.castTag(.error_set_inferred).?.data;
1730 self.is_anyerror = true;1725 try self.inferred_error_sets.put(gpa, ies, {});
1726 },
1727 .error_set_merged => {
1728 const names = err_set_ty.castTag(.error_set_merged).?.data.keys();
1729 for (names) |name| {
1730 try self.errors.put(gpa, name, {});
1731 }
1732 },
1733 else => unreachable,
1731 },1734 },
1732 else => unreachable,1735 else => @panic("TODO"),
1733 }1736 }
1734 }1737 }
1735 };1738 };
...@@ -4566,7 +4569,7 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void {...@@ -4566,7 +4569,7 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void {
4566 const struct_obj = try new_decl_arena_allocator.create(Module.Struct);4569 const struct_obj = try new_decl_arena_allocator.create(Module.Struct);
4567 const struct_ty = try Type.Tag.@"struct".create(new_decl_arena_allocator, struct_obj);4570 const struct_ty = try Type.Tag.@"struct".create(new_decl_arena_allocator, struct_obj);
4568 const struct_val = try Value.Tag.ty.create(new_decl_arena_allocator, struct_ty);4571 const struct_val = try Value.Tag.ty.create(new_decl_arena_allocator, struct_ty);
4569 const ty_ty = comptime Type.initTag(.type);4572 const ty_ty = comptime Type.type;
4570 struct_obj.* = .{4573 struct_obj.* = .{
4571 .owner_decl = undefined, // set below4574 .owner_decl = undefined, // set below
4572 .fields = .{},4575 .fields = .{},
src/Sema.zig+209-294
...@@ -1776,7 +1776,7 @@ fn analyzeAsType(...@@ -1776,7 +1776,7 @@ fn analyzeAsType(
1776 src: LazySrcLoc,1776 src: LazySrcLoc,
1777 air_inst: Air.Inst.Ref,1777 air_inst: Air.Inst.Ref,
1778) !Type {1778) !Type {
1779 const wanted_type = Type.initTag(.type);1779 const wanted_type = Type.type;
1780 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);1780 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);
1781 const val = try sema.resolveConstValue(block, src, coerced_inst, "types must be comptime-known");1781 const val = try sema.resolveConstValue(block, src, coerced_inst, "types must be comptime-known");
1782 const ty = val.toType();1782 const ty = val.toType();
...@@ -3132,7 +3132,7 @@ fn zirUnionDecl(...@@ -3132,7 +3132,7 @@ fn zirUnionDecl(
3132 errdefer mod.abortAnonDecl(new_decl_index);3132 errdefer mod.abortAnonDecl(new_decl_index);
3133 union_obj.* = .{3133 union_obj.* = .{
3134 .owner_decl = new_decl_index,3134 .owner_decl = new_decl_index,
3135 .tag_ty = Type.initTag(.null),3135 .tag_ty = Type.null,
3136 .fields = .{},3136 .fields = .{},
3137 .zir_index = inst,3137 .zir_index = inst,
3138 .layout = small.layout,3138 .layout = small.layout,
...@@ -6362,7 +6362,7 @@ fn zirCall(...@@ -6362,7 +6362,7 @@ fn zirCall(
6362 if (arg_index >= fn_params_len)6362 if (arg_index >= fn_params_len)
6363 break :inst Air.Inst.Ref.var_args_param_type;6363 break :inst Air.Inst.Ref.var_args_param_type;
63646364
6365 if (func_ty_info.param_types[arg_index].tag() == .generic_poison)6365 if (func_ty_info.param_types[arg_index].isGenericPoison())
6366 break :inst Air.Inst.Ref.generic_poison_type;6366 break :inst Air.Inst.Ref.generic_poison_type;
63676367
6368 break :inst try sema.addType(func_ty_info.param_types[arg_index]);6368 break :inst try sema.addType(func_ty_info.param_types[arg_index]);
...@@ -8175,7 +8175,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -8175,7 +8175,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
8175 return sema.fail(block, rhs_src, "expected error set type, found '{}'", .{rhs_ty.fmt(sema.mod)});8175 return sema.fail(block, rhs_src, "expected error set type, found '{}'", .{rhs_ty.fmt(sema.mod)});
81768176
8177 // Anything merged with anyerror is anyerror.8177 // Anything merged with anyerror is anyerror.
8178 if (lhs_ty.tag() == .anyerror or rhs_ty.tag() == .anyerror) {8178 if (lhs_ty.ip_index == .anyerror_type or rhs_ty.ip_index == .anyerror_type) {
8179 return Air.Inst.Ref.anyerror_type;8179 return Air.Inst.Ref.anyerror_type;
8180 }8180 }
81818181
...@@ -8206,7 +8206,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -8206,7 +8206,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
8206 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;8206 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
8207 const duped_name = try sema.arena.dupe(u8, inst_data.get(sema.code));8207 const duped_name = try sema.arena.dupe(u8, inst_data.get(sema.code));
8208 return sema.addConstant(8208 return sema.addConstant(
8209 Type.initTag(.enum_literal),8209 .{ .ip_index = .enum_literal_type, .legacy = undefined },
8210 try Value.Tag.enum_literal.create(sema.arena, duped_name),8210 try Value.Tag.enum_literal.create(sema.arena, duped_name),
8211 );8211 );
8212}8212}
...@@ -8503,6 +8503,7 @@ fn analyzeErrUnionPayload(...@@ -8503,6 +8503,7 @@ fn analyzeErrUnionPayload(
8503 operand_src: LazySrcLoc,8503 operand_src: LazySrcLoc,
8504 safety_check: bool,8504 safety_check: bool,
8505) CompileError!Air.Inst.Ref {8505) CompileError!Air.Inst.Ref {
8506 const mod = sema.mod;
8506 const payload_ty = err_union_ty.errorUnionPayload();8507 const payload_ty = err_union_ty.errorUnionPayload();
8507 if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| {8508 if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| {
8508 if (val.getError()) |name| {8509 if (val.getError()) |name| {
...@@ -8516,7 +8517,7 @@ fn analyzeErrUnionPayload(...@@ -8516,7 +8517,7 @@ fn analyzeErrUnionPayload(
85168517
8517 // If the error set has no fields then no safety check is needed.8518 // If the error set has no fields then no safety check is needed.
8518 if (safety_check and block.wantSafety() and8519 if (safety_check and block.wantSafety() and
8519 !err_union_ty.errorUnionSet().errorSetIsEmpty())8520 !err_union_ty.errorUnionSet().errorSetIsEmpty(mod))
8520 {8521 {
8521 try sema.panicUnwrapError(block, operand, .unwrap_errunion_err, .is_non_err);8522 try sema.panicUnwrapError(block, operand, .unwrap_errunion_err, .is_non_err);
8522 }8523 }
...@@ -8602,7 +8603,7 @@ fn analyzeErrUnionPayloadPtr(...@@ -8602,7 +8603,7 @@ fn analyzeErrUnionPayloadPtr(
86028603
8603 // If the error set has no fields then no safety check is needed.8604 // If the error set has no fields then no safety check is needed.
8604 if (safety_check and block.wantSafety() and8605 if (safety_check and block.wantSafety() and
8605 !err_union_ty.errorUnionSet().errorSetIsEmpty())8606 !err_union_ty.errorUnionSet().errorSetIsEmpty(mod))
8606 {8607 {
8607 try sema.panicUnwrapError(block, operand, .unwrap_errunion_err_ptr, .is_non_err_ptr);8608 try sema.panicUnwrapError(block, operand, .unwrap_errunion_err_ptr, .is_non_err_ptr);
8608 }8609 }
...@@ -8701,7 +8702,7 @@ fn zirFunc(...@@ -8701,7 +8702,7 @@ fn zirFunc(
8701 break :blk ret_ty;8702 break :blk ret_ty;
8702 } else |err| switch (err) {8703 } else |err| switch (err) {
8703 error.GenericPoison => {8704 error.GenericPoison => {
8704 break :blk Type.initTag(.generic_poison);8705 break :blk Type.generic_poison;
8705 },8706 },
8706 else => |e| return e,8707 else => |e| return e,
8707 }8708 }
...@@ -8778,7 +8779,7 @@ fn resolveGenericBody(...@@ -8778,7 +8779,7 @@ fn resolveGenericBody(
8778 };8779 };
8779 switch (err) {8780 switch (err) {
8780 error.GenericPoison => {8781 error.GenericPoison => {
8781 if (dest_ty.tag() == .type) {8782 if (dest_ty.ip_index == .type_type) {
8782 return Value.initTag(.generic_poison_type);8783 return Value.initTag(.generic_poison_type);
8783 } else {8784 } else {
8784 return Value.initTag(.generic_poison);8785 return Value.initTag(.generic_poison);
...@@ -9319,7 +9320,7 @@ fn zirParam(...@@ -9319,7 +9320,7 @@ fn zirParam(
9319 // We result the param instruction with a poison value and9320 // We result the param instruction with a poison value and
9320 // insert an anytype parameter.9321 // insert an anytype parameter.
9321 try block.params.append(sema.gpa, .{9322 try block.params.append(sema.gpa, .{
9322 .ty = Type.initTag(.generic_poison),9323 .ty = Type.generic_poison,
9323 .is_comptime = comptime_syntax,9324 .is_comptime = comptime_syntax,
9324 .name = param_name,9325 .name = param_name,
9325 });9326 });
...@@ -9340,7 +9341,7 @@ fn zirParam(...@@ -9340,7 +9341,7 @@ fn zirParam(
9340 // We result the param instruction with a poison value and9341 // We result the param instruction with a poison value and
9341 // insert an anytype parameter.9342 // insert an anytype parameter.
9342 try block.params.append(sema.gpa, .{9343 try block.params.append(sema.gpa, .{
9343 .ty = Type.initTag(.generic_poison),9344 .ty = Type.generic_poison,
9344 .is_comptime = comptime_syntax,9345 .is_comptime = comptime_syntax,
9345 .name = param_name,9346 .name = param_name,
9346 });9347 });
...@@ -9438,7 +9439,7 @@ fn zirParamAnytype(...@@ -9438,7 +9439,7 @@ fn zirParamAnytype(
9438 // We are evaluating a generic function without any comptime args provided.9439 // We are evaluating a generic function without any comptime args provided.
94399440
9440 try block.params.append(sema.gpa, .{9441 try block.params.append(sema.gpa, .{
9441 .ty = Type.initTag(.generic_poison),9442 .ty = Type.generic_poison,
9442 .is_comptime = comptime_syntax,9443 .is_comptime = comptime_syntax,
9443 .name = param_name,9444 .name = param_name,
9444 });9445 });
...@@ -18877,7 +18878,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in...@@ -18877,7 +18878,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in
18877 },18878 },
18878 .ErrorSet => {18879 .ErrorSet => {
18879 const payload_val = union_val.val.optionalValue(mod) orelse18880 const payload_val = union_val.val.optionalValue(mod) orelse
18880 return sema.addType(Type.initTag(.anyerror));18881 return sema.addType(Type.anyerror);
18881 const slice_val = payload_val.castTag(.slice).?.data;18882 const slice_val = payload_val.castTag(.slice).?.data;
1888218883
18883 const len = try sema.usizeCast(block, src, slice_val.len.toUnsignedInt(mod));18884 const len = try sema.usizeCast(block, src, slice_val.len.toUnsignedInt(mod));
...@@ -19150,7 +19151,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in...@@ -19150,7 +19151,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in
19150 errdefer mod.abortAnonDecl(new_decl_index);19151 errdefer mod.abortAnonDecl(new_decl_index);
19151 union_obj.* = .{19152 union_obj.* = .{
19152 .owner_decl = new_decl_index,19153 .owner_decl = new_decl_index,
19153 .tag_ty = Type.initTag(.null),19154 .tag_ty = Type.null,
19154 .fields = .{},19155 .fields = .{},
19155 .zir_index = inst,19156 .zir_index = inst,
19156 .layout = layout,19157 .layout = layout,
...@@ -22697,7 +22698,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -22697,7 +22698,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
22697 extra_index += 1;22698 extra_index += 1;
22698 const ret_ty_tv = sema.resolveInstConst(block, ret_src, ret_ty_ref, "return type must be comptime-known") catch |err| switch (err) {22699 const ret_ty_tv = sema.resolveInstConst(block, ret_src, ret_ty_ref, "return type must be comptime-known") catch |err| switch (err) {
22699 error.GenericPoison => {22700 error.GenericPoison => {
22700 break :blk Type.initTag(.generic_poison);22701 break :blk Type.generic_poison;
22701 },22702 },
22702 else => |e| return e,22703 else => |e| return e,
22703 };22704 };
...@@ -23022,7 +23023,7 @@ fn zirBuiltinExtern(...@@ -23022,7 +23023,7 @@ fn zirBuiltinExtern(
23022 new_decl.src_line = sema.owner_decl.src_line;23023 new_decl.src_line = sema.owner_decl.src_line;
23023 // We only access this decl through the decl_ref with the correct type created23024 // We only access this decl through the decl_ref with the correct type created
23024 // below, so this type doesn't matter23025 // below, so this type doesn't matter
23025 new_decl.ty = Type.Tag.init(.anyopaque);23026 new_decl.ty = Type.anyopaque;
23026 new_decl.val = try Value.Tag.variable.create(new_decl_arena_allocator, new_var);23027 new_decl.val = try Value.Tag.variable.create(new_decl_arena_allocator, new_var);
23027 new_decl.@"align" = 0;23028 new_decl.@"align" = 0;
23028 new_decl.@"linksection" = null;23029 new_decl.@"linksection" = null;
...@@ -24380,9 +24381,8 @@ fn fieldCallBind(...@@ -24380,9 +24381,8 @@ fn fieldCallBind(
24380 decl_type.fnParamLen() >= 1)24381 decl_type.fnParamLen() >= 1)
24381 {24382 {
24382 const first_param_type = decl_type.fnParamType(0);24383 const first_param_type = decl_type.fnParamType(0);
24383 const first_param_tag = first_param_type.tag();
24384 // zig fmt: off24384 // zig fmt: off
24385 if (first_param_tag == .generic_poison or (24385 if (first_param_type.isGenericPoison() or (
24386 first_param_type.zigTypeTag(mod) == .Pointer and24386 first_param_type.zigTypeTag(mod) == .Pointer and
24387 (first_param_type.ptrSize() == .One or24387 (first_param_type.ptrSize() == .One or
24388 first_param_type.ptrSize() == .C) and24388 first_param_type.ptrSize() == .C) and
...@@ -25535,10 +25535,7 @@ fn coerceExtra(...@@ -25535,10 +25535,7 @@ fn coerceExtra(
25535 inst_src: LazySrcLoc,25535 inst_src: LazySrcLoc,
25536 opts: CoerceOpts,25536 opts: CoerceOpts,
25537) CoersionError!Air.Inst.Ref {25537) CoersionError!Air.Inst.Ref {
25538 switch (dest_ty_unresolved.tag()) {25538 if (dest_ty_unresolved.isGenericPoison()) return inst;
25539 .generic_poison => return inst,
25540 else => {},
25541 }
25542 const dest_ty_src = inst_src; // TODO better source location25539 const dest_ty_src = inst_src; // TODO better source location
25543 const dest_ty = try sema.resolveTypeFields(dest_ty_unresolved);25540 const dest_ty = try sema.resolveTypeFields(dest_ty_unresolved);
25544 const inst_ty = try sema.resolveTypeFields(sema.typeOf(inst));25541 const inst_ty = try sema.resolveTypeFields(sema.typeOf(inst));
...@@ -25577,7 +25574,8 @@ fn coerceExtra(...@@ -25577,7 +25574,8 @@ fn coerceExtra(
2557725574
25578 // cast from ?*T and ?[*]T to ?*anyopaque25575 // cast from ?*T and ?[*]T to ?*anyopaque
25579 // but don't do it if the source type is a double pointer25576 // but don't do it if the source type is a double pointer
25580 if (dest_ty.isPtrLikeOptional(mod) and dest_ty.elemType2(mod).tag() == .anyopaque and25577 if (dest_ty.isPtrLikeOptional(mod) and
25578 dest_ty.elemType2(mod).ip_index == .anyopaque_type and
25581 inst_ty.isPtrAtRuntime(mod))25579 inst_ty.isPtrAtRuntime(mod))
25582 anyopaque_check: {25580 anyopaque_check: {
25583 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :optional;25581 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :optional;
...@@ -25715,7 +25713,7 @@ fn coerceExtra(...@@ -25715,7 +25713,7 @@ fn coerceExtra(
2571525713
25716 // cast from *T and [*]T to *anyopaque25714 // cast from *T and [*]T to *anyopaque
25717 // but don't do it if the source type is a double pointer25715 // but don't do it if the source type is a double pointer
25718 if (dest_info.pointee_type.tag() == .anyopaque and inst_ty.zigTypeTag(mod) == .Pointer) to_anyopaque: {25716 if (dest_info.pointee_type.ip_index == .anyopaque_type and inst_ty.zigTypeTag(mod) == .Pointer) to_anyopaque: {
25719 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;25717 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;
25720 const elem_ty = inst_ty.elemType2(mod);25718 const elem_ty = inst_ty.elemType2(mod);
25721 if (elem_ty.zigTypeTag(mod) == .Pointer or elem_ty.isPtrLikeOptional(mod)) {25719 if (elem_ty.zigTypeTag(mod) == .Pointer or elem_ty.isPtrLikeOptional(mod)) {
...@@ -26759,6 +26757,8 @@ fn coerceInMemoryAllowedErrorSets(...@@ -26759,6 +26757,8 @@ fn coerceInMemoryAllowedErrorSets(
26759 dest_src: LazySrcLoc,26757 dest_src: LazySrcLoc,
26760 src_src: LazySrcLoc,26758 src_src: LazySrcLoc,
26761) !InMemoryCoercionResult {26759) !InMemoryCoercionResult {
26760 const mod = sema.mod;
26761
26762 // Coercion to `anyerror`. Note that this check can return false negatives26762 // Coercion to `anyerror`. Note that this check can return false negatives
26763 // in case the error sets did not get resolved.26763 // in case the error sets did not get resolved.
26764 if (dest_ty.isAnyError()) {26764 if (dest_ty.isAnyError()) {
...@@ -26769,36 +26769,41 @@ fn coerceInMemoryAllowedErrorSets(...@@ -26769,36 +26769,41 @@ fn coerceInMemoryAllowedErrorSets(
26769 const dst_ies = dst_payload.data;26769 const dst_ies = dst_payload.data;
26770 // We will make an effort to return `ok` without resolving either error set, to26770 // We will make an effort to return `ok` without resolving either error set, to
26771 // avoid unnecessary "unable to resolve error set" dependency loop errors.26771 // avoid unnecessary "unable to resolve error set" dependency loop errors.
26772 switch (src_ty.tag()) {26772 switch (src_ty.ip_index) {
26773 .error_set_inferred => {26773 .none => switch (src_ty.tag()) {
26774 // If both are inferred error sets of functions, and26774 .error_set_inferred => {
26775 // the dest includes the source function, the coercion is OK.26775 // If both are inferred error sets of functions, and
26776 // This check is important because it works without forcing a full resolution26776 // the dest includes the source function, the coercion is OK.
26777 // of inferred error sets.26777 // This check is important because it works without forcing a full resolution
26778 const src_ies = src_ty.castTag(.error_set_inferred).?.data;26778 // of inferred error sets.
2677926779 const src_ies = src_ty.castTag(.error_set_inferred).?.data;
26780 if (dst_ies.inferred_error_sets.contains(src_ies)) {26780
26781 return .ok;26781 if (dst_ies.inferred_error_sets.contains(src_ies)) {
26782 }26782 return .ok;
26783 },26783 }
26784 .error_set_single => {26784 },
26785 const name = src_ty.castTag(.error_set_single).?.data;26785 .error_set_single => {
26786 if (dst_ies.errors.contains(name)) return .ok;26786 const name = src_ty.castTag(.error_set_single).?.data;
26787 },26787 if (dst_ies.errors.contains(name)) return .ok;
26788 .error_set_merged => {26788 },
26789 const names = src_ty.castTag(.error_set_merged).?.data.keys();26789 .error_set_merged => {
26790 for (names) |name| {26790 const names = src_ty.castTag(.error_set_merged).?.data.keys();
26791 if (!dst_ies.errors.contains(name)) break;26791 for (names) |name| {
26792 } else return .ok;26792 if (!dst_ies.errors.contains(name)) break;
26793 } else return .ok;
26794 },
26795 .error_set => {
26796 const names = src_ty.castTag(.error_set).?.data.names.keys();
26797 for (names) |name| {
26798 if (!dst_ies.errors.contains(name)) break;
26799 } else return .ok;
26800 },
26801 else => unreachable,
26793 },26802 },
26794 .error_set => {26803 .anyerror_type => {},
26795 const names = src_ty.castTag(.error_set).?.data.names.keys();26804 else => switch (mod.intern_pool.indexToKey(src_ty.ip_index)) {
26796 for (names) |name| {26805 else => @panic("TODO"),
26797 if (!dst_ies.errors.contains(name)) break;
26798 } else return .ok;
26799 },26806 },
26800 .anyerror => {},
26801 else => unreachable,
26802 }26807 }
2680326808
26804 if (dst_ies.func == sema.owner_func) {26809 if (dst_ies.func == sema.owner_func) {
...@@ -26818,79 +26823,87 @@ fn coerceInMemoryAllowedErrorSets(...@@ -26818,79 +26823,87 @@ fn coerceInMemoryAllowedErrorSets(
26818 var missing_error_buf = std.ArrayList([]const u8).init(sema.gpa);26823 var missing_error_buf = std.ArrayList([]const u8).init(sema.gpa);
26819 defer missing_error_buf.deinit();26824 defer missing_error_buf.deinit();
2682026825
26821 switch (src_ty.tag()) {26826 switch (src_ty.ip_index) {
26822 .error_set_inferred => {26827 .none => switch (src_ty.tag()) {
26823 const src_data = src_ty.castTag(.error_set_inferred).?.data;26828 .error_set_inferred => {
26829 const src_data = src_ty.castTag(.error_set_inferred).?.data;
2682426830
26825 try sema.resolveInferredErrorSet(block, src_src, src_data);26831 try sema.resolveInferredErrorSet(block, src_src, src_data);
26826 // src anyerror status might have changed after the resolution.26832 // src anyerror status might have changed after the resolution.
26827 if (src_ty.isAnyError()) {26833 if (src_ty.isAnyError()) {
26828 // dest_ty.isAnyError() == true is already checked for at this point.26834 // dest_ty.isAnyError() == true is already checked for at this point.
26829 return .from_anyerror;26835 return .from_anyerror;
26830 }26836 }
2683126837
26832 for (src_data.errors.keys()) |key| {26838 for (src_data.errors.keys()) |key| {
26833 if (!dest_ty.errorSetHasField(key)) {26839 if (!dest_ty.errorSetHasField(key)) {
26834 try missing_error_buf.append(key);26840 try missing_error_buf.append(key);
26841 }
26835 }26842 }
26836 }
2683726843
26838 if (missing_error_buf.items.len != 0) {26844 if (missing_error_buf.items.len != 0) {
26839 return InMemoryCoercionResult{26845 return InMemoryCoercionResult{
26840 .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items),26846 .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items),
26841 };26847 };
26842 }26848 }
2684326849
26844 return .ok;
26845 },
26846 .error_set_single => {
26847 const name = src_ty.castTag(.error_set_single).?.data;
26848 if (dest_ty.errorSetHasField(name)) {
26849 return .ok;26850 return .ok;
26850 }26851 },
26851 const list = try sema.arena.alloc([]const u8, 1);26852 .error_set_single => {
26852 list[0] = name;26853 const name = src_ty.castTag(.error_set_single).?.data;
26853 return InMemoryCoercionResult{ .missing_error = list };26854 if (dest_ty.errorSetHasField(name)) {
26854 },26855 return .ok;
26855 .error_set_merged => {26856 }
26856 const names = src_ty.castTag(.error_set_merged).?.data.keys();26857 const list = try sema.arena.alloc([]const u8, 1);
26857 for (names) |name| {26858 list[0] = name;
26858 if (!dest_ty.errorSetHasField(name)) {26859 return InMemoryCoercionResult{ .missing_error = list };
26859 try missing_error_buf.append(name);26860 },
26861 .error_set_merged => {
26862 const names = src_ty.castTag(.error_set_merged).?.data.keys();
26863 for (names) |name| {
26864 if (!dest_ty.errorSetHasField(name)) {
26865 try missing_error_buf.append(name);
26866 }
26860 }26867 }
26861 }
2686226868
26863 if (missing_error_buf.items.len != 0) {26869 if (missing_error_buf.items.len != 0) {
26864 return InMemoryCoercionResult{26870 return InMemoryCoercionResult{
26865 .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items),26871 .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items),
26866 };26872 };
26867 }26873 }
2686826874
26869 return .ok;26875 return .ok;
26870 },26876 },
26871 .error_set => {26877 .error_set => {
26872 const names = src_ty.castTag(.error_set).?.data.names.keys();26878 const names = src_ty.castTag(.error_set).?.data.names.keys();
26873 for (names) |name| {26879 for (names) |name| {
26874 if (!dest_ty.errorSetHasField(name)) {26880 if (!dest_ty.errorSetHasField(name)) {
26875 try missing_error_buf.append(name);26881 try missing_error_buf.append(name);
26882 }
26876 }26883 }
26877 }
2687826884
26879 if (missing_error_buf.items.len != 0) {26885 if (missing_error_buf.items.len != 0) {
26880 return InMemoryCoercionResult{26886 return InMemoryCoercionResult{
26881 .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items),26887 .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items),
26882 };26888 };
26883 }26889 }
2688426890
26885 return .ok;26891 return .ok;
26886 },26892 },
26887 .anyerror => switch (dest_ty.tag()) {
26888 .error_set_inferred => unreachable, // Caught by dest_ty.isAnyError() above.
26889 .error_set_single, .error_set_merged, .error_set => return .from_anyerror,
26890 .anyerror => unreachable, // Filtered out above.
26891 else => unreachable,26893 else => unreachable,
26892 },26894 },
26893 else => unreachable,26895
26896 .anyerror_type => switch (dest_ty.ip_index) {
26897 .none => switch (dest_ty.tag()) {
26898 .error_set_inferred => unreachable, // Caught by dest_ty.isAnyError() above.
26899 .error_set_single, .error_set_merged, .error_set => return .from_anyerror,
26900 else => unreachable,
26901 },
26902 .anyerror_type => unreachable, // Filtered out above.
26903 else => @panic("TODO"),
26904 },
26905
26906 else => @panic("TODO"),
26894 }26907 }
2689526908
26896 unreachable;26909 unreachable;
...@@ -29355,42 +29368,49 @@ fn analyzeIsNonErrComptimeOnly(...@@ -29355,42 +29368,49 @@ fn analyzeIsNonErrComptimeOnly(
29355 // exception if the error union error set is known to be empty,29368 // exception if the error union error set is known to be empty,
29356 // we allow the comparison but always make it comptime-known.29369 // we allow the comparison but always make it comptime-known.
29357 const set_ty = operand_ty.errorUnionSet();29370 const set_ty = operand_ty.errorUnionSet();
29358 switch (set_ty.tag()) {29371 switch (set_ty.ip_index) {
29359 .anyerror => {},29372 .none => switch (set_ty.tag()) {
29360 .error_set_inferred => blk: {29373 .error_set_inferred => blk: {
29361 // If the error set is empty, we must return a comptime true or false.29374 // If the error set is empty, we must return a comptime true or false.
29362 // However we want to avoid unnecessarily resolving an inferred error set29375 // However we want to avoid unnecessarily resolving an inferred error set
29363 // in case it is already non-empty.29376 // in case it is already non-empty.
29364 const ies = set_ty.castTag(.error_set_inferred).?.data;29377 const ies = set_ty.castTag(.error_set_inferred).?.data;
29365 if (ies.is_anyerror) break :blk;
29366 if (ies.errors.count() != 0) break :blk;
29367 if (maybe_operand_val == null) {
29368 // Try to avoid resolving inferred error set if possible.
29369 if (ies.errors.count() != 0) break :blk;
29370 if (ies.is_anyerror) break :blk;29378 if (ies.is_anyerror) break :blk;
29371 for (ies.inferred_error_sets.keys()) |other_ies| {29379 if (ies.errors.count() != 0) break :blk;
29372 if (ies == other_ies) continue;29380 if (maybe_operand_val == null) {
29373 try sema.resolveInferredErrorSet(block, src, other_ies);29381 // Try to avoid resolving inferred error set if possible.
29374 if (other_ies.is_anyerror) {29382 if (ies.errors.count() != 0) break :blk;
29375 ies.is_anyerror = true;29383 if (ies.is_anyerror) break :blk;
29376 ies.is_resolved = true;29384 for (ies.inferred_error_sets.keys()) |other_ies| {
29377 break :blk;29385 if (ies == other_ies) continue;
29378 }29386 try sema.resolveInferredErrorSet(block, src, other_ies);
29387 if (other_ies.is_anyerror) {
29388 ies.is_anyerror = true;
29389 ies.is_resolved = true;
29390 break :blk;
29391 }
2937929392
29380 if (other_ies.errors.count() != 0) break :blk;29393 if (other_ies.errors.count() != 0) break :blk;
29381 }29394 }
29382 if (ies.func == sema.owner_func) {29395 if (ies.func == sema.owner_func) {
29383 // We're checking the inferred errorset of the current function and none of29396 // We're checking the inferred errorset of the current function and none of
29384 // its child inferred error sets contained any errors meaning that any value29397 // its child inferred error sets contained any errors meaning that any value
29385 // so far with this type can't contain errors either.29398 // so far with this type can't contain errors either.
29386 return Air.Inst.Ref.bool_true;29399 return Air.Inst.Ref.bool_true;
29400 }
29401 try sema.resolveInferredErrorSet(block, src, ies);
29402 if (ies.is_anyerror) break :blk;
29403 if (ies.errors.count() == 0) return Air.Inst.Ref.bool_true;
29387 }29404 }
29388 try sema.resolveInferredErrorSet(block, src, ies);29405 },
29389 if (ies.is_anyerror) break :blk;29406 else => if (set_ty.errorSetNames().len == 0) return Air.Inst.Ref.bool_true,
29390 if (ies.errors.count() == 0) return Air.Inst.Ref.bool_true;29407 },
29391 }29408
29409 .anyerror_type => {},
29410
29411 else => switch (mod.intern_pool.indexToKey(set_ty.ip_index)) {
29412 else => @panic("TODO"),
29392 },29413 },
29393 else => if (set_ty.errorSetNames().len == 0) return Air.Inst.Ref.bool_true,
29394 }29414 }
2939529415
29396 if (maybe_operand_val) |err_union| {29416 if (maybe_operand_val) |err_union| {
...@@ -30308,43 +30328,48 @@ fn wrapErrorUnionSet(...@@ -30308,43 +30328,48 @@ fn wrapErrorUnionSet(
30308 const inst_ty = sema.typeOf(inst);30328 const inst_ty = sema.typeOf(inst);
30309 const dest_err_set_ty = dest_ty.errorUnionSet();30329 const dest_err_set_ty = dest_ty.errorUnionSet();
30310 if (try sema.resolveMaybeUndefVal(inst)) |val| {30330 if (try sema.resolveMaybeUndefVal(inst)) |val| {
30311 switch (dest_err_set_ty.tag()) {30331 switch (dest_err_set_ty.ip_index) {
30312 .anyerror => {},30332 .anyerror_type => {},
30313 .error_set_single => ok: {30333
30314 const expected_name = val.castTag(.@"error").?.data.name;30334 .none => switch (dest_err_set_ty.tag()) {
30315 const n = dest_err_set_ty.castTag(.error_set_single).?.data;30335 .error_set_single => ok: {
30316 if (mem.eql(u8, expected_name, n)) break :ok;30336 const expected_name = val.castTag(.@"error").?.data.name;
30317 return sema.failWithErrorSetCodeMissing(block, inst_src, dest_err_set_ty, inst_ty);30337 const n = dest_err_set_ty.castTag(.error_set_single).?.data;
30318 },30338 if (mem.eql(u8, expected_name, n)) break :ok;
30319 .error_set => {
30320 const expected_name = val.castTag(.@"error").?.data.name;
30321 const error_set = dest_err_set_ty.castTag(.error_set).?.data;
30322 if (!error_set.names.contains(expected_name)) {
30323 return sema.failWithErrorSetCodeMissing(block, inst_src, dest_err_set_ty, inst_ty);30339 return sema.failWithErrorSetCodeMissing(block, inst_src, dest_err_set_ty, inst_ty);
30324 }30340 },
30325 },30341 .error_set => {
30326 .error_set_inferred => ok: {30342 const expected_name = val.castTag(.@"error").?.data.name;
30327 const expected_name = val.castTag(.@"error").?.data.name;30343 const error_set = dest_err_set_ty.castTag(.error_set).?.data;
30328 const ies = dest_err_set_ty.castTag(.error_set_inferred).?.data;30344 if (!error_set.names.contains(expected_name)) {
3032930345 return sema.failWithErrorSetCodeMissing(block, inst_src, dest_err_set_ty, inst_ty);
30330 // We carefully do this in an order that avoids unnecessarily30346 }
30331 // resolving the destination error set type.30347 },
30332 if (ies.is_anyerror) break :ok;30348 .error_set_inferred => ok: {
30333 if (ies.errors.contains(expected_name)) break :ok;30349 const expected_name = val.castTag(.@"error").?.data.name;
30334 if (.ok == try sema.coerceInMemoryAllowedErrorSets(block, dest_err_set_ty, inst_ty, inst_src, inst_src)) {30350 const ies = dest_err_set_ty.castTag(.error_set_inferred).?.data;
30335 break :ok;30351
30336 }30352 // We carefully do this in an order that avoids unnecessarily
30353 // resolving the destination error set type.
30354 if (ies.is_anyerror) break :ok;
30355 if (ies.errors.contains(expected_name)) break :ok;
30356 if (.ok == try sema.coerceInMemoryAllowedErrorSets(block, dest_err_set_ty, inst_ty, inst_src, inst_src)) {
30357 break :ok;
30358 }
3033730359
30338 return sema.failWithErrorSetCodeMissing(block, inst_src, dest_err_set_ty, inst_ty);
30339 },
30340 .error_set_merged => {
30341 const expected_name = val.castTag(.@"error").?.data.name;
30342 const error_set = dest_err_set_ty.castTag(.error_set_merged).?.data;
30343 if (!error_set.contains(expected_name)) {
30344 return sema.failWithErrorSetCodeMissing(block, inst_src, dest_err_set_ty, inst_ty);30360 return sema.failWithErrorSetCodeMissing(block, inst_src, dest_err_set_ty, inst_ty);
30345 }30361 },
30362 .error_set_merged => {
30363 const expected_name = val.castTag(.@"error").?.data.name;
30364 const error_set = dest_err_set_ty.castTag(.error_set_merged).?.data;
30365 if (!error_set.contains(expected_name)) {
30366 return sema.failWithErrorSetCodeMissing(block, inst_src, dest_err_set_ty, inst_ty);
30367 }
30368 },
30369 else => unreachable,
30346 },30370 },
30347 else => unreachable,30371
30372 else => @panic("TODO"),
30348 }30373 }
30349 return sema.addConstant(dest_ty, val);30374 return sema.addConstant(dest_ty, val);
30350 }30375 }
...@@ -30380,7 +30405,7 @@ fn resolvePeerTypes(...@@ -30380,7 +30405,7 @@ fn resolvePeerTypes(
30380) !Type {30405) !Type {
30381 const mod = sema.mod;30406 const mod = sema.mod;
30382 switch (instructions.len) {30407 switch (instructions.len) {
30383 0 => return Type.initTag(.noreturn),30408 0 => return Type.noreturn,
30384 1 => return sema.typeOf(instructions[0]),30409 1 => return sema.typeOf(instructions[0]),
30385 else => {},30410 else => {},
30386 }30411 }
...@@ -31445,24 +31470,7 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {...@@ -31445,24 +31470,7 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
31445 .i64,31470 .i64,
31446 .u128,31471 .u128,
31447 .i128,31472 .i128,
31448 .anyopaque,31473
31449 .bool,
31450 .void,
31451 .anyerror,
31452 .noreturn,
31453 .@"anyframe",
31454 .null,
31455 .undefined,
31456 .atomic_order,
31457 .atomic_rmw_op,
31458 .calling_convention,
31459 .address_space,
31460 .float_mode,
31461 .reduce_op,
31462 .modifier,
31463 .prefetch_options,
31464 .export_options,
31465 .extern_options,
31466 .manyptr_u8,31474 .manyptr_u8,
31467 .manyptr_const_u8,31475 .manyptr_const_u8,
31468 .manyptr_const_u8_sentinel_0,31476 .manyptr_const_u8_sentinel_0,
...@@ -31476,17 +31484,12 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {...@@ -31476,17 +31484,12 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
31476 .error_set_inferred,31484 .error_set_inferred,
31477 .error_set_merged,31485 .error_set_merged,
31478 .@"opaque",31486 .@"opaque",
31479 .generic_poison,
31480 .array_u8,31487 .array_u8,
31481 .array_u8_sentinel_0,31488 .array_u8_sentinel_0,
31482 .enum_simple,31489 .enum_simple,
31483 => false,31490 => false,
3148431491
31485 .single_const_pointer_to_comptime_int,31492 .single_const_pointer_to_comptime_int,
31486 .type,
31487 .comptime_int,
31488 .enum_literal,
31489 .type_info,
31490 .function,31493 .function,
31491 => true,31494 => true,
3149231495
...@@ -31709,17 +31712,6 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {...@@ -31709,17 +31712,6 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {
31709 try sema.resolveTypeFieldsUnion(ty, union_obj);31712 try sema.resolveTypeFieldsUnion(ty, union_obj);
31710 return ty;31713 return ty;
31711 },31714 },
31712 .type_info => return sema.getBuiltinType("Type"),
31713 .extern_options => return sema.getBuiltinType("ExternOptions"),
31714 .export_options => return sema.getBuiltinType("ExportOptions"),
31715 .atomic_order => return sema.getBuiltinType("AtomicOrder"),
31716 .atomic_rmw_op => return sema.getBuiltinType("AtomicRmwOp"),
31717 .calling_convention => return sema.getBuiltinType("CallingConvention"),
31718 .address_space => return sema.getBuiltinType("AddressSpace"),
31719 .float_mode => return sema.getBuiltinType("FloatMode"),
31720 .reduce_op => return sema.getBuiltinType("ReduceOp"),
31721 .modifier => return sema.getBuiltinType("CallModifier"),
31722 .prefetch_options => return sema.getBuiltinType("PrefetchOptions"),
3172331715
31724 else => return ty,31716 else => return ty,
31725 },31717 },
...@@ -31772,6 +31764,7 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {...@@ -31772,6 +31764,7 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {
31772 .const_slice_u8_type,31764 .const_slice_u8_type,
31773 .anyerror_void_error_union_type,31765 .anyerror_void_error_union_type,
31774 .generic_poison_type,31766 .generic_poison_type,
31767 .var_args_param_type,
31775 .empty_struct_type,31768 .empty_struct_type,
31776 => return ty,31769 => return ty,
3177731770
...@@ -31789,7 +31782,6 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {...@@ -31789,7 +31782,6 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {
31789 .bool_false => unreachable,31782 .bool_false => unreachable,
31790 .empty_struct => unreachable,31783 .empty_struct => unreachable,
31791 .generic_poison => unreachable,31784 .generic_poison => unreachable,
31792 .var_args_param_type => unreachable,
3179331785
31794 .type_info_type => return sema.getBuiltinType("Type"),31786 .type_info_type => return sema.getBuiltinType("Type"),
31795 .extern_options_type => return sema.getBuiltinType("ExternOptions"),31787 .extern_options_type => return sema.getBuiltinType("ExternOptions"),
...@@ -32118,7 +32110,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void...@@ -32118,7 +32110,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
32118 return sema.failWithOwnedErrorMsg(msg);32110 return sema.failWithOwnedErrorMsg(msg);
32119 }32111 }
32120 gop.value_ptr.* = .{32112 gop.value_ptr.* = .{
32121 .ty = Type.initTag(.noreturn),32113 .ty = Type.noreturn,
32122 .abi_align = 0,32114 .abi_align = 0,
32123 .default_val = Value.initTag(.unreachable_value),32115 .default_val = Value.initTag(.unreachable_value),
32124 .is_comptime = is_comptime,32116 .is_comptime = is_comptime,
...@@ -32552,7 +32544,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {...@@ -32552,7 +32544,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
32552 const field_ty: Type = if (!has_type)32544 const field_ty: Type = if (!has_type)
32553 Type.void32545 Type.void
32554 else if (field_type_ref == .none)32546 else if (field_type_ref == .none)
32555 Type.initTag(.noreturn)32547 Type.noreturn
32556 else32548 else
32557 sema.resolveType(&block_scope, .unneeded, field_type_ref) catch |err| switch (err) {32549 sema.resolveType(&block_scope, .unneeded, field_type_ref) catch |err| switch (err) {
32558 error.NeededSourceLocation => {32550 error.NeededSourceLocation => {
...@@ -32956,7 +32948,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {...@@ -32956,7 +32948,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
32956 };32948 };
3295732949
32958 switch (ty.tag()) {32950 switch (ty.tag()) {
32959 .comptime_int,
32960 .u1,32951 .u1,
32961 .u8,32952 .u8,
32962 .i8,32953 .i8,
...@@ -32969,9 +32960,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {...@@ -32969,9 +32960,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
32969 .i64,32960 .i64,
32970 .u128,32961 .u128,
32971 .i128,32962 .i128,
32972 .bool,32963
32973 .type,
32974 .anyerror,
32975 .error_set_single,32964 .error_set_single,
32976 .error_set,32965 .error_set,
32977 .error_set_merged,32966 .error_set_merged,
...@@ -32984,28 +32973,14 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {...@@ -32984,28 +32973,14 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
32984 .const_slice_u8_sentinel_0,32973 .const_slice_u8_sentinel_0,
32985 .const_slice,32974 .const_slice,
32986 .mut_slice,32975 .mut_slice,
32987 .anyopaque,
32988 .optional_single_mut_pointer,32976 .optional_single_mut_pointer,
32989 .optional_single_const_pointer,32977 .optional_single_const_pointer,
32990 .enum_literal,
32991 .anyerror_void_error_union,32978 .anyerror_void_error_union,
32992 .error_set_inferred,32979 .error_set_inferred,
32993 .@"opaque",32980 .@"opaque",
32994 .manyptr_u8,32981 .manyptr_u8,
32995 .manyptr_const_u8,32982 .manyptr_const_u8,
32996 .manyptr_const_u8_sentinel_0,32983 .manyptr_const_u8_sentinel_0,
32997 .atomic_order,
32998 .atomic_rmw_op,
32999 .calling_convention,
33000 .address_space,
33001 .float_mode,
33002 .reduce_op,
33003 .modifier,
33004 .prefetch_options,
33005 .export_options,
33006 .extern_options,
33007 .type_info,
33008 .@"anyframe",
33009 .anyframe_T,32984 .anyframe_T,
33010 .many_const_pointer,32985 .many_const_pointer,
33011 .many_mut_pointer,32986 .many_mut_pointer,
...@@ -33138,10 +33113,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {...@@ -33138,10 +33113,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
33138 },33113 },
3313933114
33140 .empty_struct, .empty_struct_literal => return Value.initTag(.empty_struct_value),33115 .empty_struct, .empty_struct_literal => return Value.initTag(.empty_struct_value),
33141 .void => return Value.void,
33142 .noreturn => return Value.initTag(.unreachable_value),
33143 .null => return Value.null,
33144 .undefined => return Value.initTag(.undef),
3314533116
33146 .vector, .array, .array_u8 => {33117 .vector, .array, .array_u8 => {
33147 if (ty.arrayLen() == 0)33118 if (ty.arrayLen() == 0)
...@@ -33154,7 +33125,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {...@@ -33154,7 +33125,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3315433125
33155 .inferred_alloc_const => unreachable,33126 .inferred_alloc_const => unreachable,
33156 .inferred_alloc_mut => unreachable,33127 .inferred_alloc_mut => unreachable,
33157 .generic_poison => return error.GenericPoison,
33158 }33128 }
33159}33129}
3316033130
...@@ -33194,34 +33164,12 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref {...@@ -33194,34 +33164,12 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref {
33194 .i64 => return .i64_type,33164 .i64 => return .i64_type,
33195 .u128 => return .u128_type,33165 .u128 => return .u128_type,
33196 .i128 => return .i128_type,33166 .i128 => return .i128_type,
33197 .anyopaque => return .anyopaque_type,33167
33198 .bool => return .bool_type,
33199 .void => return .void_type,
33200 .type => return .type_type,
33201 .anyerror => return .anyerror_type,
33202 .comptime_int => return .comptime_int_type,
33203 .noreturn => return .noreturn_type,
33204 .@"anyframe" => return .anyframe_type,
33205 .null => return .null_type,
33206 .undefined => return .undefined_type,
33207 .enum_literal => return .enum_literal_type,
33208 .atomic_order => return .atomic_order_type,
33209 .atomic_rmw_op => return .atomic_rmw_op_type,
33210 .calling_convention => return .calling_convention_type,
33211 .address_space => return .address_space_type,
33212 .float_mode => return .float_mode_type,
33213 .reduce_op => return .reduce_op_type,
33214 .modifier => return .call_modifier_type,
33215 .prefetch_options => return .prefetch_options_type,
33216 .export_options => return .export_options_type,
33217 .extern_options => return .extern_options_type,
33218 .type_info => return .type_info_type,
33219 .manyptr_u8 => return .manyptr_u8_type,33168 .manyptr_u8 => return .manyptr_u8_type,
33220 .manyptr_const_u8 => return .manyptr_const_u8_type,33169 .manyptr_const_u8 => return .manyptr_const_u8_type,
33221 .single_const_pointer_to_comptime_int => return .single_const_pointer_to_comptime_int_type,33170 .single_const_pointer_to_comptime_int => return .single_const_pointer_to_comptime_int_type,
33222 .const_slice_u8 => return .const_slice_u8_type,33171 .const_slice_u8 => return .const_slice_u8_type,
33223 .anyerror_void_error_union => return .anyerror_void_error_union_type,33172 .anyerror_void_error_union => return .anyerror_void_error_union_type,
33224 .generic_poison => return .generic_poison_type,
33225 else => {},33173 else => {},
33226 }33174 }
33227 try sema.air_instructions.append(sema.gpa, .{33175 try sema.air_instructions.append(sema.gpa, .{
...@@ -33658,22 +33606,7 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {...@@ -33658,22 +33606,7 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
33658 .i64,33606 .i64,
33659 .u128,33607 .u128,
33660 .i128,33608 .i128,
33661 .anyopaque,33609
33662 .bool,
33663 .void,
33664 .anyerror,
33665 .noreturn,
33666 .@"anyframe",
33667 .atomic_order,
33668 .atomic_rmw_op,
33669 .calling_convention,
33670 .address_space,
33671 .float_mode,
33672 .reduce_op,
33673 .modifier,
33674 .prefetch_options,
33675 .export_options,
33676 .extern_options,
33677 .manyptr_u8,33610 .manyptr_u8,
33678 .manyptr_const_u8,33611 .manyptr_const_u8,
33679 .manyptr_const_u8_sentinel_0,33612 .manyptr_const_u8_sentinel_0,
...@@ -33687,19 +33620,12 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {...@@ -33687,19 +33620,12 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
33687 .error_set_inferred,33620 .error_set_inferred,
33688 .error_set_merged,33621 .error_set_merged,
33689 .@"opaque",33622 .@"opaque",
33690 .generic_poison,
33691 .array_u8,33623 .array_u8,
33692 .array_u8_sentinel_0,33624 .array_u8_sentinel_0,
33693 .enum_simple,33625 .enum_simple,
33694 => false,33626 => false,
3369533627
33696 .single_const_pointer_to_comptime_int,33628 .single_const_pointer_to_comptime_int,
33697 .type,
33698 .comptime_int,
33699 .enum_literal,
33700 .null,
33701 .undefined,
33702 .type_info,
33703 .function,33629 .function,
33704 => true,33630 => true,
3370533631
...@@ -34476,17 +34402,6 @@ fn enumHasInt(sema: *Sema, ty: Type, int: Value) CompileError!bool {...@@ -34476,17 +34402,6 @@ fn enumHasInt(sema: *Sema, ty: Type, int: Value) CompileError!bool {
34476 const tag_ty = try mod.intType(.unsigned, bits);34402 const tag_ty = try mod.intType(.unsigned, bits);
34477 return sema.intInRange(tag_ty, int, fields_len);34403 return sema.intInRange(tag_ty, int, fields_len);
34478 },34404 },
34479 .atomic_order,
34480 .atomic_rmw_op,
34481 .calling_convention,
34482 .address_space,
34483 .float_mode,
34484 .reduce_op,
34485 .modifier,
34486 .prefetch_options,
34487 .export_options,
34488 .extern_options,
34489 => unreachable,
3449034405
34491 else => unreachable,34406 else => unreachable,
34492 }34407 }
src/arch/aarch64/CodeGen.zig+4-3
...@@ -3071,7 +3071,7 @@ fn errUnionErr(...@@ -3071,7 +3071,7 @@ fn errUnionErr(
3071 const mod = self.bin_file.options.module.?;3071 const mod = self.bin_file.options.module.?;
3072 const err_ty = error_union_ty.errorUnionSet();3072 const err_ty = error_union_ty.errorUnionSet();
3073 const payload_ty = error_union_ty.errorUnionPayload();3073 const payload_ty = error_union_ty.errorUnionPayload();
3074 if (err_ty.errorSetIsEmpty()) {3074 if (err_ty.errorSetIsEmpty(mod)) {
3075 return MCValue{ .immediate = 0 };3075 return MCValue{ .immediate = 0 };
3076 }3076 }
3077 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {3077 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {
...@@ -3151,7 +3151,7 @@ fn errUnionPayload(...@@ -3151,7 +3151,7 @@ fn errUnionPayload(
3151 const mod = self.bin_file.options.module.?;3151 const mod = self.bin_file.options.module.?;
3152 const err_ty = error_union_ty.errorUnionSet();3152 const err_ty = error_union_ty.errorUnionSet();
3153 const payload_ty = error_union_ty.errorUnionPayload();3153 const payload_ty = error_union_ty.errorUnionPayload();
3154 if (err_ty.errorSetIsEmpty()) {3154 if (err_ty.errorSetIsEmpty(mod)) {
3155 return try error_union_bind.resolveToMcv(self);3155 return try error_union_bind.resolveToMcv(self);
3156 }3156 }
3157 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {3157 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {
...@@ -4905,9 +4905,10 @@ fn isErr(...@@ -4905,9 +4905,10 @@ fn isErr(
4905 error_union_bind: ReadArg.Bind,4905 error_union_bind: ReadArg.Bind,
4906 error_union_ty: Type,4906 error_union_ty: Type,
4907) !MCValue {4907) !MCValue {
4908 const mod = self.bin_file.options.module.?;
4908 const error_type = error_union_ty.errorUnionSet();4909 const error_type = error_union_ty.errorUnionSet();
49094910
4910 if (error_type.errorSetIsEmpty()) {4911 if (error_type.errorSetIsEmpty(mod)) {
4911 return MCValue{ .immediate = 0 }; // always false4912 return MCValue{ .immediate = 0 }; // always false
4912 }4913 }
49134914
src/arch/arm/CodeGen.zig+4-3
...@@ -2047,7 +2047,7 @@ fn errUnionErr(...@@ -2047,7 +2047,7 @@ fn errUnionErr(
2047 const mod = self.bin_file.options.module.?;2047 const mod = self.bin_file.options.module.?;
2048 const err_ty = error_union_ty.errorUnionSet();2048 const err_ty = error_union_ty.errorUnionSet();
2049 const payload_ty = error_union_ty.errorUnionPayload();2049 const payload_ty = error_union_ty.errorUnionPayload();
2050 if (err_ty.errorSetIsEmpty()) {2050 if (err_ty.errorSetIsEmpty(mod)) {
2051 return MCValue{ .immediate = 0 };2051 return MCValue{ .immediate = 0 };
2052 }2052 }
2053 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {2053 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {
...@@ -2124,7 +2124,7 @@ fn errUnionPayload(...@@ -2124,7 +2124,7 @@ fn errUnionPayload(
2124 const mod = self.bin_file.options.module.?;2124 const mod = self.bin_file.options.module.?;
2125 const err_ty = error_union_ty.errorUnionSet();2125 const err_ty = error_union_ty.errorUnionSet();
2126 const payload_ty = error_union_ty.errorUnionPayload();2126 const payload_ty = error_union_ty.errorUnionPayload();
2127 if (err_ty.errorSetIsEmpty()) {2127 if (err_ty.errorSetIsEmpty(mod)) {
2128 return try error_union_bind.resolveToMcv(self);2128 return try error_union_bind.resolveToMcv(self);
2129 }2129 }
2130 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {2130 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {
...@@ -4882,9 +4882,10 @@ fn isErr(...@@ -4882,9 +4882,10 @@ fn isErr(
4882 error_union_bind: ReadArg.Bind,4882 error_union_bind: ReadArg.Bind,
4883 error_union_ty: Type,4883 error_union_ty: Type,
4884) !MCValue {4884) !MCValue {
4885 const mod = self.bin_file.options.module.?;
4885 const error_type = error_union_ty.errorUnionSet();4886 const error_type = error_union_ty.errorUnionSet();
48864887
4887 if (error_type.errorSetIsEmpty()) {4888 if (error_type.errorSetIsEmpty(mod)) {
4888 return MCValue{ .immediate = 0 }; // always false4889 return MCValue{ .immediate = 0 }; // always false
4889 }4890 }
48904891
src/arch/sparc64/CodeGen.zig+1-1
...@@ -3530,7 +3530,7 @@ fn errUnionPayload(self: *Self, error_union_mcv: MCValue, error_union_ty: Type)...@@ -3530,7 +3530,7 @@ fn errUnionPayload(self: *Self, error_union_mcv: MCValue, error_union_ty: Type)
3530 const mod = self.bin_file.options.module.?;3530 const mod = self.bin_file.options.module.?;
3531 const err_ty = error_union_ty.errorUnionSet();3531 const err_ty = error_union_ty.errorUnionSet();
3532 const payload_ty = error_union_ty.errorUnionPayload();3532 const payload_ty = error_union_ty.errorUnionPayload();
3533 if (err_ty.errorSetIsEmpty()) {3533 if (err_ty.errorSetIsEmpty(mod)) {
3534 return error_union_mcv;3534 return error_union_mcv;
3535 }3535 }
3536 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {3536 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {
src/arch/wasm/CodeGen.zig+5-5
...@@ -1036,8 +1036,8 @@ fn genValtype(ty: Type, mod: *Module) u8 {...@@ -1036,8 +1036,8 @@ fn genValtype(ty: Type, mod: *Module) u8 {
1036/// Differently from `genValtype` this also allows `void` to create a block1036/// Differently from `genValtype` this also allows `void` to create a block
1037/// with no return type1037/// with no return type
1038fn genBlockType(ty: Type, mod: *Module) u8 {1038fn genBlockType(ty: Type, mod: *Module) u8 {
1039 return switch (ty.tag()) {1039 return switch (ty.ip_index) {
1040 .void, .noreturn => wasm.block_empty,1040 .void_type, .noreturn_type => wasm.block_empty,
1041 else => genValtype(ty, mod),1041 else => genValtype(ty, mod),
1042 };1042 };
1043}1043}
...@@ -3948,7 +3948,7 @@ fn airIsErr(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode) InnerErro...@@ -3948,7 +3948,7 @@ fn airIsErr(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode) InnerErro
3948 const pl_ty = err_union_ty.errorUnionPayload();3948 const pl_ty = err_union_ty.errorUnionPayload();
39493949
3950 const result = result: {3950 const result = result: {
3951 if (err_union_ty.errorUnionSet().errorSetIsEmpty()) {3951 if (err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) {
3952 switch (opcode) {3952 switch (opcode) {
3953 .i32_ne => break :result WValue{ .imm32 = 0 },3953 .i32_ne => break :result WValue{ .imm32 = 0 },
3954 .i32_eq => break :result WValue{ .imm32 = 1 },3954 .i32_eq => break :result WValue{ .imm32 = 1 },
...@@ -4013,7 +4013,7 @@ fn airUnwrapErrUnionError(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool)...@@ -4013,7 +4013,7 @@ fn airUnwrapErrUnionError(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool)
4013 const payload_ty = err_ty.errorUnionPayload();4013 const payload_ty = err_ty.errorUnionPayload();
40144014
4015 const result = result: {4015 const result = result: {
4016 if (err_ty.errorUnionSet().errorSetIsEmpty()) {4016 if (err_ty.errorUnionSet().errorSetIsEmpty(mod)) {
4017 break :result WValue{ .imm32 = 0 };4017 break :result WValue{ .imm32 = 0 };
4018 }4018 }
40194019
...@@ -6214,7 +6214,7 @@ fn lowerTry(...@@ -6214,7 +6214,7 @@ fn lowerTry(
6214 const pl_ty = err_union_ty.errorUnionPayload();6214 const pl_ty = err_union_ty.errorUnionPayload();
6215 const pl_has_bits = pl_ty.hasRuntimeBitsIgnoreComptime(mod);6215 const pl_has_bits = pl_ty.hasRuntimeBitsIgnoreComptime(mod);
62166216
6217 if (!err_union_ty.errorUnionSet().errorSetIsEmpty()) {6217 if (!err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) {
6218 // Block we can jump out of when error is not set6218 // Block we can jump out of when error is not set
6219 try func.startBlock(.block, wasm.block_empty);6219 try func.startBlock(.block, wasm.block_empty);
62206220
src/arch/x86_64/CodeGen.zig+4-4
...@@ -3624,7 +3624,7 @@ fn airUnwrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {...@@ -3624,7 +3624,7 @@ fn airUnwrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
3624 const operand = try self.resolveInst(ty_op.operand);3624 const operand = try self.resolveInst(ty_op.operand);
36253625
3626 const result: MCValue = result: {3626 const result: MCValue = result: {
3627 if (err_ty.errorSetIsEmpty()) {3627 if (err_ty.errorSetIsEmpty(mod)) {
3628 break :result MCValue{ .immediate = 0 };3628 break :result MCValue{ .immediate = 0 };
3629 }3629 }
36303630
...@@ -5811,7 +5811,7 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air:...@@ -5811,7 +5811,7 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air:
5811 switch (tag) {5811 switch (tag) {
5812 .not => {5812 .not => {
5813 const limb_abi_size = @intCast(u16, @min(src_ty.abiSize(mod), 8));5813 const limb_abi_size = @intCast(u16, @min(src_ty.abiSize(mod), 8));
5814 const int_info = if (src_ty.tag() == .bool)5814 const int_info = if (src_ty.ip_index == .bool_type)
5815 std.builtin.Type.Int{ .signedness = .unsigned, .bits = 1 }5815 std.builtin.Type.Int{ .signedness = .unsigned, .bits = 1 }
5816 else5816 else
5817 src_ty.intInfo(mod);5817 src_ty.intInfo(mod);
...@@ -8716,7 +8716,7 @@ fn isNull(self: *Self, inst: Air.Inst.Index, opt_ty: Type, opt_mcv: MCValue) !MC...@@ -8716,7 +8716,7 @@ fn isNull(self: *Self, inst: Air.Inst.Index, opt_ty: Type, opt_mcv: MCValue) !MC
8716 try self.asmRegisterRegister(.{ ._, .@"test" }, alias_reg, alias_reg);8716 try self.asmRegisterRegister(.{ ._, .@"test" }, alias_reg, alias_reg);
8717 return .{ .eflags = .z };8717 return .{ .eflags = .z };
8718 }8718 }
8719 assert(some_info.ty.tag() == .bool);8719 assert(some_info.ty.ip_index == .bool_type);
8720 const opt_abi_size = @intCast(u32, opt_ty.abiSize(mod));8720 const opt_abi_size = @intCast(u32, opt_ty.abiSize(mod));
8721 try self.asmRegisterImmediate(8721 try self.asmRegisterImmediate(
8722 .{ ._, .bt },8722 .{ ._, .bt },
...@@ -8808,7 +8808,7 @@ fn isErr(self: *Self, maybe_inst: ?Air.Inst.Index, ty: Type, operand: MCValue) !...@@ -8808,7 +8808,7 @@ fn isErr(self: *Self, maybe_inst: ?Air.Inst.Index, ty: Type, operand: MCValue) !
8808 const mod = self.bin_file.options.module.?;8808 const mod = self.bin_file.options.module.?;
8809 const err_type = ty.errorUnionSet();8809 const err_type = ty.errorUnionSet();
88108810
8811 if (err_type.errorSetIsEmpty()) {8811 if (err_type.errorSetIsEmpty(mod)) {
8812 return MCValue{ .immediate = 0 }; // always false8812 return MCValue{ .immediate = 0 }; // always false
8813 }8813 }
88148814
src/codegen/c.zig+8-8
...@@ -1508,7 +1508,7 @@ pub const DeclGen = struct {...@@ -1508,7 +1508,7 @@ pub const DeclGen = struct {
1508 }1508 }
1509 if (fn_decl.val.castTag(.function)) |func_payload|1509 if (fn_decl.val.castTag(.function)) |func_payload|
1510 if (func_payload.data.is_cold) try w.writeAll("zig_cold ");1510 if (func_payload.data.is_cold) try w.writeAll("zig_cold ");
1511 if (fn_info.return_type.tag() == .noreturn) try w.writeAll("zig_noreturn ");1511 if (fn_info.return_type.ip_index == .noreturn_type) try w.writeAll("zig_noreturn ");
15121512
1513 const trailing = try renderTypePrefix(1513 const trailing = try renderTypePrefix(
1514 dg.decl_index,1514 dg.decl_index,
...@@ -3783,7 +3783,7 @@ fn airNot(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -3783,7 +3783,7 @@ fn airNot(f: *Function, inst: Air.Inst.Index) !CValue {
3783 const ty_op = f.air.instructions.items(.data)[inst].ty_op;3783 const ty_op = f.air.instructions.items(.data)[inst].ty_op;
3784 const operand_ty = f.typeOf(ty_op.operand);3784 const operand_ty = f.typeOf(ty_op.operand);
3785 const scalar_ty = operand_ty.scalarType(mod);3785 const scalar_ty = operand_ty.scalarType(mod);
3786 if (scalar_ty.tag() != .bool) return try airUnBuiltinCall(f, inst, "not", .bits);3786 if (scalar_ty.ip_index != .bool_type) return try airUnBuiltinCall(f, inst, "not", .bits);
37873787
3788 const op = try f.resolveInst(ty_op.operand);3788 const op = try f.resolveInst(ty_op.operand);
3789 try reap(f, inst, &.{ty_op.operand});3789 try reap(f, inst, &.{ty_op.operand});
...@@ -4292,7 +4292,7 @@ fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -4292,7 +4292,7 @@ fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue {
4292 const writer = f.object.writer();4292 const writer = f.object.writer();
42934293
4294 const inst_ty = f.typeOfIndex(inst);4294 const inst_ty = f.typeOfIndex(inst);
4295 const result = if (inst_ty.tag() != .void and !f.liveness.isUnused(inst))4295 const result = if (inst_ty.ip_index != .void_type and !f.liveness.isUnused(inst))
4296 try f.allocLocal(inst, inst_ty)4296 try f.allocLocal(inst, inst_ty)
4297 else4297 else
4298 .none;4298 .none;
...@@ -4354,7 +4354,7 @@ fn lowerTry(...@@ -4354,7 +4354,7 @@ fn lowerTry(
4354 const payload_ty = err_union_ty.errorUnionPayload();4354 const payload_ty = err_union_ty.errorUnionPayload();
4355 const payload_has_bits = payload_ty.hasRuntimeBitsIgnoreComptime(mod);4355 const payload_has_bits = payload_ty.hasRuntimeBitsIgnoreComptime(mod);
43564356
4357 if (!err_union_ty.errorUnionSet().errorSetIsEmpty()) {4357 if (!err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) {
4358 try writer.writeAll("if (");4358 try writer.writeAll("if (");
4359 if (!payload_has_bits) {4359 if (!payload_has_bits) {
4360 if (is_ptr)4360 if (is_ptr)
...@@ -5549,7 +5549,7 @@ fn airUnwrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5549,7 +5549,7 @@ fn airUnwrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue {
5549 if (!payload_ty.hasRuntimeBits(mod)) {5549 if (!payload_ty.hasRuntimeBits(mod)) {
5550 try f.writeCValue(writer, operand, .Other);5550 try f.writeCValue(writer, operand, .Other);
5551 } else {5551 } else {
5552 if (!error_ty.errorSetIsEmpty())5552 if (!error_ty.errorSetIsEmpty(mod))
5553 if (operand_is_ptr)5553 if (operand_is_ptr)
5554 try f.writeCValueDerefMember(writer, operand, .{ .identifier = "error" })5554 try f.writeCValueDerefMember(writer, operand, .{ .identifier = "error" })
5555 else5555 else
...@@ -5768,7 +5768,7 @@ fn airIsErr(f: *Function, inst: Air.Inst.Index, is_ptr: bool, operator: []const...@@ -5768,7 +5768,7 @@ fn airIsErr(f: *Function, inst: Air.Inst.Index, is_ptr: bool, operator: []const
5768 try f.writeCValue(writer, local, .Other);5768 try f.writeCValue(writer, local, .Other);
5769 try writer.writeAll(" = ");5769 try writer.writeAll(" = ");
57705770
5771 if (!error_ty.errorSetIsEmpty())5771 if (!error_ty.errorSetIsEmpty(mod))
5772 if (payload_ty.hasRuntimeBits(mod))5772 if (payload_ty.hasRuntimeBits(mod))
5773 if (is_ptr)5773 if (is_ptr)
5774 try f.writeCValueDerefMember(writer, operand, .{ .identifier = "error" })5774 try f.writeCValueDerefMember(writer, operand, .{ .identifier = "error" })
...@@ -6032,7 +6032,7 @@ fn airCmpBuiltinCall(...@@ -6032,7 +6032,7 @@ fn airCmpBuiltinCall(
6032 try writer.writeByte(')');6032 try writer.writeByte(')');
6033 if (!ref_ret) try writer.print(" {s} {}", .{6033 if (!ref_ret) try writer.print(" {s} {}", .{
6034 compareOperatorC(operator),6034 compareOperatorC(operator),
6035 try f.fmtIntLiteral(Type.initTag(.i32), Value.zero),6035 try f.fmtIntLiteral(Type.i32, Value.zero),
6036 });6036 });
6037 try writer.writeAll(";\n");6037 try writer.writeAll(";\n");
6038 try v.end(f, inst, writer);6038 try v.end(f, inst, writer);
...@@ -7749,7 +7749,7 @@ const LowerFnRetTyBuffer = struct {...@@ -7749,7 +7749,7 @@ const LowerFnRetTyBuffer = struct {
7749 payload: Type.Payload.AnonStruct,7749 payload: Type.Payload.AnonStruct,
7750};7750};
7751fn lowerFnRetTy(ret_ty: Type, buffer: *LowerFnRetTyBuffer, mod: *const Module) Type {7751fn lowerFnRetTy(ret_ty: Type, buffer: *LowerFnRetTyBuffer, mod: *const Module) Type {
7752 if (ret_ty.zigTypeTag(mod) == .NoReturn) return Type.initTag(.noreturn);7752 if (ret_ty.zigTypeTag(mod) == .NoReturn) return Type.noreturn;
77537753
7754 if (lowersToArray(ret_ty, mod)) {7754 if (lowersToArray(ret_ty, mod)) {
7755 buffer.names = [1][]const u8{"array"};7755 buffer.names = [1][]const u8{"array"};
src/codegen/llvm.zig+18-20
...@@ -1730,7 +1730,7 @@ pub const Object = struct {...@@ -1730,7 +1730,7 @@ pub const Object = struct {
1730 return ptr_di_ty;1730 return ptr_di_ty;
1731 },1731 },
1732 .Opaque => {1732 .Opaque => {
1733 if (ty.tag() == .anyopaque) {1733 if (ty.ip_index == .anyopaque_type) {
1734 const di_ty = dib.createBasicType("anyopaque", 0, DW.ATE.signed);1734 const di_ty = dib.createBasicType("anyopaque", 0, DW.ATE.signed);
1735 gop.value_ptr.* = AnnotatedDITypePtr.initFull(di_ty);1735 gop.value_ptr.* = AnnotatedDITypePtr.initFull(di_ty);
1736 return di_ty;1736 return di_ty;
...@@ -2847,25 +2847,23 @@ pub const DeclGen = struct {...@@ -2847,25 +2847,23 @@ pub const DeclGen = struct {
2847 const llvm_addrspace = toLlvmAddressSpace(ptr_info.@"addrspace", target);2847 const llvm_addrspace = toLlvmAddressSpace(ptr_info.@"addrspace", target);
2848 return dg.context.pointerType(llvm_addrspace);2848 return dg.context.pointerType(llvm_addrspace);
2849 },2849 },
2850 .Opaque => switch (t.tag()) {2850 .Opaque => {
2851 .@"opaque" => {2851 if (t.ip_index == .anyopaque_type) return dg.context.intType(8);
2852 const gop = try dg.object.type_map.getOrPutContext(gpa, t, .{ .mod = dg.module });
2853 if (gop.found_existing) return gop.value_ptr.*;
28542852
2855 // The Type memory is ephemeral; since we want to store a longer-lived2853 const gop = try dg.object.type_map.getOrPutContext(gpa, t, .{ .mod = dg.module });
2856 // reference, we need to copy it here.2854 if (gop.found_existing) return gop.value_ptr.*;
2857 gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator());
28582855
2859 const opaque_obj = t.castTag(.@"opaque").?.data;2856 // The Type memory is ephemeral; since we want to store a longer-lived
2860 const name = try opaque_obj.getFullyQualifiedName(dg.module);2857 // reference, we need to copy it here.
2861 defer gpa.free(name);2858 gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator());
28622859
2863 const llvm_struct_ty = dg.context.structCreateNamed(name);2860 const opaque_obj = t.castTag(.@"opaque").?.data;
2864 gop.value_ptr.* = llvm_struct_ty; // must be done before any recursive calls2861 const name = try opaque_obj.getFullyQualifiedName(dg.module);
2865 return llvm_struct_ty;2862 defer gpa.free(name);
2866 },2863
2867 .anyopaque => return dg.context.intType(8),2864 const llvm_struct_ty = dg.context.structCreateNamed(name);
2868 else => unreachable,2865 gop.value_ptr.* = llvm_struct_ty; // must be done before any recursive calls
2866 return llvm_struct_ty;
2869 },2867 },
2870 .Array => {2868 .Array => {
2871 const elem_ty = t.childType();2869 const elem_ty = t.childType();
...@@ -5531,7 +5529,7 @@ pub const FuncGen = struct {...@@ -5531,7 +5529,7 @@ pub const FuncGen = struct {
5531 const payload_has_bits = payload_ty.hasRuntimeBitsIgnoreComptime(mod);5529 const payload_has_bits = payload_ty.hasRuntimeBitsIgnoreComptime(mod);
5532 const err_union_llvm_ty = try fg.dg.lowerType(err_union_ty);5530 const err_union_llvm_ty = try fg.dg.lowerType(err_union_ty);
55335531
5534 if (!err_union_ty.errorUnionSet().errorSetIsEmpty()) {5532 if (!err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) {
5535 const is_err = err: {5533 const is_err = err: {
5536 const err_set_ty = try fg.dg.lowerType(Type.anyerror);5534 const err_set_ty = try fg.dg.lowerType(Type.anyerror);
5537 const zero = err_set_ty.constNull();5535 const zero = err_set_ty.constNull();
...@@ -6715,7 +6713,7 @@ pub const FuncGen = struct {...@@ -6715,7 +6713,7 @@ pub const FuncGen = struct {
6715 const err_set_ty = try self.dg.lowerType(Type.anyerror);6713 const err_set_ty = try self.dg.lowerType(Type.anyerror);
6716 const zero = err_set_ty.constNull();6714 const zero = err_set_ty.constNull();
67176715
6718 if (err_union_ty.errorUnionSet().errorSetIsEmpty()) {6716 if (err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) {
6719 const llvm_i1 = self.context.intType(1);6717 const llvm_i1 = self.context.intType(1);
6720 switch (op) {6718 switch (op) {
6721 .EQ => return llvm_i1.constInt(1, .False), // 0 == 06719 .EQ => return llvm_i1.constInt(1, .False), // 0 == 0
...@@ -6864,7 +6862,7 @@ pub const FuncGen = struct {...@@ -6864,7 +6862,7 @@ pub const FuncGen = struct {
6864 const operand = try self.resolveInst(ty_op.operand);6862 const operand = try self.resolveInst(ty_op.operand);
6865 const operand_ty = self.typeOf(ty_op.operand);6863 const operand_ty = self.typeOf(ty_op.operand);
6866 const err_union_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty;6864 const err_union_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty;
6867 if (err_union_ty.errorUnionSet().errorSetIsEmpty()) {6865 if (err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) {
6868 const err_llvm_ty = try self.dg.lowerType(Type.anyerror);6866 const err_llvm_ty = try self.dg.lowerType(Type.anyerror);
6869 if (operand_is_ptr) {6867 if (operand_is_ptr) {
6870 return operand;6868 return operand;
src/codegen/spirv.zig+4-2
...@@ -2849,6 +2849,7 @@ pub const DeclGen = struct {...@@ -2849,6 +2849,7 @@ pub const DeclGen = struct {
2849 }2849 }
28502850
2851 fn airTry(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {2851 fn airTry(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
2852 const mod = self.module;
2852 const pl_op = self.air.instructions.items(.data)[inst].pl_op;2853 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
2853 const err_union_id = try self.resolve(pl_op.operand);2854 const err_union_id = try self.resolve(pl_op.operand);
2854 const extra = self.air.extraData(Air.Try, pl_op.payload);2855 const extra = self.air.extraData(Air.Try, pl_op.payload);
...@@ -2862,7 +2863,7 @@ pub const DeclGen = struct {...@@ -2862,7 +2863,7 @@ pub const DeclGen = struct {
28622863
2863 const eu_layout = self.errorUnionLayout(payload_ty);2864 const eu_layout = self.errorUnionLayout(payload_ty);
28642865
2865 if (!err_union_ty.errorUnionSet().errorSetIsEmpty()) {2866 if (!err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) {
2866 const err_id = if (eu_layout.payload_has_bits)2867 const err_id = if (eu_layout.payload_has_bits)
2867 try self.extractField(Type.anyerror, err_union_id, eu_layout.errorFieldIndex())2868 try self.extractField(Type.anyerror, err_union_id, eu_layout.errorFieldIndex())
2868 else2869 else
...@@ -2910,12 +2911,13 @@ pub const DeclGen = struct {...@@ -2910,12 +2911,13 @@ pub const DeclGen = struct {
2910 fn airErrUnionErr(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {2911 fn airErrUnionErr(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
2911 if (self.liveness.isUnused(inst)) return null;2912 if (self.liveness.isUnused(inst)) return null;
29122913
2914 const mod = self.module;
2913 const ty_op = self.air.instructions.items(.data)[inst].ty_op;2915 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
2914 const operand_id = try self.resolve(ty_op.operand);2916 const operand_id = try self.resolve(ty_op.operand);
2915 const err_union_ty = self.typeOf(ty_op.operand);2917 const err_union_ty = self.typeOf(ty_op.operand);
2916 const err_ty_ref = try self.resolveType(Type.anyerror, .direct);2918 const err_ty_ref = try self.resolveType(Type.anyerror, .direct);
29172919
2918 if (err_union_ty.errorUnionSet().errorSetIsEmpty()) {2920 if (err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) {
2919 // No error possible, so just return undefined.2921 // No error possible, so just return undefined.
2920 return try self.spv.constUndef(err_ty_ref);2922 return try self.spv.constUndef(err_ty_ref);
2921 }2923 }
src/print_air.zig-1
...@@ -370,7 +370,6 @@ const Writer = struct {...@@ -370,7 +370,6 @@ const Writer = struct {
370 switch (t) {370 switch (t) {
371 .inferred_alloc_const => try s.writeAll("(inferred_alloc_const)"),371 .inferred_alloc_const => try s.writeAll("(inferred_alloc_const)"),
372 .inferred_alloc_mut => try s.writeAll("(inferred_alloc_mut)"),372 .inferred_alloc_mut => try s.writeAll("(inferred_alloc_mut)"),
373 .generic_poison => try s.writeAll("(generic_poison)"),
374 else => try ty.print(s, w.module),373 else => try ty.print(s, w.module),
375 }374 }
376 }375 }
src/type.zig+135-604
...@@ -85,9 +85,9 @@ pub const Type = struct {...@@ -85,9 +85,9 @@ pub const Type = struct {
85 .address_space,85 .address_space,
86 .float_mode,86 .float_mode,
87 .reduce_op,87 .reduce_op,
88 .call_modifier,
88 => return .Enum,89 => return .Enum,
8990
90 .call_modifier,
91 .prefetch_options,91 .prefetch_options,
92 .export_options,92 .export_options,
93 .extern_options,93 .extern_options,
...@@ -95,7 +95,7 @@ pub const Type = struct {...@@ -95,7 +95,7 @@ pub const Type = struct {
9595
96 .type_info => return .Union,96 .type_info => return .Union,
9797
98 .generic_poison => unreachable,98 .generic_poison => return error.GenericPoison,
99 .var_args_param => unreachable,99 .var_args_param => unreachable,
100 },100 },
101101
...@@ -107,8 +107,6 @@ pub const Type = struct {...@@ -107,8 +107,6 @@ pub const Type = struct {
107 }107 }
108 }108 }
109 switch (ty.tag()) {109 switch (ty.tag()) {
110 .generic_poison => return error.GenericPoison,
111
112 .u1,110 .u1,
113 .u8,111 .u8,
114 .i8,112 .i8,
...@@ -125,19 +123,11 @@ pub const Type = struct {...@@ -125,19 +123,11 @@ pub const Type = struct {
125123
126 .error_set,124 .error_set,
127 .error_set_single,125 .error_set_single,
128 .anyerror,
129 .error_set_inferred,126 .error_set_inferred,
130 .error_set_merged,127 .error_set_merged,
131 => return .ErrorSet,128 => return .ErrorSet,
132129
133 .anyopaque, .@"opaque" => return .Opaque,130 .@"opaque" => return .Opaque,
134 .bool => return .Bool,
135 .void => return .Void,
136 .type => return .Type,
137 .comptime_int => return .ComptimeInt,
138 .noreturn => return .NoReturn,
139 .null => return .Null,
140 .undefined => return .Undefined,
141131
142 .function => return .Fn,132 .function => return .Fn,
143133
...@@ -172,18 +162,14 @@ pub const Type = struct {...@@ -172,18 +162,14 @@ pub const Type = struct {
172 .optional_single_const_pointer,162 .optional_single_const_pointer,
173 .optional_single_mut_pointer,163 .optional_single_mut_pointer,
174 => return .Optional,164 => return .Optional,
175 .enum_literal => return .EnumLiteral,
176165
177 .anyerror_void_error_union, .error_union => return .ErrorUnion,166 .anyerror_void_error_union, .error_union => return .ErrorUnion,
178167
179 .anyframe_T, .@"anyframe" => return .AnyFrame,168 .anyframe_T => return .AnyFrame,
180169
181 .empty_struct,170 .empty_struct,
182 .empty_struct_literal,171 .empty_struct_literal,
183 .@"struct",172 .@"struct",
184 .prefetch_options,
185 .export_options,
186 .extern_options,
187 .tuple,173 .tuple,
188 .anon_struct,174 .anon_struct,
189 => return .Struct,175 => return .Struct,
...@@ -192,19 +178,11 @@ pub const Type = struct {...@@ -192,19 +178,11 @@ pub const Type = struct {
192 .enum_nonexhaustive,178 .enum_nonexhaustive,
193 .enum_simple,179 .enum_simple,
194 .enum_numbered,180 .enum_numbered,
195 .atomic_order,
196 .atomic_rmw_op,
197 .calling_convention,
198 .address_space,
199 .float_mode,
200 .reduce_op,
201 .modifier,
202 => return .Enum,181 => return .Enum,
203182
204 .@"union",183 .@"union",
205 .union_safety_tagged,184 .union_safety_tagged,
206 .union_tagged,185 .union_tagged,
207 .type_info,
208 => return .Union,186 => return .Union,
209 }187 }
210 }188 }
...@@ -393,7 +371,7 @@ pub const Type = struct {...@@ -393,7 +371,7 @@ pub const Type = struct {
393 pub fn ptrInfo(self: Type) Payload.Pointer {371 pub fn ptrInfo(self: Type) Payload.Pointer {
394 switch (self.tag()) {372 switch (self.tag()) {
395 .single_const_pointer_to_comptime_int => return .{ .data = .{373 .single_const_pointer_to_comptime_int => return .{ .data = .{
396 .pointee_type = Type.initTag(.comptime_int),374 .pointee_type = Type.comptime_int,
397 .sentinel = null,375 .sentinel = null,
398 .@"align" = 0,376 .@"align" = 0,
399 .@"addrspace" = .generic,377 .@"addrspace" = .generic,
...@@ -405,7 +383,7 @@ pub const Type = struct {...@@ -405,7 +383,7 @@ pub const Type = struct {
405 .size = .One,383 .size = .One,
406 } },384 } },
407 .const_slice_u8 => return .{ .data = .{385 .const_slice_u8 => return .{ .data = .{
408 .pointee_type = Type.initTag(.u8),386 .pointee_type = Type.u8,
409 .sentinel = null,387 .sentinel = null,
410 .@"align" = 0,388 .@"align" = 0,
411 .@"addrspace" = .generic,389 .@"addrspace" = .generic,
...@@ -417,7 +395,7 @@ pub const Type = struct {...@@ -417,7 +395,7 @@ pub const Type = struct {
417 .size = .Slice,395 .size = .Slice,
418 } },396 } },
419 .const_slice_u8_sentinel_0 => return .{ .data = .{397 .const_slice_u8_sentinel_0 => return .{ .data = .{
420 .pointee_type = Type.initTag(.u8),398 .pointee_type = Type.u8,
421 .sentinel = Value.zero,399 .sentinel = Value.zero,
422 .@"align" = 0,400 .@"align" = 0,
423 .@"addrspace" = .generic,401 .@"addrspace" = .generic,
...@@ -465,7 +443,7 @@ pub const Type = struct {...@@ -465,7 +443,7 @@ pub const Type = struct {
465 .size = .Many,443 .size = .Many,
466 } },444 } },
467 .manyptr_const_u8 => return .{ .data = .{445 .manyptr_const_u8 => return .{ .data = .{
468 .pointee_type = Type.initTag(.u8),446 .pointee_type = Type.u8,
469 .sentinel = null,447 .sentinel = null,
470 .@"align" = 0,448 .@"align" = 0,
471 .@"addrspace" = .generic,449 .@"addrspace" = .generic,
...@@ -477,7 +455,7 @@ pub const Type = struct {...@@ -477,7 +455,7 @@ pub const Type = struct {
477 .size = .Many,455 .size = .Many,
478 } },456 } },
479 .manyptr_const_u8_sentinel_0 => return .{ .data = .{457 .manyptr_const_u8_sentinel_0 => return .{ .data = .{
480 .pointee_type = Type.initTag(.u8),458 .pointee_type = Type.u8,
481 .sentinel = Value.zero,459 .sentinel = Value.zero,
482 .@"align" = 0,460 .@"align" = 0,
483 .@"addrspace" = .generic,461 .@"addrspace" = .generic,
...@@ -501,7 +479,7 @@ pub const Type = struct {...@@ -501,7 +479,7 @@ pub const Type = struct {
501 .size = .Many,479 .size = .Many,
502 } },480 } },
503 .manyptr_u8 => return .{ .data = .{481 .manyptr_u8 => return .{ .data = .{
504 .pointee_type = Type.initTag(.u8),482 .pointee_type = Type.u8,
505 .sentinel = null,483 .sentinel = null,
506 .@"align" = 0,484 .@"align" = 0,
507 .@"addrspace" = .generic,485 .@"addrspace" = .generic,
...@@ -608,23 +586,6 @@ pub const Type = struct {...@@ -608,23 +586,6 @@ pub const Type = struct {
608 if (a.legacy.tag_if_small_enough == b.legacy.tag_if_small_enough) return true;586 if (a.legacy.tag_if_small_enough == b.legacy.tag_if_small_enough) return true;
609587
610 switch (a.tag()) {588 switch (a.tag()) {
611 .generic_poison => unreachable,
612
613 .bool,
614 .void,
615 .type,
616 .comptime_int,
617 .noreturn,
618 .null,
619 .undefined,
620 .anyopaque,
621 .@"anyframe",
622 .enum_literal,
623 => |a_tag| {
624 assert(a_tag != b.tag()); // because of the comparison at the top of the function.
625 return false;
626 },
627
628 .u1,589 .u1,
629 .u8,590 .u8,
630 .i8,591 .i8,
...@@ -653,10 +614,6 @@ pub const Type = struct {...@@ -653,10 +614,6 @@ pub const Type = struct {
653 return a_ies == b_ies;614 return a_ies == b_ies;
654 },615 },
655616
656 .anyerror => {
657 return b.tag() == .anyerror;
658 },
659
660 .error_set,617 .error_set,
661 .error_set_single,618 .error_set_single,
662 .error_set_merged,619 .error_set_merged,
...@@ -927,13 +884,6 @@ pub const Type = struct {...@@ -927,13 +884,6 @@ pub const Type = struct {
927 return true;884 return true;
928 },885 },
929886
930 // we can't compare these based on tags because it wouldn't detect if,
931 // for example, a was resolved into .@"struct" but b was one of these tags.
932 .prefetch_options,
933 .export_options,
934 .extern_options,
935 => unreachable, // needed to resolve the type before now
936
937 .enum_full, .enum_nonexhaustive => {887 .enum_full, .enum_nonexhaustive => {
938 const a_enum_obj = a.cast(Payload.EnumFull).?.data;888 const a_enum_obj = a.cast(Payload.EnumFull).?.data;
939 const b_enum_obj = (b.cast(Payload.EnumFull) orelse return false).data;889 const b_enum_obj = (b.cast(Payload.EnumFull) orelse return false).data;
...@@ -949,26 +899,12 @@ pub const Type = struct {...@@ -949,26 +899,12 @@ pub const Type = struct {
949 const b_enum_obj = (b.cast(Payload.EnumNumbered) orelse return false).data;899 const b_enum_obj = (b.cast(Payload.EnumNumbered) orelse return false).data;
950 return a_enum_obj == b_enum_obj;900 return a_enum_obj == b_enum_obj;
951 },901 },
952 // we can't compare these based on tags because it wouldn't detect if,
953 // for example, a was resolved into .enum_simple but b was one of these tags.
954 .atomic_order,
955 .atomic_rmw_op,
956 .calling_convention,
957 .address_space,
958 .float_mode,
959 .reduce_op,
960 .modifier,
961 => unreachable, // needed to resolve the type before now
962902
963 .@"union", .union_safety_tagged, .union_tagged => {903 .@"union", .union_safety_tagged, .union_tagged => {
964 const a_union_obj = a.cast(Payload.Union).?.data;904 const a_union_obj = a.cast(Payload.Union).?.data;
965 const b_union_obj = (b.cast(Payload.Union) orelse return false).data;905 const b_union_obj = (b.cast(Payload.Union) orelse return false).data;
966 return a_union_obj == b_union_obj;906 return a_union_obj == b_union_obj;
967 },907 },
968 // we can't compare these based on tags because it wouldn't detect if,
969 // for example, a was resolved into .union_tagged but b was one of these tags.
970 .type_info => unreachable, // needed to resolve the type before now
971
972 }908 }
973 }909 }
974910
...@@ -987,31 +923,6 @@ pub const Type = struct {...@@ -987,31 +923,6 @@ pub const Type = struct {
987 return;923 return;
988 }924 }
989 switch (ty.tag()) {925 switch (ty.tag()) {
990 .generic_poison => unreachable,
991
992 .bool => std.hash.autoHash(hasher, std.builtin.TypeId.Bool),
993 .void => std.hash.autoHash(hasher, std.builtin.TypeId.Void),
994 .type => std.hash.autoHash(hasher, std.builtin.TypeId.Type),
995 .comptime_int => std.hash.autoHash(hasher, std.builtin.TypeId.ComptimeInt),
996 .noreturn => std.hash.autoHash(hasher, std.builtin.TypeId.NoReturn),
997 .null => std.hash.autoHash(hasher, std.builtin.TypeId.Null),
998 .undefined => std.hash.autoHash(hasher, std.builtin.TypeId.Undefined),
999
1000 .anyopaque => {
1001 std.hash.autoHash(hasher, std.builtin.TypeId.Opaque);
1002 std.hash.autoHash(hasher, Tag.anyopaque);
1003 },
1004
1005 .@"anyframe" => {
1006 std.hash.autoHash(hasher, std.builtin.TypeId.AnyFrame);
1007 std.hash.autoHash(hasher, Tag.@"anyframe");
1008 },
1009
1010 .enum_literal => {
1011 std.hash.autoHash(hasher, std.builtin.TypeId.EnumLiteral);
1012 std.hash.autoHash(hasher, Tag.enum_literal);
1013 },
1014
1015 .u1,926 .u1,
1016 .u8,927 .u8,
1017 .i8,928 .i8,
...@@ -1046,12 +957,6 @@ pub const Type = struct {...@@ -1046,12 +957,6 @@ pub const Type = struct {
1046 for (names) |name| hasher.update(name);957 for (names) |name| hasher.update(name);
1047 },958 },
1048959
1049 .anyerror => {
1050 // anyerror is distinct from other error sets
1051 std.hash.autoHash(hasher, std.builtin.TypeId.ErrorSet);
1052 std.hash.autoHash(hasher, Tag.anyerror);
1053 },
1054
1055 .error_set_inferred => {960 .error_set_inferred => {
1056 // inferred error sets are compared using their data pointer961 // inferred error sets are compared using their data pointer
1057 const ies: *Module.Fn.InferredErrorSet = ty.castTag(.error_set_inferred).?.data;962 const ies: *Module.Fn.InferredErrorSet = ty.castTag(.error_set_inferred).?.data;
...@@ -1209,12 +1114,6 @@ pub const Type = struct {...@@ -1209,12 +1114,6 @@ pub const Type = struct {
1209 }1114 }
1210 },1115 },
12111116
1212 // we can't hash these based on tags because they wouldn't match the expanded version.
1213 .prefetch_options,
1214 .export_options,
1215 .extern_options,
1216 => unreachable, // needed to resolve the type before now
1217
1218 .enum_full, .enum_nonexhaustive => {1117 .enum_full, .enum_nonexhaustive => {
1219 const enum_obj: *const Module.EnumFull = ty.cast(Payload.EnumFull).?.data;1118 const enum_obj: *const Module.EnumFull = ty.cast(Payload.EnumFull).?.data;
1220 std.hash.autoHash(hasher, std.builtin.TypeId.Enum);1119 std.hash.autoHash(hasher, std.builtin.TypeId.Enum);
...@@ -1230,24 +1129,12 @@ pub const Type = struct {...@@ -1230,24 +1129,12 @@ pub const Type = struct {
1230 std.hash.autoHash(hasher, std.builtin.TypeId.Enum);1129 std.hash.autoHash(hasher, std.builtin.TypeId.Enum);
1231 std.hash.autoHash(hasher, enum_obj);1130 std.hash.autoHash(hasher, enum_obj);
1232 },1131 },
1233 // we can't hash these based on tags because they wouldn't match the expanded version.
1234 .atomic_order,
1235 .atomic_rmw_op,
1236 .calling_convention,
1237 .address_space,
1238 .float_mode,
1239 .reduce_op,
1240 .modifier,
1241 => unreachable, // needed to resolve the type before now
12421132
1243 .@"union", .union_safety_tagged, .union_tagged => {1133 .@"union", .union_safety_tagged, .union_tagged => {
1244 const union_obj: *const Module.Union = ty.cast(Payload.Union).?.data;1134 const union_obj: *const Module.Union = ty.cast(Payload.Union).?.data;
1245 std.hash.autoHash(hasher, std.builtin.TypeId.Union);1135 std.hash.autoHash(hasher, std.builtin.TypeId.Union);
1246 std.hash.autoHash(hasher, union_obj);1136 std.hash.autoHash(hasher, union_obj);
1247 },1137 },
1248 // we can't hash these based on tags because they wouldn't match the expanded version.
1249 .type_info => unreachable, // needed to resolve the type before now
1250
1251 }1138 }
1252 }1139 }
12531140
...@@ -1305,19 +1192,9 @@ pub const Type = struct {...@@ -1305,19 +1192,9 @@ pub const Type = struct {
1305 .i64,1192 .i64,
1306 .u128,1193 .u128,
1307 .i128,1194 .i128,
1308 .anyopaque,
1309 .bool,
1310 .void,
1311 .type,
1312 .anyerror,
1313 .comptime_int,
1314 .noreturn,
1315 .null,
1316 .undefined,
1317 .single_const_pointer_to_comptime_int,1195 .single_const_pointer_to_comptime_int,
1318 .const_slice_u8,1196 .const_slice_u8,
1319 .const_slice_u8_sentinel_0,1197 .const_slice_u8_sentinel_0,
1320 .enum_literal,
1321 .anyerror_void_error_union,1198 .anyerror_void_error_union,
1322 .inferred_alloc_const,1199 .inferred_alloc_const,
1323 .inferred_alloc_mut,1200 .inferred_alloc_mut,
...@@ -1325,19 +1202,6 @@ pub const Type = struct {...@@ -1325,19 +1202,6 @@ pub const Type = struct {
1325 .manyptr_u8,1202 .manyptr_u8,
1326 .manyptr_const_u8,1203 .manyptr_const_u8,
1327 .manyptr_const_u8_sentinel_0,1204 .manyptr_const_u8_sentinel_0,
1328 .atomic_order,
1329 .atomic_rmw_op,
1330 .calling_convention,
1331 .address_space,
1332 .float_mode,
1333 .reduce_op,
1334 .modifier,
1335 .prefetch_options,
1336 .export_options,
1337 .extern_options,
1338 .type_info,
1339 .@"anyframe",
1340 .generic_poison,
1341 => unreachable,1205 => unreachable,
13421206
1343 .array_u8,1207 .array_u8,
...@@ -1580,20 +1444,8 @@ pub const Type = struct {...@@ -1580,20 +1444,8 @@ pub const Type = struct {
1580 .i64,1444 .i64,
1581 .u128,1445 .u128,
1582 .i128,1446 .i128,
1583 .anyopaque,
1584 .bool,
1585 .void,
1586 .type,
1587 .anyerror,
1588 .@"anyframe",
1589 .comptime_int,
1590 .noreturn,
1591 => return writer.writeAll(@tagName(t)),1447 => return writer.writeAll(@tagName(t)),
15921448
1593 .enum_literal => return writer.writeAll("@Type(.EnumLiteral)"),
1594 .null => return writer.writeAll("@Type(.Null)"),
1595 .undefined => return writer.writeAll("@Type(.Undefined)"),
1596
1597 .empty_struct, .empty_struct_literal => return writer.writeAll("struct {}"),1449 .empty_struct, .empty_struct_literal => return writer.writeAll("struct {}"),
15981450
1599 .@"struct" => {1451 .@"struct" => {
...@@ -1640,17 +1492,6 @@ pub const Type = struct {...@@ -1640,17 +1492,6 @@ pub const Type = struct {
1640 .manyptr_u8 => return writer.writeAll("[*]u8"),1492 .manyptr_u8 => return writer.writeAll("[*]u8"),
1641 .manyptr_const_u8 => return writer.writeAll("[*]const u8"),1493 .manyptr_const_u8 => return writer.writeAll("[*]const u8"),
1642 .manyptr_const_u8_sentinel_0 => return writer.writeAll("[*:0]const u8"),1494 .manyptr_const_u8_sentinel_0 => return writer.writeAll("[*:0]const u8"),
1643 .atomic_order => return writer.writeAll("std.builtin.AtomicOrder"),
1644 .atomic_rmw_op => return writer.writeAll("std.builtin.AtomicRmwOp"),
1645 .calling_convention => return writer.writeAll("std.builtin.CallingConvention"),
1646 .address_space => return writer.writeAll("std.builtin.AddressSpace"),
1647 .float_mode => return writer.writeAll("std.builtin.FloatMode"),
1648 .reduce_op => return writer.writeAll("std.builtin.ReduceOp"),
1649 .modifier => return writer.writeAll("std.builtin.CallModifier"),
1650 .prefetch_options => return writer.writeAll("std.builtin.PrefetchOptions"),
1651 .export_options => return writer.writeAll("std.builtin.ExportOptions"),
1652 .extern_options => return writer.writeAll("std.builtin.ExternOptions"),
1653 .type_info => return writer.writeAll("std.builtin.Type"),
1654 .function => {1495 .function => {
1655 const payload = ty.castTag(.function).?.data;1496 const payload = ty.castTag(.function).?.data;
1656 try writer.writeAll("fn(");1497 try writer.writeAll("fn(");
...@@ -1889,7 +1730,6 @@ pub const Type = struct {...@@ -1889,7 +1730,6 @@ pub const Type = struct {
1889 },1730 },
1890 .inferred_alloc_const => return writer.writeAll("(inferred_alloc_const)"),1731 .inferred_alloc_const => return writer.writeAll("(inferred_alloc_const)"),
1891 .inferred_alloc_mut => return writer.writeAll("(inferred_alloc_mut)"),1732 .inferred_alloc_mut => return writer.writeAll("(inferred_alloc_mut)"),
1892 .generic_poison => return writer.writeAll("(generic poison)"),
1893 }1733 }
1894 unreachable;1734 unreachable;
1895 }1735 }
...@@ -1931,20 +1771,6 @@ pub const Type = struct {...@@ -1931,20 +1771,6 @@ pub const Type = struct {
1931 switch (t) {1771 switch (t) {
1932 .inferred_alloc_const => unreachable,1772 .inferred_alloc_const => unreachable,
1933 .inferred_alloc_mut => unreachable,1773 .inferred_alloc_mut => unreachable,
1934 .generic_poison => unreachable,
1935
1936 // TODO get rid of these Type.Tag values.
1937 .atomic_order => unreachable,
1938 .atomic_rmw_op => unreachable,
1939 .calling_convention => unreachable,
1940 .address_space => unreachable,
1941 .float_mode => unreachable,
1942 .reduce_op => unreachable,
1943 .modifier => unreachable,
1944 .prefetch_options => unreachable,
1945 .export_options => unreachable,
1946 .extern_options => unreachable,
1947 .type_info => unreachable,
19481774
1949 .u1,1775 .u1,
1950 .u8,1776 .u8,
...@@ -1958,19 +1784,8 @@ pub const Type = struct {...@@ -1958,19 +1784,8 @@ pub const Type = struct {
1958 .i64,1784 .i64,
1959 .u128,1785 .u128,
1960 .i128,1786 .i128,
1961 .anyopaque,
1962 .bool,
1963 .void,
1964 .type,
1965 .anyerror,
1966 .@"anyframe",
1967 .comptime_int,
1968 .noreturn,
1969 => try writer.writeAll(@tagName(t)),1787 => try writer.writeAll(@tagName(t)),
19701788
1971 .enum_literal => try writer.writeAll("@TypeOf(.enum_literal)"),
1972 .null => try writer.writeAll("@TypeOf(null)"),
1973 .undefined => try writer.writeAll("@TypeOf(undefined)"),
1974 .empty_struct_literal => try writer.writeAll("@TypeOf(.{})"),1789 .empty_struct_literal => try writer.writeAll("@TypeOf(.{})"),
19751790
1976 .empty_struct => {1791 .empty_struct => {
...@@ -2249,34 +2064,12 @@ pub const Type = struct {...@@ -2249,34 +2064,12 @@ pub const Type = struct {
2249 .i32 => return Value.initTag(.i32_type),2064 .i32 => return Value.initTag(.i32_type),
2250 .u64 => return Value.initTag(.u64_type),2065 .u64 => return Value.initTag(.u64_type),
2251 .i64 => return Value.initTag(.i64_type),2066 .i64 => return Value.initTag(.i64_type),
2252 .anyopaque => return Value.initTag(.anyopaque_type),
2253 .bool => return Value.initTag(.bool_type),
2254 .void => return Value.initTag(.void_type),
2255 .type => return Value.initTag(.type_type),
2256 .anyerror => return Value.initTag(.anyerror_type),
2257 .@"anyframe" => return Value.initTag(.anyframe_type),
2258 .comptime_int => return Value.initTag(.comptime_int_type),
2259 .noreturn => return Value.initTag(.noreturn_type),
2260 .null => return Value.initTag(.null_type),
2261 .undefined => return Value.initTag(.undefined_type),
2262 .single_const_pointer_to_comptime_int => return Value.initTag(.single_const_pointer_to_comptime_int_type),2067 .single_const_pointer_to_comptime_int => return Value.initTag(.single_const_pointer_to_comptime_int_type),
2263 .const_slice_u8 => return Value.initTag(.const_slice_u8_type),2068 .const_slice_u8 => return Value.initTag(.const_slice_u8_type),
2264 .const_slice_u8_sentinel_0 => return Value.initTag(.const_slice_u8_sentinel_0_type),2069 .const_slice_u8_sentinel_0 => return Value.initTag(.const_slice_u8_sentinel_0_type),
2265 .enum_literal => return Value.initTag(.enum_literal_type),
2266 .manyptr_u8 => return Value.initTag(.manyptr_u8_type),2070 .manyptr_u8 => return Value.initTag(.manyptr_u8_type),
2267 .manyptr_const_u8 => return Value.initTag(.manyptr_const_u8_type),2071 .manyptr_const_u8 => return Value.initTag(.manyptr_const_u8_type),
2268 .manyptr_const_u8_sentinel_0 => return Value.initTag(.manyptr_const_u8_sentinel_0_type),2072 .manyptr_const_u8_sentinel_0 => return Value.initTag(.manyptr_const_u8_sentinel_0_type),
2269 .atomic_order => return Value.initTag(.atomic_order_type),
2270 .atomic_rmw_op => return Value.initTag(.atomic_rmw_op_type),
2271 .calling_convention => return Value.initTag(.calling_convention_type),
2272 .address_space => return Value.initTag(.address_space_type),
2273 .float_mode => return Value.initTag(.float_mode_type),
2274 .reduce_op => return Value.initTag(.reduce_op_type),
2275 .modifier => return Value.initTag(.modifier_type),
2276 .prefetch_options => return Value.initTag(.prefetch_options_type),
2277 .export_options => return Value.initTag(.export_options_type),
2278 .extern_options => return Value.initTag(.extern_options_type),
2279 .type_info => return Value.initTag(.type_info_type),
2280 .inferred_alloc_const => unreachable,2073 .inferred_alloc_const => unreachable,
2281 .inferred_alloc_mut => unreachable,2074 .inferred_alloc_mut => unreachable,
2282 else => return Value.Tag.ty.create(allocator, self),2075 else => return Value.Tag.ty.create(allocator, self),
...@@ -2378,8 +2171,7 @@ pub const Type = struct {...@@ -2378,8 +2171,7 @@ pub const Type = struct {
2378 .i64,2171 .i64,
2379 .u128,2172 .u128,
2380 .i128,2173 .i128,
2381 .bool,2174
2382 .anyerror,
2383 .const_slice_u8,2175 .const_slice_u8,
2384 .const_slice_u8_sentinel_0,2176 .const_slice_u8_sentinel_0,
2385 .array_u8_sentinel_0,2177 .array_u8_sentinel_0,
...@@ -2388,18 +2180,7 @@ pub const Type = struct {...@@ -2388,18 +2180,7 @@ pub const Type = struct {
2388 .manyptr_u8,2180 .manyptr_u8,
2389 .manyptr_const_u8,2181 .manyptr_const_u8,
2390 .manyptr_const_u8_sentinel_0,2182 .manyptr_const_u8_sentinel_0,
2391 .atomic_order,2183
2392 .atomic_rmw_op,
2393 .calling_convention,
2394 .address_space,
2395 .float_mode,
2396 .reduce_op,
2397 .modifier,
2398 .prefetch_options,
2399 .export_options,
2400 .extern_options,
2401 .@"anyframe",
2402 .anyopaque,
2403 .@"opaque",2184 .@"opaque",
2404 .error_set_single,2185 .error_set_single,
2405 .error_union,2186 .error_union,
...@@ -2435,16 +2216,8 @@ pub const Type = struct {...@@ -2435,16 +2216,8 @@ pub const Type = struct {
24352216
2436 // These are false because they are comptime-only types.2217 // These are false because they are comptime-only types.
2437 .single_const_pointer_to_comptime_int,2218 .single_const_pointer_to_comptime_int,
2438 .void,
2439 .type,
2440 .comptime_int,
2441 .noreturn,
2442 .null,
2443 .undefined,
2444 .enum_literal,
2445 .empty_struct,2219 .empty_struct,
2446 .empty_struct_literal,2220 .empty_struct_literal,
2447 .type_info,
2448 // These are function *bodies*, not pointers.2221 // These are function *bodies*, not pointers.
2449 // Special exceptions have to be made when emitting functions due to2222 // Special exceptions have to be made when emitting functions due to
2450 // this returning false.2223 // this returning false.
...@@ -2558,7 +2331,6 @@ pub const Type = struct {...@@ -2558,7 +2331,6 @@ pub const Type = struct {
25582331
2559 .inferred_alloc_const => unreachable,2332 .inferred_alloc_const => unreachable,
2560 .inferred_alloc_mut => unreachable,2333 .inferred_alloc_mut => unreachable,
2561 .generic_poison => unreachable,
2562 }2334 }
2563 }2335 }
25642336
...@@ -2641,8 +2413,7 @@ pub const Type = struct {...@@ -2641,8 +2413,7 @@ pub const Type = struct {
2641 .i64,2413 .i64,
2642 .u128,2414 .u128,
2643 .i128,2415 .i128,
2644 .bool,2416
2645 .void,
2646 .manyptr_u8,2417 .manyptr_u8,
2647 .manyptr_const_u8,2418 .manyptr_const_u8,
2648 .manyptr_const_u8_sentinel_0,2419 .manyptr_const_u8_sentinel_0,
...@@ -2662,32 +2433,11 @@ pub const Type = struct {...@@ -2662,32 +2433,11 @@ pub const Type = struct {
2662 .optional_single_const_pointer,2433 .optional_single_const_pointer,
2663 => true,2434 => true,
26642435
2665 .anyopaque,
2666 .anyerror,
2667 .noreturn,
2668 .null,
2669 .@"anyframe",
2670 .undefined,
2671 .atomic_order,
2672 .atomic_rmw_op,
2673 .calling_convention,
2674 .address_space,
2675 .float_mode,
2676 .reduce_op,
2677 .modifier,
2678 .prefetch_options,
2679 .export_options,
2680 .extern_options,
2681 .error_set,2436 .error_set,
2682 .error_set_single,2437 .error_set_single,
2683 .error_set_inferred,2438 .error_set_inferred,
2684 .error_set_merged,2439 .error_set_merged,
2685 .@"opaque",2440 .@"opaque",
2686 .generic_poison,
2687 .type,
2688 .comptime_int,
2689 .enum_literal,
2690 .type_info,
2691 // These are function bodies, not function pointers.2441 // These are function bodies, not function pointers.
2692 .function,2442 .function,
2693 .const_slice_u8,2443 .const_slice_u8,
...@@ -2773,7 +2523,6 @@ pub const Type = struct {...@@ -2773,7 +2523,6 @@ pub const Type = struct {
2773 else => return false,2523 else => return false,
27742524
2775 @enumToInt(InternPool.Index.none) => switch (ty.tag()) {2525 @enumToInt(InternPool.Index.none) => switch (ty.tag()) {
2776 .noreturn => return true,
2777 .error_set => {2526 .error_set => {
2778 const err_set_obj = ty.castTag(.error_set).?.data;2527 const err_set_obj = ty.castTag(.error_set).?.data;
2779 const names = err_set_obj.names.keys();2528 const names = err_set_obj.names.keys();
...@@ -3003,21 +2752,10 @@ pub const Type = struct {...@@ -3003,21 +2752,10 @@ pub const Type = struct {
3003 .u1,2752 .u1,
3004 .u8,2753 .u8,
3005 .i8,2754 .i8,
3006 .bool,2755
3007 .array_u8_sentinel_0,2756 .array_u8_sentinel_0,
3008 .array_u8,2757 .array_u8,
3009 .atomic_order,
3010 .atomic_rmw_op,
3011 .calling_convention,
3012 .address_space,
3013 .float_mode,
3014 .reduce_op,
3015 .modifier,
3016 .prefetch_options,
3017 .export_options,
3018 .extern_options,
3019 .@"opaque",2758 .@"opaque",
3020 .anyopaque,
3021 => return AbiAlignmentAdvanced{ .scalar = 1 },2759 => return AbiAlignmentAdvanced{ .scalar = 1 },
30222760
3023 // represents machine code; not a pointer2761 // represents machine code; not a pointer
...@@ -3044,13 +2782,11 @@ pub const Type = struct {...@@ -3044,13 +2782,11 @@ pub const Type = struct {
3044 .manyptr_u8,2782 .manyptr_u8,
3045 .manyptr_const_u8,2783 .manyptr_const_u8,
3046 .manyptr_const_u8_sentinel_0,2784 .manyptr_const_u8_sentinel_0,
3047 .@"anyframe",
3048 .anyframe_T,2785 .anyframe_T,
3049 => return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) },2786 => return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) },
30502787
3051 // TODO revisit this when we have the concept of the error tag type2788 // TODO revisit this when we have the concept of the error tag type
3052 .anyerror_void_error_union,2789 .anyerror_void_error_union,
3053 .anyerror,
3054 .error_set_inferred,2790 .error_set_inferred,
3055 .error_set_single,2791 .error_set_single,
3056 .error_set,2792 .error_set,
...@@ -3229,22 +2965,12 @@ pub const Type = struct {...@@ -3229,22 +2965,12 @@ pub const Type = struct {
3229 },2965 },
32302966
3231 .empty_struct,2967 .empty_struct,
3232 .void,
3233 .empty_struct_literal,2968 .empty_struct_literal,
3234 .type,
3235 .comptime_int,
3236 .null,
3237 .undefined,
3238 .enum_literal,
3239 .type_info,
3240 => return AbiAlignmentAdvanced{ .scalar = 0 },2969 => return AbiAlignmentAdvanced{ .scalar = 0 },
32412970
3242 .noreturn,
3243 .inferred_alloc_const,2971 .inferred_alloc_const,
3244 .inferred_alloc_mut,2972 .inferred_alloc_mut,
3245 => unreachable,2973 => unreachable,
3246
3247 .generic_poison => unreachable,
3248 }2974 }
3249 }2975 }
32502976
...@@ -3422,26 +3148,12 @@ pub const Type = struct {...@@ -3422,26 +3148,12 @@ pub const Type = struct {
3422 switch (ty.tag()) {3148 switch (ty.tag()) {
3423 .function => unreachable, // represents machine code; not a pointer3149 .function => unreachable, // represents machine code; not a pointer
3424 .@"opaque" => unreachable, // no size available3150 .@"opaque" => unreachable, // no size available
3425 .noreturn => unreachable,
3426 .inferred_alloc_const => unreachable,3151 .inferred_alloc_const => unreachable,
3427 .inferred_alloc_mut => unreachable,3152 .inferred_alloc_mut => unreachable,
3428 .generic_poison => unreachable,3153
3429 .modifier => unreachable, // missing call to resolveTypeFields
3430 .prefetch_options => unreachable, // missing call to resolveTypeFields
3431 .export_options => unreachable, // missing call to resolveTypeFields
3432 .extern_options => unreachable, // missing call to resolveTypeFields
3433 .type_info => unreachable, // missing call to resolveTypeFields
3434
3435 .anyopaque,
3436 .type,
3437 .comptime_int,
3438 .null,
3439 .undefined,
3440 .enum_literal,
3441 .single_const_pointer_to_comptime_int,3154 .single_const_pointer_to_comptime_int,
3442 .empty_struct_literal,3155 .empty_struct_literal,
3443 .empty_struct,3156 .empty_struct,
3444 .void,
3445 => return AbiSizeAdvanced{ .scalar = 0 },3157 => return AbiSizeAdvanced{ .scalar = 0 },
34463158
3447 .@"struct", .tuple, .anon_struct => switch (ty.containerLayout()) {3159 .@"struct", .tuple, .anon_struct => switch (ty.containerLayout()) {
...@@ -3496,13 +3208,6 @@ pub const Type = struct {...@@ -3496,13 +3208,6 @@ pub const Type = struct {
3496 .u1,3208 .u1,
3497 .u8,3209 .u8,
3498 .i8,3210 .i8,
3499 .bool,
3500 .atomic_order,
3501 .atomic_rmw_op,
3502 .calling_convention,
3503 .address_space,
3504 .float_mode,
3505 .reduce_op,
3506 => return AbiSizeAdvanced{ .scalar = 1 },3211 => return AbiSizeAdvanced{ .scalar = 1 },
35073212
3508 .array_u8 => return AbiSizeAdvanced{ .scalar = ty.castTag(.array_u8).?.data },3213 .array_u8 => return AbiSizeAdvanced{ .scalar = ty.castTag(.array_u8).?.data },
...@@ -3552,7 +3257,6 @@ pub const Type = struct {...@@ -3552,7 +3257,6 @@ pub const Type = struct {
3552 return AbiSizeAdvanced{ .scalar = result };3257 return AbiSizeAdvanced{ .scalar = result };
3553 },3258 },
35543259
3555 .@"anyframe",
3556 .anyframe_T,3260 .anyframe_T,
3557 .optional_single_const_pointer,3261 .optional_single_const_pointer,
3558 .optional_single_mut_pointer,3262 .optional_single_mut_pointer,
...@@ -3580,7 +3284,6 @@ pub const Type = struct {...@@ -3580,7 +3284,6 @@ pub const Type = struct {
35803284
3581 // TODO revisit this when we have the concept of the error tag type3285 // TODO revisit this when we have the concept of the error tag type
3582 .anyerror_void_error_union,3286 .anyerror_void_error_union,
3583 .anyerror,
3584 .error_set_inferred,3287 .error_set_inferred,
3585 .error_set,3288 .error_set,
3586 .error_set_merged,3289 .error_set_merged,
...@@ -3758,6 +3461,7 @@ pub const Type = struct {...@@ -3758,6 +3461,7 @@ pub const Type = struct {
3758 .undefined => unreachable,3461 .undefined => unreachable,
3759 .enum_literal => unreachable,3462 .enum_literal => unreachable,
3760 .generic_poison => unreachable,3463 .generic_poison => unreachable,
3464 .var_args_param => unreachable,
37613465
3762 .atomic_order => unreachable, // missing call to resolveTypeFields3466 .atomic_order => unreachable, // missing call to resolveTypeFields
3763 .atomic_rmw_op => unreachable, // missing call to resolveTypeFields3467 .atomic_rmw_op => unreachable, // missing call to resolveTypeFields
...@@ -3770,7 +3474,6 @@ pub const Type = struct {...@@ -3770,7 +3474,6 @@ pub const Type = struct {
3770 .export_options => unreachable, // missing call to resolveTypeFields3474 .export_options => unreachable, // missing call to resolveTypeFields
3771 .extern_options => unreachable, // missing call to resolveTypeFields3475 .extern_options => unreachable, // missing call to resolveTypeFields
3772 .type_info => unreachable, // missing call to resolveTypeFields3476 .type_info => unreachable, // missing call to resolveTypeFields
3773 .var_args_param => unreachable,
3774 },3477 },
3775 .struct_type => @panic("TODO"),3478 .struct_type => @panic("TODO"),
3776 .union_type => @panic("TODO"),3479 .union_type => @panic("TODO"),
...@@ -3784,23 +3487,14 @@ pub const Type = struct {...@@ -3784,23 +3487,14 @@ pub const Type = struct {
37843487
3785 switch (ty.tag()) {3488 switch (ty.tag()) {
3786 .function => unreachable, // represents machine code; not a pointer3489 .function => unreachable, // represents machine code; not a pointer
3787 .anyopaque => unreachable,
3788 .type => unreachable,
3789 .comptime_int => unreachable,
3790 .noreturn => unreachable,
3791 .null => unreachable,
3792 .undefined => unreachable,
3793 .enum_literal => unreachable,
3794 .single_const_pointer_to_comptime_int => unreachable,3490 .single_const_pointer_to_comptime_int => unreachable,
3795 .empty_struct => unreachable,3491 .empty_struct => unreachable,
3796 .empty_struct_literal => unreachable,3492 .empty_struct_literal => unreachable,
3797 .inferred_alloc_const => unreachable,3493 .inferred_alloc_const => unreachable,
3798 .inferred_alloc_mut => unreachable,3494 .inferred_alloc_mut => unreachable,
3799 .@"opaque" => unreachable,3495 .@"opaque" => unreachable,
3800 .generic_poison => unreachable,
38013496
3802 .void => return 0,3497 .u1 => return 1,
3803 .bool, .u1 => return 1,
3804 .u8, .i8 => return 8,3498 .u8, .i8 => return 8,
3805 .i16, .u16 => return 16,3499 .i16, .u16 => return 16,
3806 .u29 => return 29,3500 .u29 => return 29,
...@@ -3875,9 +3569,7 @@ pub const Type = struct {...@@ -3875,9 +3569,7 @@ pub const Type = struct {
3875 return payload.len * 8 * elem_size + elem_bit_size;3569 return payload.len * 8 * elem_size + elem_bit_size;
3876 },3570 },
38773571
3878 .@"anyframe",3572 .anyframe_T => return target.ptrBitWidth(),
3879 .anyframe_T,
3880 => return target.ptrBitWidth(),
38813573
3882 .const_slice,3574 .const_slice,
3883 .mut_slice,3575 .mut_slice,
...@@ -3916,7 +3608,6 @@ pub const Type = struct {...@@ -3916,7 +3608,6 @@ pub const Type = struct {
3916 .error_set,3608 .error_set,
3917 .error_set_single,3609 .error_set_single,
3918 .anyerror_void_error_union,3610 .anyerror_void_error_union,
3919 .anyerror,
3920 .error_set_inferred,3611 .error_set_inferred,
3921 .error_set_merged,3612 .error_set_merged,
3922 => return 16, // TODO revisit this when we have the concept of the error tag type3613 => return 16, // TODO revisit this when we have the concept of the error tag type
...@@ -3926,19 +3617,6 @@ pub const Type = struct {...@@ -3926,19 +3617,6 @@ pub const Type = struct {
3926 // includes padding bits.3617 // includes padding bits.
3927 return (try abiSizeAdvanced(ty, mod, strat)).scalar * 8;3618 return (try abiSizeAdvanced(ty, mod, strat)).scalar * 8;
3928 },3619 },
3929
3930 .atomic_order,
3931 .atomic_rmw_op,
3932 .calling_convention,
3933 .address_space,
3934 .float_mode,
3935 .reduce_op,
3936 .modifier,
3937 .prefetch_options,
3938 .export_options,
3939 .extern_options,
3940 .type_info,
3941 => @panic("TODO at some point we gotta resolve builtin types"),
3942 }3620 }
3943 }3621 }
39443622
...@@ -4326,7 +4004,7 @@ pub const Type = struct {...@@ -4326,7 +4004,7 @@ pub const Type = struct {
4326 .manyptr_const_u8_sentinel_0,4004 .manyptr_const_u8_sentinel_0,
4327 => Type.u8,4005 => Type.u8,
43284006
4329 .single_const_pointer_to_comptime_int => Type.initTag(.comptime_int),4007 .single_const_pointer_to_comptime_int => Type.comptime_int,
4330 .pointer => ty.castTag(.pointer).?.data.pointee_type,4008 .pointer => ty.castTag(.pointer).?.data.pointee_type,
43314009
4332 else => unreachable,4010 else => unreachable,
...@@ -4372,7 +4050,7 @@ pub const Type = struct {...@@ -4372,7 +4050,7 @@ pub const Type = struct {
4372 .manyptr_const_u8_sentinel_0,4050 .manyptr_const_u8_sentinel_0,
4373 => Type.u8,4051 => Type.u8,
43744052
4375 .single_const_pointer_to_comptime_int => Type.initTag(.comptime_int),4053 .single_const_pointer_to_comptime_int => Type.comptime_int,
4376 .pointer => {4054 .pointer => {
4377 const info = ty.castTag(.pointer).?.data;4055 const info = ty.castTag(.pointer).?.data;
4378 const child_ty = info.pointee_type;4056 const child_ty = info.pointee_type;
...@@ -4387,7 +4065,6 @@ pub const Type = struct {...@@ -4387,7 +4065,6 @@ pub const Type = struct {
4387 .optional_single_const_pointer => ty.castPointer().?.data,4065 .optional_single_const_pointer => ty.castPointer().?.data,
43884066
4389 .anyframe_T => ty.castTag(.anyframe_T).?.data,4067 .anyframe_T => ty.castTag(.anyframe_T).?.data,
4390 .@"anyframe" => Type.void,
43914068
4392 else => unreachable,4069 else => unreachable,
4393 };4070 };
...@@ -4468,19 +4145,6 @@ pub const Type = struct {...@@ -4468,19 +4145,6 @@ pub const Type = struct {
4468 return union_obj.tag_ty;4145 return union_obj.tag_ty;
4469 },4146 },
44704147
4471 .atomic_order,
4472 .atomic_rmw_op,
4473 .calling_convention,
4474 .address_space,
4475 .float_mode,
4476 .reduce_op,
4477 .modifier,
4478 .prefetch_options,
4479 .export_options,
4480 .extern_options,
4481 .type_info,
4482 => unreachable, // needed to call resolveTypeFields first
4483
4484 else => null,4148 else => null,
4485 };4149 };
4486 }4150 }
...@@ -4495,19 +4159,6 @@ pub const Type = struct {...@@ -4495,19 +4159,6 @@ pub const Type = struct {
4495 return union_obj.tag_ty;4159 return union_obj.tag_ty;
4496 },4160 },
44974161
4498 .atomic_order,
4499 .atomic_rmw_op,
4500 .calling_convention,
4501 .address_space,
4502 .float_mode,
4503 .reduce_op,
4504 .modifier,
4505 .prefetch_options,
4506 .export_options,
4507 .extern_options,
4508 .type_info,
4509 => unreachable, // needed to call resolveTypeFields first
4510
4511 else => null,4162 else => null,
4512 };4163 };
4513 }4164 }
...@@ -4572,7 +4223,7 @@ pub const Type = struct {...@@ -4572,7 +4223,7 @@ pub const Type = struct {
4572 /// Asserts that the type is an error union.4223 /// Asserts that the type is an error union.
4573 pub fn errorUnionPayload(self: Type) Type {4224 pub fn errorUnionPayload(self: Type) Type {
4574 return switch (self.tag()) {4225 return switch (self.tag()) {
4575 .anyerror_void_error_union => Type.initTag(.void),4226 .anyerror_void_error_union => Type.void,
4576 .error_union => self.castTag(.error_union).?.data.payload,4227 .error_union => self.castTag(.error_union).?.data.payload,
4577 else => unreachable,4228 else => unreachable,
4578 };4229 };
...@@ -4580,33 +4231,38 @@ pub const Type = struct {...@@ -4580,33 +4231,38 @@ pub const Type = struct {
45804231
4581 pub fn errorUnionSet(self: Type) Type {4232 pub fn errorUnionSet(self: Type) Type {
4582 return switch (self.tag()) {4233 return switch (self.tag()) {
4583 .anyerror_void_error_union => Type.initTag(.anyerror),4234 .anyerror_void_error_union => Type.anyerror,
4584 .error_union => self.castTag(.error_union).?.data.error_set,4235 .error_union => self.castTag(.error_union).?.data.error_set,
4585 else => unreachable,4236 else => unreachable,
4586 };4237 };
4587 }4238 }
45884239
4589 /// Returns false for unresolved inferred error sets.4240 /// Returns false for unresolved inferred error sets.
4590 pub fn errorSetIsEmpty(ty: Type) bool {4241 pub fn errorSetIsEmpty(ty: Type, mod: *const Module) bool {
4591 switch (ty.tag()) {4242 switch (ty.ip_index) {
4592 .anyerror => return false,4243 .none => switch (ty.tag()) {
4593 .error_set_inferred => {4244 .error_set_inferred => {
4594 const inferred_error_set = ty.castTag(.error_set_inferred).?.data;4245 const inferred_error_set = ty.castTag(.error_set_inferred).?.data;
4595 // Can't know for sure.4246 // Can't know for sure.
4596 if (!inferred_error_set.is_resolved) return false;4247 if (!inferred_error_set.is_resolved) return false;
4597 if (inferred_error_set.is_anyerror) return false;4248 if (inferred_error_set.is_anyerror) return false;
4598 return inferred_error_set.errors.count() == 0;4249 return inferred_error_set.errors.count() == 0;
4599 },4250 },
4600 .error_set_single => return false,4251 .error_set_single => return false,
4601 .error_set => {4252 .error_set => {
4602 const err_set_obj = ty.castTag(.error_set).?.data;4253 const err_set_obj = ty.castTag(.error_set).?.data;
4603 return err_set_obj.names.count() == 0;4254 return err_set_obj.names.count() == 0;
4255 },
4256 .error_set_merged => {
4257 const name_map = ty.castTag(.error_set_merged).?.data;
4258 return name_map.count() == 0;
4259 },
4260 else => unreachable,
4604 },4261 },
4605 .error_set_merged => {4262 .anyerror_type => return false,
4606 const name_map = ty.castTag(.error_set_merged).?.data;4263 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {
4607 return name_map.count() == 0;4264 else => @panic("TODO"),
4608 },4265 },
4609 else => unreachable,
4610 }4266 }
4611 }4267 }
46124268
...@@ -4614,9 +4270,13 @@ pub const Type = struct {...@@ -4614,9 +4270,13 @@ pub const Type = struct {
4614 /// Note that the result may be a false negative if the type did not get error set4270 /// Note that the result may be a false negative if the type did not get error set
4615 /// resolution prior to this call.4271 /// resolution prior to this call.
4616 pub fn isAnyError(ty: Type) bool {4272 pub fn isAnyError(ty: Type) bool {
4617 return switch (ty.tag()) {4273 return switch (ty.ip_index) {
4618 .anyerror => true,4274 .none => switch (ty.tag()) {
4619 .error_set_inferred => ty.castTag(.error_set_inferred).?.data.is_anyerror,4275 .error_set_inferred => ty.castTag(.error_set_inferred).?.data.is_anyerror,
4276 else => false,
4277 },
4278 .anyerror_type => true,
4279 // TODO handle error_set_inferred here
4620 else => false,4280 else => false,
4621 };4281 };
4622 }4282 }
...@@ -4788,72 +4448,75 @@ pub const Type = struct {...@@ -4788,72 +4448,75 @@ pub const Type = struct {
4788 const target = mod.getTarget();4448 const target = mod.getTarget();
4789 var ty = starting_ty;4449 var ty = starting_ty;
47904450
4791 if (ty.ip_index != .none) switch (mod.intern_pool.indexToKey(ty.ip_index)) {4451 while (true) switch (ty.ip_index) {
4792 .int_type => |int_type| return int_type,4452 .none => switch (ty.tag()) {
4793 .ptr_type => unreachable,4453 .u1 => return .{ .signedness = .unsigned, .bits = 1 },
4794 .array_type => unreachable,4454 .u8 => return .{ .signedness = .unsigned, .bits = 8 },
4795 .vector_type => @panic("TODO"),4455 .i8 => return .{ .signedness = .signed, .bits = 8 },
4796 .optional_type => unreachable,4456 .u16 => return .{ .signedness = .unsigned, .bits = 16 },
4797 .error_union_type => unreachable,4457 .i16 => return .{ .signedness = .signed, .bits = 16 },
4798 .simple_type => |t| switch (t) {4458 .u29 => return .{ .signedness = .unsigned, .bits = 29 },
4799 .usize => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() },4459 .u32 => return .{ .signedness = .unsigned, .bits = 32 },
4800 .isize => return .{ .signedness = .signed, .bits = target.ptrBitWidth() },4460 .i32 => return .{ .signedness = .signed, .bits = 32 },
4801 .c_char => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) },4461 .u64 => return .{ .signedness = .unsigned, .bits = 64 },
4802 .c_short => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) },4462 .i64 => return .{ .signedness = .signed, .bits = 64 },
4803 .c_ushort => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) },4463 .u128 => return .{ .signedness = .unsigned, .bits = 128 },
4804 .c_int => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) },4464 .i128 => return .{ .signedness = .signed, .bits = 128 },
4805 .c_uint => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.uint) },4465
4806 .c_long => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.long) },4466 .enum_full, .enum_nonexhaustive => ty = ty.cast(Payload.EnumFull).?.data.tag_ty,
4807 .c_ulong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulong) },4467 .enum_numbered => ty = ty.castTag(.enum_numbered).?.data.tag_ty,
4808 .c_longlong => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longlong) },4468 .enum_simple => {
4809 .c_ulonglong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) },4469 const enum_obj = ty.castTag(.enum_simple).?.data;
4810 else => unreachable,4470 const field_count = enum_obj.fields.count();
4811 },4471 if (field_count == 0) return .{ .signedness = .unsigned, .bits = 0 };
4812 .struct_type => @panic("TODO"),4472 return .{ .signedness = .unsigned, .bits = smallestUnsignedBits(field_count - 1) };
4813 .union_type => unreachable,4473 },
4814 .simple_value => unreachable,
4815 .extern_func => unreachable,
4816 .int => unreachable,
4817 .enum_tag => unreachable, // it's a value, not a type
4818 };
48194474
4820 while (true) switch (ty.tag()) {4475 .error_set, .error_set_single, .error_set_inferred, .error_set_merged => {
4821 .u1 => return .{ .signedness = .unsigned, .bits = 1 },4476 // TODO revisit this when error sets support custom int types
4822 .u8 => return .{ .signedness = .unsigned, .bits = 8 },4477 return .{ .signedness = .unsigned, .bits = 16 };
4823 .i8 => return .{ .signedness = .signed, .bits = 8 },4478 },
4824 .u16 => return .{ .signedness = .unsigned, .bits = 16 },4479
4825 .i16 => return .{ .signedness = .signed, .bits = 16 },4480 .vector => ty = ty.castTag(.vector).?.data.elem_type,
4826 .u29 => return .{ .signedness = .unsigned, .bits = 29 },4481
4827 .u32 => return .{ .signedness = .unsigned, .bits = 32 },4482 .@"struct" => {
4828 .i32 => return .{ .signedness = .signed, .bits = 32 },4483 const struct_obj = ty.castTag(.@"struct").?.data;
4829 .u64 => return .{ .signedness = .unsigned, .bits = 64 },4484 assert(struct_obj.layout == .Packed);
4830 .i64 => return .{ .signedness = .signed, .bits = 64 },4485 ty = struct_obj.backing_int_ty;
4831 .u128 => return .{ .signedness = .unsigned, .bits = 128 },4486 },
4832 .i128 => return .{ .signedness = .signed, .bits = 128 },
4833
4834 .enum_full, .enum_nonexhaustive => ty = ty.cast(Payload.EnumFull).?.data.tag_ty,
4835 .enum_numbered => ty = ty.castTag(.enum_numbered).?.data.tag_ty,
4836 .enum_simple => {
4837 const enum_obj = ty.castTag(.enum_simple).?.data;
4838 const field_count = enum_obj.fields.count();
4839 if (field_count == 0) return .{ .signedness = .unsigned, .bits = 0 };
4840 return .{ .signedness = .unsigned, .bits = smallestUnsignedBits(field_count - 1) };
4841 },
48424487
4843 .error_set, .error_set_single, .anyerror, .error_set_inferred, .error_set_merged => {4488 else => unreachable,
4489 },
4490 .anyerror_type => {
4844 // TODO revisit this when error sets support custom int types4491 // TODO revisit this when error sets support custom int types
4845 return .{ .signedness = .unsigned, .bits = 16 };4492 return .{ .signedness = .unsigned, .bits = 16 };
4846 },4493 },
48474494 .usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() },
4848 .vector => ty = ty.castTag(.vector).?.data.elem_type,4495 .isize_type => return .{ .signedness = .signed, .bits = target.ptrBitWidth() },
48494496 .c_char_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) },
4850 .@"struct" => {4497 .c_short_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) },
4851 const struct_obj = ty.castTag(.@"struct").?.data;4498 .c_ushort_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) },
4852 assert(struct_obj.layout == .Packed);4499 .c_int_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) },
4853 ty = struct_obj.backing_int_ty;4500 .c_uint_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.uint) },
4501 .c_long_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.long) },
4502 .c_ulong_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulong) },
4503 .c_longlong_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longlong) },
4504 .c_ulonglong_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) },
4505 else => switch (mod.intern_pool.indexToKey(ty.ip_index)) {
4506 .int_type => |int_type| return int_type,
4507 .ptr_type => unreachable,
4508 .array_type => unreachable,
4509 .vector_type => @panic("TODO"),
4510 .optional_type => unreachable,
4511 .error_union_type => unreachable,
4512 .simple_type => unreachable, // handled via Index enum tag above
4513 .struct_type => @panic("TODO"),
4514 .union_type => unreachable,
4515 .simple_value => unreachable,
4516 .extern_func => unreachable,
4517 .int => unreachable,
4518 .enum_tag => unreachable,
4854 },4519 },
4855
4856 else => unreachable,
4857 };4520 };
4858 }4521 }
48594522
...@@ -5021,7 +4684,6 @@ pub const Type = struct {...@@ -5021,7 +4684,6 @@ pub const Type = struct {
5021 else => false,4684 else => false,
5022 };4685 };
5023 return switch (ty.tag()) {4686 return switch (ty.tag()) {
5024 .comptime_int,
5025 .u1,4687 .u1,
5026 .u8,4688 .u8,
5027 .i8,4689 .i8,
...@@ -5114,7 +4776,6 @@ pub const Type = struct {...@@ -5114,7 +4776,6 @@ pub const Type = struct {
5114 };4776 };
51154777
5116 while (true) switch (ty.tag()) {4778 while (true) switch (ty.tag()) {
5117 .comptime_int,
5118 .u1,4779 .u1,
5119 .u8,4780 .u8,
5120 .i8,4781 .i8,
...@@ -5127,9 +4788,7 @@ pub const Type = struct {...@@ -5127,9 +4788,7 @@ pub const Type = struct {
5127 .i64,4788 .i64,
5128 .u128,4789 .u128,
5129 .i128,4790 .i128,
5130 .bool,4791
5131 .type,
5132 .anyerror,
5133 .error_union,4792 .error_union,
5134 .error_set_single,4793 .error_set_single,
5135 .error_set,4794 .error_set,
...@@ -5142,28 +4801,14 @@ pub const Type = struct {...@@ -5142,28 +4801,14 @@ pub const Type = struct {
5142 .const_slice_u8_sentinel_0,4801 .const_slice_u8_sentinel_0,
5143 .const_slice,4802 .const_slice,
5144 .mut_slice,4803 .mut_slice,
5145 .anyopaque,
5146 .optional_single_mut_pointer,4804 .optional_single_mut_pointer,
5147 .optional_single_const_pointer,4805 .optional_single_const_pointer,
5148 .enum_literal,
5149 .anyerror_void_error_union,4806 .anyerror_void_error_union,
5150 .error_set_inferred,4807 .error_set_inferred,
5151 .@"opaque",4808 .@"opaque",
5152 .manyptr_u8,4809 .manyptr_u8,
5153 .manyptr_const_u8,4810 .manyptr_const_u8,
5154 .manyptr_const_u8_sentinel_0,4811 .manyptr_const_u8_sentinel_0,
5155 .atomic_order,
5156 .atomic_rmw_op,
5157 .calling_convention,
5158 .address_space,
5159 .float_mode,
5160 .reduce_op,
5161 .modifier,
5162 .prefetch_options,
5163 .export_options,
5164 .extern_options,
5165 .type_info,
5166 .@"anyframe",
5167 .anyframe_T,4812 .anyframe_T,
5168 .many_const_pointer,4813 .many_const_pointer,
5169 .many_mut_pointer,4814 .many_mut_pointer,
...@@ -5258,10 +4903,6 @@ pub const Type = struct {...@@ -5258,10 +4903,6 @@ pub const Type = struct {
5258 },4903 },
52594904
5260 .empty_struct, .empty_struct_literal => return Value.initTag(.empty_struct_value),4905 .empty_struct, .empty_struct_literal => return Value.initTag(.empty_struct_value),
5261 .void => return Value.initTag(.void_value),
5262 .noreturn => return Value.initTag(.unreachable_value),
5263 .null => return Value.initTag(.null_value),
5264 .undefined => return Value.initTag(.undef),
52654906
5266 .vector, .array, .array_u8 => {4907 .vector, .array, .array_u8 => {
5267 if (ty.arrayLen() == 0)4908 if (ty.arrayLen() == 0)
...@@ -5273,7 +4914,6 @@ pub const Type = struct {...@@ -5273,7 +4914,6 @@ pub const Type = struct {
52734914
5274 .inferred_alloc_const => unreachable,4915 .inferred_alloc_const => unreachable,
5275 .inferred_alloc_mut => unreachable,4916 .inferred_alloc_mut => unreachable,
5276 .generic_poison => unreachable,
5277 };4917 };
5278 }4918 }
52794919
...@@ -5358,22 +4998,7 @@ pub const Type = struct {...@@ -5358,22 +4998,7 @@ pub const Type = struct {
5358 .i64,4998 .i64,
5359 .u128,4999 .u128,
5360 .i128,5000 .i128,
5361 .anyopaque,5001
5362 .bool,
5363 .void,
5364 .anyerror,
5365 .noreturn,
5366 .@"anyframe",
5367 .atomic_order,
5368 .atomic_rmw_op,
5369 .calling_convention,
5370 .address_space,
5371 .float_mode,
5372 .reduce_op,
5373 .modifier,
5374 .prefetch_options,
5375 .export_options,
5376 .extern_options,
5377 .manyptr_u8,5002 .manyptr_u8,
5378 .manyptr_const_u8,5003 .manyptr_const_u8,
5379 .manyptr_const_u8_sentinel_0,5004 .manyptr_const_u8_sentinel_0,
...@@ -5387,21 +5012,14 @@ pub const Type = struct {...@@ -5387,21 +5012,14 @@ pub const Type = struct {
5387 .error_set_inferred,5012 .error_set_inferred,
5388 .error_set_merged,5013 .error_set_merged,
5389 .@"opaque",5014 .@"opaque",
5390 .generic_poison,
5391 .array_u8,5015 .array_u8,
5392 .array_u8_sentinel_0,5016 .array_u8_sentinel_0,
5393 .enum_simple,5017 .enum_simple,
5394 => false,5018 => false,
53955019
5396 .single_const_pointer_to_comptime_int,5020 .single_const_pointer_to_comptime_int,
5397 .type,
5398 .comptime_int,
5399 .enum_literal,
5400 .type_info,
5401 // These are function bodies, not function pointers.5021 // These are function bodies, not function pointers.
5402 .function,5022 .function,
5403 .null,
5404 .undefined,
5405 => true,5023 => true,
54065024
5407 .inferred_alloc_mut => unreachable,5025 .inferred_alloc_mut => unreachable,
...@@ -5701,17 +5319,6 @@ pub const Type = struct {...@@ -5701,17 +5319,6 @@ pub const Type = struct {
5701 .enum_full, .enum_nonexhaustive => ty.cast(Payload.EnumFull).?.data.fields,5319 .enum_full, .enum_nonexhaustive => ty.cast(Payload.EnumFull).?.data.fields,
5702 .enum_simple => ty.castTag(.enum_simple).?.data.fields,5320 .enum_simple => ty.castTag(.enum_simple).?.data.fields,
5703 .enum_numbered => ty.castTag(.enum_numbered).?.data.fields,5321 .enum_numbered => ty.castTag(.enum_numbered).?.data.fields,
5704 .atomic_order,
5705 .atomic_rmw_op,
5706 .calling_convention,
5707 .address_space,
5708 .float_mode,
5709 .reduce_op,
5710 .modifier,
5711 .prefetch_options,
5712 .export_options,
5713 .extern_options,
5714 => @panic("TODO resolve std.builtin types"),
5715 else => unreachable,5322 else => unreachable,
5716 };5323 };
5717 }5324 }
...@@ -5779,17 +5386,6 @@ pub const Type = struct {...@@ -5779,17 +5386,6 @@ pub const Type = struct {
5779 const tag_ty = mod.intType(.unsigned, bits) catch @panic("TODO: handle OOM here");5386 const tag_ty = mod.intType(.unsigned, bits) catch @panic("TODO: handle OOM here");
5780 return S.fieldWithRange(tag_ty, enum_tag, fields_len, mod);5387 return S.fieldWithRange(tag_ty, enum_tag, fields_len, mod);
5781 },5388 },
5782 .atomic_order,
5783 .atomic_rmw_op,
5784 .calling_convention,
5785 .address_space,
5786 .float_mode,
5787 .reduce_op,
5788 .modifier,
5789 .prefetch_options,
5790 .export_options,
5791 .extern_options,
5792 => @panic("TODO resolve std.builtin types"),
5793 else => unreachable,5389 else => unreachable,
5794 }5390 }
5795 }5391 }
...@@ -6102,18 +5698,6 @@ pub const Type = struct {...@@ -6102,18 +5698,6 @@ pub const Type = struct {
6102 const opaque_obj = ty.cast(Payload.Opaque).?.data;5698 const opaque_obj = ty.cast(Payload.Opaque).?.data;
6103 return opaque_obj.srcLoc(mod);5699 return opaque_obj.srcLoc(mod);
6104 },5700 },
6105 .atomic_order,
6106 .atomic_rmw_op,
6107 .calling_convention,
6108 .address_space,
6109 .float_mode,
6110 .reduce_op,
6111 .modifier,
6112 .prefetch_options,
6113 .export_options,
6114 .extern_options,
6115 .type_info,
6116 => unreachable, // needed to call resolveTypeFields first
61175701
6118 else => return null,5702 else => return null,
6119 }5703 }
...@@ -6150,29 +5734,17 @@ pub const Type = struct {...@@ -6150,29 +5734,17 @@ pub const Type = struct {
6150 const opaque_obj = ty.cast(Payload.Opaque).?.data;5734 const opaque_obj = ty.cast(Payload.Opaque).?.data;
6151 return opaque_obj.owner_decl;5735 return opaque_obj.owner_decl;
6152 },5736 },
6153 .atomic_order,
6154 .atomic_rmw_op,
6155 .calling_convention,
6156 .address_space,
6157 .float_mode,
6158 .reduce_op,
6159 .modifier,
6160 .prefetch_options,
6161 .export_options,
6162 .extern_options,
6163 .type_info,
6164 => unreachable, // These need to be resolved earlier.
61655737
6166 else => return null,5738 else => return null,
6167 }5739 }
6168 }5740 }
61695741
6170 pub fn isGenericPoison(ty: Type) bool {5742 pub fn isGenericPoison(ty: Type) bool {
6171 return switch (ty.ip_index) {5743 return ty.ip_index == .generic_poison_type;
6172 .generic_poison_type => true,5744 }
6173 .none => ty.tag() == .generic_poison,5745
6174 else => false,5746 pub fn isVarArgsParam(ty: Type) bool {
6175 };5747 return ty.ip_index == .none and ty.tag() == .var_args_param;
6176 }5748 }
61775749
6178 /// This enum does not directly correspond to `std.builtin.TypeId` because5750 /// This enum does not directly correspond to `std.builtin.TypeId` because
...@@ -6195,28 +5767,7 @@ pub const Type = struct {...@@ -6195,28 +5767,7 @@ pub const Type = struct {
6195 i64,5767 i64,
6196 u128,5768 u128,
6197 i128,5769 i128,
6198 anyopaque,5770
6199 bool,
6200 void,
6201 type,
6202 anyerror,
6203 comptime_int,
6204 noreturn,
6205 @"anyframe",
6206 null,
6207 undefined,
6208 enum_literal,
6209 atomic_order,
6210 atomic_rmw_op,
6211 calling_convention,
6212 address_space,
6213 float_mode,
6214 reduce_op,
6215 modifier,
6216 prefetch_options,
6217 export_options,
6218 extern_options,
6219 type_info,
6220 manyptr_u8,5771 manyptr_u8,
6221 manyptr_const_u8,5772 manyptr_const_u8,
6222 manyptr_const_u8_sentinel_0,5773 manyptr_const_u8_sentinel_0,
...@@ -6224,7 +5775,6 @@ pub const Type = struct {...@@ -6224,7 +5775,6 @@ pub const Type = struct {
6224 const_slice_u8,5775 const_slice_u8,
6225 const_slice_u8_sentinel_0,5776 const_slice_u8_sentinel_0,
6226 anyerror_void_error_union,5777 anyerror_void_error_union,
6227 generic_poison,
6228 /// Same as `empty_struct` except it has an empty namespace.5778 /// Same as `empty_struct` except it has an empty namespace.
6229 empty_struct_literal,5779 empty_struct_literal,
6230 /// This is a special value that tracks a set of types that have been stored5780 /// This is a special value that tracks a set of types that have been stored
...@@ -6292,39 +5842,17 @@ pub const Type = struct {...@@ -6292,39 +5842,17 @@ pub const Type = struct {
6292 .i64,5842 .i64,
6293 .u128,5843 .u128,
6294 .i128,5844 .i128,
6295 .anyopaque,5845
6296 .bool,
6297 .void,
6298 .type,
6299 .anyerror,
6300 .comptime_int,
6301 .noreturn,
6302 .enum_literal,
6303 .null,
6304 .undefined,
6305 .single_const_pointer_to_comptime_int,5846 .single_const_pointer_to_comptime_int,
6306 .anyerror_void_error_union,5847 .anyerror_void_error_union,
6307 .const_slice_u8,5848 .const_slice_u8,
6308 .const_slice_u8_sentinel_0,5849 .const_slice_u8_sentinel_0,
6309 .generic_poison,
6310 .inferred_alloc_const,5850 .inferred_alloc_const,
6311 .inferred_alloc_mut,5851 .inferred_alloc_mut,
6312 .empty_struct_literal,5852 .empty_struct_literal,
6313 .manyptr_u8,5853 .manyptr_u8,
6314 .manyptr_const_u8,5854 .manyptr_const_u8,
6315 .manyptr_const_u8_sentinel_0,5855 .manyptr_const_u8_sentinel_0,
6316 .atomic_order,
6317 .atomic_rmw_op,
6318 .calling_convention,
6319 .address_space,
6320 .float_mode,
6321 .reduce_op,
6322 .modifier,
6323 .prefetch_options,
6324 .export_options,
6325 .extern_options,
6326 .type_info,
6327 .@"anyframe",
6328 => @compileError("Type Tag " ++ @tagName(t) ++ " has no payload"),5856 => @compileError("Type Tag " ++ @tagName(t) ++ " has no payload"),
63295857
6330 .array_u8,5858 .array_u8,
...@@ -6674,18 +6202,19 @@ pub const Type = struct {...@@ -6674,18 +6202,19 @@ pub const Type = struct {
6674 pub const @"f80": Type = .{ .ip_index = .f80_type, .legacy = undefined };6202 pub const @"f80": Type = .{ .ip_index = .f80_type, .legacy = undefined };
6675 pub const @"f128": Type = .{ .ip_index = .f128_type, .legacy = undefined };6203 pub const @"f128": Type = .{ .ip_index = .f128_type, .legacy = undefined };
66766204
6677 pub const @"bool" = initTag(.bool);6205 pub const @"bool": Type = .{ .ip_index = .bool_type, .legacy = undefined };
6678 pub const @"usize": Type = .{ .ip_index = .usize_type, .legacy = undefined };6206 pub const @"usize": Type = .{ .ip_index = .usize_type, .legacy = undefined };
6679 pub const @"isize": Type = .{ .ip_index = .isize_type, .legacy = undefined };6207 pub const @"isize": Type = .{ .ip_index = .isize_type, .legacy = undefined };
6680 pub const @"comptime_int": Type = .{ .ip_index = .comptime_int_type, .legacy = undefined };6208 pub const @"comptime_int": Type = .{ .ip_index = .comptime_int_type, .legacy = undefined };
6681 pub const @"comptime_float": Type = .{ .ip_index = .comptime_float_type, .legacy = undefined };6209 pub const @"comptime_float": Type = .{ .ip_index = .comptime_float_type, .legacy = undefined };
6682 pub const @"void" = initTag(.void);6210 pub const @"void": Type = .{ .ip_index = .void_type, .legacy = undefined };
6683 pub const @"type" = initTag(.type);6211 pub const @"type": Type = .{ .ip_index = .type_type, .legacy = undefined };
6684 pub const @"anyerror" = initTag(.anyerror);6212 pub const @"anyerror": Type = .{ .ip_index = .anyerror_type, .legacy = undefined };
6685 pub const @"anyopaque" = initTag(.anyopaque);6213 pub const @"anyopaque": Type = .{ .ip_index = .anyopaque_type, .legacy = undefined };
6686 pub const @"null" = initTag(.null);6214 pub const @"anyframe": Type = .{ .ip_index = .anyframe_type, .legacy = undefined };
6687 pub const @"undefined" = initTag(.undefined);6215 pub const @"null": Type = .{ .ip_index = .null_type, .legacy = undefined };
6688 pub const @"noreturn" = initTag(.noreturn);6216 pub const @"undefined": Type = .{ .ip_index = .undefined_type, .legacy = undefined };
6217 pub const @"noreturn": Type = .{ .ip_index = .noreturn_type, .legacy = undefined };
66896218
6690 pub const @"c_char": Type = .{ .ip_index = .c_char_type, .legacy = undefined };6219 pub const @"c_char": Type = .{ .ip_index = .c_char_type, .legacy = undefined };
6691 pub const @"c_short": Type = .{ .ip_index = .c_short_type, .legacy = undefined };6220 pub const @"c_short": Type = .{ .ip_index = .c_short_type, .legacy = undefined };
...@@ -6698,6 +6227,8 @@ pub const Type = struct {...@@ -6698,6 +6227,8 @@ pub const Type = struct {
6698 pub const @"c_ulonglong": Type = .{ .ip_index = .c_ulonglong_type, .legacy = undefined };6227 pub const @"c_ulonglong": Type = .{ .ip_index = .c_ulonglong_type, .legacy = undefined };
6699 pub const @"c_longdouble": Type = .{ .ip_index = .c_longdouble_type, .legacy = undefined };6228 pub const @"c_longdouble": Type = .{ .ip_index = .c_longdouble_type, .legacy = undefined };
67006229
6230 pub const generic_poison: Type = .{ .ip_index = .generic_poison_type, .legacy = undefined };
6231
6701 pub const err_int = Type.u16;6232 pub const err_int = Type.u16;
67026233
6703 pub fn ptr(arena: Allocator, mod: *Module, data: Payload.Pointer.Data) !Type {6234 pub fn ptr(arena: Allocator, mod: *Module, data: Payload.Pointer.Data) !Type {
src/value.zig+14-14
...@@ -991,26 +991,26 @@ pub const Value = struct {...@@ -991,26 +991,26 @@ pub const Value = struct {
991 .null_type => Type.null,991 .null_type => Type.null,
992 .undefined_type => Type.undefined,992 .undefined_type => Type.undefined,
993 .single_const_pointer_to_comptime_int_type => Type.initTag(.single_const_pointer_to_comptime_int),993 .single_const_pointer_to_comptime_int_type => Type.initTag(.single_const_pointer_to_comptime_int),
994 .anyframe_type => Type.initTag(.@"anyframe"),994 .anyframe_type => Type.@"anyframe",
995 .const_slice_u8_type => Type.initTag(.const_slice_u8),995 .const_slice_u8_type => Type.initTag(.const_slice_u8),
996 .const_slice_u8_sentinel_0_type => Type.initTag(.const_slice_u8_sentinel_0),996 .const_slice_u8_sentinel_0_type => Type.initTag(.const_slice_u8_sentinel_0),
997 .anyerror_void_error_union_type => Type.initTag(.anyerror_void_error_union),997 .anyerror_void_error_union_type => Type.initTag(.anyerror_void_error_union),
998 .generic_poison_type => Type.initTag(.generic_poison),998 .generic_poison_type => .{ .ip_index = .generic_poison_type, .legacy = undefined },
999 .enum_literal_type => Type.initTag(.enum_literal),999 .enum_literal_type => .{ .ip_index = .enum_literal_type, .legacy = undefined },
1000 .manyptr_u8_type => Type.initTag(.manyptr_u8),1000 .manyptr_u8_type => Type.initTag(.manyptr_u8),
1001 .manyptr_const_u8_type => Type.initTag(.manyptr_const_u8),1001 .manyptr_const_u8_type => Type.initTag(.manyptr_const_u8),
1002 .manyptr_const_u8_sentinel_0_type => Type.initTag(.manyptr_const_u8_sentinel_0),1002 .manyptr_const_u8_sentinel_0_type => Type.initTag(.manyptr_const_u8_sentinel_0),
1003 .atomic_order_type => Type.initTag(.atomic_order),1003 .atomic_order_type => .{ .ip_index = .atomic_order_type, .legacy = undefined },
1004 .atomic_rmw_op_type => Type.initTag(.atomic_rmw_op),1004 .atomic_rmw_op_type => .{ .ip_index = .atomic_rmw_op_type, .legacy = undefined },
1005 .calling_convention_type => Type.initTag(.calling_convention),1005 .calling_convention_type => .{ .ip_index = .calling_convention_type, .legacy = undefined },
1006 .address_space_type => Type.initTag(.address_space),1006 .address_space_type => .{ .ip_index = .address_space_type, .legacy = undefined },
1007 .float_mode_type => Type.initTag(.float_mode),1007 .float_mode_type => .{ .ip_index = .float_mode_type, .legacy = undefined },
1008 .reduce_op_type => Type.initTag(.reduce_op),1008 .reduce_op_type => .{ .ip_index = .reduce_op_type, .legacy = undefined },
1009 .modifier_type => Type.initTag(.modifier),1009 .modifier_type => .{ .ip_index = .call_modifier_type, .legacy = undefined },
1010 .prefetch_options_type => Type.initTag(.prefetch_options),1010 .prefetch_options_type => .{ .ip_index = .prefetch_options_type, .legacy = undefined },
1011 .export_options_type => Type.initTag(.export_options),1011 .export_options_type => .{ .ip_index = .export_options_type, .legacy = undefined },
1012 .extern_options_type => Type.initTag(.extern_options),1012 .extern_options_type => .{ .ip_index = .extern_options_type, .legacy = undefined },
1013 .type_info_type => Type.initTag(.type_info),1013 .type_info_type => .{ .ip_index = .type_info_type, .legacy = undefined },
10141014
1015 else => unreachable,1015 else => unreachable,
1016 };1016 };