aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-06-04 13:12:55 +0300
committerAndrew Kelley <andrew@ziglang.org>2022-06-06 13:11:50 -0700
commitcb5d2b691aadde5665cefc54542e3e0651ebc2fa (patch)
tree75c7dba7e75a9c1ed3abdb5471b49fbf4258b39a /test/cases/compile_errors
parenta040ccb42f1b34ba612c975b7030ccdcbb3f8086 (diff)
downloadzig-cb5d2b691aadde5665cefc54542e3e0651ebc2fa.tar.gz
zig-cb5d2b691aadde5665cefc54542e3e0651ebc2fa.zip
Sema: validate equality on store to comptime field
Diffstat (limited to 'test/cases/compile_errors')
-rw-r--r--test/cases/compile_errors/invalid_store_to_comptime_field.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/cases/compile_errors/invalid_store_to_comptime_field.zig b/test/cases/compile_errors/invalid_store_to_comptime_field.zig
new file mode 100644
index 0000000000..3bbd9bbaa8
--- /dev/null
+++ b/test/cases/compile_errors/invalid_store_to_comptime_field.zig
@@ -0,0 +1,20 @@
+pub export fn entry() void {
+ const S = struct {
+ comptime a: [2]u32 = [2]u32{ 1, 2 },
+ };
+ var s: S = .{};
+ s.a = [2]u32{ 2, 2 };
+}
+pub export fn entry1() void {
+ const T = struct { a: u32, b: u32 };
+ const S = struct {
+ comptime a: T = T{ .a = 1, .b = 2 },
+ };
+ var s: S = .{};
+ s.a = T{ .a = 2, .b = 2 };
+}
+// error
+// backend=stage2,llvm
+//
+// :6:19: error: value stored in comptime field does not match the default value of the field
+// :14:19: error: value stored in comptime field does not match the default value of the field