aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2024-01-31 12:06:47 +0200
committerAndrew Kelley <andrew@ziglang.org>2024-02-09 13:51:51 -0800
commit731ff120d0ee68f3ce2eb30648eeaf96a283142d (patch)
treedf9c78eec99467ce10264bc6d0b81bfb9d682040 /test
parent32f30399e5cd42af2d670321979aa424803b1819 (diff)
downloadzig-731ff120d0ee68f3ce2eb30648eeaf96a283142d.tar.gz
zig-731ff120d0ee68f3ce2eb30648eeaf96a283142d.zip
Sema: catch runtime stores to comptime variables through calls
Diffstat (limited to 'test')
-rw-r--r--test/cases/compile_errors/store_to_comptime_var_through_call.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/cases/compile_errors/store_to_comptime_var_through_call.zig b/test/cases/compile_errors/store_to_comptime_var_through_call.zig
new file mode 100644
index 0000000000..0fb1246e31
--- /dev/null
+++ b/test/cases/compile_errors/store_to_comptime_var_through_call.zig
@@ -0,0 +1,15 @@
+export fn entry(b: bool) void {
+ comptime var int = 0;
+ if (b) {
+ comptime incr(&int);
+ }
+}
+fn incr(x: *comptime_int) void {
+ x.* += 1;
+}
+
+// error
+//
+// :8:9: error: store to comptime variable depends on runtime condition
+// :3:9: note: runtime condition here
+// :4:22: note: called from here