aboutsummaryrefslogtreecommitdiff
path: root/src/Type.zig
diff options
context:
space:
mode:
authorDavid Rubin <daviru007@icloud.com>2024-08-12 15:28:05 -0700
committerDavid Rubin <daviru007@icloud.com>2024-08-25 15:18:20 -0700
commitce92ccccc961992c00a10e714ce9e799956c50f2 (patch)
tree39d25560175d0787a0891c0f8fa25f68bb1ba7cd /src/Type.zig
parent472f3ac419386327a3ed464256509af456092785 (diff)
downloadzig-ce92ccccc961992c00a10e714ce9e799956c50f2.tar.gz
zig-ce92ccccc961992c00a10e714ce9e799956c50f2.zip
sema: `resolve{Struct,Union}Inner` don't throw away Semas
before this, calls to `resolveTypeFieldsStruct` (now renamed to the more correct `resolveStructFieldTypes`) would just throw away the sema that `resolveStructInner` created and create its own. There is no reason to do this, and we fix it to preserve the sema through it all.
Diffstat (limited to 'src/Type.zig')
-rw-r--r--src/Type.zig14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Type.zig b/src/Type.zig
index f2f8f89594..e85e10aacf 100644
--- a/src/Type.zig
+++ b/src/Type.zig
@@ -3911,11 +3911,12 @@ fn resolveStructInner(
var comptime_err_ret_trace = std.ArrayList(Zcu.LazySrcLoc).init(gpa);
defer comptime_err_ret_trace.deinit();
+ const zir = zcu.namespacePtr(struct_obj.namespace.unwrap().?).fileScope(zcu).zir;
var sema: Sema = .{
.pt = pt,
.gpa = gpa,
.arena = analysis_arena.allocator(),
- .code = undefined, // This ZIR will not be used.
+ .code = zir,
.owner = owner,
.func_index = .none,
.func_is_naked = false,
@@ -3925,8 +3926,10 @@ fn resolveStructInner(
};
defer sema.deinit();
+ assert(sema.owner.unwrap().cau == struct_obj.cau.unwrap().?);
+
(switch (resolution) {
- .fields => sema.resolveTypeFieldsStruct(ty.toIntern(), struct_obj),
+ .fields => sema.resolveStructFieldTypes(ty.toIntern(), struct_obj),
.inits => sema.resolveStructFieldInits(ty),
.alignment => sema.resolveStructAlignment(ty.toIntern(), struct_obj),
.layout => sema.resolveStructLayout(ty),
@@ -3964,11 +3967,12 @@ fn resolveUnionInner(
var comptime_err_ret_trace = std.ArrayList(Zcu.LazySrcLoc).init(gpa);
defer comptime_err_ret_trace.deinit();
+ const zir = zcu.namespacePtr(union_obj.namespace).fileScope(zcu).zir;
var sema: Sema = .{
.pt = pt,
.gpa = gpa,
.arena = analysis_arena.allocator(),
- .code = undefined, // This ZIR will not be used.
+ .code = zir,
.owner = owner,
.func_index = .none,
.func_is_naked = false,
@@ -3978,8 +3982,10 @@ fn resolveUnionInner(
};
defer sema.deinit();
+ assert(sema.owner.unwrap().cau == union_obj.cau);
+
(switch (resolution) {
- .fields => sema.resolveTypeFieldsUnion(ty, union_obj),
+ .fields => sema.resolveUnionFieldTypes(ty, union_obj),
.alignment => sema.resolveUnionAlignment(ty, union_obj),
.layout => sema.resolveUnionLayout(ty),
.full => sema.resolveUnionFully(ty),