authorgravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2018-09-17 21:25:23-04:00
committergravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2018-09-17 21:25:37-04:00
log13645585fe2904f38d13df12e571ecac5bf9e8e6
tree915d2dfd34bc3c517b896c41a7940d847219fee4
parent8f0618a5b1a1aa65ed1600b55aca0ab144c68932

link to #1544


1 files changed, 3 insertions(+), 1 deletions(-)

test/cases/bit_shifting.zig+3-1
...@@ -15,13 +15,15 @@ fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, compt...@@ -15,13 +15,15 @@ fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, compt
15 }15 }
1616
17 fn getShardKey(key: Key) ShardKey {17 fn getShardKey(key: Key) ShardKey {
18 // https://github.com/ziglang/zig/issues/1544
18 // this special case is needed because you can't u32 >> 32.19 // this special case is needed because you can't u32 >> 32.
19 if (ShardKey == u0) return 0;20 if (ShardKey == u0) return 0;
2021
21 // this can be u1 >> u022 // this can be u1 >> u0
22 const shard_key = key >> shift_amount;23 const shard_key = key >> shift_amount;
2324
24 // TODO: this cast could be implicit if we teach the compiler that25 // TODO: https://github.com/ziglang/zig/issues/1544
26 // This cast could be implicit if we teach the compiler that
25 // u32 >> 30 -> u227 // u32 >> 30 -> u2
26 return @intCast(ShardKey, shard_key);28 return @intCast(ShardKey, shard_key);
27 }29 }