zig/test/cases/bugs/1442.zig
Andrew Kelley 7dd3c3814d
fix incorrect error union const value generation
closes #1442

zig needed to insert explicit padding into this structure before
it got bitcasted.
2018-09-11 15:16:50 -04:00

12 lines
281 B
Zig

const std = @import("std");
const Union = union(enum) {
Text: []const u8,
Color: u32,
};
test "const error union field alignment" {
var union_or_err: error!Union = Union{ .Color = 1234 };
std.debug.assertOrPanic((union_or_err catch unreachable).Color == 1234);
}