| author | |
| committer | |
| log | 836d8a1f64cb811641e621799429c54f222717eb |
| tree | bbcdd77b43cf4fa0bdd97abcfbe2457b57d9ae46 |
| parent | bcd4bb8afbea84d86fd8758b581b141e7086b16b |
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 | 1333 | .ret_load, |
| 1334 | 1334 | .unreach, |
| 1335 | 1335 | .trap, |
| 1336 | => return Type.initTag(.noreturn), | |
| 1336 | => return Type.noreturn, | |
| 1337 | 1337 | |
| 1338 | 1338 | .breakpoint, |
| 1339 | 1339 | .dbg_stmt, |
| ... | ... | @@ -1370,7 +1370,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: InternPool) Type { |
| 1370 | 1370 | .wasm_memory_grow => return Type.i32, |
| 1371 | 1371 | .wasm_memory_size => return Type.u32, |
| 1372 | 1372 | |
| 1373 | .bool_to_int => return Type.initTag(.u1), | |
| 1373 | .bool_to_int => return Type.u1, | |
| 1374 | 1374 | |
| 1375 | 1375 | .tag_name, .error_name => return Type.initTag(.const_slice_u8_sentinel_0), |
| 1376 | 1376 |
src/Module.zig+27-24| ... | ... | @@ -1005,7 +1005,7 @@ pub const Struct = struct { |
| 1005 | 1005 | /// If the layout is packed, this is the backing integer type of the packed struct. |
| 1006 | 1006 | /// Whether zig chooses this type or the user specifies it, it is stored here. |
| 1007 | 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 | 1009 | status: enum { |
| 1010 | 1010 | none, |
| 1011 | 1011 | field_types_wip, |
| ... | ... | @@ -1705,31 +1705,34 @@ pub const Fn = struct { |
| 1705 | 1705 | is_resolved: bool = false, |
| 1706 | 1706 | |
| 1707 | 1707 | pub fn addErrorSet(self: *InferredErrorSet, gpa: Allocator, err_set_ty: Type) !void { |
| 1708 | switch (err_set_ty.tag()) { | |
| 1709 | .error_set => { | |
| 1710 | const names = err_set_ty.castTag(.error_set).?.data.names.keys(); | |
| 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, {}); | |
| 1708 | switch (err_set_ty.ip_index) { | |
| 1709 | .anyerror_type => { | |
| 1710 | self.is_anyerror = true; | |
| 1722 | 1711 | }, |
| 1723 | .error_set_merged => { | |
| 1724 | const names = err_set_ty.castTag(.error_set_merged).?.data.keys(); | |
| 1725 | for (names) |name| { | |
| 1712 | .none => switch (err_set_ty.tag()) { | |
| 1713 | .error_set => { | |
| 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 | 1721 | try self.errors.put(gpa, name, {}); |
| 1727 | } | |
| 1728 | }, | |
| 1729 | .anyerror => { | |
| 1730 | self.is_anyerror = true; | |
| 1722 | }, | |
| 1723 | .error_set_inferred => { | |
| 1724 | const ies = err_set_ty.castTag(.error_set_inferred).?.data; | |
| 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 | 4569 | const struct_obj = try new_decl_arena_allocator.create(Module.Struct); |
| 4567 | 4570 | const struct_ty = try Type.Tag.@"struct".create(new_decl_arena_allocator, struct_obj); |
| 4568 | 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 | 4573 | struct_obj.* = .{ |
| 4571 | 4574 | .owner_decl = undefined, // set below |
| 4572 | 4575 | .fields = .{}, |
src/Sema.zig+209-294| ... | ... | @@ -1776,7 +1776,7 @@ fn analyzeAsType( |
| 1776 | 1776 | src: LazySrcLoc, |
| 1777 | 1777 | air_inst: Air.Inst.Ref, |
| 1778 | 1778 | ) !Type { |
| 1779 | const wanted_type = Type.initTag(.type); | |
| 1779 | const wanted_type = Type.type; | |
| 1780 | 1780 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 1781 | 1781 | const val = try sema.resolveConstValue(block, src, coerced_inst, "types must be comptime-known"); |
| 1782 | 1782 | const ty = val.toType(); |
| ... | ... | @@ -3132,7 +3132,7 @@ fn zirUnionDecl( |
| 3132 | 3132 | errdefer mod.abortAnonDecl(new_decl_index); |
| 3133 | 3133 | union_obj.* = .{ |
| 3134 | 3134 | .owner_decl = new_decl_index, |
| 3135 | .tag_ty = Type.initTag(.null), | |
| 3135 | .tag_ty = Type.null, | |
| 3136 | 3136 | .fields = .{}, |
| 3137 | 3137 | .zir_index = inst, |
| 3138 | 3138 | .layout = small.layout, |
| ... | ... | @@ -6362,7 +6362,7 @@ fn zirCall( |
| 6362 | 6362 | if (arg_index >= fn_params_len) |
| 6363 | 6363 | break :inst Air.Inst.Ref.var_args_param_type; |
| 6364 | 6364 | |
| 6365 | if (func_ty_info.param_types[arg_index].tag() == .generic_poison) | |
| 6365 | if (func_ty_info.param_types[arg_index].isGenericPoison()) | |
| 6366 | 6366 | break :inst Air.Inst.Ref.generic_poison_type; |
| 6367 | 6367 | |
| 6368 | 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 | 8175 | return sema.fail(block, rhs_src, "expected error set type, found '{}'", .{rhs_ty.fmt(sema.mod)}); |
| 8176 | 8176 | |
| 8177 | 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 | 8179 | return Air.Inst.Ref.anyerror_type; |
| 8180 | 8180 | } |
| 8181 | 8181 | |
| ... | ... | @@ -8206,7 +8206,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8206 | 8206 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 8207 | 8207 | const duped_name = try sema.arena.dupe(u8, inst_data.get(sema.code)); |
| 8208 | 8208 | return sema.addConstant( |
| 8209 | Type.initTag(.enum_literal), | |
| 8209 | .{ .ip_index = .enum_literal_type, .legacy = undefined }, | |
| 8210 | 8210 | try Value.Tag.enum_literal.create(sema.arena, duped_name), |
| 8211 | 8211 | ); |
| 8212 | 8212 | } |
| ... | ... | @@ -8503,6 +8503,7 @@ fn analyzeErrUnionPayload( |
| 8503 | 8503 | operand_src: LazySrcLoc, |
| 8504 | 8504 | safety_check: bool, |
| 8505 | 8505 | ) CompileError!Air.Inst.Ref { |
| 8506 | const mod = sema.mod; | |
| 8506 | 8507 | const payload_ty = err_union_ty.errorUnionPayload(); |
| 8507 | 8508 | if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| { |
| 8508 | 8509 | if (val.getError()) |name| { |
| ... | ... | @@ -8516,7 +8517,7 @@ fn analyzeErrUnionPayload( |
| 8516 | 8517 | |
| 8517 | 8518 | // If the error set has no fields then no safety check is needed. |
| 8518 | 8519 | if (safety_check and block.wantSafety() and |
| 8519 | !err_union_ty.errorUnionSet().errorSetIsEmpty()) | |
| 8520 | !err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) | |
| 8520 | 8521 | { |
| 8521 | 8522 | try sema.panicUnwrapError(block, operand, .unwrap_errunion_err, .is_non_err); |
| 8522 | 8523 | } |
| ... | ... | @@ -8602,7 +8603,7 @@ fn analyzeErrUnionPayloadPtr( |
| 8602 | 8603 | |
| 8603 | 8604 | // If the error set has no fields then no safety check is needed. |
| 8604 | 8605 | if (safety_check and block.wantSafety() and |
| 8605 | !err_union_ty.errorUnionSet().errorSetIsEmpty()) | |
| 8606 | !err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) | |
| 8606 | 8607 | { |
| 8607 | 8608 | try sema.panicUnwrapError(block, operand, .unwrap_errunion_err_ptr, .is_non_err_ptr); |
| 8608 | 8609 | } |
| ... | ... | @@ -8701,7 +8702,7 @@ fn zirFunc( |
| 8701 | 8702 | break :blk ret_ty; |
| 8702 | 8703 | } else |err| switch (err) { |
| 8703 | 8704 | error.GenericPoison => { |
| 8704 | break :blk Type.initTag(.generic_poison); | |
| 8705 | break :blk Type.generic_poison; | |
| 8705 | 8706 | }, |
| 8706 | 8707 | else => |e| return e, |
| 8707 | 8708 | } |
| ... | ... | @@ -8778,7 +8779,7 @@ fn resolveGenericBody( |
| 8778 | 8779 | }; |
| 8779 | 8780 | switch (err) { |
| 8780 | 8781 | error.GenericPoison => { |
| 8781 | if (dest_ty.tag() == .type) { | |
| 8782 | if (dest_ty.ip_index == .type_type) { | |
| 8782 | 8783 | return Value.initTag(.generic_poison_type); |
| 8783 | 8784 | } else { |
| 8784 | 8785 | return Value.initTag(.generic_poison); |
| ... | ... | @@ -9319,7 +9320,7 @@ fn zirParam( |
| 9319 | 9320 | // We result the param instruction with a poison value and |
| 9320 | 9321 | // insert an anytype parameter. |
| 9321 | 9322 | try block.params.append(sema.gpa, .{ |
| 9322 | .ty = Type.initTag(.generic_poison), | |
| 9323 | .ty = Type.generic_poison, | |
| 9323 | 9324 | .is_comptime = comptime_syntax, |
| 9324 | 9325 | .name = param_name, |
| 9325 | 9326 | }); |
| ... | ... | @@ -9340,7 +9341,7 @@ fn zirParam( |
| 9340 | 9341 | // We result the param instruction with a poison value and |
| 9341 | 9342 | // insert an anytype parameter. |
| 9342 | 9343 | try block.params.append(sema.gpa, .{ |
| 9343 | .ty = Type.initTag(.generic_poison), | |
| 9344 | .ty = Type.generic_poison, | |
| 9344 | 9345 | .is_comptime = comptime_syntax, |
| 9345 | 9346 | .name = param_name, |
| 9346 | 9347 | }); |
| ... | ... | @@ -9438,7 +9439,7 @@ fn zirParamAnytype( |
| 9438 | 9439 | // We are evaluating a generic function without any comptime args provided. |
| 9439 | 9440 | |
| 9440 | 9441 | try block.params.append(sema.gpa, .{ |
| 9441 | .ty = Type.initTag(.generic_poison), | |
| 9442 | .ty = Type.generic_poison, | |
| 9442 | 9443 | .is_comptime = comptime_syntax, |
| 9443 | 9444 | .name = param_name, |
| 9444 | 9445 | }); |
| ... | ... | @@ -18877,7 +18878,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 18877 | 18878 | }, |
| 18878 | 18879 | .ErrorSet => { |
| 18879 | 18880 | const payload_val = union_val.val.optionalValue(mod) orelse |
| 18880 | return sema.addType(Type.initTag(.anyerror)); | |
| 18881 | return sema.addType(Type.anyerror); | |
| 18881 | 18882 | const slice_val = payload_val.castTag(.slice).?.data; |
| 18882 | 18883 | |
| 18883 | 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 | 19151 | errdefer mod.abortAnonDecl(new_decl_index); |
| 19151 | 19152 | union_obj.* = .{ |
| 19152 | 19153 | .owner_decl = new_decl_index, |
| 19153 | .tag_ty = Type.initTag(.null), | |
| 19154 | .tag_ty = Type.null, | |
| 19154 | 19155 | .fields = .{}, |
| 19155 | 19156 | .zir_index = inst, |
| 19156 | 19157 | .layout = layout, |
| ... | ... | @@ -22697,7 +22698,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 22697 | 22698 | extra_index += 1; |
| 22698 | 22699 | const ret_ty_tv = sema.resolveInstConst(block, ret_src, ret_ty_ref, "return type must be comptime-known") catch |err| switch (err) { |
| 22699 | 22700 | error.GenericPoison => { |
| 22700 | break :blk Type.initTag(.generic_poison); | |
| 22701 | break :blk Type.generic_poison; | |
| 22701 | 22702 | }, |
| 22702 | 22703 | else => |e| return e, |
| 22703 | 22704 | }; |
| ... | ... | @@ -23022,7 +23023,7 @@ fn zirBuiltinExtern( |
| 23022 | 23023 | new_decl.src_line = sema.owner_decl.src_line; |
| 23023 | 23024 | // We only access this decl through the decl_ref with the correct type created |
| 23024 | 23025 | // below, so this type doesn't matter |
| 23025 | new_decl.ty = Type.Tag.init(.anyopaque); | |
| 23026 | new_decl.ty = Type.anyopaque; | |
| 23026 | 23027 | new_decl.val = try Value.Tag.variable.create(new_decl_arena_allocator, new_var); |
| 23027 | 23028 | new_decl.@"align" = 0; |
| 23028 | 23029 | new_decl.@"linksection" = null; |
| ... | ... | @@ -24380,9 +24381,8 @@ fn fieldCallBind( |
| 24380 | 24381 | decl_type.fnParamLen() >= 1) |
| 24381 | 24382 | { |
| 24382 | 24383 | const first_param_type = decl_type.fnParamType(0); |
| 24383 | const first_param_tag = first_param_type.tag(); | |
| 24384 | 24384 | // zig fmt: off |
| 24385 | if (first_param_tag == .generic_poison or ( | |
| 24385 | if (first_param_type.isGenericPoison() or ( | |
| 24386 | 24386 | first_param_type.zigTypeTag(mod) == .Pointer and |
| 24387 | 24387 | (first_param_type.ptrSize() == .One or |
| 24388 | 24388 | first_param_type.ptrSize() == .C) and |
| ... | ... | @@ -25535,10 +25535,7 @@ fn coerceExtra( |
| 25535 | 25535 | inst_src: LazySrcLoc, |
| 25536 | 25536 | opts: CoerceOpts, |
| 25537 | 25537 | ) CoersionError!Air.Inst.Ref { |
| 25538 | switch (dest_ty_unresolved.tag()) { | |
| 25539 | .generic_poison => return inst, | |
| 25540 | else => {}, | |
| 25541 | } | |
| 25538 | if (dest_ty_unresolved.isGenericPoison()) return inst; | |
| 25542 | 25539 | const dest_ty_src = inst_src; // TODO better source location |
| 25543 | 25540 | const dest_ty = try sema.resolveTypeFields(dest_ty_unresolved); |
| 25544 | 25541 | const inst_ty = try sema.resolveTypeFields(sema.typeOf(inst)); |
| ... | ... | @@ -25577,7 +25574,8 @@ fn coerceExtra( |
| 25577 | 25574 | |
| 25578 | 25575 | // cast from ?*T and ?[*]T to ?*anyopaque |
| 25579 | 25576 | // 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 and | |
| 25577 | if (dest_ty.isPtrLikeOptional(mod) and | |
| 25578 | dest_ty.elemType2(mod).ip_index == .anyopaque_type and | |
| 25581 | 25579 | inst_ty.isPtrAtRuntime(mod)) |
| 25582 | 25580 | anyopaque_check: { |
| 25583 | 25581 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :optional; |
| ... | ... | @@ -25715,7 +25713,7 @@ fn coerceExtra( |
| 25715 | 25713 | |
| 25716 | 25714 | // cast from *T and [*]T to *anyopaque |
| 25717 | 25715 | // 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 | 25717 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; |
| 25720 | 25718 | const elem_ty = inst_ty.elemType2(mod); |
| 25721 | 25719 | if (elem_ty.zigTypeTag(mod) == .Pointer or elem_ty.isPtrLikeOptional(mod)) { |
| ... | ... | @@ -26759,6 +26757,8 @@ fn coerceInMemoryAllowedErrorSets( |
| 26759 | 26757 | dest_src: LazySrcLoc, |
| 26760 | 26758 | src_src: LazySrcLoc, |
| 26761 | 26759 | ) !InMemoryCoercionResult { |
| 26760 | const mod = sema.mod; | |
| 26761 | ||
| 26762 | 26762 | // Coercion to `anyerror`. Note that this check can return false negatives |
| 26763 | 26763 | // in case the error sets did not get resolved. |
| 26764 | 26764 | if (dest_ty.isAnyError()) { |
| ... | ... | @@ -26769,36 +26769,41 @@ fn coerceInMemoryAllowedErrorSets( |
| 26769 | 26769 | const dst_ies = dst_payload.data; |
| 26770 | 26770 | // We will make an effort to return `ok` without resolving either error set, to |
| 26771 | 26771 | // avoid unnecessary "unable to resolve error set" dependency loop errors. |
| 26772 | switch (src_ty.tag()) { | |
| 26773 | .error_set_inferred => { | |
| 26774 | // If both are inferred error sets of functions, and | |
| 26775 | // the dest includes the source function, the coercion is OK. | |
| 26776 | // This check is important because it works without forcing a full resolution | |
| 26777 | // of inferred error sets. | |
| 26778 | const src_ies = src_ty.castTag(.error_set_inferred).?.data; | |
| 26779 | ||
| 26780 | if (dst_ies.inferred_error_sets.contains(src_ies)) { | |
| 26781 | return .ok; | |
| 26782 | } | |
| 26783 | }, | |
| 26784 | .error_set_single => { | |
| 26785 | const name = src_ty.castTag(.error_set_single).?.data; | |
| 26786 | if (dst_ies.errors.contains(name)) return .ok; | |
| 26787 | }, | |
| 26788 | .error_set_merged => { | |
| 26789 | const names = src_ty.castTag(.error_set_merged).?.data.keys(); | |
| 26790 | for (names) |name| { | |
| 26791 | if (!dst_ies.errors.contains(name)) break; | |
| 26792 | } else return .ok; | |
| 26772 | switch (src_ty.ip_index) { | |
| 26773 | .none => switch (src_ty.tag()) { | |
| 26774 | .error_set_inferred => { | |
| 26775 | // If both are inferred error sets of functions, and | |
| 26776 | // the dest includes the source function, the coercion is OK. | |
| 26777 | // This check is important because it works without forcing a full resolution | |
| 26778 | // of inferred error sets. | |
| 26779 | const src_ies = src_ty.castTag(.error_set_inferred).?.data; | |
| 26780 | ||
| 26781 | if (dst_ies.inferred_error_sets.contains(src_ies)) { | |
| 26782 | return .ok; | |
| 26783 | } | |
| 26784 | }, | |
| 26785 | .error_set_single => { | |
| 26786 | const name = src_ty.castTag(.error_set_single).?.data; | |
| 26787 | if (dst_ies.errors.contains(name)) return .ok; | |
| 26788 | }, | |
| 26789 | .error_set_merged => { | |
| 26790 | const names = src_ty.castTag(.error_set_merged).?.data.keys(); | |
| 26791 | for (names) |name| { | |
| 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 => { | |
| 26795 | const names = src_ty.castTag(.error_set).?.data.names.keys(); | |
| 26796 | for (names) |name| { | |
| 26797 | if (!dst_ies.errors.contains(name)) break; | |
| 26798 | } else return .ok; | |
| 26803 | .anyerror_type => {}, | |
| 26804 | else => switch (mod.intern_pool.indexToKey(src_ty.ip_index)) { | |
| 26805 | else => @panic("TODO"), | |
| 26799 | 26806 | }, |
| 26800 | .anyerror => {}, | |
| 26801 | else => unreachable, | |
| 26802 | 26807 | } |
| 26803 | 26808 | |
| 26804 | 26809 | if (dst_ies.func == sema.owner_func) { |
| ... | ... | @@ -26818,79 +26823,87 @@ fn coerceInMemoryAllowedErrorSets( |
| 26818 | 26823 | var missing_error_buf = std.ArrayList([]const u8).init(sema.gpa); |
| 26819 | 26824 | defer missing_error_buf.deinit(); |
| 26820 | 26825 | |
| 26821 | switch (src_ty.tag()) { | |
| 26822 | .error_set_inferred => { | |
| 26823 | const src_data = src_ty.castTag(.error_set_inferred).?.data; | |
| 26826 | switch (src_ty.ip_index) { | |
| 26827 | .none => switch (src_ty.tag()) { | |
| 26828 | .error_set_inferred => { | |
| 26829 | const src_data = src_ty.castTag(.error_set_inferred).?.data; | |
| 26824 | 26830 | |
| 26825 | try sema.resolveInferredErrorSet(block, src_src, src_data); | |
| 26826 | // src anyerror status might have changed after the resolution. | |
| 26827 | if (src_ty.isAnyError()) { | |
| 26828 | // dest_ty.isAnyError() == true is already checked for at this point. | |
| 26829 | return .from_anyerror; | |
| 26830 | } | |
| 26831 | try sema.resolveInferredErrorSet(block, src_src, src_data); | |
| 26832 | // src anyerror status might have changed after the resolution. | |
| 26833 | if (src_ty.isAnyError()) { | |
| 26834 | // dest_ty.isAnyError() == true is already checked for at this point. | |
| 26835 | return .from_anyerror; | |
| 26836 | } | |
| 26831 | 26837 | |
| 26832 | for (src_data.errors.keys()) |key| { | |
| 26833 | if (!dest_ty.errorSetHasField(key)) { | |
| 26834 | try missing_error_buf.append(key); | |
| 26838 | for (src_data.errors.keys()) |key| { | |
| 26839 | if (!dest_ty.errorSetHasField(key)) { | |
| 26840 | try missing_error_buf.append(key); | |
| 26841 | } | |
| 26835 | 26842 | } |
| 26836 | } | |
| 26837 | 26843 | |
| 26838 | if (missing_error_buf.items.len != 0) { | |
| 26839 | return InMemoryCoercionResult{ | |
| 26840 | .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items), | |
| 26841 | }; | |
| 26842 | } | |
| 26844 | if (missing_error_buf.items.len != 0) { | |
| 26845 | return InMemoryCoercionResult{ | |
| 26846 | .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items), | |
| 26847 | }; | |
| 26848 | } | |
| 26843 | 26849 | |
| 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 | 26850 | return .ok; |
| 26850 | } | |
| 26851 | const list = try sema.arena.alloc([]const u8, 1); | |
| 26852 | list[0] = name; | |
| 26853 | return InMemoryCoercionResult{ .missing_error = list }; | |
| 26854 | }, | |
| 26855 | .error_set_merged => { | |
| 26856 | const names = src_ty.castTag(.error_set_merged).?.data.keys(); | |
| 26857 | for (names) |name| { | |
| 26858 | if (!dest_ty.errorSetHasField(name)) { | |
| 26859 | try missing_error_buf.append(name); | |
| 26851 | }, | |
| 26852 | .error_set_single => { | |
| 26853 | const name = src_ty.castTag(.error_set_single).?.data; | |
| 26854 | if (dest_ty.errorSetHasField(name)) { | |
| 26855 | return .ok; | |
| 26856 | } | |
| 26857 | const list = try sema.arena.alloc([]const u8, 1); | |
| 26858 | list[0] = name; | |
| 26859 | return InMemoryCoercionResult{ .missing_error = list }; | |
| 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 | } | |
| 26862 | 26868 | |
| 26863 | if (missing_error_buf.items.len != 0) { | |
| 26864 | return InMemoryCoercionResult{ | |
| 26865 | .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items), | |
| 26866 | }; | |
| 26867 | } | |
| 26869 | if (missing_error_buf.items.len != 0) { | |
| 26870 | return InMemoryCoercionResult{ | |
| 26871 | .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items), | |
| 26872 | }; | |
| 26873 | } | |
| 26868 | 26874 | |
| 26869 | return .ok; | |
| 26870 | }, | |
| 26871 | .error_set => { | |
| 26872 | const names = src_ty.castTag(.error_set).?.data.names.keys(); | |
| 26873 | for (names) |name| { | |
| 26874 | if (!dest_ty.errorSetHasField(name)) { | |
| 26875 | try missing_error_buf.append(name); | |
| 26875 | return .ok; | |
| 26876 | }, | |
| 26877 | .error_set => { | |
| 26878 | const names = src_ty.castTag(.error_set).?.data.names.keys(); | |
| 26879 | for (names) |name| { | |
| 26880 | if (!dest_ty.errorSetHasField(name)) { | |
| 26881 | try missing_error_buf.append(name); | |
| 26882 | } | |
| 26876 | 26883 | } |
| 26877 | } | |
| 26878 | 26884 | |
| 26879 | if (missing_error_buf.items.len != 0) { | |
| 26880 | return InMemoryCoercionResult{ | |
| 26881 | .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items), | |
| 26882 | }; | |
| 26883 | } | |
| 26885 | if (missing_error_buf.items.len != 0) { | |
| 26886 | return InMemoryCoercionResult{ | |
| 26887 | .missing_error = try sema.arena.dupe([]const u8, missing_error_buf.items), | |
| 26888 | }; | |
| 26889 | } | |
| 26884 | 26890 | |
| 26885 | return .ok; | |
| 26886 | }, | |
| 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 | return .ok; | |
| 26892 | }, | |
| 26891 | 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 | } |
| 26895 | 26908 | |
| 26896 | 26909 | unreachable; |
| ... | ... | @@ -29355,42 +29368,49 @@ fn analyzeIsNonErrComptimeOnly( |
| 29355 | 29368 | // exception if the error union error set is known to be empty, |
| 29356 | 29369 | // we allow the comparison but always make it comptime-known. |
| 29357 | 29370 | const set_ty = operand_ty.errorUnionSet(); |
| 29358 | switch (set_ty.tag()) { | |
| 29359 | .anyerror => {}, | |
| 29360 | .error_set_inferred => blk: { | |
| 29361 | // 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 set | |
| 29363 | // in case it is already non-empty. | |
| 29364 | 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; | |
| 29371 | switch (set_ty.ip_index) { | |
| 29372 | .none => switch (set_ty.tag()) { | |
| 29373 | .error_set_inferred => blk: { | |
| 29374 | // If the error set is empty, we must return a comptime true or false. | |
| 29375 | // However we want to avoid unnecessarily resolving an inferred error set | |
| 29376 | // in case it is already non-empty. | |
| 29377 | const ies = set_ty.castTag(.error_set_inferred).?.data; | |
| 29370 | 29378 | if (ies.is_anyerror) break :blk; |
| 29371 | for (ies.inferred_error_sets.keys()) |other_ies| { | |
| 29372 | if (ies == other_ies) continue; | |
| 29373 | try sema.resolveInferredErrorSet(block, src, other_ies); | |
| 29374 | if (other_ies.is_anyerror) { | |
| 29375 | ies.is_anyerror = true; | |
| 29376 | ies.is_resolved = true; | |
| 29377 | break :blk; | |
| 29378 | } | |
| 29379 | if (ies.errors.count() != 0) break :blk; | |
| 29380 | if (maybe_operand_val == null) { | |
| 29381 | // Try to avoid resolving inferred error set if possible. | |
| 29382 | if (ies.errors.count() != 0) break :blk; | |
| 29383 | if (ies.is_anyerror) break :blk; | |
| 29384 | for (ies.inferred_error_sets.keys()) |other_ies| { | |
| 29385 | if (ies == other_ies) continue; | |
| 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 | } | |
| 29379 | 29392 | |
| 29380 | if (other_ies.errors.count() != 0) break :blk; | |
| 29381 | } | |
| 29382 | if (ies.func == sema.owner_func) { | |
| 29383 | // 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 value | |
| 29385 | // so far with this type can't contain errors either. | |
| 29386 | return Air.Inst.Ref.bool_true; | |
| 29393 | if (other_ies.errors.count() != 0) break :blk; | |
| 29394 | } | |
| 29395 | if (ies.func == sema.owner_func) { | |
| 29396 | // We're checking the inferred errorset of the current function and none of | |
| 29397 | // its child inferred error sets contained any errors meaning that any value | |
| 29398 | // so far with this type can't contain errors either. | |
| 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); | |
| 29389 | if (ies.is_anyerror) break :blk; | |
| 29390 | if (ies.errors.count() == 0) return Air.Inst.Ref.bool_true; | |
| 29391 | } | |
| 29405 | }, | |
| 29406 | else => if (set_ty.errorSetNames().len == 0) return Air.Inst.Ref.bool_true, | |
| 29407 | }, | |
| 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 | } |
| 29395 | 29415 | |
| 29396 | 29416 | if (maybe_operand_val) |err_union| { |
| ... | ... | @@ -30308,43 +30328,48 @@ fn wrapErrorUnionSet( |
| 30308 | 30328 | const inst_ty = sema.typeOf(inst); |
| 30309 | 30329 | const dest_err_set_ty = dest_ty.errorUnionSet(); |
| 30310 | 30330 | if (try sema.resolveMaybeUndefVal(inst)) |val| { |
| 30311 | switch (dest_err_set_ty.tag()) { | |
| 30312 | .anyerror => {}, | |
| 30313 | .error_set_single => ok: { | |
| 30314 | const expected_name = val.castTag(.@"error").?.data.name; | |
| 30315 | const n = dest_err_set_ty.castTag(.error_set_single).?.data; | |
| 30316 | if (mem.eql(u8, expected_name, n)) break :ok; | |
| 30317 | return sema.failWithErrorSetCodeMissing(block, inst_src, dest_err_set_ty, inst_ty); | |
| 30318 | }, | |
| 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)) { | |
| 30331 | switch (dest_err_set_ty.ip_index) { | |
| 30332 | .anyerror_type => {}, | |
| 30333 | ||
| 30334 | .none => switch (dest_err_set_ty.tag()) { | |
| 30335 | .error_set_single => ok: { | |
| 30336 | const expected_name = val.castTag(.@"error").?.data.name; | |
| 30337 | const n = dest_err_set_ty.castTag(.error_set_single).?.data; | |
| 30338 | if (mem.eql(u8, expected_name, n)) break :ok; | |
| 30323 | 30339 | return sema.failWithErrorSetCodeMissing(block, inst_src, dest_err_set_ty, inst_ty); |
| 30324 | } | |
| 30325 | }, | |
| 30326 | .error_set_inferred => ok: { | |
| 30327 | const expected_name = val.castTag(.@"error").?.data.name; | |
| 30328 | const ies = dest_err_set_ty.castTag(.error_set_inferred).?.data; | |
| 30329 | ||
| 30330 | // We carefully do this in an order that avoids unnecessarily | |
| 30331 | // resolving the destination error set type. | |
| 30332 | if (ies.is_anyerror) break :ok; | |
| 30333 | if (ies.errors.contains(expected_name)) break :ok; | |
| 30334 | if (.ok == try sema.coerceInMemoryAllowedErrorSets(block, dest_err_set_ty, inst_ty, inst_src, inst_src)) { | |
| 30335 | break :ok; | |
| 30336 | } | |
| 30340 | }, | |
| 30341 | .error_set => { | |
| 30342 | const expected_name = val.castTag(.@"error").?.data.name; | |
| 30343 | const error_set = dest_err_set_ty.castTag(.error_set).?.data; | |
| 30344 | if (!error_set.names.contains(expected_name)) { | |
| 30345 | return sema.failWithErrorSetCodeMissing(block, inst_src, dest_err_set_ty, inst_ty); | |
| 30346 | } | |
| 30347 | }, | |
| 30348 | .error_set_inferred => ok: { | |
| 30349 | const expected_name = val.castTag(.@"error").?.data.name; | |
| 30350 | const ies = dest_err_set_ty.castTag(.error_set_inferred).?.data; | |
| 30351 | ||
| 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 | } | |
| 30337 | 30359 | |
| 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 | 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 | 30374 | return sema.addConstant(dest_ty, val); |
| 30350 | 30375 | } |
| ... | ... | @@ -30380,7 +30405,7 @@ fn resolvePeerTypes( |
| 30380 | 30405 | ) !Type { |
| 30381 | 30406 | const mod = sema.mod; |
| 30382 | 30407 | switch (instructions.len) { |
| 30383 | 0 => return Type.initTag(.noreturn), | |
| 30408 | 0 => return Type.noreturn, | |
| 30384 | 30409 | 1 => return sema.typeOf(instructions[0]), |
| 30385 | 30410 | else => {}, |
| 30386 | 30411 | } |
| ... | ... | @@ -31445,24 +31470,7 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool { |
| 31445 | 31470 | .i64, |
| 31446 | 31471 | .u128, |
| 31447 | 31472 | .i128, |
| 31448 | .anyopaque, | |
| 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, | |
| 31473 | ||
| 31466 | 31474 | .manyptr_u8, |
| 31467 | 31475 | .manyptr_const_u8, |
| 31468 | 31476 | .manyptr_const_u8_sentinel_0, |
| ... | ... | @@ -31476,17 +31484,12 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool { |
| 31476 | 31484 | .error_set_inferred, |
| 31477 | 31485 | .error_set_merged, |
| 31478 | 31486 | .@"opaque", |
| 31479 | .generic_poison, | |
| 31480 | 31487 | .array_u8, |
| 31481 | 31488 | .array_u8_sentinel_0, |
| 31482 | 31489 | .enum_simple, |
| 31483 | 31490 | => false, |
| 31484 | 31491 | |
| 31485 | 31492 | .single_const_pointer_to_comptime_int, |
| 31486 | .type, | |
| 31487 | .comptime_int, | |
| 31488 | .enum_literal, | |
| 31489 | .type_info, | |
| 31490 | 31493 | .function, |
| 31491 | 31494 | => true, |
| 31492 | 31495 | |
| ... | ... | @@ -31709,17 +31712,6 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type { |
| 31709 | 31712 | try sema.resolveTypeFieldsUnion(ty, union_obj); |
| 31710 | 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"), | |
| 31723 | 31715 | |
| 31724 | 31716 | else => return ty, |
| 31725 | 31717 | }, |
| ... | ... | @@ -31772,6 +31764,7 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type { |
| 31772 | 31764 | .const_slice_u8_type, |
| 31773 | 31765 | .anyerror_void_error_union_type, |
| 31774 | 31766 | .generic_poison_type, |
| 31767 | .var_args_param_type, | |
| 31775 | 31768 | .empty_struct_type, |
| 31776 | 31769 | => return ty, |
| 31777 | 31770 | |
| ... | ... | @@ -31789,7 +31782,6 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type { |
| 31789 | 31782 | .bool_false => unreachable, |
| 31790 | 31783 | .empty_struct => unreachable, |
| 31791 | 31784 | .generic_poison => unreachable, |
| 31792 | .var_args_param_type => unreachable, | |
| 31793 | 31785 | |
| 31794 | 31786 | .type_info_type => return sema.getBuiltinType("Type"), |
| 31795 | 31787 | .extern_options_type => return sema.getBuiltinType("ExternOptions"), |
| ... | ... | @@ -32118,7 +32110,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void |
| 32118 | 32110 | return sema.failWithOwnedErrorMsg(msg); |
| 32119 | 32111 | } |
| 32120 | 32112 | gop.value_ptr.* = .{ |
| 32121 | .ty = Type.initTag(.noreturn), | |
| 32113 | .ty = Type.noreturn, | |
| 32122 | 32114 | .abi_align = 0, |
| 32123 | 32115 | .default_val = Value.initTag(.unreachable_value), |
| 32124 | 32116 | .is_comptime = is_comptime, |
| ... | ... | @@ -32552,7 +32544,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { |
| 32552 | 32544 | const field_ty: Type = if (!has_type) |
| 32553 | 32545 | Type.void |
| 32554 | 32546 | else if (field_type_ref == .none) |
| 32555 | Type.initTag(.noreturn) | |
| 32547 | Type.noreturn | |
| 32556 | 32548 | else |
| 32557 | 32549 | sema.resolveType(&block_scope, .unneeded, field_type_ref) catch |err| switch (err) { |
| 32558 | 32550 | error.NeededSourceLocation => { |
| ... | ... | @@ -32956,7 +32948,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 32956 | 32948 | }; |
| 32957 | 32949 | |
| 32958 | 32950 | switch (ty.tag()) { |
| 32959 | .comptime_int, | |
| 32960 | 32951 | .u1, |
| 32961 | 32952 | .u8, |
| 32962 | 32953 | .i8, |
| ... | ... | @@ -32969,9 +32960,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 32969 | 32960 | .i64, |
| 32970 | 32961 | .u128, |
| 32971 | 32962 | .i128, |
| 32972 | .bool, | |
| 32973 | .type, | |
| 32974 | .anyerror, | |
| 32963 | ||
| 32975 | 32964 | .error_set_single, |
| 32976 | 32965 | .error_set, |
| 32977 | 32966 | .error_set_merged, |
| ... | ... | @@ -32984,28 +32973,14 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 32984 | 32973 | .const_slice_u8_sentinel_0, |
| 32985 | 32974 | .const_slice, |
| 32986 | 32975 | .mut_slice, |
| 32987 | .anyopaque, | |
| 32988 | 32976 | .optional_single_mut_pointer, |
| 32989 | 32977 | .optional_single_const_pointer, |
| 32990 | .enum_literal, | |
| 32991 | 32978 | .anyerror_void_error_union, |
| 32992 | 32979 | .error_set_inferred, |
| 32993 | 32980 | .@"opaque", |
| 32994 | 32981 | .manyptr_u8, |
| 32995 | 32982 | .manyptr_const_u8, |
| 32996 | 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 | 32984 | .anyframe_T, |
| 33010 | 32985 | .many_const_pointer, |
| 33011 | 32986 | .many_mut_pointer, |
| ... | ... | @@ -33138,10 +33113,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 33138 | 33113 | }, |
| 33139 | 33114 | |
| 33140 | 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), | |
| 33145 | 33116 | |
| 33146 | 33117 | .vector, .array, .array_u8 => { |
| 33147 | 33118 | if (ty.arrayLen() == 0) |
| ... | ... | @@ -33154,7 +33125,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 33154 | 33125 | |
| 33155 | 33126 | .inferred_alloc_const => unreachable, |
| 33156 | 33127 | .inferred_alloc_mut => unreachable, |
| 33157 | .generic_poison => return error.GenericPoison, | |
| 33158 | 33128 | } |
| 33159 | 33129 | } |
| 33160 | 33130 | |
| ... | ... | @@ -33194,34 +33164,12 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref { |
| 33194 | 33164 | .i64 => return .i64_type, |
| 33195 | 33165 | .u128 => return .u128_type, |
| 33196 | 33166 | .i128 => return .i128_type, |
| 33197 | .anyopaque => return .anyopaque_type, | |
| 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, | |
| 33167 | ||
| 33219 | 33168 | .manyptr_u8 => return .manyptr_u8_type, |
| 33220 | 33169 | .manyptr_const_u8 => return .manyptr_const_u8_type, |
| 33221 | 33170 | .single_const_pointer_to_comptime_int => return .single_const_pointer_to_comptime_int_type, |
| 33222 | 33171 | .const_slice_u8 => return .const_slice_u8_type, |
| 33223 | 33172 | .anyerror_void_error_union => return .anyerror_void_error_union_type, |
| 33224 | .generic_poison => return .generic_poison_type, | |
| 33225 | 33173 | else => {}, |
| 33226 | 33174 | } |
| 33227 | 33175 | try sema.air_instructions.append(sema.gpa, .{ |
| ... | ... | @@ -33658,22 +33606,7 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool { |
| 33658 | 33606 | .i64, |
| 33659 | 33607 | .u128, |
| 33660 | 33608 | .i128, |
| 33661 | .anyopaque, | |
| 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, | |
| 33609 | ||
| 33677 | 33610 | .manyptr_u8, |
| 33678 | 33611 | .manyptr_const_u8, |
| 33679 | 33612 | .manyptr_const_u8_sentinel_0, |
| ... | ... | @@ -33687,19 +33620,12 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool { |
| 33687 | 33620 | .error_set_inferred, |
| 33688 | 33621 | .error_set_merged, |
| 33689 | 33622 | .@"opaque", |
| 33690 | .generic_poison, | |
| 33691 | 33623 | .array_u8, |
| 33692 | 33624 | .array_u8_sentinel_0, |
| 33693 | 33625 | .enum_simple, |
| 33694 | 33626 | => false, |
| 33695 | 33627 | |
| 33696 | 33628 | .single_const_pointer_to_comptime_int, |
| 33697 | .type, | |
| 33698 | .comptime_int, | |
| 33699 | .enum_literal, | |
| 33700 | .null, | |
| 33701 | .undefined, | |
| 33702 | .type_info, | |
| 33703 | 33629 | .function, |
| 33704 | 33630 | => true, |
| 33705 | 33631 | |
| ... | ... | @@ -34476,17 +34402,6 @@ fn enumHasInt(sema: *Sema, ty: Type, int: Value) CompileError!bool { |
| 34476 | 34402 | const tag_ty = try mod.intType(.unsigned, bits); |
| 34477 | 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, | |
| 34490 | 34405 | |
| 34491 | 34406 | else => unreachable, |
| 34492 | 34407 | } |
src/arch/aarch64/CodeGen.zig+4-3| ... | ... | @@ -3071,7 +3071,7 @@ fn errUnionErr( |
| 3071 | 3071 | const mod = self.bin_file.options.module.?; |
| 3072 | 3072 | const err_ty = error_union_ty.errorUnionSet(); |
| 3073 | 3073 | const payload_ty = error_union_ty.errorUnionPayload(); |
| 3074 | if (err_ty.errorSetIsEmpty()) { | |
| 3074 | if (err_ty.errorSetIsEmpty(mod)) { | |
| 3075 | 3075 | return MCValue{ .immediate = 0 }; |
| 3076 | 3076 | } |
| 3077 | 3077 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| ... | ... | @@ -3151,7 +3151,7 @@ fn errUnionPayload( |
| 3151 | 3151 | const mod = self.bin_file.options.module.?; |
| 3152 | 3152 | const err_ty = error_union_ty.errorUnionSet(); |
| 3153 | 3153 | const payload_ty = error_union_ty.errorUnionPayload(); |
| 3154 | if (err_ty.errorSetIsEmpty()) { | |
| 3154 | if (err_ty.errorSetIsEmpty(mod)) { | |
| 3155 | 3155 | return try error_union_bind.resolveToMcv(self); |
| 3156 | 3156 | } |
| 3157 | 3157 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| ... | ... | @@ -4905,9 +4905,10 @@ fn isErr( |
| 4905 | 4905 | error_union_bind: ReadArg.Bind, |
| 4906 | 4906 | error_union_ty: Type, |
| 4907 | 4907 | ) !MCValue { |
| 4908 | const mod = self.bin_file.options.module.?; | |
| 4908 | 4909 | const error_type = error_union_ty.errorUnionSet(); |
| 4909 | 4910 | |
| 4910 | if (error_type.errorSetIsEmpty()) { | |
| 4911 | if (error_type.errorSetIsEmpty(mod)) { | |
| 4911 | 4912 | return MCValue{ .immediate = 0 }; // always false |
| 4912 | 4913 | } |
| 4913 | 4914 |
src/arch/arm/CodeGen.zig+4-3| ... | ... | @@ -2047,7 +2047,7 @@ fn errUnionErr( |
| 2047 | 2047 | const mod = self.bin_file.options.module.?; |
| 2048 | 2048 | const err_ty = error_union_ty.errorUnionSet(); |
| 2049 | 2049 | const payload_ty = error_union_ty.errorUnionPayload(); |
| 2050 | if (err_ty.errorSetIsEmpty()) { | |
| 2050 | if (err_ty.errorSetIsEmpty(mod)) { | |
| 2051 | 2051 | return MCValue{ .immediate = 0 }; |
| 2052 | 2052 | } |
| 2053 | 2053 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| ... | ... | @@ -2124,7 +2124,7 @@ fn errUnionPayload( |
| 2124 | 2124 | const mod = self.bin_file.options.module.?; |
| 2125 | 2125 | const err_ty = error_union_ty.errorUnionSet(); |
| 2126 | 2126 | const payload_ty = error_union_ty.errorUnionPayload(); |
| 2127 | if (err_ty.errorSetIsEmpty()) { | |
| 2127 | if (err_ty.errorSetIsEmpty(mod)) { | |
| 2128 | 2128 | return try error_union_bind.resolveToMcv(self); |
| 2129 | 2129 | } |
| 2130 | 2130 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| ... | ... | @@ -4882,9 +4882,10 @@ fn isErr( |
| 4882 | 4882 | error_union_bind: ReadArg.Bind, |
| 4883 | 4883 | error_union_ty: Type, |
| 4884 | 4884 | ) !MCValue { |
| 4885 | const mod = self.bin_file.options.module.?; | |
| 4885 | 4886 | const error_type = error_union_ty.errorUnionSet(); |
| 4886 | 4887 | |
| 4887 | if (error_type.errorSetIsEmpty()) { | |
| 4888 | if (error_type.errorSetIsEmpty(mod)) { | |
| 4888 | 4889 | return MCValue{ .immediate = 0 }; // always false |
| 4889 | 4890 | } |
| 4890 | 4891 |
src/arch/sparc64/CodeGen.zig+1-1| ... | ... | @@ -3530,7 +3530,7 @@ fn errUnionPayload(self: *Self, error_union_mcv: MCValue, error_union_ty: Type) |
| 3530 | 3530 | const mod = self.bin_file.options.module.?; |
| 3531 | 3531 | const err_ty = error_union_ty.errorUnionSet(); |
| 3532 | 3532 | const payload_ty = error_union_ty.errorUnionPayload(); |
| 3533 | if (err_ty.errorSetIsEmpty()) { | |
| 3533 | if (err_ty.errorSetIsEmpty(mod)) { | |
| 3534 | 3534 | return error_union_mcv; |
| 3535 | 3535 | } |
| 3536 | 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 | 1036 | /// Differently from `genValtype` this also allows `void` to create a block |
| 1037 | 1037 | /// with no return type |
| 1038 | 1038 | fn genBlockType(ty: Type, mod: *Module) u8 { |
| 1039 | return switch (ty.tag()) { | |
| 1040 | .void, .noreturn => wasm.block_empty, | |
| 1039 | return switch (ty.ip_index) { | |
| 1040 | .void_type, .noreturn_type => wasm.block_empty, | |
| 1041 | 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 | 3948 | const pl_ty = err_union_ty.errorUnionPayload(); |
| 3949 | 3949 | |
| 3950 | 3950 | const result = result: { |
| 3951 | if (err_union_ty.errorUnionSet().errorSetIsEmpty()) { | |
| 3951 | if (err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) { | |
| 3952 | 3952 | switch (opcode) { |
| 3953 | 3953 | .i32_ne => break :result WValue{ .imm32 = 0 }, |
| 3954 | 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 | 4013 | const payload_ty = err_ty.errorUnionPayload(); |
| 4014 | 4014 | |
| 4015 | 4015 | const result = result: { |
| 4016 | if (err_ty.errorUnionSet().errorSetIsEmpty()) { | |
| 4016 | if (err_ty.errorUnionSet().errorSetIsEmpty(mod)) { | |
| 4017 | 4017 | break :result WValue{ .imm32 = 0 }; |
| 4018 | 4018 | } |
| 4019 | 4019 | |
| ... | ... | @@ -6214,7 +6214,7 @@ fn lowerTry( |
| 6214 | 6214 | const pl_ty = err_union_ty.errorUnionPayload(); |
| 6215 | 6215 | const pl_has_bits = pl_ty.hasRuntimeBitsIgnoreComptime(mod); |
| 6216 | 6216 | |
| 6217 | if (!err_union_ty.errorUnionSet().errorSetIsEmpty()) { | |
| 6217 | if (!err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) { | |
| 6218 | 6218 | // Block we can jump out of when error is not set |
| 6219 | 6219 | try func.startBlock(.block, wasm.block_empty); |
| 6220 | 6220 |
src/arch/x86_64/CodeGen.zig+4-4| ... | ... | @@ -3624,7 +3624,7 @@ fn airUnwrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void { |
| 3624 | 3624 | const operand = try self.resolveInst(ty_op.operand); |
| 3625 | 3625 | |
| 3626 | 3626 | const result: MCValue = result: { |
| 3627 | if (err_ty.errorSetIsEmpty()) { | |
| 3627 | if (err_ty.errorSetIsEmpty(mod)) { | |
| 3628 | 3628 | break :result MCValue{ .immediate = 0 }; |
| 3629 | 3629 | } |
| 3630 | 3630 | |
| ... | ... | @@ -5811,7 +5811,7 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air: |
| 5811 | 5811 | switch (tag) { |
| 5812 | 5812 | .not => { |
| 5813 | 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 | 5815 | std.builtin.Type.Int{ .signedness = .unsigned, .bits = 1 } |
| 5816 | 5816 | else |
| 5817 | 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 | 8716 | try self.asmRegisterRegister(.{ ._, .@"test" }, alias_reg, alias_reg); |
| 8717 | 8717 | return .{ .eflags = .z }; |
| 8718 | 8718 | } |
| 8719 | assert(some_info.ty.tag() == .bool); | |
| 8719 | assert(some_info.ty.ip_index == .bool_type); | |
| 8720 | 8720 | const opt_abi_size = @intCast(u32, opt_ty.abiSize(mod)); |
| 8721 | 8721 | try self.asmRegisterImmediate( |
| 8722 | 8722 | .{ ._, .bt }, |
| ... | ... | @@ -8808,7 +8808,7 @@ fn isErr(self: *Self, maybe_inst: ?Air.Inst.Index, ty: Type, operand: MCValue) ! |
| 8808 | 8808 | const mod = self.bin_file.options.module.?; |
| 8809 | 8809 | const err_type = ty.errorUnionSet(); |
| 8810 | 8810 | |
| 8811 | if (err_type.errorSetIsEmpty()) { | |
| 8811 | if (err_type.errorSetIsEmpty(mod)) { | |
| 8812 | 8812 | return MCValue{ .immediate = 0 }; // always false |
| 8813 | 8813 | } |
| 8814 | 8814 |
src/codegen/c.zig+8-8| ... | ... | @@ -1508,7 +1508,7 @@ pub const DeclGen = struct { |
| 1508 | 1508 | } |
| 1509 | 1509 | if (fn_decl.val.castTag(.function)) |func_payload| |
| 1510 | 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 "); | |
| 1512 | 1512 | |
| 1513 | 1513 | const trailing = try renderTypePrefix( |
| 1514 | 1514 | dg.decl_index, |
| ... | ... | @@ -3783,7 +3783,7 @@ fn airNot(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3783 | 3783 | const ty_op = f.air.instructions.items(.data)[inst].ty_op; |
| 3784 | 3784 | const operand_ty = f.typeOf(ty_op.operand); |
| 3785 | 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); | |
| 3787 | 3787 | |
| 3788 | 3788 | const op = try f.resolveInst(ty_op.operand); |
| 3789 | 3789 | try reap(f, inst, &.{ty_op.operand}); |
| ... | ... | @@ -4292,7 +4292,7 @@ fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4292 | 4292 | const writer = f.object.writer(); |
| 4293 | 4293 | |
| 4294 | 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 | 4296 | try f.allocLocal(inst, inst_ty) |
| 4297 | 4297 | else |
| 4298 | 4298 | .none; |
| ... | ... | @@ -4354,7 +4354,7 @@ fn lowerTry( |
| 4354 | 4354 | const payload_ty = err_union_ty.errorUnionPayload(); |
| 4355 | 4355 | const payload_has_bits = payload_ty.hasRuntimeBitsIgnoreComptime(mod); |
| 4356 | 4356 | |
| 4357 | if (!err_union_ty.errorUnionSet().errorSetIsEmpty()) { | |
| 4357 | if (!err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) { | |
| 4358 | 4358 | try writer.writeAll("if ("); |
| 4359 | 4359 | if (!payload_has_bits) { |
| 4360 | 4360 | if (is_ptr) |
| ... | ... | @@ -5549,7 +5549,7 @@ fn airUnwrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5549 | 5549 | if (!payload_ty.hasRuntimeBits(mod)) { |
| 5550 | 5550 | try f.writeCValue(writer, operand, .Other); |
| 5551 | 5551 | } else { |
| 5552 | if (!error_ty.errorSetIsEmpty()) | |
| 5552 | if (!error_ty.errorSetIsEmpty(mod)) | |
| 5553 | 5553 | if (operand_is_ptr) |
| 5554 | 5554 | try f.writeCValueDerefMember(writer, operand, .{ .identifier = "error" }) |
| 5555 | 5555 | else |
| ... | ... | @@ -5768,7 +5768,7 @@ fn airIsErr(f: *Function, inst: Air.Inst.Index, is_ptr: bool, operator: []const |
| 5768 | 5768 | try f.writeCValue(writer, local, .Other); |
| 5769 | 5769 | try writer.writeAll(" = "); |
| 5770 | 5770 | |
| 5771 | if (!error_ty.errorSetIsEmpty()) | |
| 5771 | if (!error_ty.errorSetIsEmpty(mod)) | |
| 5772 | 5772 | if (payload_ty.hasRuntimeBits(mod)) |
| 5773 | 5773 | if (is_ptr) |
| 5774 | 5774 | try f.writeCValueDerefMember(writer, operand, .{ .identifier = "error" }) |
| ... | ... | @@ -6032,7 +6032,7 @@ fn airCmpBuiltinCall( |
| 6032 | 6032 | try writer.writeByte(')'); |
| 6033 | 6033 | if (!ref_ret) try writer.print(" {s} {}", .{ |
| 6034 | 6034 | compareOperatorC(operator), |
| 6035 | try f.fmtIntLiteral(Type.initTag(.i32), Value.zero), | |
| 6035 | try f.fmtIntLiteral(Type.i32, Value.zero), | |
| 6036 | 6036 | }); |
| 6037 | 6037 | try writer.writeAll(";\n"); |
| 6038 | 6038 | try v.end(f, inst, writer); |
| ... | ... | @@ -7749,7 +7749,7 @@ const LowerFnRetTyBuffer = struct { |
| 7749 | 7749 | payload: Type.Payload.AnonStruct, |
| 7750 | 7750 | }; |
| 7751 | 7751 | fn 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; | |
| 7753 | 7753 | |
| 7754 | 7754 | if (lowersToArray(ret_ty, mod)) { |
| 7755 | 7755 | buffer.names = [1][]const u8{"array"}; |
src/codegen/llvm.zig+18-20| ... | ... | @@ -1730,7 +1730,7 @@ pub const Object = struct { |
| 1730 | 1730 | return ptr_di_ty; |
| 1731 | 1731 | }, |
| 1732 | 1732 | .Opaque => { |
| 1733 | if (ty.tag() == .anyopaque) { | |
| 1733 | if (ty.ip_index == .anyopaque_type) { | |
| 1734 | 1734 | const di_ty = dib.createBasicType("anyopaque", 0, DW.ATE.signed); |
| 1735 | 1735 | gop.value_ptr.* = AnnotatedDITypePtr.initFull(di_ty); |
| 1736 | 1736 | return di_ty; |
| ... | ... | @@ -2847,25 +2847,23 @@ pub const DeclGen = struct { |
| 2847 | 2847 | const llvm_addrspace = toLlvmAddressSpace(ptr_info.@"addrspace", target); |
| 2848 | 2848 | return dg.context.pointerType(llvm_addrspace); |
| 2849 | 2849 | }, |
| 2850 | .Opaque => switch (t.tag()) { | |
| 2851 | .@"opaque" => { | |
| 2852 | const gop = try dg.object.type_map.getOrPutContext(gpa, t, .{ .mod = dg.module }); | |
| 2853 | if (gop.found_existing) return gop.value_ptr.*; | |
| 2850 | .Opaque => { | |
| 2851 | if (t.ip_index == .anyopaque_type) return dg.context.intType(8); | |
| 2854 | 2852 | |
| 2855 | // The Type memory is ephemeral; since we want to store a longer-lived | |
| 2856 | // reference, we need to copy it here. | |
| 2857 | gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator()); | |
| 2853 | const gop = try dg.object.type_map.getOrPutContext(gpa, t, .{ .mod = dg.module }); | |
| 2854 | if (gop.found_existing) return gop.value_ptr.*; | |
| 2858 | 2855 | |
| 2859 | const opaque_obj = t.castTag(.@"opaque").?.data; | |
| 2860 | const name = try opaque_obj.getFullyQualifiedName(dg.module); | |
| 2861 | defer gpa.free(name); | |
| 2856 | // The Type memory is ephemeral; since we want to store a longer-lived | |
| 2857 | // reference, we need to copy it here. | |
| 2858 | gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator()); | |
| 2862 | 2859 | |
| 2863 | const llvm_struct_ty = dg.context.structCreateNamed(name); | |
| 2864 | gop.value_ptr.* = llvm_struct_ty; // must be done before any recursive calls | |
| 2865 | return llvm_struct_ty; | |
| 2866 | }, | |
| 2867 | .anyopaque => return dg.context.intType(8), | |
| 2868 | else => unreachable, | |
| 2860 | const opaque_obj = t.castTag(.@"opaque").?.data; | |
| 2861 | const name = try opaque_obj.getFullyQualifiedName(dg.module); | |
| 2862 | defer gpa.free(name); | |
| 2863 | ||
| 2864 | const llvm_struct_ty = dg.context.structCreateNamed(name); | |
| 2865 | gop.value_ptr.* = llvm_struct_ty; // must be done before any recursive calls | |
| 2866 | return llvm_struct_ty; | |
| 2869 | 2867 | }, |
| 2870 | 2868 | .Array => { |
| 2871 | 2869 | const elem_ty = t.childType(); |
| ... | ... | @@ -5531,7 +5529,7 @@ pub const FuncGen = struct { |
| 5531 | 5529 | const payload_has_bits = payload_ty.hasRuntimeBitsIgnoreComptime(mod); |
| 5532 | 5530 | const err_union_llvm_ty = try fg.dg.lowerType(err_union_ty); |
| 5533 | 5531 | |
| 5534 | if (!err_union_ty.errorUnionSet().errorSetIsEmpty()) { | |
| 5532 | if (!err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) { | |
| 5535 | 5533 | const is_err = err: { |
| 5536 | 5534 | const err_set_ty = try fg.dg.lowerType(Type.anyerror); |
| 5537 | 5535 | const zero = err_set_ty.constNull(); |
| ... | ... | @@ -6715,7 +6713,7 @@ pub const FuncGen = struct { |
| 6715 | 6713 | const err_set_ty = try self.dg.lowerType(Type.anyerror); |
| 6716 | 6714 | const zero = err_set_ty.constNull(); |
| 6717 | 6715 | |
| 6718 | if (err_union_ty.errorUnionSet().errorSetIsEmpty()) { | |
| 6716 | if (err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) { | |
| 6719 | 6717 | const llvm_i1 = self.context.intType(1); |
| 6720 | 6718 | switch (op) { |
| 6721 | 6719 | .EQ => return llvm_i1.constInt(1, .False), // 0 == 0 |
| ... | ... | @@ -6864,7 +6862,7 @@ pub const FuncGen = struct { |
| 6864 | 6862 | const operand = try self.resolveInst(ty_op.operand); |
| 6865 | 6863 | const operand_ty = self.typeOf(ty_op.operand); |
| 6866 | 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 | 6866 | const err_llvm_ty = try self.dg.lowerType(Type.anyerror); |
| 6869 | 6867 | if (operand_is_ptr) { |
| 6870 | 6868 | return operand; |
src/codegen/spirv.zig+4-2| ... | ... | @@ -2849,6 +2849,7 @@ pub const DeclGen = struct { |
| 2849 | 2849 | } |
| 2850 | 2850 | |
| 2851 | 2851 | fn airTry(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| 2852 | const mod = self.module; | |
| 2852 | 2853 | const pl_op = self.air.instructions.items(.data)[inst].pl_op; |
| 2853 | 2854 | const err_union_id = try self.resolve(pl_op.operand); |
| 2854 | 2855 | const extra = self.air.extraData(Air.Try, pl_op.payload); |
| ... | ... | @@ -2862,7 +2863,7 @@ pub const DeclGen = struct { |
| 2862 | 2863 | |
| 2863 | 2864 | const eu_layout = self.errorUnionLayout(payload_ty); |
| 2864 | 2865 | |
| 2865 | if (!err_union_ty.errorUnionSet().errorSetIsEmpty()) { | |
| 2866 | if (!err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) { | |
| 2866 | 2867 | const err_id = if (eu_layout.payload_has_bits) |
| 2867 | 2868 | try self.extractField(Type.anyerror, err_union_id, eu_layout.errorFieldIndex()) |
| 2868 | 2869 | else |
| ... | ... | @@ -2910,12 +2911,13 @@ pub const DeclGen = struct { |
| 2910 | 2911 | fn airErrUnionErr(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| 2911 | 2912 | if (self.liveness.isUnused(inst)) return null; |
| 2912 | 2913 | |
| 2914 | const mod = self.module; | |
| 2913 | 2915 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 2914 | 2916 | const operand_id = try self.resolve(ty_op.operand); |
| 2915 | 2917 | const err_union_ty = self.typeOf(ty_op.operand); |
| 2916 | 2918 | const err_ty_ref = try self.resolveType(Type.anyerror, .direct); |
| 2917 | 2919 | |
| 2918 | if (err_union_ty.errorUnionSet().errorSetIsEmpty()) { | |
| 2920 | if (err_union_ty.errorUnionSet().errorSetIsEmpty(mod)) { | |
| 2919 | 2921 | // No error possible, so just return undefined. |
| 2920 | 2922 | return try self.spv.constUndef(err_ty_ref); |
| 2921 | 2923 | } |
src/print_air.zig-1| ... | ... | @@ -370,7 +370,6 @@ const Writer = struct { |
| 370 | 370 | switch (t) { |
| 371 | 371 | .inferred_alloc_const => try s.writeAll("(inferred_alloc_const)"), |
| 372 | 372 | .inferred_alloc_mut => try s.writeAll("(inferred_alloc_mut)"), |
| 373 | .generic_poison => try s.writeAll("(generic_poison)"), | |
| 374 | 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 | 85 | .address_space, |
| 86 | 86 | .float_mode, |
| 87 | 87 | .reduce_op, |
| 88 | .call_modifier, | |
| 88 | 89 | => return .Enum, |
| 89 | 90 | |
| 90 | .call_modifier, | |
| 91 | 91 | .prefetch_options, |
| 92 | 92 | .export_options, |
| 93 | 93 | .extern_options, |
| ... | ... | @@ -95,7 +95,7 @@ pub const Type = struct { |
| 95 | 95 | |
| 96 | 96 | .type_info => return .Union, |
| 97 | 97 | |
| 98 | .generic_poison => unreachable, | |
| 98 | .generic_poison => return error.GenericPoison, | |
| 99 | 99 | .var_args_param => unreachable, |
| 100 | 100 | }, |
| 101 | 101 | |
| ... | ... | @@ -107,8 +107,6 @@ pub const Type = struct { |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | switch (ty.tag()) { |
| 110 | .generic_poison => return error.GenericPoison, | |
| 111 | ||
| 112 | 110 | .u1, |
| 113 | 111 | .u8, |
| 114 | 112 | .i8, |
| ... | ... | @@ -125,19 +123,11 @@ pub const Type = struct { |
| 125 | 123 | |
| 126 | 124 | .error_set, |
| 127 | 125 | .error_set_single, |
| 128 | .anyerror, | |
| 129 | 126 | .error_set_inferred, |
| 130 | 127 | .error_set_merged, |
| 131 | 128 | => return .ErrorSet, |
| 132 | 129 | |
| 133 | .anyopaque, .@"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, | |
| 130 | .@"opaque" => return .Opaque, | |
| 141 | 131 | |
| 142 | 132 | .function => return .Fn, |
| 143 | 133 | |
| ... | ... | @@ -172,18 +162,14 @@ pub const Type = struct { |
| 172 | 162 | .optional_single_const_pointer, |
| 173 | 163 | .optional_single_mut_pointer, |
| 174 | 164 | => return .Optional, |
| 175 | .enum_literal => return .EnumLiteral, | |
| 176 | 165 | |
| 177 | 166 | .anyerror_void_error_union, .error_union => return .ErrorUnion, |
| 178 | 167 | |
| 179 | .anyframe_T, .@"anyframe" => return .AnyFrame, | |
| 168 | .anyframe_T => return .AnyFrame, | |
| 180 | 169 | |
| 181 | 170 | .empty_struct, |
| 182 | 171 | .empty_struct_literal, |
| 183 | 172 | .@"struct", |
| 184 | .prefetch_options, | |
| 185 | .export_options, | |
| 186 | .extern_options, | |
| 187 | 173 | .tuple, |
| 188 | 174 | .anon_struct, |
| 189 | 175 | => return .Struct, |
| ... | ... | @@ -192,19 +178,11 @@ pub const Type = struct { |
| 192 | 178 | .enum_nonexhaustive, |
| 193 | 179 | .enum_simple, |
| 194 | 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 | 181 | => return .Enum, |
| 203 | 182 | |
| 204 | 183 | .@"union", |
| 205 | 184 | .union_safety_tagged, |
| 206 | 185 | .union_tagged, |
| 207 | .type_info, | |
| 208 | 186 | => return .Union, |
| 209 | 187 | } |
| 210 | 188 | } |
| ... | ... | @@ -393,7 +371,7 @@ pub const Type = struct { |
| 393 | 371 | pub fn ptrInfo(self: Type) Payload.Pointer { |
| 394 | 372 | switch (self.tag()) { |
| 395 | 373 | .single_const_pointer_to_comptime_int => return .{ .data = .{ |
| 396 | .pointee_type = Type.initTag(.comptime_int), | |
| 374 | .pointee_type = Type.comptime_int, | |
| 397 | 375 | .sentinel = null, |
| 398 | 376 | .@"align" = 0, |
| 399 | 377 | .@"addrspace" = .generic, |
| ... | ... | @@ -405,7 +383,7 @@ pub const Type = struct { |
| 405 | 383 | .size = .One, |
| 406 | 384 | } }, |
| 407 | 385 | .const_slice_u8 => return .{ .data = .{ |
| 408 | .pointee_type = Type.initTag(.u8), | |
| 386 | .pointee_type = Type.u8, | |
| 409 | 387 | .sentinel = null, |
| 410 | 388 | .@"align" = 0, |
| 411 | 389 | .@"addrspace" = .generic, |
| ... | ... | @@ -417,7 +395,7 @@ pub const Type = struct { |
| 417 | 395 | .size = .Slice, |
| 418 | 396 | } }, |
| 419 | 397 | .const_slice_u8_sentinel_0 => return .{ .data = .{ |
| 420 | .pointee_type = Type.initTag(.u8), | |
| 398 | .pointee_type = Type.u8, | |
| 421 | 399 | .sentinel = Value.zero, |
| 422 | 400 | .@"align" = 0, |
| 423 | 401 | .@"addrspace" = .generic, |
| ... | ... | @@ -465,7 +443,7 @@ pub const Type = struct { |
| 465 | 443 | .size = .Many, |
| 466 | 444 | } }, |
| 467 | 445 | .manyptr_const_u8 => return .{ .data = .{ |
| 468 | .pointee_type = Type.initTag(.u8), | |
| 446 | .pointee_type = Type.u8, | |
| 469 | 447 | .sentinel = null, |
| 470 | 448 | .@"align" = 0, |
| 471 | 449 | .@"addrspace" = .generic, |
| ... | ... | @@ -477,7 +455,7 @@ pub const Type = struct { |
| 477 | 455 | .size = .Many, |
| 478 | 456 | } }, |
| 479 | 457 | .manyptr_const_u8_sentinel_0 => return .{ .data = .{ |
| 480 | .pointee_type = Type.initTag(.u8), | |
| 458 | .pointee_type = Type.u8, | |
| 481 | 459 | .sentinel = Value.zero, |
| 482 | 460 | .@"align" = 0, |
| 483 | 461 | .@"addrspace" = .generic, |
| ... | ... | @@ -501,7 +479,7 @@ pub const Type = struct { |
| 501 | 479 | .size = .Many, |
| 502 | 480 | } }, |
| 503 | 481 | .manyptr_u8 => return .{ .data = .{ |
| 504 | .pointee_type = Type.initTag(.u8), | |
| 482 | .pointee_type = Type.u8, | |
| 505 | 483 | .sentinel = null, |
| 506 | 484 | .@"align" = 0, |
| 507 | 485 | .@"addrspace" = .generic, |
| ... | ... | @@ -608,23 +586,6 @@ pub const Type = struct { |
| 608 | 586 | if (a.legacy.tag_if_small_enough == b.legacy.tag_if_small_enough) return true; |
| 609 | 587 | |
| 610 | 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 | 589 | .u1, |
| 629 | 590 | .u8, |
| 630 | 591 | .i8, |
| ... | ... | @@ -653,10 +614,6 @@ pub const Type = struct { |
| 653 | 614 | return a_ies == b_ies; |
| 654 | 615 | }, |
| 655 | 616 | |
| 656 | .anyerror => { | |
| 657 | return b.tag() == .anyerror; | |
| 658 | }, | |
| 659 | ||
| 660 | 617 | .error_set, |
| 661 | 618 | .error_set_single, |
| 662 | 619 | .error_set_merged, |
| ... | ... | @@ -927,13 +884,6 @@ pub const Type = struct { |
| 927 | 884 | return true; |
| 928 | 885 | }, |
| 929 | 886 | |
| 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 | 887 | .enum_full, .enum_nonexhaustive => { |
| 938 | 888 | const a_enum_obj = a.cast(Payload.EnumFull).?.data; |
| 939 | 889 | const b_enum_obj = (b.cast(Payload.EnumFull) orelse return false).data; |
| ... | ... | @@ -949,26 +899,12 @@ pub const Type = struct { |
| 949 | 899 | const b_enum_obj = (b.cast(Payload.EnumNumbered) orelse return false).data; |
| 950 | 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 | |
| 962 | 902 | |
| 963 | 903 | .@"union", .union_safety_tagged, .union_tagged => { |
| 964 | 904 | const a_union_obj = a.cast(Payload.Union).?.data; |
| 965 | 905 | const b_union_obj = (b.cast(Payload.Union) orelse return false).data; |
| 966 | 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 | } |
| 974 | 910 | |
| ... | ... | @@ -987,31 +923,6 @@ pub const Type = struct { |
| 987 | 923 | return; |
| 988 | 924 | } |
| 989 | 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 | 926 | .u1, |
| 1016 | 927 | .u8, |
| 1017 | 928 | .i8, |
| ... | ... | @@ -1046,12 +957,6 @@ pub const Type = struct { |
| 1046 | 957 | for (names) |name| hasher.update(name); |
| 1047 | 958 | }, |
| 1048 | 959 | |
| 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 | 960 | .error_set_inferred => { |
| 1056 | 961 | // inferred error sets are compared using their data pointer |
| 1057 | 962 | const ies: *Module.Fn.InferredErrorSet = ty.castTag(.error_set_inferred).?.data; |
| ... | ... | @@ -1209,12 +1114,6 @@ pub const Type = struct { |
| 1209 | 1114 | } |
| 1210 | 1115 | }, |
| 1211 | 1116 | |
| 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 | 1117 | .enum_full, .enum_nonexhaustive => { |
| 1219 | 1118 | const enum_obj: *const Module.EnumFull = ty.cast(Payload.EnumFull).?.data; |
| 1220 | 1119 | std.hash.autoHash(hasher, std.builtin.TypeId.Enum); |
| ... | ... | @@ -1230,24 +1129,12 @@ pub const Type = struct { |
| 1230 | 1129 | std.hash.autoHash(hasher, std.builtin.TypeId.Enum); |
| 1231 | 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 | |
| 1242 | 1132 | |
| 1243 | 1133 | .@"union", .union_safety_tagged, .union_tagged => { |
| 1244 | 1134 | const union_obj: *const Module.Union = ty.cast(Payload.Union).?.data; |
| 1245 | 1135 | std.hash.autoHash(hasher, std.builtin.TypeId.Union); |
| 1246 | 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 | } |
| 1253 | 1140 | |
| ... | ... | @@ -1305,19 +1192,9 @@ pub const Type = struct { |
| 1305 | 1192 | .i64, |
| 1306 | 1193 | .u128, |
| 1307 | 1194 | .i128, |
| 1308 | .anyopaque, | |
| 1309 | .bool, | |
| 1310 | .void, | |
| 1311 | .type, | |
| 1312 | .anyerror, | |
| 1313 | .comptime_int, | |
| 1314 | .noreturn, | |
| 1315 | .null, | |
| 1316 | .undefined, | |
| 1317 | 1195 | .single_const_pointer_to_comptime_int, |
| 1318 | 1196 | .const_slice_u8, |
| 1319 | 1197 | .const_slice_u8_sentinel_0, |
| 1320 | .enum_literal, | |
| 1321 | 1198 | .anyerror_void_error_union, |
| 1322 | 1199 | .inferred_alloc_const, |
| 1323 | 1200 | .inferred_alloc_mut, |
| ... | ... | @@ -1325,19 +1202,6 @@ pub const Type = struct { |
| 1325 | 1202 | .manyptr_u8, |
| 1326 | 1203 | .manyptr_const_u8, |
| 1327 | 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 | 1205 | => unreachable, |
| 1342 | 1206 | |
| 1343 | 1207 | .array_u8, |
| ... | ... | @@ -1580,20 +1444,8 @@ pub const Type = struct { |
| 1580 | 1444 | .i64, |
| 1581 | 1445 | .u128, |
| 1582 | 1446 | .i128, |
| 1583 | .anyopaque, | |
| 1584 | .bool, | |
| 1585 | .void, | |
| 1586 | .type, | |
| 1587 | .anyerror, | |
| 1588 | .@"anyframe", | |
| 1589 | .comptime_int, | |
| 1590 | .noreturn, | |
| 1591 | 1447 | => return writer.writeAll(@tagName(t)), |
| 1592 | 1448 | |
| 1593 | .enum_literal => return writer.writeAll("@Type(.EnumLiteral)"), | |
| 1594 | .null => return writer.writeAll("@Type(.Null)"), | |
| 1595 | .undefined => return writer.writeAll("@Type(.Undefined)"), | |
| 1596 | ||
| 1597 | 1449 | .empty_struct, .empty_struct_literal => return writer.writeAll("struct {}"), |
| 1598 | 1450 | |
| 1599 | 1451 | .@"struct" => { |
| ... | ... | @@ -1640,17 +1492,6 @@ pub const Type = struct { |
| 1640 | 1492 | .manyptr_u8 => return writer.writeAll("[*]u8"), |
| 1641 | 1493 | .manyptr_const_u8 => return writer.writeAll("[*]const u8"), |
| 1642 | 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 | 1495 | .function => { |
| 1655 | 1496 | const payload = ty.castTag(.function).?.data; |
| 1656 | 1497 | try writer.writeAll("fn("); |
| ... | ... | @@ -1889,7 +1730,6 @@ pub const Type = struct { |
| 1889 | 1730 | }, |
| 1890 | 1731 | .inferred_alloc_const => return writer.writeAll("(inferred_alloc_const)"), |
| 1891 | 1732 | .inferred_alloc_mut => return writer.writeAll("(inferred_alloc_mut)"), |
| 1892 | .generic_poison => return writer.writeAll("(generic poison)"), | |
| 1893 | 1733 | } |
| 1894 | 1734 | unreachable; |
| 1895 | 1735 | } |
| ... | ... | @@ -1931,20 +1771,6 @@ pub const Type = struct { |
| 1931 | 1771 | switch (t) { |
| 1932 | 1772 | .inferred_alloc_const => unreachable, |
| 1933 | 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, | |
| 1948 | 1774 | |
| 1949 | 1775 | .u1, |
| 1950 | 1776 | .u8, |
| ... | ... | @@ -1958,19 +1784,8 @@ pub const Type = struct { |
| 1958 | 1784 | .i64, |
| 1959 | 1785 | .u128, |
| 1960 | 1786 | .i128, |
| 1961 | .anyopaque, | |
| 1962 | .bool, | |
| 1963 | .void, | |
| 1964 | .type, | |
| 1965 | .anyerror, | |
| 1966 | .@"anyframe", | |
| 1967 | .comptime_int, | |
| 1968 | .noreturn, | |
| 1969 | 1787 | => try writer.writeAll(@tagName(t)), |
| 1970 | 1788 | |
| 1971 | .enum_literal => try writer.writeAll("@TypeOf(.enum_literal)"), | |
| 1972 | .null => try writer.writeAll("@TypeOf(null)"), | |
| 1973 | .undefined => try writer.writeAll("@TypeOf(undefined)"), | |
| 1974 | 1789 | .empty_struct_literal => try writer.writeAll("@TypeOf(.{})"), |
| 1975 | 1790 | |
| 1976 | 1791 | .empty_struct => { |
| ... | ... | @@ -2249,34 +2064,12 @@ pub const Type = struct { |
| 2249 | 2064 | .i32 => return Value.initTag(.i32_type), |
| 2250 | 2065 | .u64 => return Value.initTag(.u64_type), |
| 2251 | 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 | 2067 | .single_const_pointer_to_comptime_int => return Value.initTag(.single_const_pointer_to_comptime_int_type), |
| 2263 | 2068 | .const_slice_u8 => return Value.initTag(.const_slice_u8_type), |
| 2264 | 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 | 2070 | .manyptr_u8 => return Value.initTag(.manyptr_u8_type), |
| 2267 | 2071 | .manyptr_const_u8 => return Value.initTag(.manyptr_const_u8_type), |
| 2268 | 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 | 2073 | .inferred_alloc_const => unreachable, |
| 2281 | 2074 | .inferred_alloc_mut => unreachable, |
| 2282 | 2075 | else => return Value.Tag.ty.create(allocator, self), |
| ... | ... | @@ -2378,8 +2171,7 @@ pub const Type = struct { |
| 2378 | 2171 | .i64, |
| 2379 | 2172 | .u128, |
| 2380 | 2173 | .i128, |
| 2381 | .bool, | |
| 2382 | .anyerror, | |
| 2174 | ||
| 2383 | 2175 | .const_slice_u8, |
| 2384 | 2176 | .const_slice_u8_sentinel_0, |
| 2385 | 2177 | .array_u8_sentinel_0, |
| ... | ... | @@ -2388,18 +2180,7 @@ pub const Type = struct { |
| 2388 | 2180 | .manyptr_u8, |
| 2389 | 2181 | .manyptr_const_u8, |
| 2390 | 2182 | .manyptr_const_u8_sentinel_0, |
| 2391 | .atomic_order, | |
| 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, | |
| 2183 | ||
| 2403 | 2184 | .@"opaque", |
| 2404 | 2185 | .error_set_single, |
| 2405 | 2186 | .error_union, |
| ... | ... | @@ -2435,16 +2216,8 @@ pub const Type = struct { |
| 2435 | 2216 | |
| 2436 | 2217 | // These are false because they are comptime-only types. |
| 2437 | 2218 | .single_const_pointer_to_comptime_int, |
| 2438 | .void, | |
| 2439 | .type, | |
| 2440 | .comptime_int, | |
| 2441 | .noreturn, | |
| 2442 | .null, | |
| 2443 | .undefined, | |
| 2444 | .enum_literal, | |
| 2445 | 2219 | .empty_struct, |
| 2446 | 2220 | .empty_struct_literal, |
| 2447 | .type_info, | |
| 2448 | 2221 | // These are function *bodies*, not pointers. |
| 2449 | 2222 | // Special exceptions have to be made when emitting functions due to |
| 2450 | 2223 | // this returning false. |
| ... | ... | @@ -2558,7 +2331,6 @@ pub const Type = struct { |
| 2558 | 2331 | |
| 2559 | 2332 | .inferred_alloc_const => unreachable, |
| 2560 | 2333 | .inferred_alloc_mut => unreachable, |
| 2561 | .generic_poison => unreachable, | |
| 2562 | 2334 | } |
| 2563 | 2335 | } |
| 2564 | 2336 | |
| ... | ... | @@ -2641,8 +2413,7 @@ pub const Type = struct { |
| 2641 | 2413 | .i64, |
| 2642 | 2414 | .u128, |
| 2643 | 2415 | .i128, |
| 2644 | .bool, | |
| 2645 | .void, | |
| 2416 | ||
| 2646 | 2417 | .manyptr_u8, |
| 2647 | 2418 | .manyptr_const_u8, |
| 2648 | 2419 | .manyptr_const_u8_sentinel_0, |
| ... | ... | @@ -2662,32 +2433,11 @@ pub const Type = struct { |
| 2662 | 2433 | .optional_single_const_pointer, |
| 2663 | 2434 | => true, |
| 2664 | 2435 | |
| 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 | 2436 | .error_set, |
| 2682 | 2437 | .error_set_single, |
| 2683 | 2438 | .error_set_inferred, |
| 2684 | 2439 | .error_set_merged, |
| 2685 | 2440 | .@"opaque", |
| 2686 | .generic_poison, | |
| 2687 | .type, | |
| 2688 | .comptime_int, | |
| 2689 | .enum_literal, | |
| 2690 | .type_info, | |
| 2691 | 2441 | // These are function bodies, not function pointers. |
| 2692 | 2442 | .function, |
| 2693 | 2443 | .const_slice_u8, |
| ... | ... | @@ -2773,7 +2523,6 @@ pub const Type = struct { |
| 2773 | 2523 | else => return false, |
| 2774 | 2524 | |
| 2775 | 2525 | @enumToInt(InternPool.Index.none) => switch (ty.tag()) { |
| 2776 | .noreturn => return true, | |
| 2777 | 2526 | .error_set => { |
| 2778 | 2527 | const err_set_obj = ty.castTag(.error_set).?.data; |
| 2779 | 2528 | const names = err_set_obj.names.keys(); |
| ... | ... | @@ -3003,21 +2752,10 @@ pub const Type = struct { |
| 3003 | 2752 | .u1, |
| 3004 | 2753 | .u8, |
| 3005 | 2754 | .i8, |
| 3006 | .bool, | |
| 2755 | ||
| 3007 | 2756 | .array_u8_sentinel_0, |
| 3008 | 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 | 2758 | .@"opaque", |
| 3020 | .anyopaque, | |
| 3021 | 2759 | => return AbiAlignmentAdvanced{ .scalar = 1 }, |
| 3022 | 2760 | |
| 3023 | 2761 | // represents machine code; not a pointer |
| ... | ... | @@ -3044,13 +2782,11 @@ pub const Type = struct { |
| 3044 | 2782 | .manyptr_u8, |
| 3045 | 2783 | .manyptr_const_u8, |
| 3046 | 2784 | .manyptr_const_u8_sentinel_0, |
| 3047 | .@"anyframe", | |
| 3048 | 2785 | .anyframe_T, |
| 3049 | 2786 | => return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 3050 | 2787 | |
| 3051 | 2788 | // TODO revisit this when we have the concept of the error tag type |
| 3052 | 2789 | .anyerror_void_error_union, |
| 3053 | .anyerror, | |
| 3054 | 2790 | .error_set_inferred, |
| 3055 | 2791 | .error_set_single, |
| 3056 | 2792 | .error_set, |
| ... | ... | @@ -3229,22 +2965,12 @@ pub const Type = struct { |
| 3229 | 2965 | }, |
| 3230 | 2966 | |
| 3231 | 2967 | .empty_struct, |
| 3232 | .void, | |
| 3233 | 2968 | .empty_struct_literal, |
| 3234 | .type, | |
| 3235 | .comptime_int, | |
| 3236 | .null, | |
| 3237 | .undefined, | |
| 3238 | .enum_literal, | |
| 3239 | .type_info, | |
| 3240 | 2969 | => return AbiAlignmentAdvanced{ .scalar = 0 }, |
| 3241 | 2970 | |
| 3242 | .noreturn, | |
| 3243 | 2971 | .inferred_alloc_const, |
| 3244 | 2972 | .inferred_alloc_mut, |
| 3245 | 2973 | => unreachable, |
| 3246 | ||
| 3247 | .generic_poison => unreachable, | |
| 3248 | 2974 | } |
| 3249 | 2975 | } |
| 3250 | 2976 | |
| ... | ... | @@ -3422,26 +3148,12 @@ pub const Type = struct { |
| 3422 | 3148 | switch (ty.tag()) { |
| 3423 | 3149 | .function => unreachable, // represents machine code; not a pointer |
| 3424 | 3150 | .@"opaque" => unreachable, // no size available |
| 3425 | .noreturn => unreachable, | |
| 3426 | 3151 | .inferred_alloc_const => unreachable, |
| 3427 | 3152 | .inferred_alloc_mut => unreachable, |
| 3428 | .generic_poison => unreachable, | |
| 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, | |
| 3153 | ||
| 3441 | 3154 | .single_const_pointer_to_comptime_int, |
| 3442 | 3155 | .empty_struct_literal, |
| 3443 | 3156 | .empty_struct, |
| 3444 | .void, | |
| 3445 | 3157 | => return AbiSizeAdvanced{ .scalar = 0 }, |
| 3446 | 3158 | |
| 3447 | 3159 | .@"struct", .tuple, .anon_struct => switch (ty.containerLayout()) { |
| ... | ... | @@ -3496,13 +3208,6 @@ pub const Type = struct { |
| 3496 | 3208 | .u1, |
| 3497 | 3209 | .u8, |
| 3498 | 3210 | .i8, |
| 3499 | .bool, | |
| 3500 | .atomic_order, | |
| 3501 | .atomic_rmw_op, | |
| 3502 | .calling_convention, | |
| 3503 | .address_space, | |
| 3504 | .float_mode, | |
| 3505 | .reduce_op, | |
| 3506 | 3211 | => return AbiSizeAdvanced{ .scalar = 1 }, |
| 3507 | 3212 | |
| 3508 | 3213 | .array_u8 => return AbiSizeAdvanced{ .scalar = ty.castTag(.array_u8).?.data }, |
| ... | ... | @@ -3552,7 +3257,6 @@ pub const Type = struct { |
| 3552 | 3257 | return AbiSizeAdvanced{ .scalar = result }; |
| 3553 | 3258 | }, |
| 3554 | 3259 | |
| 3555 | .@"anyframe", | |
| 3556 | 3260 | .anyframe_T, |
| 3557 | 3261 | .optional_single_const_pointer, |
| 3558 | 3262 | .optional_single_mut_pointer, |
| ... | ... | @@ -3580,7 +3284,6 @@ pub const Type = struct { |
| 3580 | 3284 | |
| 3581 | 3285 | // TODO revisit this when we have the concept of the error tag type |
| 3582 | 3286 | .anyerror_void_error_union, |
| 3583 | .anyerror, | |
| 3584 | 3287 | .error_set_inferred, |
| 3585 | 3288 | .error_set, |
| 3586 | 3289 | .error_set_merged, |
| ... | ... | @@ -3758,6 +3461,7 @@ pub const Type = struct { |
| 3758 | 3461 | .undefined => unreachable, |
| 3759 | 3462 | .enum_literal => unreachable, |
| 3760 | 3463 | .generic_poison => unreachable, |
| 3464 | .var_args_param => unreachable, | |
| 3761 | 3465 | |
| 3762 | 3466 | .atomic_order => unreachable, // missing call to resolveTypeFields |
| 3763 | 3467 | .atomic_rmw_op => unreachable, // missing call to resolveTypeFields |
| ... | ... | @@ -3770,7 +3474,6 @@ pub const Type = struct { |
| 3770 | 3474 | .export_options => unreachable, // missing call to resolveTypeFields |
| 3771 | 3475 | .extern_options => unreachable, // missing call to resolveTypeFields |
| 3772 | 3476 | .type_info => unreachable, // missing call to resolveTypeFields |
| 3773 | .var_args_param => unreachable, | |
| 3774 | 3477 | }, |
| 3775 | 3478 | .struct_type => @panic("TODO"), |
| 3776 | 3479 | .union_type => @panic("TODO"), |
| ... | ... | @@ -3784,23 +3487,14 @@ pub const Type = struct { |
| 3784 | 3487 | |
| 3785 | 3488 | switch (ty.tag()) { |
| 3786 | 3489 | .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 | 3490 | .single_const_pointer_to_comptime_int => unreachable, |
| 3795 | 3491 | .empty_struct => unreachable, |
| 3796 | 3492 | .empty_struct_literal => unreachable, |
| 3797 | 3493 | .inferred_alloc_const => unreachable, |
| 3798 | 3494 | .inferred_alloc_mut => unreachable, |
| 3799 | 3495 | .@"opaque" => unreachable, |
| 3800 | .generic_poison => unreachable, | |
| 3801 | 3496 | |
| 3802 | .void => return 0, | |
| 3803 | .bool, .u1 => return 1, | |
| 3497 | .u1 => return 1, | |
| 3804 | 3498 | .u8, .i8 => return 8, |
| 3805 | 3499 | .i16, .u16 => return 16, |
| 3806 | 3500 | .u29 => return 29, |
| ... | ... | @@ -3875,9 +3569,7 @@ pub const Type = struct { |
| 3875 | 3569 | return payload.len * 8 * elem_size + elem_bit_size; |
| 3876 | 3570 | }, |
| 3877 | 3571 | |
| 3878 | .@"anyframe", | |
| 3879 | .anyframe_T, | |
| 3880 | => return target.ptrBitWidth(), | |
| 3572 | .anyframe_T => return target.ptrBitWidth(), | |
| 3881 | 3573 | |
| 3882 | 3574 | .const_slice, |
| 3883 | 3575 | .mut_slice, |
| ... | ... | @@ -3916,7 +3608,6 @@ pub const Type = struct { |
| 3916 | 3608 | .error_set, |
| 3917 | 3609 | .error_set_single, |
| 3918 | 3610 | .anyerror_void_error_union, |
| 3919 | .anyerror, | |
| 3920 | 3611 | .error_set_inferred, |
| 3921 | 3612 | .error_set_merged, |
| 3922 | 3613 | => return 16, // TODO revisit this when we have the concept of the error tag type |
| ... | ... | @@ -3926,19 +3617,6 @@ pub const Type = struct { |
| 3926 | 3617 | // includes padding bits. |
| 3927 | 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 | } |
| 3944 | 3622 | |
| ... | ... | @@ -4326,7 +4004,7 @@ pub const Type = struct { |
| 4326 | 4004 | .manyptr_const_u8_sentinel_0, |
| 4327 | 4005 | => Type.u8, |
| 4328 | 4006 | |
| 4329 | .single_const_pointer_to_comptime_int => Type.initTag(.comptime_int), | |
| 4007 | .single_const_pointer_to_comptime_int => Type.comptime_int, | |
| 4330 | 4008 | .pointer => ty.castTag(.pointer).?.data.pointee_type, |
| 4331 | 4009 | |
| 4332 | 4010 | else => unreachable, |
| ... | ... | @@ -4372,7 +4050,7 @@ pub const Type = struct { |
| 4372 | 4050 | .manyptr_const_u8_sentinel_0, |
| 4373 | 4051 | => Type.u8, |
| 4374 | 4052 | |
| 4375 | .single_const_pointer_to_comptime_int => Type.initTag(.comptime_int), | |
| 4053 | .single_const_pointer_to_comptime_int => Type.comptime_int, | |
| 4376 | 4054 | .pointer => { |
| 4377 | 4055 | const info = ty.castTag(.pointer).?.data; |
| 4378 | 4056 | const child_ty = info.pointee_type; |
| ... | ... | @@ -4387,7 +4065,6 @@ pub const Type = struct { |
| 4387 | 4065 | .optional_single_const_pointer => ty.castPointer().?.data, |
| 4388 | 4066 | |
| 4389 | 4067 | .anyframe_T => ty.castTag(.anyframe_T).?.data, |
| 4390 | .@"anyframe" => Type.void, | |
| 4391 | 4068 | |
| 4392 | 4069 | else => unreachable, |
| 4393 | 4070 | }; |
| ... | ... | @@ -4468,19 +4145,6 @@ pub const Type = struct { |
| 4468 | 4145 | return union_obj.tag_ty; |
| 4469 | 4146 | }, |
| 4470 | 4147 | |
| 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 | 4148 | else => null, |
| 4485 | 4149 | }; |
| 4486 | 4150 | } |
| ... | ... | @@ -4495,19 +4159,6 @@ pub const Type = struct { |
| 4495 | 4159 | return union_obj.tag_ty; |
| 4496 | 4160 | }, |
| 4497 | 4161 | |
| 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 | 4162 | else => null, |
| 4512 | 4163 | }; |
| 4513 | 4164 | } |
| ... | ... | @@ -4572,7 +4223,7 @@ pub const Type = struct { |
| 4572 | 4223 | /// Asserts that the type is an error union. |
| 4573 | 4224 | pub fn errorUnionPayload(self: Type) Type { |
| 4574 | 4225 | return switch (self.tag()) { |
| 4575 | .anyerror_void_error_union => Type.initTag(.void), | |
| 4226 | .anyerror_void_error_union => Type.void, | |
| 4576 | 4227 | .error_union => self.castTag(.error_union).?.data.payload, |
| 4577 | 4228 | else => unreachable, |
| 4578 | 4229 | }; |
| ... | ... | @@ -4580,33 +4231,38 @@ pub const Type = struct { |
| 4580 | 4231 | |
| 4581 | 4232 | pub fn errorUnionSet(self: Type) Type { |
| 4582 | 4233 | return switch (self.tag()) { |
| 4583 | .anyerror_void_error_union => Type.initTag(.anyerror), | |
| 4234 | .anyerror_void_error_union => Type.anyerror, | |
| 4584 | 4235 | .error_union => self.castTag(.error_union).?.data.error_set, |
| 4585 | 4236 | else => unreachable, |
| 4586 | 4237 | }; |
| 4587 | 4238 | } |
| 4588 | 4239 | |
| 4589 | 4240 | /// Returns false for unresolved inferred error sets. |
| 4590 | pub fn errorSetIsEmpty(ty: Type) bool { | |
| 4591 | switch (ty.tag()) { | |
| 4592 | .anyerror => return false, | |
| 4593 | .error_set_inferred => { | |
| 4594 | const inferred_error_set = ty.castTag(.error_set_inferred).?.data; | |
| 4595 | // Can't know for sure. | |
| 4596 | if (!inferred_error_set.is_resolved) return false; | |
| 4597 | if (inferred_error_set.is_anyerror) return false; | |
| 4598 | return inferred_error_set.errors.count() == 0; | |
| 4599 | }, | |
| 4600 | .error_set_single => return false, | |
| 4601 | .error_set => { | |
| 4602 | const err_set_obj = ty.castTag(.error_set).?.data; | |
| 4603 | return err_set_obj.names.count() == 0; | |
| 4241 | pub fn errorSetIsEmpty(ty: Type, mod: *const Module) bool { | |
| 4242 | switch (ty.ip_index) { | |
| 4243 | .none => switch (ty.tag()) { | |
| 4244 | .error_set_inferred => { | |
| 4245 | const inferred_error_set = ty.castTag(.error_set_inferred).?.data; | |
| 4246 | // Can't know for sure. | |
| 4247 | if (!inferred_error_set.is_resolved) return false; | |
| 4248 | if (inferred_error_set.is_anyerror) return false; | |
| 4249 | return inferred_error_set.errors.count() == 0; | |
| 4250 | }, | |
| 4251 | .error_set_single => return false, | |
| 4252 | .error_set => { | |
| 4253 | const err_set_obj = ty.castTag(.error_set).?.data; | |
| 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 => { | |
| 4606 | const name_map = ty.castTag(.error_set_merged).?.data; | |
| 4607 | return name_map.count() == 0; | |
| 4262 | .anyerror_type => return false, | |
| 4263 | else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { | |
| 4264 | else => @panic("TODO"), | |
| 4608 | 4265 | }, |
| 4609 | else => unreachable, | |
| 4610 | 4266 | } |
| 4611 | 4267 | } |
| 4612 | 4268 | |
| ... | ... | @@ -4614,9 +4270,13 @@ pub const Type = struct { |
| 4614 | 4270 | /// Note that the result may be a false negative if the type did not get error set |
| 4615 | 4271 | /// resolution prior to this call. |
| 4616 | 4272 | pub fn isAnyError(ty: Type) bool { |
| 4617 | return switch (ty.tag()) { | |
| 4618 | .anyerror => true, | |
| 4619 | .error_set_inferred => ty.castTag(.error_set_inferred).?.data.is_anyerror, | |
| 4273 | return switch (ty.ip_index) { | |
| 4274 | .none => switch (ty.tag()) { | |
| 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 | 4280 | else => false, |
| 4621 | 4281 | }; |
| 4622 | 4282 | } |
| ... | ... | @@ -4788,72 +4448,75 @@ pub const Type = struct { |
| 4788 | 4448 | const target = mod.getTarget(); |
| 4789 | 4449 | var ty = starting_ty; |
| 4790 | 4450 | |
| 4791 | if (ty.ip_index != .none) switch (mod.intern_pool.indexToKey(ty.ip_index)) { | |
| 4792 | .int_type => |int_type| return int_type, | |
| 4793 | .ptr_type => unreachable, | |
| 4794 | .array_type => unreachable, | |
| 4795 | .vector_type => @panic("TODO"), | |
| 4796 | .optional_type => unreachable, | |
| 4797 | .error_union_type => unreachable, | |
| 4798 | .simple_type => |t| switch (t) { | |
| 4799 | .usize => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() }, | |
| 4800 | .isize => return .{ .signedness = .signed, .bits = target.ptrBitWidth() }, | |
| 4801 | .c_char => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) }, | |
| 4802 | .c_short => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) }, | |
| 4803 | .c_ushort => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) }, | |
| 4804 | .c_int => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) }, | |
| 4805 | .c_uint => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.uint) }, | |
| 4806 | .c_long => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.long) }, | |
| 4807 | .c_ulong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulong) }, | |
| 4808 | .c_longlong => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longlong) }, | |
| 4809 | .c_ulonglong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) }, | |
| 4810 | else => unreachable, | |
| 4811 | }, | |
| 4812 | .struct_type => @panic("TODO"), | |
| 4813 | .union_type => unreachable, | |
| 4814 | .simple_value => unreachable, | |
| 4815 | .extern_func => unreachable, | |
| 4816 | .int => unreachable, | |
| 4817 | .enum_tag => unreachable, // it's a value, not a type | |
| 4818 | }; | |
| 4451 | while (true) switch (ty.ip_index) { | |
| 4452 | .none => switch (ty.tag()) { | |
| 4453 | .u1 => return .{ .signedness = .unsigned, .bits = 1 }, | |
| 4454 | .u8 => return .{ .signedness = .unsigned, .bits = 8 }, | |
| 4455 | .i8 => return .{ .signedness = .signed, .bits = 8 }, | |
| 4456 | .u16 => return .{ .signedness = .unsigned, .bits = 16 }, | |
| 4457 | .i16 => return .{ .signedness = .signed, .bits = 16 }, | |
| 4458 | .u29 => return .{ .signedness = .unsigned, .bits = 29 }, | |
| 4459 | .u32 => return .{ .signedness = .unsigned, .bits = 32 }, | |
| 4460 | .i32 => return .{ .signedness = .signed, .bits = 32 }, | |
| 4461 | .u64 => return .{ .signedness = .unsigned, .bits = 64 }, | |
| 4462 | .i64 => return .{ .signedness = .signed, .bits = 64 }, | |
| 4463 | .u128 => return .{ .signedness = .unsigned, .bits = 128 }, | |
| 4464 | .i128 => return .{ .signedness = .signed, .bits = 128 }, | |
| 4465 | ||
| 4466 | .enum_full, .enum_nonexhaustive => ty = ty.cast(Payload.EnumFull).?.data.tag_ty, | |
| 4467 | .enum_numbered => ty = ty.castTag(.enum_numbered).?.data.tag_ty, | |
| 4468 | .enum_simple => { | |
| 4469 | const enum_obj = ty.castTag(.enum_simple).?.data; | |
| 4470 | const field_count = enum_obj.fields.count(); | |
| 4471 | if (field_count == 0) return .{ .signedness = .unsigned, .bits = 0 }; | |
| 4472 | return .{ .signedness = .unsigned, .bits = smallestUnsignedBits(field_count - 1) }; | |
| 4473 | }, | |
| 4819 | 4474 | |
| 4820 | while (true) switch (ty.tag()) { | |
| 4821 | .u1 => return .{ .signedness = .unsigned, .bits = 1 }, | |
| 4822 | .u8 => return .{ .signedness = .unsigned, .bits = 8 }, | |
| 4823 | .i8 => return .{ .signedness = .signed, .bits = 8 }, | |
| 4824 | .u16 => return .{ .signedness = .unsigned, .bits = 16 }, | |
| 4825 | .i16 => return .{ .signedness = .signed, .bits = 16 }, | |
| 4826 | .u29 => return .{ .signedness = .unsigned, .bits = 29 }, | |
| 4827 | .u32 => return .{ .signedness = .unsigned, .bits = 32 }, | |
| 4828 | .i32 => return .{ .signedness = .signed, .bits = 32 }, | |
| 4829 | .u64 => return .{ .signedness = .unsigned, .bits = 64 }, | |
| 4830 | .i64 => return .{ .signedness = .signed, .bits = 64 }, | |
| 4831 | .u128 => return .{ .signedness = .unsigned, .bits = 128 }, | |
| 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 | }, | |
| 4475 | .error_set, .error_set_single, .error_set_inferred, .error_set_merged => { | |
| 4476 | // TODO revisit this when error sets support custom int types | |
| 4477 | return .{ .signedness = .unsigned, .bits = 16 }; | |
| 4478 | }, | |
| 4479 | ||
| 4480 | .vector => ty = ty.castTag(.vector).?.data.elem_type, | |
| 4481 | ||
| 4482 | .@"struct" => { | |
| 4483 | const struct_obj = ty.castTag(.@"struct").?.data; | |
| 4484 | assert(struct_obj.layout == .Packed); | |
| 4485 | ty = struct_obj.backing_int_ty; | |
| 4486 | }, | |
| 4842 | 4487 | |
| 4843 | .error_set, .error_set_single, .anyerror, .error_set_inferred, .error_set_merged => { | |
| 4488 | else => unreachable, | |
| 4489 | }, | |
| 4490 | .anyerror_type => { | |
| 4844 | 4491 | // TODO revisit this when error sets support custom int types |
| 4845 | 4492 | return .{ .signedness = .unsigned, .bits = 16 }; |
| 4846 | 4493 | }, |
| 4847 | ||
| 4848 | .vector => ty = ty.castTag(.vector).?.data.elem_type, | |
| 4849 | ||
| 4850 | .@"struct" => { | |
| 4851 | const struct_obj = ty.castTag(.@"struct").?.data; | |
| 4852 | assert(struct_obj.layout == .Packed); | |
| 4853 | ty = struct_obj.backing_int_ty; | |
| 4494 | .usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() }, | |
| 4495 | .isize_type => return .{ .signedness = .signed, .bits = target.ptrBitWidth() }, | |
| 4496 | .c_char_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) }, | |
| 4497 | .c_short_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) }, | |
| 4498 | .c_ushort_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) }, | |
| 4499 | .c_int_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) }, | |
| 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 | } |
| 4859 | 4522 | |
| ... | ... | @@ -5021,7 +4684,6 @@ pub const Type = struct { |
| 5021 | 4684 | else => false, |
| 5022 | 4685 | }; |
| 5023 | 4686 | return switch (ty.tag()) { |
| 5024 | .comptime_int, | |
| 5025 | 4687 | .u1, |
| 5026 | 4688 | .u8, |
| 5027 | 4689 | .i8, |
| ... | ... | @@ -5114,7 +4776,6 @@ pub const Type = struct { |
| 5114 | 4776 | }; |
| 5115 | 4777 | |
| 5116 | 4778 | while (true) switch (ty.tag()) { |
| 5117 | .comptime_int, | |
| 5118 | 4779 | .u1, |
| 5119 | 4780 | .u8, |
| 5120 | 4781 | .i8, |
| ... | ... | @@ -5127,9 +4788,7 @@ pub const Type = struct { |
| 5127 | 4788 | .i64, |
| 5128 | 4789 | .u128, |
| 5129 | 4790 | .i128, |
| 5130 | .bool, | |
| 5131 | .type, | |
| 5132 | .anyerror, | |
| 4791 | ||
| 5133 | 4792 | .error_union, |
| 5134 | 4793 | .error_set_single, |
| 5135 | 4794 | .error_set, |
| ... | ... | @@ -5142,28 +4801,14 @@ pub const Type = struct { |
| 5142 | 4801 | .const_slice_u8_sentinel_0, |
| 5143 | 4802 | .const_slice, |
| 5144 | 4803 | .mut_slice, |
| 5145 | .anyopaque, | |
| 5146 | 4804 | .optional_single_mut_pointer, |
| 5147 | 4805 | .optional_single_const_pointer, |
| 5148 | .enum_literal, | |
| 5149 | 4806 | .anyerror_void_error_union, |
| 5150 | 4807 | .error_set_inferred, |
| 5151 | 4808 | .@"opaque", |
| 5152 | 4809 | .manyptr_u8, |
| 5153 | 4810 | .manyptr_const_u8, |
| 5154 | 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 | 4812 | .anyframe_T, |
| 5168 | 4813 | .many_const_pointer, |
| 5169 | 4814 | .many_mut_pointer, |
| ... | ... | @@ -5258,10 +4903,6 @@ pub const Type = struct { |
| 5258 | 4903 | }, |
| 5259 | 4904 | |
| 5260 | 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), | |
| 5265 | 4906 | |
| 5266 | 4907 | .vector, .array, .array_u8 => { |
| 5267 | 4908 | if (ty.arrayLen() == 0) |
| ... | ... | @@ -5273,7 +4914,6 @@ pub const Type = struct { |
| 5273 | 4914 | |
| 5274 | 4915 | .inferred_alloc_const => unreachable, |
| 5275 | 4916 | .inferred_alloc_mut => unreachable, |
| 5276 | .generic_poison => unreachable, | |
| 5277 | 4917 | }; |
| 5278 | 4918 | } |
| 5279 | 4919 | |
| ... | ... | @@ -5358,22 +4998,7 @@ pub const Type = struct { |
| 5358 | 4998 | .i64, |
| 5359 | 4999 | .u128, |
| 5360 | 5000 | .i128, |
| 5361 | .anyopaque, | |
| 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, | |
| 5001 | ||
| 5377 | 5002 | .manyptr_u8, |
| 5378 | 5003 | .manyptr_const_u8, |
| 5379 | 5004 | .manyptr_const_u8_sentinel_0, |
| ... | ... | @@ -5387,21 +5012,14 @@ pub const Type = struct { |
| 5387 | 5012 | .error_set_inferred, |
| 5388 | 5013 | .error_set_merged, |
| 5389 | 5014 | .@"opaque", |
| 5390 | .generic_poison, | |
| 5391 | 5015 | .array_u8, |
| 5392 | 5016 | .array_u8_sentinel_0, |
| 5393 | 5017 | .enum_simple, |
| 5394 | 5018 | => false, |
| 5395 | 5019 | |
| 5396 | 5020 | .single_const_pointer_to_comptime_int, |
| 5397 | .type, | |
| 5398 | .comptime_int, | |
| 5399 | .enum_literal, | |
| 5400 | .type_info, | |
| 5401 | 5021 | // These are function bodies, not function pointers. |
| 5402 | 5022 | .function, |
| 5403 | .null, | |
| 5404 | .undefined, | |
| 5405 | 5023 | => true, |
| 5406 | 5024 | |
| 5407 | 5025 | .inferred_alloc_mut => unreachable, |
| ... | ... | @@ -5701,17 +5319,6 @@ pub const Type = struct { |
| 5701 | 5319 | .enum_full, .enum_nonexhaustive => ty.cast(Payload.EnumFull).?.data.fields, |
| 5702 | 5320 | .enum_simple => ty.castTag(.enum_simple).?.data.fields, |
| 5703 | 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 | 5322 | else => unreachable, |
| 5716 | 5323 | }; |
| 5717 | 5324 | } |
| ... | ... | @@ -5779,17 +5386,6 @@ pub const Type = struct { |
| 5779 | 5386 | const tag_ty = mod.intType(.unsigned, bits) catch @panic("TODO: handle OOM here"); |
| 5780 | 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 | 5389 | else => unreachable, |
| 5794 | 5390 | } |
| 5795 | 5391 | } |
| ... | ... | @@ -6102,18 +5698,6 @@ pub const Type = struct { |
| 6102 | 5698 | const opaque_obj = ty.cast(Payload.Opaque).?.data; |
| 6103 | 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 | |
| 6117 | 5701 | |
| 6118 | 5702 | else => return null, |
| 6119 | 5703 | } |
| ... | ... | @@ -6150,29 +5734,17 @@ pub const Type = struct { |
| 6150 | 5734 | const opaque_obj = ty.cast(Payload.Opaque).?.data; |
| 6151 | 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. | |
| 6165 | 5737 | |
| 6166 | 5738 | else => return null, |
| 6167 | 5739 | } |
| 6168 | 5740 | } |
| 6169 | 5741 | |
| 6170 | 5742 | pub fn isGenericPoison(ty: Type) bool { |
| 6171 | return switch (ty.ip_index) { | |
| 6172 | .generic_poison_type => true, | |
| 6173 | .none => ty.tag() == .generic_poison, | |
| 6174 | else => false, | |
| 6175 | }; | |
| 5743 | return ty.ip_index == .generic_poison_type; | |
| 5744 | } | |
| 5745 | ||
| 5746 | pub fn isVarArgsParam(ty: Type) bool { | |
| 5747 | return ty.ip_index == .none and ty.tag() == .var_args_param; | |
| 6176 | 5748 | } |
| 6177 | 5749 | |
| 6178 | 5750 | /// This enum does not directly correspond to `std.builtin.TypeId` because |
| ... | ... | @@ -6195,28 +5767,7 @@ pub const Type = struct { |
| 6195 | 5767 | i64, |
| 6196 | 5768 | u128, |
| 6197 | 5769 | i128, |
| 6198 | anyopaque, | |
| 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, | |
| 5770 | ||
| 6220 | 5771 | manyptr_u8, |
| 6221 | 5772 | manyptr_const_u8, |
| 6222 | 5773 | manyptr_const_u8_sentinel_0, |
| ... | ... | @@ -6224,7 +5775,6 @@ pub const Type = struct { |
| 6224 | 5775 | const_slice_u8, |
| 6225 | 5776 | const_slice_u8_sentinel_0, |
| 6226 | 5777 | anyerror_void_error_union, |
| 6227 | generic_poison, | |
| 6228 | 5778 | /// Same as `empty_struct` except it has an empty namespace. |
| 6229 | 5779 | empty_struct_literal, |
| 6230 | 5780 | /// This is a special value that tracks a set of types that have been stored |
| ... | ... | @@ -6292,39 +5842,17 @@ pub const Type = struct { |
| 6292 | 5842 | .i64, |
| 6293 | 5843 | .u128, |
| 6294 | 5844 | .i128, |
| 6295 | .anyopaque, | |
| 6296 | .bool, | |
| 6297 | .void, | |
| 6298 | .type, | |
| 6299 | .anyerror, | |
| 6300 | .comptime_int, | |
| 6301 | .noreturn, | |
| 6302 | .enum_literal, | |
| 6303 | .null, | |
| 6304 | .undefined, | |
| 5845 | ||
| 6305 | 5846 | .single_const_pointer_to_comptime_int, |
| 6306 | 5847 | .anyerror_void_error_union, |
| 6307 | 5848 | .const_slice_u8, |
| 6308 | 5849 | .const_slice_u8_sentinel_0, |
| 6309 | .generic_poison, | |
| 6310 | 5850 | .inferred_alloc_const, |
| 6311 | 5851 | .inferred_alloc_mut, |
| 6312 | 5852 | .empty_struct_literal, |
| 6313 | 5853 | .manyptr_u8, |
| 6314 | 5854 | .manyptr_const_u8, |
| 6315 | 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 | 5856 | => @compileError("Type Tag " ++ @tagName(t) ++ " has no payload"), |
| 6329 | 5857 | |
| 6330 | 5858 | .array_u8, |
| ... | ... | @@ -6674,18 +6202,19 @@ pub const Type = struct { |
| 6674 | 6202 | pub const @"f80": Type = .{ .ip_index = .f80_type, .legacy = undefined }; |
| 6675 | 6203 | pub const @"f128": Type = .{ .ip_index = .f128_type, .legacy = undefined }; |
| 6676 | 6204 | |
| 6677 | pub const @"bool" = initTag(.bool); | |
| 6205 | pub const @"bool": Type = .{ .ip_index = .bool_type, .legacy = undefined }; | |
| 6678 | 6206 | pub const @"usize": Type = .{ .ip_index = .usize_type, .legacy = undefined }; |
| 6679 | 6207 | pub const @"isize": Type = .{ .ip_index = .isize_type, .legacy = undefined }; |
| 6680 | 6208 | pub const @"comptime_int": Type = .{ .ip_index = .comptime_int_type, .legacy = undefined }; |
| 6681 | 6209 | pub const @"comptime_float": Type = .{ .ip_index = .comptime_float_type, .legacy = undefined }; |
| 6682 | pub const @"void" = initTag(.void); | |
| 6683 | pub const @"type" = initTag(.type); | |
| 6684 | pub const @"anyerror" = initTag(.anyerror); | |
| 6685 | pub const @"anyopaque" = initTag(.anyopaque); | |
| 6686 | pub const @"null" = initTag(.null); | |
| 6687 | pub const @"undefined" = initTag(.undefined); | |
| 6688 | pub const @"noreturn" = initTag(.noreturn); | |
| 6210 | pub const @"void": Type = .{ .ip_index = .void_type, .legacy = undefined }; | |
| 6211 | pub const @"type": Type = .{ .ip_index = .type_type, .legacy = undefined }; | |
| 6212 | pub const @"anyerror": Type = .{ .ip_index = .anyerror_type, .legacy = undefined }; | |
| 6213 | pub const @"anyopaque": Type = .{ .ip_index = .anyopaque_type, .legacy = undefined }; | |
| 6214 | pub const @"anyframe": Type = .{ .ip_index = .anyframe_type, .legacy = undefined }; | |
| 6215 | pub const @"null": Type = .{ .ip_index = .null_type, .legacy = undefined }; | |
| 6216 | pub const @"undefined": Type = .{ .ip_index = .undefined_type, .legacy = undefined }; | |
| 6217 | pub const @"noreturn": Type = .{ .ip_index = .noreturn_type, .legacy = undefined }; | |
| 6689 | 6218 | |
| 6690 | 6219 | pub const @"c_char": Type = .{ .ip_index = .c_char_type, .legacy = undefined }; |
| 6691 | 6220 | pub const @"c_short": Type = .{ .ip_index = .c_short_type, .legacy = undefined }; |
| ... | ... | @@ -6698,6 +6227,8 @@ pub const Type = struct { |
| 6698 | 6227 | pub const @"c_ulonglong": Type = .{ .ip_index = .c_ulonglong_type, .legacy = undefined }; |
| 6699 | 6228 | pub const @"c_longdouble": Type = .{ .ip_index = .c_longdouble_type, .legacy = undefined }; |
| 6700 | 6229 | |
| 6230 | pub const generic_poison: Type = .{ .ip_index = .generic_poison_type, .legacy = undefined }; | |
| 6231 | ||
| 6701 | 6232 | pub const err_int = Type.u16; |
| 6702 | 6233 | |
| 6703 | 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 | 991 | .null_type => Type.null, |
| 992 | 992 | .undefined_type => Type.undefined, |
| 993 | 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 | 995 | .const_slice_u8_type => Type.initTag(.const_slice_u8), |
| 996 | 996 | .const_slice_u8_sentinel_0_type => Type.initTag(.const_slice_u8_sentinel_0), |
| 997 | 997 | .anyerror_void_error_union_type => Type.initTag(.anyerror_void_error_union), |
| 998 | .generic_poison_type => Type.initTag(.generic_poison), | |
| 999 | .enum_literal_type => Type.initTag(.enum_literal), | |
| 998 | .generic_poison_type => .{ .ip_index = .generic_poison_type, .legacy = undefined }, | |
| 999 | .enum_literal_type => .{ .ip_index = .enum_literal_type, .legacy = undefined }, | |
| 1000 | 1000 | .manyptr_u8_type => Type.initTag(.manyptr_u8), |
| 1001 | 1001 | .manyptr_const_u8_type => Type.initTag(.manyptr_const_u8), |
| 1002 | 1002 | .manyptr_const_u8_sentinel_0_type => Type.initTag(.manyptr_const_u8_sentinel_0), |
| 1003 | .atomic_order_type => Type.initTag(.atomic_order), | |
| 1004 | .atomic_rmw_op_type => Type.initTag(.atomic_rmw_op), | |
| 1005 | .calling_convention_type => Type.initTag(.calling_convention), | |
| 1006 | .address_space_type => Type.initTag(.address_space), | |
| 1007 | .float_mode_type => Type.initTag(.float_mode), | |
| 1008 | .reduce_op_type => Type.initTag(.reduce_op), | |
| 1009 | .modifier_type => Type.initTag(.modifier), | |
| 1010 | .prefetch_options_type => Type.initTag(.prefetch_options), | |
| 1011 | .export_options_type => Type.initTag(.export_options), | |
| 1012 | .extern_options_type => Type.initTag(.extern_options), | |
| 1013 | .type_info_type => Type.initTag(.type_info), | |
| 1003 | .atomic_order_type => .{ .ip_index = .atomic_order_type, .legacy = undefined }, | |
| 1004 | .atomic_rmw_op_type => .{ .ip_index = .atomic_rmw_op_type, .legacy = undefined }, | |
| 1005 | .calling_convention_type => .{ .ip_index = .calling_convention_type, .legacy = undefined }, | |
| 1006 | .address_space_type => .{ .ip_index = .address_space_type, .legacy = undefined }, | |
| 1007 | .float_mode_type => .{ .ip_index = .float_mode_type, .legacy = undefined }, | |
| 1008 | .reduce_op_type => .{ .ip_index = .reduce_op_type, .legacy = undefined }, | |
| 1009 | .modifier_type => .{ .ip_index = .call_modifier_type, .legacy = undefined }, | |
| 1010 | .prefetch_options_type => .{ .ip_index = .prefetch_options_type, .legacy = undefined }, | |
| 1011 | .export_options_type => .{ .ip_index = .export_options_type, .legacy = undefined }, | |
| 1012 | .extern_options_type => .{ .ip_index = .extern_options_type, .legacy = undefined }, | |
| 1013 | .type_info_type => .{ .ip_index = .type_info_type, .legacy = undefined }, | |
| 1014 | 1014 | |
| 1015 | 1015 | else => unreachable, |
| 1016 | 1016 | }; |