Merge branch 'master' into kt128r

* master:
  std.Zig.AstGen: handle properly .inferred_ptr and .destructure in enum_literal handling
  std.testing: Fix expectEqualDeep formatted enum (#25960)
This commit is contained in:
Frank Denis 2025-11-25 15:59:32 +01:00
commit 2994a206ae
2 changed files with 15 additions and 3 deletions

View file

@ -760,7 +760,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
.error_set,
=> {
if (actual != expected) {
print("expected {}, found {}\n", .{ expected, actual });
print("expected {any}, found {any}\n", .{ expected, actual });
return error.TestExpectedEqual;
}
},
@ -923,6 +923,18 @@ test "expectEqualDeep primitive type" {
}.foo;
try expectEqualDeep(fnType, fnType);
}
// enum with formatter
{
const TestEnum = enum {
a,
b,
pub fn format(self: @This(), writer: *std.Io.Writer) !void {
try writer.writeAll(@tagName(self));
}
};
try expectEqualDeep(TestEnum.b, TestEnum.b);
}
}
test "expectEqualDeep pointer" {

View file

@ -1006,9 +1006,9 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE
.field_name_start = str_index,
});
switch (ri.rl) {
.discard, .none, .ref => unreachable, // no result type
.discard, .none, .ref, .inferred_ptr, .destructure => unreachable, // no result type
.ty, .coerced_ty => return res, // `decl_literal` does the coercion for us
.ref_coerced_ty, .ptr, .inferred_ptr, .destructure => return rvalue(gz, ri, res, node),
.ref_coerced_ty, .ptr => return rvalue(gz, ri, res, node),
}
} else return simpleStrTok(gz, ri, tree.nodeMainToken(node), node, .enum_literal),
.error_value => return simpleStrTok(gz, ri, tree.nodeMainToken(node) + 2, node, .error_value),