From 16dcefaca5956af747c29d6ab1915cc955f81af9 Mon Sep 17 00:00:00 2001 From: Stevie Hryciw Date: Sun, 6 Aug 2023 18:11:49 -0700 Subject: [PATCH] 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. --- .../comptime_dereference_slice_of_struct.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/cases/compile_errors/comptime_dereference_slice_of_struct.zig diff --git a/test/cases/compile_errors/comptime_dereference_slice_of_struct.zig b/test/cases/compile_errors/comptime_dereference_slice_of_struct.zig new file mode 100644 index 0000000000..8d3619d906 --- /dev/null +++ b/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.