| ... | ... | @@ -14209,10 +14209,10 @@ fn maybeErrorUnwrap( |
| 14209 | 14209 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 14210 | 14210 | const msg_inst = try sema.resolveInst(inst_data.operand); |
| 14211 | 14211 | |
| 14212 | | const panic_fn = try getBuiltinInnerAsInst(sema, block, operand_src, "Panic", "call"); |
| 14212 | const panic_fn = try getPanicInnerFn(sema, block, operand_src, "call"); |
| 14213 | 14213 | const err_return_trace = try sema.getErrorReturnTrace(block); |
| 14214 | 14214 | const args: [3]Air.Inst.Ref = .{ msg_inst, err_return_trace, .null_value }; |
| 14215 | | try sema.callBuiltin(block, operand_src, panic_fn, .auto, &args, .@"safety check"); |
| 14215 | try sema.callBuiltin(block, operand_src, Air.internedToRef(panic_fn), .auto, &args, .@"safety check"); |
| 14216 | 14216 | return true; |
| 14217 | 14217 | }, |
| 14218 | 14218 | else => unreachable, |
| ... | ... | @@ -18293,8 +18293,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18293 | 18293 | => |type_info_tag| return unionInitFromEnumTag(sema, block, src, type_info_ty, @intFromEnum(type_info_tag), .void_value), |
| 18294 | 18294 | |
| 18295 | 18295 | .@"fn" => { |
| 18296 | | const fn_info_ty = try getInnerType(sema, block, src, type_info_ty, "Fn"); |
| 18297 | | const param_info_ty = try getInnerType(sema, block, src, fn_info_ty, "Param"); |
| 18296 | const fn_info_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Fn"); |
| 18297 | const param_info_ty = try getBuiltinInnerType(sema, block, src, fn_info_ty, "Type.Fn", "Param"); |
| 18298 | 18298 | |
| 18299 | 18299 | const func_ty_info = zcu.typeToFunc(ty).?; |
| 18300 | 18300 | const param_vals = try sema.arena.alloc(InternPool.Index, func_ty_info.param_types.len); |
| ... | ... | @@ -18388,7 +18388,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18388 | 18388 | }))); |
| 18389 | 18389 | }, |
| 18390 | 18390 | .int => { |
| 18391 | | const int_info_ty = try getInnerType(sema, block, src, type_info_ty, "Int"); |
| 18391 | const int_info_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Int"); |
| 18392 | 18392 | const signedness_ty = try sema.getBuiltinType("Signedness"); |
| 18393 | 18393 | const info = ty.intInfo(zcu); |
| 18394 | 18394 | const field_values = .{ |
| ... | ... | @@ -18407,7 +18407,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18407 | 18407 | }))); |
| 18408 | 18408 | }, |
| 18409 | 18409 | .float => { |
| 18410 | | const float_info_ty = try getInnerType(sema, block, src, type_info_ty, "Float"); |
| 18410 | const float_info_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Float"); |
| 18411 | 18411 | |
| 18412 | 18412 | const field_vals = .{ |
| 18413 | 18413 | // bits: u16, |
| ... | ... | @@ -18430,8 +18430,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18430 | 18430 | try Type.fromInterned(info.child).lazyAbiAlignment(pt); |
| 18431 | 18431 | |
| 18432 | 18432 | const addrspace_ty = try sema.getBuiltinType("AddressSpace"); |
| 18433 | | const pointer_ty = try getInnerType(sema, block, src, type_info_ty, "Pointer"); |
| 18434 | | const ptr_size_ty = try getInnerType(sema, block, src, pointer_ty, "Size"); |
| 18433 | const pointer_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Pointer"); |
| 18434 | const ptr_size_ty = try getBuiltinInnerType(sema, block, src, pointer_ty, "Type.Pointer", "Size"); |
| 18435 | 18435 | |
| 18436 | 18436 | const field_values = .{ |
| 18437 | 18437 | // size: Size, |
| ... | ... | @@ -18464,7 +18464,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18464 | 18464 | }))); |
| 18465 | 18465 | }, |
| 18466 | 18466 | .array => { |
| 18467 | | const array_field_ty = try getInnerType(sema, block, src, type_info_ty, "Array"); |
| 18467 | const array_field_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Array"); |
| 18468 | 18468 | |
| 18469 | 18469 | const info = ty.arrayInfo(zcu); |
| 18470 | 18470 | const field_values = .{ |
| ... | ... | @@ -18485,7 +18485,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18485 | 18485 | }))); |
| 18486 | 18486 | }, |
| 18487 | 18487 | .vector => { |
| 18488 | | const vector_field_ty = try getInnerType(sema, block, src, type_info_ty, "Vector"); |
| 18488 | const vector_field_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Vector"); |
| 18489 | 18489 | |
| 18490 | 18490 | const info = ty.arrayInfo(zcu); |
| 18491 | 18491 | const field_values = .{ |
| ... | ... | @@ -18504,7 +18504,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18504 | 18504 | }))); |
| 18505 | 18505 | }, |
| 18506 | 18506 | .optional => { |
| 18507 | | const optional_field_ty = try getInnerType(sema, block, src, type_info_ty, "Optional"); |
| 18507 | const optional_field_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Optional"); |
| 18508 | 18508 | |
| 18509 | 18509 | const field_values = .{ |
| 18510 | 18510 | // child: type, |
| ... | ... | @@ -18521,7 +18521,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18521 | 18521 | }, |
| 18522 | 18522 | .error_set => { |
| 18523 | 18523 | // Get the Error type |
| 18524 | | const error_field_ty = try getInnerType(sema, block, src, type_info_ty, "Error"); |
| 18524 | const error_field_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Error"); |
| 18525 | 18525 | |
| 18526 | 18526 | // Build our list of Error values |
| 18527 | 18527 | // Optional value is only null if anyerror |
| ... | ... | @@ -18617,7 +18617,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18617 | 18617 | }))); |
| 18618 | 18618 | }, |
| 18619 | 18619 | .error_union => { |
| 18620 | | const error_union_field_ty = try getInnerType(sema, block, src, type_info_ty, "ErrorUnion"); |
| 18620 | const error_union_field_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "ErrorUnion"); |
| 18621 | 18621 | |
| 18622 | 18622 | const field_values = .{ |
| 18623 | 18623 | // error_set: type, |
| ... | ... | @@ -18637,7 +18637,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18637 | 18637 | .@"enum" => { |
| 18638 | 18638 | const is_exhaustive = Value.makeBool(ip.loadEnumType(ty.toIntern()).tag_mode != .nonexhaustive); |
| 18639 | 18639 | |
| 18640 | | const enum_field_ty = try getInnerType(sema, block, src, type_info_ty, "EnumField"); |
| 18640 | const enum_field_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "EnumField"); |
| 18641 | 18641 | |
| 18642 | 18642 | const enum_field_vals = try sema.arena.alloc(InternPool.Index, ip.loadEnumType(ty.toIntern()).names.len); |
| 18643 | 18643 | for (enum_field_vals, 0..) |*field_val, tag_index| { |
| ... | ... | @@ -18724,7 +18724,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18724 | 18724 | |
| 18725 | 18725 | const decls_val = try sema.typeInfoDecls(block, src, type_info_ty, ip.loadEnumType(ty.toIntern()).namespace.toOptional()); |
| 18726 | 18726 | |
| 18727 | | const type_enum_ty = try getInnerType(sema, block, src, type_info_ty, "Enum"); |
| 18727 | const type_enum_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Enum"); |
| 18728 | 18728 | |
| 18729 | 18729 | const field_values = .{ |
| 18730 | 18730 | // tag_type: type, |
| ... | ... | @@ -18746,8 +18746,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18746 | 18746 | }))); |
| 18747 | 18747 | }, |
| 18748 | 18748 | .@"union" => { |
| 18749 | | const type_union_ty = try getInnerType(sema, block, src, type_info_ty, "Union"); |
| 18750 | | const union_field_ty = try getInnerType(sema, block, src, type_info_ty, "UnionField"); |
| 18749 | const type_union_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Union"); |
| 18750 | const union_field_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "UnionField"); |
| 18751 | 18751 | |
| 18752 | 18752 | try ty.resolveLayout(pt); // Getting alignment requires type layout |
| 18753 | 18753 | const union_obj = zcu.typeToUnion(ty).?; |
| ... | ... | @@ -18842,7 +18842,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18842 | 18842 | .val = if (ty.unionTagType(zcu)) |tag_ty| tag_ty.toIntern() else .none, |
| 18843 | 18843 | } }); |
| 18844 | 18844 | |
| 18845 | | const container_layout_ty = try getBuiltinInnerType(sema, block, src, "Type", "ContainerLayout"); |
| 18845 | const container_layout_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "ContainerLayout"); |
| 18846 | 18846 | |
| 18847 | 18847 | const field_values = .{ |
| 18848 | 18848 | // layout: ContainerLayout, |
| ... | ... | @@ -18865,8 +18865,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18865 | 18865 | }))); |
| 18866 | 18866 | }, |
| 18867 | 18867 | .@"struct" => { |
| 18868 | | const type_struct_ty = try getInnerType(sema, block, src, type_info_ty, "Struct"); |
| 18869 | | const struct_field_ty = try getInnerType(sema, block, src, type_info_ty, "StructField"); |
| 18868 | const type_struct_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Struct"); |
| 18869 | const struct_field_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "StructField"); |
| 18870 | 18870 | |
| 18871 | 18871 | try ty.resolveLayout(pt); // Getting alignment requires type layout |
| 18872 | 18872 | |
| ... | ... | @@ -19043,7 +19043,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 19043 | 19043 | } else .none, |
| 19044 | 19044 | } }); |
| 19045 | 19045 | |
| 19046 | | const container_layout_ty = try getInnerType(sema, block, src, type_info_ty, "ContainerLayout"); |
| 19046 | const container_layout_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "ContainerLayout"); |
| 19047 | 19047 | |
| 19048 | 19048 | const layout = ty.containerLayout(zcu); |
| 19049 | 19049 | |
| ... | ... | @@ -19069,7 +19069,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 19069 | 19069 | }))); |
| 19070 | 19070 | }, |
| 19071 | 19071 | .@"opaque" => { |
| 19072 | | const type_opaque_ty = try getInnerType(sema, block, src, type_info_ty, "Opaque"); |
| 19072 | const type_opaque_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Opaque"); |
| 19073 | 19073 | |
| 19074 | 19074 | try ty.resolveFields(pt); |
| 19075 | 19075 | const decls_val = try sema.typeInfoDecls(block, src, type_info_ty, ty.getNamespace(zcu)); |
| ... | ... | @@ -19103,7 +19103,7 @@ fn typeInfoDecls( |
| 19103 | 19103 | const zcu = pt.zcu; |
| 19104 | 19104 | const gpa = sema.gpa; |
| 19105 | 19105 | |
| 19106 | | const declaration_ty = try getInnerType(sema, block, src, type_info_ty, "Declaration"); |
| 19106 | const declaration_ty = try getBuiltinInnerType(sema, block, src, type_info_ty, "Type", "Declaration"); |
| 19107 | 19107 | |
| 19108 | 19108 | var decl_vals = std.ArrayList(InternPool.Index).init(gpa); |
| 19109 | 19109 | defer decl_vals.deinit(); |
| ... | ... | @@ -27639,14 +27639,10 @@ fn prepareSimplePanic(sema: *Sema, block: *Block, src: LazySrcLoc) !void { |
| 27639 | 27639 | const zcu = pt.zcu; |
| 27640 | 27640 | |
| 27641 | 27641 | if (zcu.panic_func_index == .none) { |
| 27642 | | const fn_ref = try sema.getBuiltinInnerAsInst(block, src, "Panic", "call"); |
| 27643 | | const fn_val = try sema.resolveConstValue(block, src, fn_ref, .{ |
| 27644 | | .needed_comptime_reason = "panic handler must be comptime-known", |
| 27645 | | }); |
| 27646 | | assert(fn_val.typeOf(zcu).zigTypeTag(zcu) == .@"fn"); |
| 27647 | | assert(try fn_val.typeOf(zcu).fnHasRuntimeBitsSema(pt)); |
| 27648 | | try zcu.ensureFuncBodyAnalysisQueued(fn_val.toIntern()); |
| 27649 | | zcu.panic_func_index = fn_val.toIntern(); |
| 27642 | zcu.panic_func_index = try sema.getPanicInnerFn(block, src, "call"); |
| 27643 | // Here, function body analysis must be queued up so that backends can |
| 27644 | // make calls to this function. |
| 27645 | try zcu.ensureFuncBodyAnalysisQueued(zcu.panic_func_index); |
| 27650 | 27646 | } |
| 27651 | 27647 | |
| 27652 | 27648 | if (zcu.null_stack_trace == .none) { |
| ... | ... | @@ -27678,14 +27674,15 @@ fn preparePanicId(sema: *Sema, block: *Block, src: LazySrcLoc, panic_id: Zcu.Pan |
| 27678 | 27674 | |
| 27679 | 27675 | try sema.prepareSimplePanic(block, src); |
| 27680 | 27676 | |
| 27681 | | const panic_messages_ty = try sema.getBuiltinType("panic_messages"); |
| 27677 | const panic_ty = try sema.getBuiltinType("Panic"); |
| 27678 | const panic_messages_ty = try sema.getBuiltinInnerType(block, src, panic_ty, "Panic", "messages"); |
| 27682 | 27679 | const msg_nav_index = (sema.namespaceLookup( |
| 27683 | 27680 | block, |
| 27684 | 27681 | LazySrcLoc.unneeded, |
| 27685 | 27682 | panic_messages_ty.getNamespaceIndex(zcu), |
| 27686 | 27683 | try zcu.intern_pool.getOrPutString(gpa, pt.tid, @tagName(panic_id), .no_embedded_nulls), |
| 27687 | 27684 | ) catch |err| switch (err) { |
| 27688 | | error.AnalysisFail => @panic("std.builtin.panic_messages is corrupt"), |
| 27685 | error.AnalysisFail => return error.AnalysisFail, |
| 27689 | 27686 | error.GenericPoison, error.ComptimeReturn, error.ComptimeBreak => unreachable, |
| 27690 | 27687 | error.OutOfMemory => |e| return e, |
| 27691 | 27688 | }).?; |
| ... | ... | @@ -27846,10 +27843,10 @@ fn safetyPanicUnwrapError(sema: *Sema, block: *Block, src: LazySrcLoc, err: Air. |
| 27846 | 27843 | if (!zcu.backendSupportsFeature(.panic_fn)) { |
| 27847 | 27844 | _ = try block.addNoOp(.trap); |
| 27848 | 27845 | } else { |
| 27849 | | const panic_fn = try getBuiltinInnerAsInst(sema, block, src, "Panic", "unwrapError"); |
| 27846 | const panic_fn = try getPanicInnerFn(sema, block, src, "unwrapError"); |
| 27850 | 27847 | const err_return_trace = try sema.getErrorReturnTrace(block); |
| 27851 | 27848 | const args: [2]Air.Inst.Ref = .{ err_return_trace, err }; |
| 27852 | | try sema.callBuiltin(block, src, panic_fn, .auto, &args, .@"safety check"); |
| 27849 | try sema.callBuiltin(block, src, Air.internedToRef(panic_fn), .auto, &args, .@"safety check"); |
| 27853 | 27850 | } |
| 27854 | 27851 | } |
| 27855 | 27852 | |
| ... | ... | @@ -27950,8 +27947,8 @@ fn addSafetyCheckCall( |
| 27950 | 27947 | if (!zcu.backendSupportsFeature(.panic_fn)) { |
| 27951 | 27948 | _ = try fail_block.addNoOp(.trap); |
| 27952 | 27949 | } else { |
| 27953 | | const panic_fn = try getBuiltinInnerAsInst(sema, &fail_block, src, "Panic", func_name); |
| 27954 | | try sema.callBuiltin(&fail_block, src, panic_fn, .auto, args, .@"safety check"); |
| 27950 | const panic_fn = try getPanicInnerFn(sema, &fail_block, src, func_name); |
| 27951 | try sema.callBuiltin(&fail_block, src, Air.internedToRef(panic_fn), .auto, args, .@"safety check"); |
| 27955 | 27952 | } |
| 27956 | 27953 | |
| 27957 | 27954 | try sema.addSafetyCheckExtra(parent_block, ok, &fail_block); |
| ... | ... | @@ -38908,61 +38905,62 @@ const ComptimeLoadResult = @import("Sema/comptime_ptr_access.zig").ComptimeLoadR |
| 38908 | 38905 | const storeComptimePtr = @import("Sema/comptime_ptr_access.zig").storeComptimePtr; |
| 38909 | 38906 | const ComptimeStoreResult = @import("Sema/comptime_ptr_access.zig").ComptimeStoreResult; |
| 38910 | 38907 | |
| 38911 | | /// Convenience function that looks 2 levels deep into `std.builtin`. |
| 38912 | | fn getBuiltinInnerAsInst( |
| 38908 | fn getPanicInnerFn( |
| 38913 | 38909 | sema: *Sema, |
| 38914 | 38910 | block: *Block, |
| 38915 | 38911 | src: LazySrcLoc, |
| 38916 | | outer_name: []const u8, |
| 38917 | 38912 | inner_name: []const u8, |
| 38918 | | ) !Air.Inst.Ref { |
| 38919 | | const outer_ty = try sema.getBuiltinType(outer_name); |
| 38920 | | const inner_val = try getInnerValue(sema, block, src, outer_ty, inner_name); |
| 38921 | | return Air.internedToRef(inner_val.toIntern()); |
| 38913 | ) !InternPool.Index { |
| 38914 | const gpa = sema.gpa; |
| 38915 | const pt = sema.pt; |
| 38916 | const zcu = pt.zcu; |
| 38917 | const ip = &zcu.intern_pool; |
| 38918 | const outer_ty = try sema.getBuiltinType("Panic"); |
| 38919 | const inner_name_ip = try ip.getOrPutString(gpa, pt.tid, inner_name, .no_embedded_nulls); |
| 38920 | const opt_fn_ref = try namespaceLookupVal(sema, block, src, outer_ty.getNamespaceIndex(zcu), inner_name_ip); |
| 38921 | const fn_ref = opt_fn_ref orelse return sema.fail(block, src, "std.builtin.Panic missing {s}", .{inner_name}); |
| 38922 | const fn_val = try sema.resolveConstValue(block, src, fn_ref, .{ |
| 38923 | .needed_comptime_reason = "panic handler must be comptime-known", |
| 38924 | }); |
| 38925 | if (fn_val.typeOf(zcu).zigTypeTag(zcu) != .@"fn") { |
| 38926 | return sema.fail(block, src, "std.builtin.Panic.{s} is not a function", .{inner_name}); |
| 38927 | } |
| 38928 | // Better not to queue up function body analysis because the function might be generic, and |
| 38929 | // the semantic analysis for the call will already queue if necessary. |
| 38930 | return fn_val.toIntern(); |
| 38922 | 38931 | } |
| 38923 | 38932 | |
| 38924 | | /// Convenience function that looks 2 levels deep into `std.builtin`. |
| 38925 | | fn getBuiltinInnerType( |
| 38926 | | sema: *Sema, |
| 38927 | | block: *Block, |
| 38928 | | src: LazySrcLoc, |
| 38929 | | outer_name: []const u8, |
| 38930 | | inner_name: []const u8, |
| 38931 | | ) !Type { |
| 38932 | | const outer_ty = try sema.getBuiltinType(outer_name); |
| 38933 | | return getInnerType(sema, block, src, outer_ty, inner_name); |
| 38933 | fn getBuiltinType(sema: *Sema, name: []const u8) SemaError!Type { |
| 38934 | const pt = sema.pt; |
| 38935 | const ty_inst = try sema.getBuiltin(name); |
| 38936 | const ty = Type.fromInterned(ty_inst.toInterned() orelse @panic("std.builtin is corrupt")); |
| 38937 | try ty.resolveFully(pt); |
| 38938 | return ty; |
| 38934 | 38939 | } |
| 38935 | 38940 | |
| 38936 | | fn getInnerType( |
| 38941 | fn getBuiltinInnerType( |
| 38937 | 38942 | sema: *Sema, |
| 38938 | 38943 | block: *Block, |
| 38939 | 38944 | src: LazySrcLoc, |
| 38940 | 38945 | outer_ty: Type, |
| 38946 | /// Relative to "std.builtin". |
| 38947 | compile_error_parent_name: []const u8, |
| 38941 | 38948 | inner_name: []const u8, |
| 38942 | 38949 | ) !Type { |
| 38943 | | const inner_val = try getInnerValue(sema, block, src, outer_ty, inner_name); |
| 38944 | | return inner_val.toType(); |
| 38945 | | } |
| 38946 | | |
| 38947 | | fn getInnerValue( |
| 38948 | | sema: *Sema, |
| 38949 | | block: *Block, |
| 38950 | | src: LazySrcLoc, |
| 38951 | | outer_ty: Type, |
| 38952 | | inner_name: []const u8, |
| 38953 | | ) !Value { |
| 38954 | 38950 | const pt = sema.pt; |
| 38955 | 38951 | const zcu = pt.zcu; |
| 38956 | 38952 | const ip = &zcu.intern_pool; |
| 38957 | 38953 | const gpa = sema.gpa; |
| 38958 | | const nav = try sema.namespaceLookup( |
| 38959 | | block, |
| 38960 | | src, |
| 38961 | | outer_ty.getNamespaceIndex(zcu), |
| 38962 | | try ip.getOrPutString(gpa, pt.tid, inner_name, .no_embedded_nulls), |
| 38963 | | ) orelse return sema.fail(block, src, "std.builtin missing {s}", .{inner_name}); |
| 38954 | const inner_name_ip = try ip.getOrPutString(gpa, pt.tid, inner_name, .no_embedded_nulls); |
| 38955 | const opt_nav = try sema.namespaceLookup(block, src, outer_ty.getNamespaceIndex(zcu), inner_name_ip); |
| 38956 | const nav = opt_nav orelse return sema.fail(block, src, "std.builtin.{s} missing {s}", .{ |
| 38957 | compile_error_parent_name, inner_name, |
| 38958 | }); |
| 38964 | 38959 | try sema.ensureNavResolved(src, nav); |
| 38965 | | return Value.fromInterned(ip.getNav(nav).status.resolved.val); |
| 38960 | const val = Value.fromInterned(ip.getNav(nav).status.resolved.val); |
| 38961 | const ty = val.toType(); |
| 38962 | try ty.resolveFully(pt); |
| 38963 | return ty; |
| 38966 | 38964 | } |
| 38967 | 38965 | |
| 38968 | 38966 | fn getBuiltin(sema: *Sema, name: []const u8) SemaError!Air.Inst.Ref { |
| ... | ... | @@ -38973,11 +38971,3 @@ fn getBuiltin(sema: *Sema, name: []const u8) SemaError!Air.Inst.Ref { |
| 38973 | 38971 | try pt.ensureCauAnalyzed(ip.getNav(nav).analysis_owner.unwrap().?); |
| 38974 | 38972 | return Air.internedToRef(ip.getNav(nav).status.resolved.val); |
| 38975 | 38973 | } |
| 38976 | | |
| 38977 | | fn getBuiltinType(sema: *Sema, name: []const u8) SemaError!Type { |
| 38978 | | const pt = sema.pt; |
| 38979 | | const ty_inst = try sema.getBuiltin(name); |
| 38980 | | const ty = Type.fromInterned(ty_inst.toInterned() orelse @panic("std.builtin is corrupt")); |
| 38981 | | try ty.resolveFully(pt); |
| 38982 | | return ty; |
| 38983 | | } |