zig
zig copied to clipboard
confusing left shift error
Zig Version
0.11.0-dev.1+841235b3f
Steps to Reproduce and Observed Behavior
const std = @import("std");
test {
try std.testing.expect(init(.constructed, .context) == 0b10100000);
}
fn init(pc: enum(u1) { primitive, constructed }, class: enum(u2) { universal, application, context, private }) u8 {
var res: u8 = 0;
res |= (@enumToInt(pc) << 5);
res |= (@enumToInt(class) << 6);
return res;
}
a.zig:9:31: error: type 'u0' cannot represent integer value '5'
res |= (@enumToInt(pc) << 5);
^
Expected Behavior
successful compile or error about u1/u2 not having enough space to shift 5/6 spaces respectively