Why does this test produce an unexpected result?
const std = @import("std");
test "fail" {
const a: i16 = -32767; // 0x8001
const shift: u4 = 4;
const result: i16 = a >> shift; // 0xF802 (-2046)
const expected: i16 = -2048; // 0xF800
try std.testing.expectEqual(expected, result);
}
zig test file.zig
expected -2048, found -2046
1/1 file.test.fail...FAIL (TestExpectedEqual)
zig version
0.14.0-dev.1012+b7c01120b
For a similar issue on the zig’s github, I was told that this “semantic inline” stuff was a feature and not a bug. But I just don’t understand this.