Sema: complete the Type.hash function
Similar to how Type.eql was reworked in the previous commit, this commit reworks Type.hash to check all the different kinds of tags that a Type can be represented with. It also completes the implementation for all types except error sets, which need to have Type.eql enhanced as well.
This commit is contained in:
@@ -2040,9 +2040,19 @@ pub const Value = extern union {
|
||||
}
|
||||
const fields = ty.structFields().values();
|
||||
if (fields.len == 0) return;
|
||||
const field_values = val.castTag(.@"struct").?.data;
|
||||
for (field_values) |field_val, i| {
|
||||
field_val.hash(fields[i].ty, hasher);
|
||||
switch (val.tag()) {
|
||||
.empty_struct_value => {
|
||||
for (fields) |field| {
|
||||
field.default_val.hash(field.ty, hasher);
|
||||
}
|
||||
},
|
||||
.@"struct" => {
|
||||
const field_values = val.castTag(.@"struct").?.data;
|
||||
for (field_values) |field_val, i| {
|
||||
field_val.hash(fields[i].ty, hasher);
|
||||
}
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
},
|
||||
.Optional => {
|
||||
|
||||
Reference in New Issue
Block a user