| author | |
| committer | |
| log | 52ebba6bdf5662353ce11a701a3361cc0616c01c |
| tree | 540214fd396068acba89acfa6f29c425a12a1ee4 |
| parent | 10016e0368c382363e168e45fac2cca4bc64e38f |
* Add clarification in langref
* move test case to behavior tests3 files changed, 7 insertions(+), 6 deletions(-)
doc/langref.html.in+5| ... | ... | @@ -9163,6 +9163,11 @@ test "@setRuntimeSafety" { |
| 9163 | 9163 | The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).Int.bits){#endsyntax#} bits. |
| 9164 | 9164 | This is because {#syntax#}shift_amt >= @typeInfo(T).Int.bits{#endsyntax#} is undefined behavior. |
| 9165 | 9165 | </p> |
| 9166 | <p> | |
| 9167 | {#syntax#}comptime_int{#endsyntax#} is modeled as an integer with an infinite number of bits, | |
| 9168 | meaning that in such case, {#syntax#}@shlExact{#endsyntax#} always produces a result and | |
| 9169 | cannot produce a compile error. | |
| 9170 | </p> | |
| 9166 | 9171 | {#see_also|@shrExact|@shlWithOverflow#} |
| 9167 | 9172 | {#header_close#} |
| 9168 | 9173 |
test/behavior/math.zig+2| ... | ... | @@ -1314,6 +1314,8 @@ test "exact shift left" { |
| 1314 | 1314 | |
| 1315 | 1315 | try testShlExact(0b00110101); |
| 1316 | 1316 | try comptime testShlExact(0b00110101); |
| 1317 | ||
| 1318 | if (@shlExact(1, 1) != 2) @compileError("should be 2"); | |
| 1317 | 1319 | } |
| 1318 | 1320 | fn testShlExact(x: u8) !void { |
| 1319 | 1321 | const shifted = @shlExact(x, 2); |
test/cases/shl_exact_comptime_int_lhs.zig deleted-6| ... | ... | @@ -1,6 +0,0 @@ |
| 1 | export fn entry() void { | |
| 2 | if (@shlExact(1, 1) != 2) @compileError("should be 2"); | |
| 3 | } | |
| 4 | ||
| 5 | // compile | |
| 6 | // output_mode=Obj |