aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/compile_time_struct_field.zig
diff options
context:
space:
mode:
authorWillLillis <wlillis@umass.edu>2024-07-25 20:52:49 -0400
committerVeikka Tuominen <git@vexu.eu>2024-09-01 17:31:00 +0300
commit28383d4d985cd04c897f6b6a63bd2107d8e2a8e9 (patch)
tree8fa7df88c64a5574bdcb0ccad579e8c578fbd336 /test/cases/compile_errors/compile_time_struct_field.zig
parentcad65307b757d4dfcbae018dbdb4c2a98b87b7e3 (diff)
downloadzig-28383d4d985cd04c897f6b6a63bd2107d8e2a8e9.tar.gz
zig-28383d4d985cd04c897f6b6a63bd2107d8e2a8e9.zip
fix(Sema): patch segfault in `finishStructInit`
Diffstat (limited to 'test/cases/compile_errors/compile_time_struct_field.zig')
-rw-r--r--test/cases/compile_errors/compile_time_struct_field.zig19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/cases/compile_errors/compile_time_struct_field.zig b/test/cases/compile_errors/compile_time_struct_field.zig
new file mode 100644
index 0000000000..8ca502f645
--- /dev/null
+++ b/test/cases/compile_errors/compile_time_struct_field.zig
@@ -0,0 +1,19 @@
+const S = struct {
+ comptime_field: comptime_int = 2,
+ normal_ptr: *u32,
+};
+
+export fn a() void {
+ var value: u32 = 3;
+ const comptimeStruct = S {
+ .normal_ptr = &value,
+ };
+ _ = comptimeStruct;
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// 9:6: error: unable to resolve comptime value
+// 9:6: note: initializer of comptime only struct must be comptime-known