aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-09-21 01:49:28 -0700
committerGitHub <noreply@github.com>2025-09-21 01:49:28 -0700
commit010d9a63f20d8a4bd14cff0ada690b2d127a0371 (patch)
tree12b56ddfe5a5b235ef0676832902a0b04ad7d57a /test/cases/compile_errors
parent3fbb88c4bd146ca7bd9e7ab5da9c4b05298f3b34 (diff)
parent633162eb0c8d302ba7585cd308e01237409f042e (diff)
downloadzig-010d9a63f20d8a4bd14cff0ada690b2d127a0371.tar.gz
zig-010d9a63f20d8a4bd14cff0ada690b2d127a0371.zip
Merge pull request #25154 from ziglang/no-decl-val-3
rework byval ZIR instructions; forbid runtime vector indexes
Diffstat (limited to 'test/cases/compile_errors')
-rw-r--r--test/cases/compile_errors/comptime_var_referenced_at_runtime.zig20
-rw-r--r--test/cases/compile_errors/comptime_var_referenced_by_decl.zig16
-rw-r--r--test/cases/compile_errors/comptime_var_referenced_by_type.zig3
-rw-r--r--test/cases/compile_errors/enum_field_value_references_enum.zig2
-rw-r--r--test/cases/compile_errors/enum_field_value_references_nonexistent_circular.zig13
-rw-r--r--test/cases/compile_errors/for_comptime_array_pointer.zig2
-rw-r--r--test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig19
-rw-r--r--test/cases/compile_errors/implicitly_increasing_slice_alignment.zig19
-rw-r--r--test/cases/compile_errors/load_vector_pointer_with_unknown_runtime_index.zig2
-rw-r--r--test/cases/compile_errors/store_vector_pointer_with_unknown_runtime_index.zig2
10 files changed, 38 insertions, 60 deletions
diff --git a/test/cases/compile_errors/comptime_var_referenced_at_runtime.zig b/test/cases/compile_errors/comptime_var_referenced_at_runtime.zig
index e060da33a8..603ce49732 100644
--- a/test/cases/compile_errors/comptime_var_referenced_at_runtime.zig
+++ b/test/cases/compile_errors/comptime_var_referenced_at_runtime.zig
@@ -75,31 +75,31 @@ export fn bax() void {
//
// :5:19: error: runtime value contains reference to comptime var
// :5:19: note: comptime var pointers are not available at runtime
-// :4:27: note: 'runtime_value' points to comptime var declared here
+// :4:14: note: 'runtime_value' points to comptime var declared here
// :12:40: error: runtime value contains reference to comptime var
// :12:40: note: comptime var pointers are not available at runtime
-// :11:27: note: 'runtime_value' points to comptime var declared here
+// :11:14: note: 'runtime_value' points to comptime var declared here
// :19:50: error: runtime value contains reference to comptime var
// :19:50: note: comptime var pointers are not available at runtime
-// :18:27: note: 'runtime_value' points to comptime var declared here
+// :18:14: note: 'runtime_value' points to comptime var declared here
// :28:9: error: runtime value contains reference to comptime var
// :28:9: note: comptime var pointers are not available at runtime
-// :27:27: note: 'runtime_value' points to comptime var declared here
+// :27:14: note: 'runtime_value' points to comptime var declared here
// :36:9: error: runtime value contains reference to comptime var
// :36:9: note: comptime var pointers are not available at runtime
-// :35:27: note: 'runtime_value' points to comptime var declared here
+// :35:14: note: 'runtime_value' points to comptime var declared here
// :41:12: error: runtime value contains reference to comptime var
// :41:12: note: comptime var pointers are not available at runtime
-// :40:27: note: 'runtime_value' points to comptime var declared here
+// :40:14: note: 'runtime_value' points to comptime var declared here
// :46:39: error: runtime value contains reference to comptime var
// :46:39: note: comptime var pointers are not available at runtime
-// :45:27: note: 'runtime_value' points to comptime var declared here
+// :45:14: note: 'runtime_value' points to comptime var declared here
// :55:18: error: runtime value contains reference to comptime var
// :55:18: note: comptime var pointers are not available at runtime
-// :51:30: note: 'runtime_value' points to comptime var declared here
+// :51:14: note: 'runtime_value' points to comptime var declared here
// :63:18: error: runtime value contains reference to comptime var
// :63:18: note: comptime var pointers are not available at runtime
-// :59:27: note: 'runtime_value' points to comptime var declared here
+// :59:14: note: 'runtime_value' points to comptime var declared here
// :71:19: error: runtime value contains reference to comptime var
// :71:19: note: comptime var pointers are not available at runtime
-// :67:30: note: 'runtime_value' points to comptime var declared here
+// :67:14: note: 'runtime_value' points to comptime var declared here
diff --git a/test/cases/compile_errors/comptime_var_referenced_by_decl.zig b/test/cases/compile_errors/comptime_var_referenced_by_decl.zig
index 8bd0186b12..4f4b359311 100644
--- a/test/cases/compile_errors/comptime_var_referenced_by_decl.zig
+++ b/test/cases/compile_errors/comptime_var_referenced_by_decl.zig
@@ -47,19 +47,19 @@ export var h: *[1]u32 = h: {
// error
//
// :1:27: error: global variable contains reference to comptime var
-// :2:18: note: 'a' points to comptime var declared here
+// :2:5: note: 'a' points to comptime var declared here
// :6:30: error: global variable contains reference to comptime var
-// :7:18: note: 'b[0]' points to comptime var declared here
+// :7:5: note: 'b[0]' points to comptime var declared here
// :11:30: error: global variable contains reference to comptime var
-// :12:18: note: 'c' points to comptime var declared here
+// :12:5: note: 'c' points to comptime var declared here
// :16:33: error: global variable contains reference to comptime var
-// :17:18: note: 'd' points to comptime var declared here
+// :17:5: note: 'd' points to comptime var declared here
// :22:24: error: global variable contains reference to comptime var
-// :23:18: note: 'e.ptr' points to comptime var declared here
+// :23:5: note: 'e.ptr' points to comptime var declared here
// :28:33: error: global variable contains reference to comptime var
-// :29:18: note: 'f' points to comptime var declared here
+// :29:5: note: 'f' points to comptime var declared here
// :34:40: error: global variable contains reference to comptime var
// :34:40: note: 'g' points to 'v0[0]', where
-// :36:24: note: 'v0[1]' points to comptime var declared here
+// :36:5: note: 'v0[1]' points to comptime var declared here
// :42:28: error: global variable contains reference to comptime var
-// :43:22: note: 'h' points to comptime var declared here
+// :43:5: note: 'h' points to comptime var declared here
diff --git a/test/cases/compile_errors/comptime_var_referenced_by_type.zig b/test/cases/compile_errors/comptime_var_referenced_by_type.zig
index 1f1ba8318c..1b476d9cde 100644
--- a/test/cases/compile_errors/comptime_var_referenced_by_type.zig
+++ b/test/cases/compile_errors/comptime_var_referenced_by_type.zig
@@ -21,5 +21,6 @@ comptime {
// error
//
// :7:16: error: captured value contains reference to comptime var
-// :16:30: note: 'wrapper.ptr' points to comptime var declared here
+// :7:16: note: 'wrapper' points to '@as(*const tmp.Wrapper, @ptrCast(&v0)).*', where
+// :16:5: note: 'v0.ptr' points to comptime var declared here
// :17:29: note: called at comptime here
diff --git a/test/cases/compile_errors/enum_field_value_references_enum.zig b/test/cases/compile_errors/enum_field_value_references_enum.zig
index d658876cf6..2915048708 100644
--- a/test/cases/compile_errors/enum_field_value_references_enum.zig
+++ b/test/cases/compile_errors/enum_field_value_references_enum.zig
@@ -1,6 +1,8 @@
pub const Foo = enum(c_int) {
A = Foo.B,
C = D,
+
+ pub const B = 0;
};
export fn entry() void {
const s: Foo = Foo.E;
diff --git a/test/cases/compile_errors/enum_field_value_references_nonexistent_circular.zig b/test/cases/compile_errors/enum_field_value_references_nonexistent_circular.zig
new file mode 100644
index 0000000000..d658876cf6
--- /dev/null
+++ b/test/cases/compile_errors/enum_field_value_references_nonexistent_circular.zig
@@ -0,0 +1,13 @@
+pub const Foo = enum(c_int) {
+ A = Foo.B,
+ C = D,
+};
+export fn entry() void {
+ const s: Foo = Foo.E;
+ _ = s;
+}
+const D = 1;
+
+// error
+//
+// :1:5: error: dependency loop detected
diff --git a/test/cases/compile_errors/for_comptime_array_pointer.zig b/test/cases/compile_errors/for_comptime_array_pointer.zig
index 48f461cf42..8925fed2f6 100644
--- a/test/cases/compile_errors/for_comptime_array_pointer.zig
+++ b/test/cases/compile_errors/for_comptime_array_pointer.zig
@@ -9,4 +9,4 @@ export fn foo() void {
//
// :3:10: error: runtime value contains reference to comptime var
// :3:10: note: comptime var pointers are not available at runtime
-// :2:34: note: 'runtime_value' points to comptime var declared here
+// :2:14: note: 'runtime_value' points to comptime var declared here
diff --git a/test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig b/test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig
deleted file mode 100644
index 367b547d8e..0000000000
--- a/test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig
+++ /dev/null
@@ -1,19 +0,0 @@
-const Foo = packed struct {
- a: u8,
- b: u32,
-};
-
-export fn entry() void {
- var foo = Foo{ .a = 1, .b = 10 };
- bar(&foo.b);
-}
-
-fn bar(x: *u32) void {
- x.* += 1;
-}
-
-// error
-//
-// :8:9: error: expected type '*u32', found '*align(1) u32'
-// :8:9: note: pointer alignment '1' cannot cast into pointer alignment '4'
-// :11:11: note: parameter type declared here
diff --git a/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig b/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig
deleted file mode 100644
index 5a3d6ec53c..0000000000
--- a/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig
+++ /dev/null
@@ -1,19 +0,0 @@
-const Foo = packed struct {
- a: u8,
- b: u32,
-};
-
-export fn entry() void {
- var foo = Foo{ .a = 1, .b = 10 };
- foo.b += 1;
- bar(@as(*[1]u32, &foo.b)[0..]);
-}
-
-fn bar(x: []u32) void {
- x[0] += 1;
-}
-
-// error
-//
-// :9:22: error: expected type '*[1]u32', found '*align(1) u32'
-// :9:22: note: pointer alignment '1' cannot cast into pointer alignment '4'
diff --git a/test/cases/compile_errors/load_vector_pointer_with_unknown_runtime_index.zig b/test/cases/compile_errors/load_vector_pointer_with_unknown_runtime_index.zig
index 053dfde525..f72f44ca21 100644
--- a/test/cases/compile_errors/load_vector_pointer_with_unknown_runtime_index.zig
+++ b/test/cases/compile_errors/load_vector_pointer_with_unknown_runtime_index.zig
@@ -12,4 +12,4 @@ fn loadv(ptr: anytype) i31 {
// error
//
-// :10:15: error: unable to determine vector element index of type '*align(16:0:4:?) i31'
+// :5:22: error: vector index not comptime known
diff --git a/test/cases/compile_errors/store_vector_pointer_with_unknown_runtime_index.zig b/test/cases/compile_errors/store_vector_pointer_with_unknown_runtime_index.zig
index ee587b09ae..32a595d877 100644
--- a/test/cases/compile_errors/store_vector_pointer_with_unknown_runtime_index.zig
+++ b/test/cases/compile_errors/store_vector_pointer_with_unknown_runtime_index.zig
@@ -12,4 +12,4 @@ fn storev(ptr: anytype, val: i31) void {
// error
//
-// :10:8: error: unable to determine vector element index of type '*align(16:0:4:?) i31'
+// :6:15: error: vector index not comptime known