diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 0155ad3fa8..e54f6591b5 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -6842,4 +6842,19 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { "tmp.zig:8:23: error: use of undefined value here causes undefined behavior", "tmp.zig:14:23: error: use of undefined value here causes undefined behavior", }); + + cases.add("issue #3818: bitcast from parray/slice to u16", + \\export fn foo1() void { + \\ var bytes = [_]u8{1, 2}; + \\ const word: u16 = @bitCast(u16, bytes[0..]); + \\} + \\export fn foo2() void { + \\ var bytes: []u8 = &[_]u8{1, 2}; + \\ const word: u16 = @bitCast(u16, bytes); + \\} + , &[_][]const u8{ + "tmp.zig:3:42: error: unable to @bitCast from pointer type '*[2]u8'", + "tmp.zig:7:32: error: destination type 'u16' has size 2 but source type '[]u8' has size 16", + "tmp.zig:7:37: note: referenced here", + }); }