Add compile error test for comptime slice-of-struct copy

Closes #6305. In the C++ implementation this hit a compiler assertion.
It is handled properly in the self-hosted version.
This commit is contained in:
Stevie Hryciw
2023-08-06 18:11:49 -07:00
parent 6bba5a39e4
commit 16dcefaca5

View File

@@ -0,0 +1,13 @@
const MyStruct = struct { x: bool = false };
comptime {
const x = &[_]MyStruct{ .{}, .{} };
const y = x[0..1] ++ &[_]MyStruct{};
_ = y;
}
// error
// backend=stage2
// target=native
//
// :5:16: error: comptime dereference requires '[1]tmp.MyStruct' to have a well-defined layout, but it does not.