Commit 16dcefaca5

Stevie Hryciw <codroid@gmail.com>
2023-08-07 03:11:49
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.
1 parent 6bba5a3
Changed files (1)
test/cases/compile_errors/comptime_dereference_slice_of_struct.zig
@@ -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.