zig/test/cases/bugs/1322.zig
Jimmi Holst Christensen 378d3e4403
Solve the return type ambiguity (#1628)
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
2018-10-15 09:51:15 -04:00

20 lines
385 B
Zig

const std = @import("std");
const B = union(enum).{
c: C,
None,
};
const A = struct.{
b: B,
};
const C = struct.{};
test "tagged union with all void fields but a meaningful tag" {
var a: A = A.{ .b = B.{ .c = C.{} } };
std.debug.assert(@TagType(B)(a.b) == @TagType(B).c);
a = A.{ .b = B.None };
std.debug.assert(@TagType(B)(a.b) == @TagType(B).None);
}