Commit 9ff80d7950

mlugg <mlugg@mlugg.co.uk>
2024-12-30 02:56:48
cases: update to new compile error wordings
1 parent 07b936c
test/cases/compile_errors/address_of_threadlocal_not_comptime_known.zig
@@ -10,5 +10,5 @@ pub export fn entry() void {
 // target=native
 //
 // :2:36: error: unable to resolve comptime value
-// :2:36: note: global variable initializer must be comptime-known
-// :2:36: note: thread local and dll imported variables have runtime-known addresses
+// :2:36: note: initializer of container-level variable must be comptime-known
+// :2:36: note: threadlocal and dll imported variables have runtime-known addresses
test/cases/compile_errors/anytype_param_requires_comptime.zig
@@ -13,8 +13,8 @@ pub export fn entry() void {
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :7:25: error: unable to resolve comptime value
-// :7:25: note: initializer of comptime only struct must be comptime-known
+// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_166.C' must be comptime-known
+// :4:16: note: struct requires comptime because of this field
+// :4:16: note: types are not available at runtime
test/cases/compile_errors/array_mult_with_number_type.zig
@@ -1,10 +1,9 @@
-export fn entry(base: f32, exponent: f32) f32 {
+const exponent: f32 = 1.0;
+export fn entry(base: f32) f32 {
     return base ** exponent;
 }
 
 // error
-// backend=stage2
-// target=native
 //
-// :2:12: error: expected indexable; found 'f32'
-// :2:17: note: this operator multiplies arrays; use std.math.pow for exponentiation
+// :3:12: error: expected indexable; found 'f32'
+// :3:17: note: this operator multiplies arrays; use std.math.pow for exponentiation
test/cases/compile_errors/asm_at_compile_time.zig
@@ -15,4 +15,5 @@ fn doSomeAsm() void {
 // target=native
 //
 // :6:5: error: unable to evaluate comptime expression
-// :2:14: note: called from here
+// :2:14: note: called at comptime from here
+// :1:1: note: 'comptime' keyword forces comptime evaluation
test/cases/compile_errors/attempted_double_pipe_on_boolean_values.zig
@@ -1,13 +1,11 @@
-export fn entry(a: bool, b: bool) i32 {
-    if (a || b) {
+export fn entry() i32 {
+    if (true || false) {
         return 1234;
     }
     return 5678;
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :2:9: error: expected error set type, found 'bool'
-// :2:11: note: '||' merges error sets; 'or' performs boolean OR
+// :2:14: note: '||' merges error sets; 'or' performs boolean OR
test/cases/compile_errors/branch_in_comptime_only_scope_uses_condbr_inline.zig
@@ -20,4 +20,6 @@ pub export fn entry2() void {
 //
 // :5:15: error: unable to evaluate comptime expression
 // :5:13: note: operation is runtime due to this operand
+// :4:72: note: '@shuffle' mask must be comptime-known
 // :13:11: error: unable to evaluate comptime expression
+// :12:72: note: '@shuffle' mask must be comptime-known
test/cases/compile_errors/builtin_extern_in_comptime_scope.zig
@@ -11,8 +11,8 @@ pub export fn entry2() void {
 // target=native
 //
 // :1:16: error: unable to resolve comptime value
-// :1:16: note: global variable initializer must be comptime-known
-// :1:16: note: thread local and dll imported variables have runtime-known addresses
+// :1:16: note: initializer of container-level variable must be comptime-known
+// :1:16: note: threadlocal and dll imported variables have runtime-known addresses
 // :2:17: error: unable to resolve comptime value
-// :2:17: note: global variable initializer must be comptime-known
-// :2:17: note: thread local and dll imported variables have runtime-known addresses
+// :2:17: note: initializer of container-level variable must be comptime-known
+// :2:17: note: threadlocal and dll imported variables have runtime-known addresses
test/cases/compile_errors/compile_time_struct_field.zig
@@ -4,16 +4,15 @@ const S = struct {
 };
 
 export fn a() void {
-  var value: u32 = 3;
-  const comptimeStruct = S {
-    .normal_ptr = &value,
-  };
-  _ = comptimeStruct;
+    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
+// :9:10: error: unable to resolve comptime value
+// :9:10: note: initializer of comptime-only struct 'tmp.S' must be comptime-known
+// :2:21: note: struct requires comptime because of this field
test/cases/compile_errors/condition_comptime_reason_explained.zig
@@ -33,18 +33,14 @@ pub export fn entry2() void {
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :8:9: error: unable to resolve comptime value
-// :8:9: note: condition in comptime branch must be comptime-known
-// :7:13: note: expression is evaluated at comptime because the function returns a comptime-only type 'tmp.S'
+// :19:15: note: called at comptime from here
+// :7:13: note: function with comptime-only return type 'tmp.S' is evaluated at comptime
 // :2:12: note: struct requires comptime because of this field
 // :2:12: note: use '*const fn () void' for a function pointer type
-// :19:15: note: called from here
 // :22:13: error: unable to resolve comptime value
-// :22:13: note: condition in comptime switch must be comptime-known
-// :21:17: note: expression is evaluated at comptime because the function returns a comptime-only type 'tmp.S'
+// :32:19: note: called at comptime from here
+// :21:17: note: function with comptime-only return type 'tmp.S' is evaluated at comptime
 // :2:12: note: struct requires comptime because of this field
 // :2:12: note: use '*const fn () void' for a function pointer type
-// :32:19: note: called from here
test/cases/compile_errors/enum_backed_by_comptime_int_must_be_casted_from_comptime_value.zig
@@ -11,4 +11,4 @@ export fn entry() void {
 // target=native
 //
 // :6:31: error: unable to resolve comptime value
-// :6:31: note: value being casted to enum with 'comptime_int' tag type must be comptime-known
+// :6:31: note: value casted to enum with 'comptime_int' tag type must be comptime-known
test/cases/compile_errors/error_in_typeof_param.zig
@@ -11,4 +11,4 @@ pub export fn entry() void {
 // target=native
 //
 // :6:31: error: unable to resolve comptime value
-// :6:31: note: value being casted to 'comptime_int' must be comptime-known
+// :6:31: note: value casted to 'comptime_int' must be comptime-known
test/cases/compile_errors/explain_why_fn_is_called_at_comptime.zig
@@ -4,7 +4,7 @@ const S = struct {
 };
 fn bar() void {}
 
-fn foo(comptime a: *u8) S {
+fn foo(a: *u8) S {
     return .{ .fnPtr = bar, .a = a.* };
 }
 pub export fn entry() void {
@@ -13,11 +13,8 @@ pub export fn entry() void {
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :12:13: error: unable to resolve comptime value
-// :12:13: note: argument to function being called at comptime must be comptime-known
-// :7:25: note: expression is evaluated at comptime because the function returns a comptime-only type 'tmp.S'
+// :7:16: note: function with comptime-only return type 'tmp.S' is evaluated at comptime
 // :2:12: note: struct requires comptime because of this field
 // :2:12: note: use '*const fn () void' for a function pointer type
test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig
@@ -15,9 +15,8 @@ pub export fn entry() void {
     _ = foo(a, fn () void);
 }
 // error
-// backend=stage2
-// target=native
 //
 // :15:13: error: unable to resolve comptime value
-// :15:13: note: argument to function being called at comptime must be comptime-known
-// :9:38: note: expression is evaluated at comptime because the generic function was instantiated with a comptime-only return type
+// :9:38: note: generic function instantiated with comptime-only return type 'tmp.S(fn () void)' is evaluated at comptime
+// :3:16: note: struct requires comptime because of this field
+// :3:16: note: use '*const fn () void' for a function pointer type
test/cases/compile_errors/global_var_struct_init_in_comptim_block.zig → test/cases/compile_errors/global_var_struct_init_in_comptime_block.zig
@@ -12,3 +12,4 @@ comptime {
 //
 // :6:17: error: unable to evaluate comptime expression
 // :6:17: note: operation is runtime due to this operand
+// :5:1: note: 'comptime' keyword forces comptime evaluation
test/cases/compile_errors/global_variable_stored_in_global_const.zig
@@ -5,8 +5,6 @@ pub export fn entry() void {
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :2:11: error: unable to resolve comptime value
-// :2:11: note: global variable initializer must be comptime-known
+// :2:11: note: initializer of container-level variable must be comptime-known
test/cases/compile_errors/incorrect_pointer_dereference_syntax.zig
@@ -1,12 +1,9 @@
 pub export fn entry() void {
-    var a: *u32 = undefined;
+    const a: *u32 = undefined;
     _ = *a;
-    _ = &a;
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :3:10: error: expected type 'type', found '*u32'
 // :3:10: note: use '.*' to dereference pointer
test/cases/compile_errors/inline_call_runtime_value_to_comptime_param.zig
@@ -14,4 +14,4 @@ pub export fn entry() void {
 // target=native
 //
 // :5:18: error: unable to resolve comptime value
-// :5:18: note: parameter is comptime
+// :5:18: note: argument to comptime parameter must be comptime-known
test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig
@@ -10,10 +10,8 @@ export fn bar() void {
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :4:41: error: unable to resolve comptime value
-// :4:41: note: value being casted to 'comptime_int' must be comptime-known
+// :4:41: note: value casted to 'comptime_int' must be comptime-known
 // :9:43: error: unable to resolve comptime value
-// :9:43: note: value being casted to 'comptime_float' must be comptime-known
+// :9:43: note: value casted to 'comptime_float' must be comptime-known
test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig
@@ -13,9 +13,8 @@ export fn entry() usize {
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :6:24: error: unable to evaluate comptime expression
 // :6:5: note: operation is runtime due to this operand
-// :4:17: note: called from here
+// :4:17: note: called at comptime from here
+// :4:17: note: initializer of container-level variable must be comptime-known
test/cases/compile_errors/non-pure_function_returns_type.zig
@@ -23,4 +23,5 @@ export fn function_with_return_type_type() void {
 //
 // :3:7: error: unable to evaluate comptime expression
 // :3:5: note: operation is runtime due to this operand
-// :16:19: note: called from here
+// :16:19: note: called at comptime from here
+// :16:19: note: types must be comptime-known
test/cases/compile_errors/non_comptime_param_in_comptime_function.zig
@@ -9,10 +9,7 @@ export fn entry() void {
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :8:11: error: unable to resolve comptime value
-// :8:11: note: argument to function being called at comptime must be comptime-known
-// :1:20: note: expression is evaluated at comptime because the function returns a comptime-only type 'type'
+// :1:20: note: function with comptime-only return type 'type' is evaluated at comptime
 // :1:20: note: types are not available at runtime
test/cases/compile_errors/non_constant_expression_in_array_size.zig
@@ -15,5 +15,5 @@ export fn entry() usize {
 // target=native
 //
 // :6:12: error: unable to resolve comptime value
-// :6:12: note: value being returned at comptime must be comptime-known
-// :2:12: note: called from here
+// :2:12: note: called at comptime from here
+// :1:13: note: struct fields must be comptime-known
test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig
@@ -10,8 +10,8 @@ export fn f() void {
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :7:23: error: unable to resolve comptime value
-// :7:23: note: initializer of comptime only struct must be comptime-known
+// :7:23: note: initializer of comptime-only struct 'tmp.Foo' must be comptime-known
+// :3:10: note: struct requires comptime because of this field
+// :3:10: note: types are not available at runtime
test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig
@@ -10,8 +10,8 @@ export fn f() void {
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :8:23: error: unable to resolve comptime value
-// :8:23: note: initializer of comptime only union must be comptime-known
+// :8:23: note: initializer of comptime-only union 'tmp.Foo' must be comptime-known
+// :3:10: note: union requires comptime because of this field
+// :3:10: note: types are not available at runtime
test/cases/compile_errors/runtime_to_comptime_num.zig
@@ -26,10 +26,10 @@ pub export fn entry4() void {
 // target=native
 //
 // :4:27: error: unable to resolve comptime value
-// :4:27: note: value being casted to 'comptime_int' must be comptime-known
+// :4:27: note: value casted to 'comptime_int' must be comptime-known
 // :9:29: error: unable to resolve comptime value
-// :9:29: note: value being casted to 'comptime_float' must be comptime-known
+// :9:29: note: value casted to 'comptime_float' must be comptime-known
 // :15:10: error: unable to resolve comptime value
-// :15:10: note: value being casted to 'comptime_float' must be comptime-known
+// :15:10: note: value casted to 'comptime_float' must be comptime-known
 // :21:10: error: unable to resolve comptime value
-// :21:10: note: value being casted to 'comptime_int' must be comptime-known
+// :21:10: note: value casted to 'comptime_int' must be comptime-known
test/cases/compile_errors/slice_of_single-item_pointer_bounds.zig
@@ -31,13 +31,13 @@ export fn entry2() void {
 
 // error
 //
-// :5:12: error: slice of single-item pointer must have comptime-known bounds [0..0], [0..1], or [1..1]
-// :9:13: error: slice of single-item pointer must have comptime-known bounds [0..0], [0..1], or [1..1]
+// :5:12: error: slice of single-item pointer must be bounded
+// :9:13: error: slice of single-item pointer must have bounds [0..0], [0..1], or [1..1]
 // :9:13: note: expected '0', found '1'
-// :13:16: error: slice of single-item pointer must have comptime-known bounds [0..0], [0..1], or [1..1]
+// :13:16: error: slice of single-item pointer must have bounds [0..0], [0..1], or [1..1]
 // :13:16: note: expected '1', found '2'
 // :17:16: error: end index 2 out of bounds for slice of single-item pointer
 // :23:13: error: unable to resolve comptime value
-// :23:13: note: slice of single-item pointer must have comptime-known bounds [0..0], [0..1], or [1..1]
+// :23:13: note: slice of single-item pointer must have comptime-known bounds
 // :29:16: error: unable to resolve comptime value
-// :29:16: note: slice of single-item pointer must have comptime-known bounds [0..0], [0..1], or [1..1]
+// :29:16: note: slice of single-item pointer must have comptime-known bounds
test/cases/compile_errors/unable_to_evaluate_comptime_expr.zig
@@ -33,12 +33,13 @@ pub export fn entry3() void {
 }
 
 // error
-// backend=stage2
-// target=native
 //
 // :7:13: error: unable to evaluate comptime expression
 // :7:16: note: operation is runtime due to this operand
+// :7:13: note: initializer of container-level variable must be comptime-known
 // :13:13: error: unable to evaluate comptime expression
 // :13:16: note: operation is runtime due to this operand
+// :13:13: note: initializer of container-level variable must be comptime-known
 // :22:9: error: unable to evaluate comptime expression
 // :22:21: note: operation is runtime due to this operand
+// :21:13: note: enum fields must be comptime-known
test/cases/compile_errors/unable_to_evaluate_expr_inside_cimport.zig
@@ -12,4 +12,4 @@ export fn entry() void {
 //
 // :2:11: error: unable to evaluate comptime expression
 // :2:13: note: operation is runtime due to this operand
-// :1:11: note: expression is evaluated at comptime because it is inside a @cImport
+// :1:11: note: operand to '@cImport' is evaluated at comptime
test/compile_errors.zig
@@ -57,8 +57,8 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
             \\}
         , &[_][]const u8{
             ":3:12: error: unable to resolve comptime value",
-            ":3:12: note: argument to function being called at comptime must be comptime-known",
-            ":2:55: note: expression is evaluated at comptime because the generic function was instantiated with a comptime-only return type",
+            ":2:55: note: generic function instantiated with comptime-only return type '?fn () void' is evaluated at comptime",
+            ":2:55: note: use '*const fn () void' for a function pointer type",
         });
         case.addSourceFile("b.zig",
             \\pub const ElfDynLib = struct {
@@ -198,7 +198,9 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
             ":8:36: error: runtime-known argument passed to comptime parameter",
             ":2:41: note: declared comptime here",
             ":13:32: error: unable to resolve comptime value",
-            ":13:32: note: initializer of comptime only struct must be comptime-known",
+            ":13:32: note: initializer of comptime-only struct 'tmp.callAnytypeFunctionWithRuntimeComptimeOnlyType.S' must be comptime-known",
+            ":12:35: note: struct requires comptime because of this field",
+            ":12:35: note: types are not available at runtime",
         });
 
         case.addSourceFile("import.zig",