| ... | @@ -2308,6 +2308,7 @@ pub fn resolveConstValue( | ... | @@ -2308,6 +2308,7 @@ pub fn resolveConstValue( |
| 2308 | /// being comptime-resolved is that the block is being comptime-evaluated. | 2308 | /// being comptime-resolved is that the block is being comptime-evaluated. |
| 2309 | reason: ?ComptimeReason, | 2309 | reason: ?ComptimeReason, |
| 2310 | ) CompileError!Value { | 2310 | ) CompileError!Value { |
| | 2311 | assert(reason != null or block.isComptime()); |
| 2311 | return sema.resolveValue(inst) orelse { | 2312 | return sema.resolveValue(inst) orelse { |
| 2312 | return sema.failWithNeededComptime(block, src, reason); | 2313 | return sema.failWithNeededComptime(block, src, reason); |
| 2313 | }; | 2314 | }; |
| ... | @@ -12927,6 +12928,8 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -12927,6 +12928,8 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 12927 | try pt.ensureFileAnalyzed(file_index); | 12928 | try pt.ensureFileAnalyzed(file_index); |
| 12928 | const ty: Type = .fromInterned(zcu.fileRootType(file_index)); | 12929 | const ty: Type = .fromInterned(zcu.fileRootType(file_index)); |
| 12929 | try sema.addTypeReferenceEntry(operand_src, ty); | 12930 | try sema.addTypeReferenceEntry(operand_src, ty); |
| | 12931 | // No need for `ensureNamespaceUpToDate`, because `Zcu.PerThread.updateFileNamespace` |
| | 12932 | // already made sure that all root file structs have up-to-date namespaces. |
| 12930 | return .fromType(ty); | 12933 | return .fromType(ty); |
| 12931 | }, | 12934 | }, |
| 12932 | .zon => { | 12935 | .zon => { |
| ... | @@ -16342,7 +16345,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -16342,7 +16345,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16342 | const alignment_val = try pt.intValue(.comptime_int, bytes: { | 16345 | const alignment_val = try pt.intValue(.comptime_int, bytes: { |
| 16343 | if (info.flags.alignment.toByteUnits()) |b| break :bytes b; | 16346 | if (info.flags.alignment.toByteUnits()) |b| break :bytes b; |
| 16344 | const elem_ty: Type = .fromInterned(info.child); | 16347 | const elem_ty: Type = .fromInterned(info.child); |
| 16345 | // MLUGG TODO: this resolution is sus, but i doubt i'll solve it in this branch | | |
| 16346 | try sema.ensureLayoutResolved(elem_ty, src); | 16348 | try sema.ensureLayoutResolved(elem_ty, src); |
| 16347 | break :bytes elem_ty.abiAlignment(zcu).toByteUnits().?; | 16349 | break :bytes elem_ty.abiAlignment(zcu).toByteUnits().?; |
| 16348 | }); | 16350 | }); |
| ... | @@ -18942,12 +18944,13 @@ fn structInitAnon( | ... | @@ -18942,12 +18944,13 @@ fn structInitAnon( |
| 18942 | .file_scope = block.getFileScopeIndex(zcu), | 18944 | .file_scope = block.getFileScopeIndex(zcu), |
| 18943 | .generation = zcu.generation, | 18945 | .generation = zcu.generation, |
| 18944 | }); | 18946 | }); |
| | 18947 | errdefer pt.destroyNamespace(new_namespace_index); |
| 18945 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); | 18948 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); |
| 18946 | | | |
| 18947 | break :ty .fromInterned(wip.finish(ip, new_namespace_index)); | 18949 | break :ty .fromInterned(wip.finish(ip, new_namespace_index)); |
| 18948 | }, | 18950 | }, |
| 18949 | }; | 18951 | }; |
| 18950 | try sema.addTypeReferenceEntry(src, struct_ty); | 18952 | try sema.addTypeReferenceEntry(src, struct_ty); |
| | 18953 | // No need for `ensureNamespaceUpToDate` because this type's namespace is always empty. |
| 18951 | try sema.ensureLayoutResolved(struct_ty, src); | 18954 | try sema.ensureLayoutResolved(struct_ty, src); |
| 18952 | | 18955 | |
| 18953 | _ = opt_runtime_index orelse { | 18956 | _ = opt_runtime_index orelse { |
| ... | @@ -20150,6 +20153,7 @@ fn zirReifyStruct( | ... | @@ -20150,6 +20153,7 @@ fn zirReifyStruct( |
| 20150 | })) { | 20153 | })) { |
| 20151 | .existing => |ty| { | 20154 | .existing => |ty| { |
| 20152 | try sema.addTypeReferenceEntry(src, .fromInterned(ty)); | 20155 | try sema.addTypeReferenceEntry(src, .fromInterned(ty)); |
| | 20156 | // No need for `ensureNamespaceUpToDate` because this type's namespace is always empty. |
| 20153 | return .fromIntern(ty); | 20157 | return .fromIntern(ty); |
| 20154 | }, | 20158 | }, |
| 20155 | .wip => |wip| { | 20159 | .wip => |wip| { |
| ... | @@ -20210,9 +20214,9 @@ fn zirReifyStruct( | ... | @@ -20210,9 +20214,9 @@ fn zirReifyStruct( |
| 20210 | .file_scope = block.getFileScopeIndex(zcu), | 20214 | .file_scope = block.getFileScopeIndex(zcu), |
| 20211 | .generation = zcu.generation, | 20215 | .generation = zcu.generation, |
| 20212 | }); | 20216 | }); |
| 20213 | try sema.addTypeReferenceEntry(src, .fromInterned(wip.index)); | 20217 | errdefer pt.destroyNamespace(new_namespace_index); |
| 20214 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); | 20218 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); |
| 20215 | | 20219 | try sema.addTypeReferenceEntry(src, .fromInterned(wip.index)); |
| 20216 | return .fromIntern(wip.finish(ip, new_namespace_index)); | 20220 | return .fromIntern(wip.finish(ip, new_namespace_index)); |
| 20217 | }, | 20221 | }, |
| 20218 | } | 20222 | } |
| ... | @@ -20393,6 +20397,7 @@ fn zirReifyUnion( | ... | @@ -20393,6 +20397,7 @@ fn zirReifyUnion( |
| 20393 | })) { | 20397 | })) { |
| 20394 | .existing => |ty| { | 20398 | .existing => |ty| { |
| 20395 | try sema.addTypeReferenceEntry(src, .fromInterned(ty)); | 20399 | try sema.addTypeReferenceEntry(src, .fromInterned(ty)); |
| | 20400 | // No need for `ensureNamespaceUpToDate` because this type's namespace is always empty. |
| 20396 | return .fromIntern(ty); | 20401 | return .fromIntern(ty); |
| 20397 | }, | 20402 | }, |
| 20398 | .wip => |wip| { | 20403 | .wip => |wip| { |
| ... | @@ -20430,9 +20435,9 @@ fn zirReifyUnion( | ... | @@ -20430,9 +20435,9 @@ fn zirReifyUnion( |
| 20430 | .file_scope = block.getFileScopeIndex(zcu), | 20435 | .file_scope = block.getFileScopeIndex(zcu), |
| 20431 | .generation = zcu.generation, | 20436 | .generation = zcu.generation, |
| 20432 | }); | 20437 | }); |
| | 20438 | errdefer pt.destroyNamespace(new_namespace_index); |
| 20433 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); | 20439 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); |
| 20434 | try sema.addTypeReferenceEntry(src, .fromInterned(wip.index)); | 20440 | try sema.addTypeReferenceEntry(src, .fromInterned(wip.index)); |
| 20435 | | | |
| 20436 | return .fromIntern(wip.finish(ip, new_namespace_index)); | 20441 | return .fromIntern(wip.finish(ip, new_namespace_index)); |
| 20437 | }, | 20442 | }, |
| 20438 | } | 20443 | } |
| ... | @@ -20557,6 +20562,7 @@ fn zirReifyEnum( | ... | @@ -20557,6 +20562,7 @@ fn zirReifyEnum( |
| 20557 | })) { | 20562 | })) { |
| 20558 | .existing => |ty| { | 20563 | .existing => |ty| { |
| 20559 | try sema.addTypeReferenceEntry(src, .fromInterned(ty)); | 20564 | try sema.addTypeReferenceEntry(src, .fromInterned(ty)); |
| | 20565 | // No need for `ensureNamespaceUpToDate` because this type's namespace is always empty. |
| 20560 | return .fromIntern(ty); | 20566 | return .fromIntern(ty); |
| 20561 | }, | 20567 | }, |
| 20562 | .wip => |wip| { | 20568 | .wip => |wip| { |
| ... | @@ -20581,10 +20587,9 @@ fn zirReifyEnum( | ... | @@ -20581,10 +20587,9 @@ fn zirReifyEnum( |
| 20581 | .file_scope = block.getFileScopeIndex(zcu), | 20587 | .file_scope = block.getFileScopeIndex(zcu), |
| 20582 | .generation = zcu.generation, | 20588 | .generation = zcu.generation, |
| 20583 | }); | 20589 | }); |
| 20584 | | 20590 | errdefer pt.destroyNamespace(new_namespace_index); |
| 20585 | try sema.addTypeReferenceEntry(src, .fromInterned(wip.index)); | | |
| 20586 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); | 20591 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); |
| 20587 | | 20592 | try sema.addTypeReferenceEntry(src, .fromInterned(wip.index)); |
| 20588 | return .fromIntern(wip.finish(ip, new_namespace_index)); | 20593 | return .fromIntern(wip.finish(ip, new_namespace_index)); |
| 20589 | }, | 20594 | }, |
| 20590 | } | 20595 | } |
| ... | @@ -33861,7 +33866,7 @@ pub fn resolveNavPtrModifiers( | ... | @@ -33861,7 +33866,7 @@ pub fn resolveNavPtrModifiers( |
| 33861 | }; | 33866 | }; |
| 33862 | } | 33867 | } |
| 33863 | | 33868 | |
| 33864 | pub fn analyzeMemoizedState(sema: *Sema, block: *Block, simple_src: LazySrcLoc, builtin_namespace: InternPool.NamespaceIndex, stage: InternPool.MemoizedStateStage) CompileError!bool { | 33869 | pub fn analyzeMemoizedState(sema: *Sema, stage: InternPool.MemoizedStateStage) CompileError!bool { |
| 33865 | const pt = sema.pt; | 33870 | const pt = sema.pt; |
| 33866 | const zcu = pt.zcu; | 33871 | const zcu = pt.zcu; |
| 33867 | const comp = zcu.comp; | 33872 | const comp = zcu.comp; |
| ... | @@ -33869,53 +33874,87 @@ pub fn analyzeMemoizedState(sema: *Sema, block: *Block, simple_src: LazySrcLoc, | ... | @@ -33869,53 +33874,87 @@ pub fn analyzeMemoizedState(sema: *Sema, block: *Block, simple_src: LazySrcLoc, |
| 33869 | const io = comp.io; | 33874 | const io = comp.io; |
| 33870 | const ip = &zcu.intern_pool; | 33875 | const ip = &zcu.intern_pool; |
| 33871 | | 33876 | |
| | 33877 | // This `Block` acts kind of like it's evaluating a `comptime` declaration in the root source |
| | 33878 | // file of the standard library. In particular, its namespace is the root std namespace. |
| | 33879 | var block: Block = block: { |
| | 33880 | // Get the main struct type of the root source file of `std`. No need for a reference entry |
| | 33881 | // because `std` is always an analysis root. |
| | 33882 | const std_file_index = zcu.module_roots.get(zcu.std_mod).?.unwrap().?; |
| | 33883 | try pt.ensureFileAnalyzed(std_file_index); |
| | 33884 | const std_type: Type = .fromInterned(zcu.fileRootType(std_file_index)); |
| | 33885 | break :block .{ |
| | 33886 | .parent = null, |
| | 33887 | .sema = sema, |
| | 33888 | .namespace = std_type.getNamespaceIndex(zcu), |
| | 33889 | .instructions = .empty, |
| | 33890 | .inlining = null, |
| | 33891 | .comptime_reason = null, |
| | 33892 | .src_base_inst = std_type.typeDeclInst(zcu).?, |
| | 33893 | .type_name_ctx = .empty, |
| | 33894 | }; |
| | 33895 | }; |
| | 33896 | defer block.instructions.deinit(gpa); |
| | 33897 | |
| | 33898 | const std_builtin_ty: Type = ty: { |
| | 33899 | const std_src = block.nodeOffset(.zero); |
| | 33900 | const decl_name = try ip.getOrPutString(gpa, io, pt.tid, "builtin", .no_embedded_nulls); |
| | 33901 | const nav = try sema.namespaceLookup(&block, std_src, block.namespace, decl_name) orelse { |
| | 33902 | return sema.fail(&block, std_src, "'std' missing 'builtin'", .{}); |
| | 33903 | }; |
| | 33904 | const uncoerced_val = try sema.analyzeNavVal(&block, std_src, nav); |
| | 33905 | const decl_src: LazySrcLoc = .{ |
| | 33906 | .base_node_inst = ip.getNav(nav).srcInst(ip), |
| | 33907 | .offset = .nodeOffset(.zero), |
| | 33908 | }; |
| | 33909 | break :ty try sema.analyzeAsType(&block, decl_src, .std_builtin_decl, uncoerced_val); |
| | 33910 | }; |
| | 33911 | |
| 33872 | var any_changed = false; | 33912 | var any_changed = false; |
| 33873 | | 33913 | |
| 33874 | inline for (comptime std.enums.values(Zcu.BuiltinDecl)) |builtin_decl| { | 33914 | inline for (comptime std.enums.values(Zcu.BuiltinDecl)) |builtin_decl| { |
| 33875 | if (stage == comptime builtin_decl.stage()) { | 33915 | if (stage == comptime builtin_decl.stage()) { |
| 33876 | const parent_ns: Zcu.Namespace.Index, const parent_name: []const u8, const name: []const u8 = switch (comptime builtin_decl.access()) { | 33916 | const parent_ns_ty: Type, const parent_name: []const u8, const name: []const u8 = switch (comptime builtin_decl.access()) { |
| 33877 | .direct => |name| .{ builtin_namespace, "std.builtin", name }, | 33917 | .direct => |name| .{ std_builtin_ty, "std.builtin", name }, |
| 33878 | .nested => |nested| access: { | 33918 | .nested => |nested| access: { |
| 33879 | const parent_ty: Type = .fromInterned(zcu.builtin_decl_values.get(nested[0])); | 33919 | const parent_decl, const name = nested; |
| 33880 | const parent_ns = parent_ty.getNamespace(zcu).unwrap() orelse { | 33920 | const parent_ty: Type = .fromInterned(zcu.builtin_decl_values.get(parent_decl)); |
| 33881 | return sema.fail(block, simple_src, "std.builtin.{s} is not a container type", .{@tagName(nested[0])}); | 33921 | break :access .{ parent_ty, "std.builtin." ++ @tagName(parent_decl), name }; |
| 33882 | }; | | |
| 33883 | break :access .{ parent_ns, "std.builtin." ++ @tagName(nested[0]), nested[1] }; | | |
| 33884 | }, | 33922 | }, |
| 33885 | }; | 33923 | }; |
| 33886 | | 33924 | |
| | 33925 | const parent_ns = parent_ns_ty.getNamespace(zcu).unwrap() orelse { |
| | 33926 | return sema.fail(&block, block.nodeOffset(.zero), "'{s}' is not a container type", .{parent_name}); |
| | 33927 | }; |
| | 33928 | const parent_ty_src = parent_ns_ty.srcLoc(zcu); |
| 33887 | const name_nts = try ip.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls); | 33929 | const name_nts = try ip.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls); |
| 33888 | const nav = try sema.namespaceLookup(block, simple_src, parent_ns, name_nts) orelse | 33930 | const nav = try sema.namespaceLookup(&block, parent_ty_src, parent_ns, name_nts) orelse { |
| 33889 | return sema.fail(block, simple_src, "{s} missing {s}", .{ parent_name, name }); | 33931 | return sema.fail(&block, parent_ty_src, "'{s}' missing '{s}'", .{ parent_name, name }); |
| | 33932 | }; |
| | 33933 | const uncoerced_val = try sema.analyzeNavVal(&block, parent_ty_src, nav); |
| 33890 | | 33934 | |
| 33891 | const src: LazySrcLoc = .{ | 33935 | const decl_src: LazySrcLoc = .{ |
| 33892 | .base_node_inst = ip.getNav(nav).srcInst(ip), | 33936 | .base_node_inst = ip.getNav(nav).srcInst(ip), |
| 33893 | .offset = .nodeOffset(.zero), | 33937 | .offset = .nodeOffset(.zero), |
| 33894 | }; | 33938 | }; |
| 33895 | | 33939 | |
| 33896 | const result = try sema.analyzeNavVal(block, src, nav); | | |
| 33897 | | | |
| 33898 | const uncoerced_val = try sema.resolveConstDefinedValue(block, src, result, null); | | |
| 33899 | const val: Value = switch (builtin_decl.kind()) { | 33940 | const val: Value = switch (builtin_decl.kind()) { |
| 33900 | .type => if (uncoerced_val.typeOf(zcu).zigTypeTag(zcu) != .type) { | 33941 | .type => val: { |
| 33901 | return sema.fail(block, src, "{s}.{s} is not a type", .{ parent_name, name }); | 33942 | const ty = try sema.analyzeAsType(&block, decl_src, .std_builtin_decl, uncoerced_val); |
| 33902 | } else val: { | 33943 | try sema.ensureLayoutResolved(ty, decl_src); |
| 33903 | try sema.ensureLayoutResolved(uncoerced_val.toType(), src); | 33944 | break :val ty.toValue(); |
| 33904 | break :val uncoerced_val; | | |
| 33905 | }, | 33945 | }, |
| 33906 | .func => val: { | 33946 | .func => val: { |
| 33907 | const func_ty = try sema.getExpectedBuiltinFnType(builtin_decl); | 33947 | const func_ty = try sema.getExpectedBuiltinFnType(builtin_decl); |
| 33908 | const coerced = try sema.coerce(block, func_ty, Air.internedToRef(uncoerced_val.toIntern()), src); | 33948 | const coerced = try sema.coerce(&block, func_ty, uncoerced_val, decl_src); |
| 33909 | break :val .fromInterned(coerced.toInterned().?); | 33949 | break :val try sema.resolveConstDefinedValue(&block, decl_src, coerced, .{ .simple = .std_builtin_decl }); |
| 33910 | }, | 33950 | }, |
| 33911 | .string => val: { | 33951 | .string => val: { |
| 33912 | const coerced = try sema.coerce(block, .slice_const_u8, Air.internedToRef(uncoerced_val.toIntern()), src); | 33952 | const coerced = try sema.coerce(&block, .slice_const_u8, uncoerced_val, decl_src); |
| 33913 | break :val .fromInterned(coerced.toInterned().?); | 33953 | break :val try sema.resolveConstDefinedValue(&block, decl_src, coerced, .{ .simple = .std_builtin_decl }); |
| 33914 | }, | 33954 | }, |
| 33915 | }; | 33955 | }; |
| 33916 | | 33956 | |
| 33917 | const prev = zcu.builtin_decl_values.get(builtin_decl); | 33957 | if (zcu.builtin_decl_values.get(builtin_decl) != val.toIntern()) { |
| 33918 | if (val.toIntern() != prev) { | | |
| 33919 | zcu.builtin_decl_values.set(builtin_decl, val.toIntern()); | 33958 | zcu.builtin_decl_values.set(builtin_decl, val.toIntern()); |
| 33920 | any_changed = true; | 33959 | any_changed = true; |
| 33921 | } | 33960 | } |
| ... | @@ -34147,21 +34186,15 @@ fn zirStructDecl( | ... | @@ -34147,21 +34186,15 @@ fn zirStructDecl( |
| 34147 | }); | 34186 | }); |
| 34148 | errdefer pt.destroyNamespace(new_namespace_index); | 34187 | errdefer pt.destroyNamespace(new_namespace_index); |
| 34149 | try pt.scanNamespace(new_namespace_index, struct_decl.decls); | 34188 | try pt.scanNamespace(new_namespace_index, struct_decl.decls); |
| 34150 | | | |
| 34151 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); | 34189 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); |
| 34152 | | | |
| 34153 | break :ty .fromInterned(wip.finish(ip, new_namespace_index)); | 34190 | break :ty .fromInterned(wip.finish(ip, new_namespace_index)); |
| 34154 | }, | 34191 | }, |
| 34155 | }; | 34192 | }; |
| 34156 | | 34193 | |
| 34157 | try sema.addTypeReferenceEntry(src, ty); | 34194 | try sema.addTypeReferenceEntry(src, ty); |
| 34158 | | | |
| 34159 | // Make sure we update the namespace if the declaration is re-analyzed, to pick | | |
| 34160 | // up on e.g. changed comptime decls. | | |
| 34161 | // TODO MLUGG: me no likey, maybe model namespaces less badly idk | | |
| 34162 | try pt.ensureNamespaceUpToDate(ty.getNamespaceIndex(zcu)); | 34195 | try pt.ensureNamespaceUpToDate(ty.getNamespaceIndex(zcu)); |
| 34163 | | 34196 | |
| 34164 | return .fromIntern(ty.toIntern()); | 34197 | return .fromType(ty); |
| 34165 | } | 34198 | } |
| 34166 | fn zirUnionDecl( | 34199 | fn zirUnionDecl( |
| 34167 | sema: *Sema, | 34200 | sema: *Sema, |
| ... | @@ -34218,7 +34251,6 @@ fn zirUnionDecl( | ... | @@ -34218,7 +34251,6 @@ fn zirUnionDecl( |
| 34218 | .wip => |wip| ty: { | 34251 | .wip => |wip| ty: { |
| 34219 | errdefer wip.cancel(ip, pt.tid); | 34252 | errdefer wip.cancel(ip, pt.tid); |
| 34220 | try sema.setTypeName(block, &wip, union_decl.name_strategy, "union", inst); | 34253 | try sema.setTypeName(block, &wip, union_decl.name_strategy, "union", inst); |
| 34221 | | | |
| 34222 | const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{ | 34254 | const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{ |
| 34223 | .parent = block.namespace.toOptional(), | 34255 | .parent = block.namespace.toOptional(), |
| 34224 | .owner_type = wip.index, | 34256 | .owner_type = wip.index, |
| ... | @@ -34226,23 +34258,16 @@ fn zirUnionDecl( | ... | @@ -34226,23 +34258,16 @@ fn zirUnionDecl( |
| 34226 | .generation = zcu.generation, | 34258 | .generation = zcu.generation, |
| 34227 | }); | 34259 | }); |
| 34228 | errdefer pt.destroyNamespace(new_namespace_index); | 34260 | errdefer pt.destroyNamespace(new_namespace_index); |
| 34229 | | | |
| 34230 | try pt.scanNamespace(new_namespace_index, union_decl.decls); | 34261 | try pt.scanNamespace(new_namespace_index, union_decl.decls); |
| 34231 | | | |
| 34232 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); | 34262 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); |
| 34233 | | | |
| 34234 | break :ty .fromInterned(wip.finish(ip, new_namespace_index)); | 34263 | break :ty .fromInterned(wip.finish(ip, new_namespace_index)); |
| 34235 | }, | 34264 | }, |
| 34236 | }; | 34265 | }; |
| 34237 | | 34266 | |
| 34238 | try sema.addTypeReferenceEntry(src, ty); | 34267 | try sema.addTypeReferenceEntry(src, ty); |
| 34239 | | | |
| 34240 | // Make sure we update the namespace if the declaration is re-analyzed, to pick | | |
| 34241 | // up on e.g. changed comptime decls. | | |
| 34242 | // TODO MLUGG: me no likey, maybe model namespaces less badly idk | | |
| 34243 | try pt.ensureNamespaceUpToDate(ty.getNamespaceIndex(zcu)); | 34268 | try pt.ensureNamespaceUpToDate(ty.getNamespaceIndex(zcu)); |
| 34244 | | 34269 | |
| 34245 | return .fromIntern(ty.toIntern()); | 34270 | return .fromType(ty); |
| 34246 | } | 34271 | } |
| 34247 | fn zirEnumDecl( | 34272 | fn zirEnumDecl( |
| 34248 | sema: *Sema, | 34273 | sema: *Sema, |
| ... | @@ -34277,9 +34302,7 @@ fn zirEnumDecl( | ... | @@ -34277,9 +34302,7 @@ fn zirEnumDecl( |
| 34277 | .existing => |ty| .fromInterned(ty), | 34302 | .existing => |ty| .fromInterned(ty), |
| 34278 | .wip => |wip| ty: { | 34303 | .wip => |wip| ty: { |
| 34279 | errdefer wip.cancel(ip, pt.tid); | 34304 | errdefer wip.cancel(ip, pt.tid); |
| 34280 | | | |
| 34281 | try sema.setTypeName(block, &wip, enum_decl.name_strategy, "enum", inst); | 34305 | try sema.setTypeName(block, &wip, enum_decl.name_strategy, "enum", inst); |
| 34282 | | | |
| 34283 | const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{ | 34306 | const new_namespace_index: InternPool.NamespaceIndex = try pt.createNamespace(.{ |
| 34284 | .parent = block.namespace.toOptional(), | 34307 | .parent = block.namespace.toOptional(), |
| 34285 | .owner_type = wip.index, | 34308 | .owner_type = wip.index, |
| ... | @@ -34287,23 +34310,16 @@ fn zirEnumDecl( | ... | @@ -34287,23 +34310,16 @@ fn zirEnumDecl( |
| 34287 | .generation = zcu.generation, | 34310 | .generation = zcu.generation, |
| 34288 | }); | 34311 | }); |
| 34289 | errdefer pt.destroyNamespace(new_namespace_index); | 34312 | errdefer pt.destroyNamespace(new_namespace_index); |
| 34290 | | | |
| 34291 | try pt.scanNamespace(new_namespace_index, enum_decl.decls); | 34313 | try pt.scanNamespace(new_namespace_index, enum_decl.decls); |
| 34292 | | | |
| 34293 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); | 34314 | if (zcu.comp.debugIncremental()) try zcu.incremental_debug_state.newType(zcu, wip.index); |
| 34294 | | | |
| 34295 | break :ty .fromInterned(wip.finish(ip, new_namespace_index)); | 34315 | break :ty .fromInterned(wip.finish(ip, new_namespace_index)); |
| 34296 | }, | 34316 | }, |
| 34297 | }; | 34317 | }; |
| 34298 | | 34318 | |
| 34299 | try sema.addTypeReferenceEntry(src, ty); | 34319 | try sema.addTypeReferenceEntry(src, ty); |
| 34300 | | | |
| 34301 | // Make sure we update the namespace if the declaration is re-analyzed, to pick | | |
| 34302 | // up on e.g. changed comptime decls. | | |
| 34303 | // TODO MLUGG: me no likey, maybe model namespaces less badly idk | | |
| 34304 | try pt.ensureNamespaceUpToDate(ty.getNamespaceIndex(zcu)); | 34320 | try pt.ensureNamespaceUpToDate(ty.getNamespaceIndex(zcu)); |
| 34305 | | 34321 | |
| 34306 | return .fromIntern(ty.toIntern()); | 34322 | return .fromType(ty); |
| 34307 | } | 34323 | } |
| 34308 | fn zirOpaqueDecl( | 34324 | fn zirOpaqueDecl( |
| 34309 | sema: *Sema, | 34325 | sema: *Sema, |
| ... | @@ -34350,11 +34366,7 @@ fn zirOpaqueDecl( | ... | @@ -34350,11 +34366,7 @@ fn zirOpaqueDecl( |
| 34350 | }; | 34366 | }; |
| 34351 | | 34367 | |
| 34352 | try sema.addTypeReferenceEntry(src, ty); | 34368 | try sema.addTypeReferenceEntry(src, ty); |
| 34353 | | | |
| 34354 | // Make sure we update the namespace if the declaration is re-analyzed, to pick | | |
| 34355 | // up on e.g. changed comptime decls. | | |
| 34356 | // TODO MLUGG: me no likey, maybe model namespaces less badly idk | | |
| 34357 | try pt.ensureNamespaceUpToDate(ty.getNamespaceIndex(zcu)); | 34369 | try pt.ensureNamespaceUpToDate(ty.getNamespaceIndex(zcu)); |
| 34358 | | 34370 | |
| 34359 | return .fromIntern(ty.toIntern()); | 34371 | return .fromType(ty); |
| 34360 | } | 34372 | } |