Skip to content

std.testing.expectEqualDeep fails compiling with formatted enum #25959

@Nirlah

Description

@Nirlah

Zig Version

0.15.2

Steps to Reproduce and Observed Behavior

const TestEnum = enum {
    a,
    b,

    pub fn format(self: @This(), writer: *std.io.Writer) !void {
        try writer.writeAll(@tagName(self));
    }
};

test {
    try std.testing.expectEqualDeep(TestEnum.b, TestEnum.b);
}

Compiling fails with the following error:

error: ambiguous format string; specify {f} to call format method, or {any} to skip it
    @compileError("ambiguous format string; specify {f} to call format method, or {any} to skip it");

Expected Behavior

No compiler errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions