diff --git a/src/value.zig b/src/value.zig index d63452ee5640f5156184842d66385b1534971013..005f1f1ffdb616f0476f9c58a464c3a01899f6a8 100644 --- a/src/value.zig +++ b/src/value.zig @@ -2977,6 +2977,11 @@ pub const Value = extern union { const info = ty.intInfo(target); + if (info.bits == 0) { + assert(val.isZero()); // Sema should guarantee + return val; + } + // TODO is this a performance issue? maybe we should try the operation without // resorting to BigInt first. var val_space: Value.BigIntSpace = undefined; diff --git a/test/behavior/math.zig b/test/behavior/math.zig index 05decb348e6a8ab2296db7766da55296b5a753d8..5b91ceed47cd0492957b53011957a9157770abca 100644 --- a/test/behavior/math.zig +++ b/test/behavior/math.zig @@ -375,6 +375,9 @@ test "binary not" { try expect(comptime x: { break :x ~@as(u64, 2147483647) == 18446744071562067968; }); + try expect(comptime x: { + break :x ~@as(u0, 0) == 0; + }); try testBinaryNot(0b1010101010101010); }