aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/bugs/7047.zig
blob: a60a7d2bbb2e944578383298ec4066e34ec81f8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const std = @import("std");

const U = union(enum) {
    T: type,
    N: void,
};

fn S(comptime query: U) type {
    return struct {
        fn tag() type {
            return query.T;
        }
    };
}

test "compiler doesn't consider equal unions with different 'type' payload" {
    const s1 = S(U{ .T = u32 }).tag();
    try std.testing.expectEqual(u32, s1);

    const s2 = S(U{ .T = u64 }).tag();
    try std.testing.expectEqual(u64, s2);
}