authorgravatar for codroid@gmail.comStevie Hryciw <codroid@gmail.com> 2023-08-06 18:11:49-07:00
committergravatar for codroid@gmail.comStevie Hryciw <codroid@gmail.com> 2023-08-06 18:11:49-07:00
log16dcefaca5956af747c29d6ab1915cc955f81af9
tree1d9eccf190b7a65a9ab9e78f1dd799de6ea55b4f
parent6bba5a39e4a4eb2262052a6d218cf71795a9d704

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 files changed, 13 insertions(+), 0 deletions(-)

test/cases/compile_errors/comptime_dereference_slice_of_struct.zig created+13
......@@ -0,0 +1,13 @@
1const MyStruct = struct { x: bool = false };
2
3comptime {
4 const x = &[_]MyStruct{ .{}, .{} };
5 const y = x[0..1] ++ &[_]MyStruct{};
6 _ = y;
7}
8
9// error
10// backend=stage2
11// target=native
12//
13// :5:16: error: comptime dereference requires '[1]tmp.MyStruct' to have a well-defined layout, but it does not.