Skip to content

Commit

Permalink
@shlExact fixups
Browse files Browse the repository at this point in the history
* Add clarification in langref
* move test case to behavior tests
  • Loading branch information
andrewrk committed Jan 4, 2024
1 parent 10016e0 commit 52ebba6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 5 additions & 0 deletions doc/langref.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -9163,6 +9163,11 @@ test "@setRuntimeSafety" {
The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).Int.bits){#endsyntax#} bits.
This is because {#syntax#}shift_amt >= @typeInfo(T).Int.bits{#endsyntax#} is undefined behavior.
</p>
<p>
{#syntax#}comptime_int{#endsyntax#} is modeled as an integer with an infinite number of bits,
meaning that in such case, {#syntax#}@shlExact{#endsyntax#} always produces a result and
cannot produce a compile error.
</p>
{#see_also|@shrExact|@shlWithOverflow#}
{#header_close#}

Expand Down
2 changes: 2 additions & 0 deletions test/behavior/math.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,8 @@ test "exact shift left" {

try testShlExact(0b00110101);
try comptime testShlExact(0b00110101);

if (@shlExact(1, 1) != 2) @compileError("should be 2");
}
fn testShlExact(x: u8) !void {
const shifted = @shlExact(x, 2);
Expand Down
6 changes: 0 additions & 6 deletions test/cases/shl_exact_comptime_int_lhs.zig

This file was deleted.

0 comments on commit 52ebba6

Please sign in to comment.