@@ -127,8 +127,10 @@ fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!Inter
127
127
},
128
128
.struct_literal = > | init | {
129
129
const elems = try self .sema .arena .alloc (InternPool .Index , init .names .len );
130
+ const types = try self .sema .arena .alloc (InternPool .Index , init .names .len );
130
131
for (0.. init .names .len ) | i | {
131
132
elems [i ] = try self .lowerExprAnonResTy (init .vals .at (@intCast (i )));
133
+ types [i ] = Value .fromInterned (elems [i ]).typeOf (pt .zcu ).toIntern ();
132
134
}
133
135
const struct_ty = switch (try ip .getStructType (
134
136
gpa ,
@@ -144,7 +146,14 @@ fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!Inter
144
146
.any_aligned_fields = false ,
145
147
.key = .{ .reified = .{
146
148
.zir_index = self .base_node_inst ,
147
- .type_hash = @intFromEnum (node ),
149
+ .type_hash = hash : {
150
+ var hasher : std.hash.Wyhash = .init (0 );
151
+ hasher .update (std .mem .asBytes (& node ));
152
+ hasher .update (std .mem .sliceAsBytes (elems ));
153
+ hasher .update (std .mem .sliceAsBytes (types ));
154
+ hasher .update (std .mem .sliceAsBytes (init .names ));
155
+ break :hash hasher .final ();
156
+ },
148
157
} },
149
158
},
150
159
false ,
@@ -173,10 +182,7 @@ fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!Inter
173
182
}
174
183
175
184
@memcpy (struct_type .field_inits .get (ip ), elems );
176
- const types = struct_type .field_types .get (ip );
177
- for (0.. init .names .len ) | i | {
178
- types [i ] = Value .fromInterned (elems [i ]).typeOf (pt .zcu ).toIntern ();
179
- }
185
+ @memcpy (struct_type .field_types .get (ip ), types );
180
186
181
187
const new_namespace_index = try pt .createNamespace (.{
182
188
.parent = self .block .namespace .toOptional (),
0 commit comments