diff options
| author | Stevie Hryciw <codroid@gmail.com> | 2023-08-06 18:11:49 -0700 |
|---|---|---|
| committer | Stevie Hryciw <codroid@gmail.com> | 2023-08-06 18:11:49 -0700 |
| commit | 16dcefaca5956af747c29d6ab1915cc955f81af9 (patch) | |
| tree | 1d9eccf190b7a65a9ab9e78f1dd799de6ea55b4f /test/cases/compile_errors | |
| parent | 6bba5a39e4a4eb2262052a6d218cf71795a9d704 (diff) | |
| download | zig-16dcefaca5956af747c29d6ab1915cc955f81af9.tar.gz zig-16dcefaca5956af747c29d6ab1915cc955f81af9.zip | |
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.
Diffstat (limited to 'test/cases/compile_errors')
| -rw-r--r-- | test/cases/compile_errors/comptime_dereference_slice_of_struct.zig | 13 |
1 files changed, 13 insertions, 0 deletions
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. |
