❯ roc --version
roc nightly pre-release, built from commit 010aed88f9d on Wed May 8 09:12:51 UTC 2024
I’m currently testing Roc on macos with an M3 chip. In these conditions, I’m observing some UB and panics. Here is the output of the repl for example (I’m changing white space for readability).
During the discussion, @bhansconnect also mentioned Zig behavior, which limits the integer size of the shift to the integer size, instead of U8 for all integer types. For example, A shift on U32 numbers is done with a shift value of type U5.
I’m currently testing Roc on macos with an M3 chip. In these conditions, I’m observing some UB and panics. Here is the output of the repl for example (I’m changing white space for readability).
The UB happens when the shift value corresponds to the integer size. Sometimes it returns 0, sometimes it returns the integer input unchanged.
Similar UB is also observed when compiling with
roc test
.This problem was originally reported on zulip: https://roc.zulipchat.com/#narrow/stream/231634-beginners/topic/Bug.20with.20shiftRightZfBy.3F
During the discussion, @bhansconnect also mentioned Zig behavior, which limits the integer size of the shift to the integer size, instead of U8 for all integer types. For example, A shift on
U32
numbers is done with a shift value of typeU5
.