authorgravatar for mitchell.hashimoto@gmail.comMitchell Hashimoto <mitchell.hashimoto@gmail.com> 2022-03-16 21:22:02-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-16 23:18:35-07:00
log79d3780fbda475a50d6e0ca53d51c9e7c7690ab1
treec500f3c426116267f37fdb0a567bb8de282fa199
parent1af51a083383be5bbb3249c24e00326aff935122

stage2: bit_not on u0 is always 0


2 files changed, 8 insertions(+), 0 deletions(-)

src/value.zig+5
...@@ -2977,6 +2977,11 @@ pub const Value = extern union {...@@ -2977,6 +2977,11 @@ pub const Value = extern union {
29772977
2978 const info = ty.intInfo(target);2978 const info = ty.intInfo(target);
29792979
2980 if (info.bits == 0) {
2981 assert(val.isZero()); // Sema should guarantee
2982 return val;
2983 }
2984
2980 // TODO is this a performance issue? maybe we should try the operation without2985 // TODO is this a performance issue? maybe we should try the operation without
2981 // resorting to BigInt first.2986 // resorting to BigInt first.
2982 var val_space: Value.BigIntSpace = undefined;2987 var val_space: Value.BigIntSpace = undefined;
test/behavior/math.zig+3
...@@ -375,6 +375,9 @@ test "binary not" {...@@ -375,6 +375,9 @@ test "binary not" {
375 try expect(comptime x: {375 try expect(comptime x: {
376 break :x ~@as(u64, 2147483647) == 18446744071562067968;376 break :x ~@as(u64, 2147483647) == 18446744071562067968;
377 });377 });
378 try expect(comptime x: {
379 break :x ~@as(u0, 0) == 0;
380 });
378 try testBinaryNot(0b1010101010101010);381 try testBinaryNot(0b1010101010101010);
379}382}
380383