New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enums don't get assigned the correct size when tag type is specified #820

Closed
Hejsil opened this Issue Mar 8, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@Hejsil
Member

Hejsil commented Mar 8, 2018

test "" {
    const Enum = enum(u8) { B = 2 };
    comptime @import("std").debug.assert(@sizeOf(Enum) == 1);
}
std/debug/index.zig:86:13: error: encountered @panic at compile-time
            @panic("assertion failure");
            ^
test/test.zig:3:41: note: called from here
    comptime @import("std").debug.assert(@sizeOf(Enum) == 1);

@Hejsil Hejsil added the bug label Mar 8, 2018

@andrewrk andrewrk added this to the 0.2.0 milestone Mar 8, 2018

@andrewrk

This comment has been minimized.

Member

andrewrk commented Mar 8, 2018

Aha, so what's going on is zig actually needs 0 bytes to represent this enum. Enum is a 0-bit type, same as void. However, I agree that if you specify the tag type explicitly, it should use that tag type. So I'll make that work.

@andrewrk andrewrk closed this in 028ec0f Mar 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment