aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-11-11 07:27:31 +0000
committermlugg <mlugg@mlugg.co.uk>2023-11-19 09:56:51 +0000
commit21fa187abc2a06c9bd5cfe4355c5edbfb3177f6b (patch)
treeaab7cc16498184bac0fd8b6d5443f7bd606e7bf8 /test/cases/compile_errors
parent2c1acb618027939c0812bc87a432b51632127717 (diff)
downloadzig-21fa187abc2a06c9bd5cfe4355c5edbfb3177f6b.tar.gz
zig-21fa187abc2a06c9bd5cfe4355c5edbfb3177f6b.zip
test: update cases to silence 'var is never mutated' errors
Diffstat (limited to 'test/cases/compile_errors')
-rw-r--r--test/cases/compile_errors/AstGen_comptime_known_struct_is_resolved_before_error.zig2
-rw-r--r--test/cases/compile_errors/C_pointer_pointing_to_non_C_ABI_compatible_type_or_has_align_attr.zig2
-rw-r--r--test/cases/compile_errors/C_pointer_to_anyopaque.zig2
-rw-r--r--test/cases/compile_errors/accessing_runtime_parameter_from_outer_function.zig4
-rw-r--r--test/cases/compile_errors/add_on_undefined_value.zig2
-rw-r--r--test/cases/compile_errors/alignment_of_enum_field_specified.zig2
-rw-r--r--test/cases/compile_errors/ambiguous_coercion_of_division_operands.zig12
-rw-r--r--test/cases/compile_errors/and_on_undefined_value.zig3
-rw-r--r--test/cases/compile_errors/array_access_of_non_array.zig2
-rw-r--r--test/cases/compile_errors/array_access_of_type.zig2
-rw-r--r--test/cases/compile_errors/array_access_with_non_integer_index.zig4
-rw-r--r--test/cases/compile_errors/array_init_invalid_elem_count.zig12
-rw-r--r--test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig2
-rw-r--r--test/cases/compile_errors/assign_local_bad_coercion.zig2
-rw-r--r--test/cases/compile_errors/assign_too_big_number_to_u16.zig4
-rw-r--r--test/cases/compile_errors/assigning_to_struct_or_union_fields_that_are_not_optionals_with_a_function_that_returns_an_optional.zig4
-rw-r--r--test/cases/compile_errors/async/Frame_of_generic_function.zig4
-rw-r--r--test/cases/compile_errors/async/async_function_depends_on_its_own_frame.zig2
-rw-r--r--test/cases/compile_errors/async/async_function_indirectly_depends_on_its_own_frame.zig2
-rw-r--r--test/cases/compile_errors/async/bad_alignment_in_asynccall.zig1
-rw-r--r--test/cases/compile_errors/async/const_frame_cast_to_anyframe.zig2
-rw-r--r--test/cases/compile_errors/async/indirect_recursion_of_async_functions_detected.zig8
-rw-r--r--test/cases/compile_errors/async/invalid_suspend_in_exported_function.zig2
-rw-r--r--test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig1
-rw-r--r--test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig6
-rw-r--r--test/cases/compile_errors/async/runtime-known_async_function_called.zig1
-rw-r--r--test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig1
-rw-r--r--test/cases/compile_errors/attempted_implicit_cast_from_const_T_to_array_len_1_T.zig4
-rw-r--r--test/cases/compile_errors/bad_alignment_in_implicit_cast_from_array_pointer_to_slice.zig6
-rw-r--r--test/cases/compile_errors/bad_alignment_type.zig8
-rw-r--r--test/cases/compile_errors/bad_usage_of_call.zig5
-rw-r--r--test/cases/compile_errors/binary_OR_operator_on_error_sets.zig2
-rw-r--r--test/cases/compile_errors/bitCast_same_size_but_bit_count_mismatch.zig4
-rw-r--r--test/cases/compile_errors/bitCast_with_different_sizes_inside_an_expression.zig5
-rw-r--r--test/cases/compile_errors/branch_in_comptime_only_scope_uses_condbr_inline.zig8
-rw-r--r--test/cases/compile_errors/break_void_result_location.zig5
-rw-r--r--test/cases/compile_errors/c_pointer_to_void.zig6
-rw-r--r--test/cases/compile_errors/callconv_stdcall_fastcall_thiscall_on_unsupported_platform.zig6
-rw-r--r--test/cases/compile_errors/cast_between_optional_T_where_T_is_not_a_pointer.zig8
-rw-r--r--test/cases/compile_errors/cast_error_union_of_global_error_set_to_error_union_of_smaller_error_set.zig6
-rw-r--r--test/cases/compile_errors/cast_global_error_set_to_error_set.zig6
-rw-r--r--test/cases/compile_errors/catch_on_undefined_value.zig2
-rw-r--r--test/cases/compile_errors/compare_optional_to_non_optional_with_incomparable_type.zig4
-rw-r--r--test/cases/compile_errors/comparison_operators_with_undefined_value.zig12
-rw-r--r--test/cases/compile_errors/compile_error_in_struct_init_expression.zig2
-rw-r--r--test/cases/compile_errors/compile_time_null_ptr_cast.zig2
-rw-r--r--test/cases/compile_errors/compile_time_undef_ptr_cast.zig1
-rw-r--r--test/cases/compile_errors/comptime_cast_enum_to_union_but_field_has_payload.zig2
-rw-r--r--test/cases/compile_errors/comptime_continue_inside_runtime_if_bool.zig5
-rw-r--r--test/cases/compile_errors/comptime_continue_inside_runtime_if_error.zig5
-rw-r--r--test/cases/compile_errors/comptime_continue_inside_runtime_if_optional.zig5
-rw-r--r--test/cases/compile_errors/comptime_continue_inside_runtime_switch.zig5
-rw-r--r--test/cases/compile_errors/comptime_continue_inside_runtime_while_bool.zig5
-rw-r--r--test/cases/compile_errors/comptime_continue_inside_runtime_while_error.zig5
-rw-r--r--test/cases/compile_errors/comptime_continue_inside_runtime_while_optional.zig5
-rw-r--r--test/cases/compile_errors/comptime_continue_to_outer_inline_loop.zig5
-rw-r--r--test/cases/compile_errors/comptime_if_inside_runtime_for.zig7
-rw-r--r--test/cases/compile_errors/comptime_slice_of_an_undefined_slice.zig2
-rw-r--r--test/cases/compile_errors/comptime_struct_field_no_init_value.zig2
-rw-r--r--test/cases/compile_errors/comptime_vector_overflow_shows_the_index.zig2
-rw-r--r--test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig6
-rw-r--r--test/cases/compile_errors/deref_on_undefined_value.zig2
-rw-r--r--test/cases/compile_errors/deref_slice_and_get_len_field.zig1
-rw-r--r--test/cases/compile_errors/dereference_an_array.zig3
-rw-r--r--test/cases/compile_errors/dereferencing_invalid_payload_ptr_at_comptime.zig2
-rw-r--r--test/cases/compile_errors/directly_embedding_opaque_type_in_struct_and_union.zig4
-rw-r--r--test/cases/compile_errors/div_on_undefined_value.zig1
-rw-r--r--test/cases/compile_errors/double_pointer_to_anyopaque_pointer.zig7
-rw-r--r--test/cases/compile_errors/empty_switch_on_an_integer.zig2
-rw-r--r--test/cases/compile_errors/enum_backed_by_comptime_int_must_be_comptime.zig2
-rw-r--r--test/cases/compile_errors/enum_field_value_references_enum.zig2
-rw-r--r--test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig4
-rw-r--r--test/cases/compile_errors/enum_value_already_taken.zig2
-rw-r--r--test/cases/compile_errors/error_in_struct_initializer_doesnt_crash_the_compiler.zig2
-rw-r--r--test/cases/compile_errors/error_union_operator_with_non_error_set_LHS.zig2
-rw-r--r--test/cases/compile_errors/error_when_evaluating_return_type.zig2
-rw-r--r--test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig5
-rw-r--r--test/cases/compile_errors/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig6
-rw-r--r--test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig4
-rw-r--r--test/cases/compile_errors/extern_union_field_missing_type.zig2
-rw-r--r--test/cases/compile_errors/extern_union_given_enum_tag_type.zig2
-rw-r--r--test/cases/compile_errors/field_access_of_slices.zig5
-rw-r--r--test/cases/compile_errors/for.zig7
-rw-r--r--test/cases/compile_errors/for_loop_body_expression_ignored.zig2
-rw-r--r--test/cases/compile_errors/function_ptr_alignment.zig10
-rw-r--r--test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig3
-rw-r--r--test/cases/compile_errors/generic_method_call_with_invalid_param.zig9
-rw-r--r--test/cases/compile_errors/ignored_expression_in_while_continuation.zig10
-rw-r--r--test/cases/compile_errors/implicit_cast_between_C_pointer_and_Zig_pointer-bad_const-align-child.zig12
-rw-r--r--test/cases/compile_errors/implicit_cast_from_f64_to_f32.zig2
-rw-r--r--test/cases/compile_errors/implicit_cast_of_error_set_not_a_subset.zig6
-rw-r--r--test/cases/compile_errors/implicit_casting_C_pointers_which_would_mess_up_null_semantics.zig13
-rw-r--r--test/cases/compile_errors/implicit_casting_null_c_pointer_to_zig_pointer.zig5
-rw-r--r--test/cases/compile_errors/implicitly_casting_enum_to_tag_type.zig2
-rw-r--r--test/cases/compile_errors/incompatible sub-byte fields.zig7
-rw-r--r--test/cases/compile_errors/incompatible_sentinels.zig4
-rw-r--r--test/cases/compile_errors/incorrect_pointer_dereference_syntax.zig1
-rw-r--r--test/cases/compile_errors/incorrect_type_to_memset_memcpy.zig8
-rw-r--r--test/cases/compile_errors/indexing_an_array_of_size_zero_with_runtime_index.zig3
-rw-r--r--test/cases/compile_errors/inline_call_runtime_value_to_comptime_param.zig2
-rw-r--r--test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig10
-rw-r--r--test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig4
-rw-r--r--test/cases/compile_errors/int_to_err_global_invalid_number.zig2
-rw-r--r--test/cases/compile_errors/int_to_err_non_global_invalid_number.zig6
-rw-r--r--test/cases/compile_errors/integer_cast_truncates_bits.zig4
-rw-r--r--test/cases/compile_errors/invalid_compare_string.zig8
-rw-r--r--test/cases/compile_errors/invalid_deref_on_switch_target.zig2
-rw-r--r--test/cases/compile_errors/invalid_float_casts.zig12
-rw-r--r--test/cases/compile_errors/invalid_inline_else_type.zig9
-rw-r--r--test/cases/compile_errors/invalid_int_casts.zig12
-rw-r--r--test/cases/compile_errors/invalid_multiple_dereferences.zig9
-rw-r--r--test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig4
-rw-r--r--test/cases/compile_errors/invalid_peer_type_resolution.zig38
-rw-r--r--test/cases/compile_errors/invalid_store_to_comptime_field.zig24
-rw-r--r--test/cases/compile_errors/invalid_struct_field.zig5
-rw-r--r--test/cases/compile_errors/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig4
-rw-r--r--test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig2
-rw-r--r--test/cases/compile_errors/issue_5618_coercion_of_optional_anyopaque_to_anyopaque_must_fail.zig10
-rw-r--r--test/cases/compile_errors/lazy_pointer_with_undefined_element_type.zig3
-rw-r--r--test/cases/compile_errors/load_vector_pointer_with_unknown_runtime_index.zig2
-rw-r--r--test/cases/compile_errors/memset_no_length.zig10
-rw-r--r--test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig2
-rw-r--r--test/cases/compile_errors/missing_else_clause.zig4
-rw-r--r--test/cases/compile_errors/missing_parameter_name_of_generic_function.zig2
-rw-r--r--test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig2
-rw-r--r--test/cases/compile_errors/mod_on_undefined_value.zig1
-rw-r--r--test/cases/compile_errors/mult_on_undefined_value.zig2
-rw-r--r--test/cases/compile_errors/negate_on_undefined_value.zig2
-rw-r--r--test/cases/compile_errors/nested_vectors.zig2
-rw-r--r--test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig14
-rw-r--r--test/cases/compile_errors/non-integer_tag_type_to_enum.zig2
-rw-r--r--test/cases/compile_errors/non_void_error_union_payload_ignored.zig6
-rw-r--r--test/cases/compile_errors/not_an_enum_type.zig2
-rw-r--r--test/cases/compile_errors/or_on_undefined_value.zig3
-rw-r--r--test/cases/compile_errors/orelse_on_undefined_value.zig2
-rw-r--r--test/cases/compile_errors/out_of_bounds_index.zig16
-rw-r--r--test/cases/compile_errors/overflow_in_enum_value_allocation.zig2
-rw-r--r--test/cases/compile_errors/packed_union_given_enum_tag_type.zig2
-rw-r--r--test/cases/compile_errors/packed_union_with_automatic_layout_field.zig2
-rw-r--r--test/cases/compile_errors/pointer_arithmetic_on_pointer-to-array.zig10
-rw-r--r--test/cases/compile_errors/pointer_to_anyopaque_slice.zig1
-rw-r--r--test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig2
-rw-r--r--test/cases/compile_errors/recursive_inline_fn.zig3
-rw-r--r--test/cases/compile_errors/reference_to_const_data.zig9
-rw-r--r--test/cases/compile_errors/reify_typeOf_with_incompatible_arguments.zig1
-rw-r--r--test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr.zig2
-rw-r--r--test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr_generic_call.zig2
-rw-r--r--test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig1
-rw-r--r--test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig5
-rw-r--r--test/cases/compile_errors/runtime_cast_to_union_which_has_non-void_fields.zig4
-rw-r--r--test/cases/compile_errors/runtime_indexing_comptime_array.zig6
-rw-r--r--test/cases/compile_errors/runtime_to_comptime_num.zig20
-rw-r--r--test/cases/compile_errors/runtime_value_in_switch_prong.zig2
-rw-r--r--test/cases/compile_errors/self_referential_struct_requires_comptime.zig2
-rw-r--r--test/cases/compile_errors/self_referential_union_requires_comptime.zig2
-rw-r--r--test/cases/compile_errors/shift_by_negative_comptime_integer.zig4
-rw-r--r--test/cases/compile_errors/shift_on_type_with_non-power-of-two_size.zig12
-rw-r--r--test/cases/compile_errors/shifting_without_int_type_or_comptime_known.zig6
-rw-r--r--test/cases/compile_errors/shuffle_with_selected_index_past_first_vector_length.zig8
-rw-r--r--test/cases/compile_errors/slice_cannot_have_its_bytes_reinterpreted.zig5
-rw-r--r--test/cases/compile_errors/slice_of_null_pointer.zig6
-rw-r--r--test/cases/compile_errors/slice_sentinel_mismatch-2.zig2
-rw-r--r--test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig3
-rw-r--r--test/cases/compile_errors/specify_non-integer_enum_tag_type.zig2
-rw-r--r--test/cases/compile_errors/stage1/obj/variable_in_inline_assembly_template_cannot_be_found.zig2
-rw-r--r--test/cases/compile_errors/store_vector_pointer_with_unknown_runtime_index.zig3
-rw-r--r--test/cases/compile_errors/sub_on_undefined_value.zig2
-rw-r--r--test/cases/compile_errors/switch_capture_incompatible_types.zig4
-rw-r--r--test/cases/compile_errors/switch_on_enum_with_1_field_with_no_prongs.zig2
-rw-r--r--test/cases/compile_errors/switch_on_slice.zig3
-rw-r--r--test/cases/compile_errors/switch_ranges_endpoints_are_validated.zig4
-rw-r--r--test/cases/compile_errors/switch_with_overlapping_case_ranges.zig2
-rw-r--r--test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig2
-rw-r--r--test/cases/compile_errors/switching_with_non-exhaustive_enums.zig6
-rw-r--r--test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig7
-rw-r--r--test/cases/compile_errors/truncate_sign_mismatch.zig16
-rw-r--r--test/cases/compile_errors/tuple_init_edge_cases.zig41
-rw-r--r--test/cases/compile_errors/union_access_of_inactive_field.zig1
-rw-r--r--test/cases/compile_errors/union_auto-enum_value_already_taken.zig2
-rw-r--r--test/cases/compile_errors/union_duplicate_enum_field.zig2
-rw-r--r--test/cases/compile_errors/union_enum_field_does_not_match_enum.zig2
-rw-r--r--test/cases/compile_errors/union_noreturn_field_initialized.zig6
-rw-r--r--test/cases/compile_errors/union_runtime_coercion_from_enum.zig2
-rw-r--r--test/cases/compile_errors/unreachable_else_prong_err_set.zig (renamed from test/cases/compile_errors/uncreachable_else_prong_err_set.zig)4
-rw-r--r--test/cases/compile_errors/use_implicit_casts_to_assign_null_to_non-nullable_pointer.zig11
-rw-r--r--test/cases/compile_errors/use_invalid_number_literal_as_array_index.zig2
-rw-r--r--test/cases/compile_errors/variable_with_type_noreturn.zig2
-rw-r--r--test/cases/compile_errors/variadic_arg_validation.zig9
-rw-r--r--test/cases/compile_errors/while_loop_body_expression_ignored.zig28
-rw-r--r--test/cases/compile_errors/while_loop_break_value_ignored.zig6
-rw-r--r--test/cases/compile_errors/wrong_type_passed_to_panic.zig2
191 files changed, 532 insertions, 431 deletions
diff --git a/test/cases/compile_errors/AstGen_comptime_known_struct_is_resolved_before_error.zig b/test/cases/compile_errors/AstGen_comptime_known_struct_is_resolved_before_error.zig
index 3ec79c7c53..0764dc9472 100644
--- a/test/cases/compile_errors/AstGen_comptime_known_struct_is_resolved_before_error.zig
+++ b/test/cases/compile_errors/AstGen_comptime_known_struct_is_resolved_before_error.zig
@@ -6,7 +6,7 @@ const S2 = struct {
};
pub export fn entry() void {
var s: S1 = undefined;
- _ = s;
+ _ = &s;
}
// error
diff --git a/test/cases/compile_errors/C_pointer_pointing_to_non_C_ABI_compatible_type_or_has_align_attr.zig b/test/cases/compile_errors/C_pointer_pointing_to_non_C_ABI_compatible_type_or_has_align_attr.zig
index c10a146cf0..c0188477b8 100644
--- a/test/cases/compile_errors/C_pointer_pointing_to_non_C_ABI_compatible_type_or_has_align_attr.zig
+++ b/test/cases/compile_errors/C_pointer_pointing_to_non_C_ABI_compatible_type_or_has_align_attr.zig
@@ -1,7 +1,7 @@
const Foo = struct { a: u32 };
export fn a() void {
const T = [*c]Foo;
- var t: T = undefined;
+ const t: T = undefined;
_ = t;
}
diff --git a/test/cases/compile_errors/C_pointer_to_anyopaque.zig b/test/cases/compile_errors/C_pointer_to_anyopaque.zig
index c2a0ad088d..21c67e151c 100644
--- a/test/cases/compile_errors/C_pointer_to_anyopaque.zig
+++ b/test/cases/compile_errors/C_pointer_to_anyopaque.zig
@@ -1,7 +1,7 @@
export fn a() void {
var x: *anyopaque = undefined;
var y: [*c]anyopaque = x;
- _ = y;
+ _ = .{ &x, &y };
}
// error
diff --git a/test/cases/compile_errors/accessing_runtime_parameter_from_outer_function.zig b/test/cases/compile_errors/accessing_runtime_parameter_from_outer_function.zig
index 49ef3b4d4d..176ace28db 100644
--- a/test/cases/compile_errors/accessing_runtime_parameter_from_outer_function.zig
+++ b/test/cases/compile_errors/accessing_runtime_parameter_from_outer_function.zig
@@ -7,8 +7,8 @@ fn outer(y: u32) *const fn (u32) u32 {
return st.get;
}
export fn entry() void {
- var func = outer(10);
- var x = func(3);
+ const func = outer(10);
+ const x = func(3);
_ = x;
}
diff --git a/test/cases/compile_errors/add_on_undefined_value.zig b/test/cases/compile_errors/add_on_undefined_value.zig
index 404f5019be..b59de233c5 100644
--- a/test/cases/compile_errors/add_on_undefined_value.zig
+++ b/test/cases/compile_errors/add_on_undefined_value.zig
@@ -1,5 +1,5 @@
comptime {
- var a: i64 = undefined;
+ const a: i64 = undefined;
_ = a + a;
}
diff --git a/test/cases/compile_errors/alignment_of_enum_field_specified.zig b/test/cases/compile_errors/alignment_of_enum_field_specified.zig
index ecb06aa254..409a8e0f93 100644
--- a/test/cases/compile_errors/alignment_of_enum_field_specified.zig
+++ b/test/cases/compile_errors/alignment_of_enum_field_specified.zig
@@ -6,7 +6,7 @@ const Number = enum {
// zig fmt: on
export fn entry1() void {
- var x: Number = undefined;
+ const x: Number = undefined;
_ = x;
}
diff --git a/test/cases/compile_errors/ambiguous_coercion_of_division_operands.zig b/test/cases/compile_errors/ambiguous_coercion_of_division_operands.zig
index f3e51a1bed..5defb463c2 100644
--- a/test/cases/compile_errors/ambiguous_coercion_of_division_operands.zig
+++ b/test/cases/compile_errors/ambiguous_coercion_of_division_operands.zig
@@ -1,17 +1,17 @@
export fn entry1() void {
- var f: f32 = 54.0 / 5;
+ const f: f32 = 54.0 / 5;
_ = f;
}
export fn entry2() void {
- var f: f32 = 54 / 5.0;
+ const f: f32 = 54 / 5.0;
_ = f;
}
export fn entry3() void {
- var f: f32 = 55.0 / 5;
+ const f: f32 = 55.0 / 5;
_ = f;
}
export fn entry4() void {
- var f: f32 = 55 / 5.0;
+ const f: f32 = 55 / 5.0;
_ = f;
}
@@ -19,5 +19,5 @@ export fn entry4() void {
// backend=stage2
// target=native
//
-// :2:23: error: ambiguous coercion of division operands 'comptime_float' and 'comptime_int'; non-zero remainder '4'
-// :6:21: error: ambiguous coercion of division operands 'comptime_int' and 'comptime_float'; non-zero remainder '4'
+// :2:25: error: ambiguous coercion of division operands 'comptime_float' and 'comptime_int'; non-zero remainder '4'
+// :6:23: error: ambiguous coercion of division operands 'comptime_int' and 'comptime_float'; non-zero remainder '4'
diff --git a/test/cases/compile_errors/and_on_undefined_value.zig b/test/cases/compile_errors/and_on_undefined_value.zig
index cee23d0540..416ba80097 100644
--- a/test/cases/compile_errors/and_on_undefined_value.zig
+++ b/test/cases/compile_errors/and_on_undefined_value.zig
@@ -1,5 +1,6 @@
comptime {
var a: bool = undefined;
+ _ = &a;
_ = a and a;
}
@@ -7,4 +8,4 @@ comptime {
// backend=stage2
// target=native
//
-// :3:9: error: use of undefined value here causes undefined behavior
+// :4:9: error: use of undefined value here causes undefined behavior
diff --git a/test/cases/compile_errors/array_access_of_non_array.zig b/test/cases/compile_errors/array_access_of_non_array.zig
index 0f06bae1dd..4bcb9bd237 100644
--- a/test/cases/compile_errors/array_access_of_non_array.zig
+++ b/test/cases/compile_errors/array_access_of_non_array.zig
@@ -3,7 +3,7 @@ export fn f() void {
bad[0] = bad[0];
}
export fn g() void {
- var bad: bool = undefined;
+ const bad: bool = undefined;
_ = bad[0];
}
diff --git a/test/cases/compile_errors/array_access_of_type.zig b/test/cases/compile_errors/array_access_of_type.zig
index 1e66ca3776..b9e6f24a55 100644
--- a/test/cases/compile_errors/array_access_of_type.zig
+++ b/test/cases/compile_errors/array_access_of_type.zig
@@ -1,6 +1,6 @@
export fn foo() void {
var b: u8[40] = undefined;
- _ = b;
+ _ = &b;
}
// error
diff --git a/test/cases/compile_errors/array_access_with_non_integer_index.zig b/test/cases/compile_errors/array_access_with_non_integer_index.zig
index 3d7bde7364..0189d0f09c 100644
--- a/test/cases/compile_errors/array_access_with_non_integer_index.zig
+++ b/test/cases/compile_errors/array_access_with_non_integer_index.zig
@@ -2,11 +2,13 @@ export fn f() void {
var array = "aoeu";
var bad = false;
array[bad] = array[bad];
+ _ = &bad;
}
export fn g() void {
var array = "aoeu";
var bad = false;
_ = array[bad];
+ _ = .{ &array, &bad };
}
// error
@@ -14,4 +16,4 @@ export fn g() void {
// target=native
//
// :4:11: error: expected type 'usize', found 'bool'
-// :9:15: error: expected type 'usize', found 'bool'
+// :10:15: error: expected type 'usize', found 'bool'
diff --git a/test/cases/compile_errors/array_init_invalid_elem_count.zig b/test/cases/compile_errors/array_init_invalid_elem_count.zig
index 23e00cd057..ce28145269 100644
--- a/test/cases/compile_errors/array_init_invalid_elem_count.zig
+++ b/test/cases/compile_errors/array_init_invalid_elem_count.zig
@@ -2,27 +2,27 @@ const V = @Vector(8, u8);
const A = [8]u8;
comptime {
var v: V = V{1};
- _ = v;
+ _ = &v;
}
comptime {
var v: V = V{};
- _ = v;
+ _ = &v;
}
comptime {
var a: A = A{1};
- _ = a;
+ _ = &a;
}
comptime {
var a: A = A{};
- _ = a;
+ _ = &a;
}
pub export fn entry1() void {
var bla: V = .{ 1, 2, 3, 4 };
- _ = bla;
+ _ = &bla;
}
pub export fn entry2() void {
var bla: A = .{ 1, 2, 3, 4 };
- _ = bla;
+ _ = &bla;
}
const S = struct {
list: [2]u8 = .{0},
diff --git a/test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig b/test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig
index b2da9f32d9..155df733fb 100644
--- a/test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig
+++ b/test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig
@@ -1,6 +1,6 @@
export fn entry() void {
var a = &b;
- _ = a;
+ _ = &a;
}
inline fn b() void {}
diff --git a/test/cases/compile_errors/assign_local_bad_coercion.zig b/test/cases/compile_errors/assign_local_bad_coercion.zig
index 0aa93f48bd..405af4f235 100644
--- a/test/cases/compile_errors/assign_local_bad_coercion.zig
+++ b/test/cases/compile_errors/assign_local_bad_coercion.zig
@@ -9,7 +9,7 @@ export fn constEntry() u32 {
export fn varEntry() u32 {
var x: u32 = g();
- return x;
+ return (&x).*;
}
// error
diff --git a/test/cases/compile_errors/assign_too_big_number_to_u16.zig b/test/cases/compile_errors/assign_too_big_number_to_u16.zig
index 1f8b097ae2..4f595a95da 100644
--- a/test/cases/compile_errors/assign_too_big_number_to_u16.zig
+++ b/test/cases/compile_errors/assign_too_big_number_to_u16.zig
@@ -1,5 +1,5 @@
export fn foo() void {
- var vga_mem: u16 = 0xB8000;
+ const vga_mem: u16 = 0xB8000;
_ = vga_mem;
}
@@ -7,4 +7,4 @@ export fn foo() void {
// backend=stage2
// target=native
//
-// :2:24: error: type 'u16' cannot represent integer value '753664'
+// :2:26: error: type 'u16' cannot represent integer value '753664'
diff --git a/test/cases/compile_errors/assigning_to_struct_or_union_fields_that_are_not_optionals_with_a_function_that_returns_an_optional.zig b/test/cases/compile_errors/assigning_to_struct_or_union_fields_that_are_not_optionals_with_a_function_that_returns_an_optional.zig
index 6a7de57352..f91b6a4ef2 100644
--- a/test/cases/compile_errors/assigning_to_struct_or_union_fields_that_are_not_optionals_with_a_function_that_returns_an_optional.zig
+++ b/test/cases/compile_errors/assigning_to_struct_or_union_fields_that_are_not_optionals_with_a_function_that_returns_an_optional.zig
@@ -10,8 +10,8 @@ const S = struct {
export fn entry() void {
var u = U{ .Ye = maybe(false) };
var s = S{ .num = maybe(false) };
- _ = u;
- _ = s;
+ _ = &u;
+ _ = &s;
}
// error
diff --git a/test/cases/compile_errors/async/Frame_of_generic_function.zig b/test/cases/compile_errors/async/Frame_of_generic_function.zig
index d90e53eb46..af0fb5c72e 100644
--- a/test/cases/compile_errors/async/Frame_of_generic_function.zig
+++ b/test/cases/compile_errors/async/Frame_of_generic_function.zig
@@ -1,10 +1,10 @@
export fn entry() void {
var frame: @Frame(func) = undefined;
- _ = frame;
+ _ = &frame;
}
fn func(comptime T: type) void {
var x: T = undefined;
- _ = x;
+ _ = &x;
}
// error
diff --git a/test/cases/compile_errors/async/async_function_depends_on_its_own_frame.zig b/test/cases/compile_errors/async/async_function_depends_on_its_own_frame.zig
index 4dde5860ba..b266d86ed8 100644
--- a/test/cases/compile_errors/async/async_function_depends_on_its_own_frame.zig
+++ b/test/cases/compile_errors/async/async_function_depends_on_its_own_frame.zig
@@ -3,7 +3,7 @@ export fn entry() void {
}
fn amain() callconv(.Async) void {
var x: [@sizeOf(@Frame(amain))]u8 = undefined;
- _ = x;
+ _ = &x;
}
// error
diff --git a/test/cases/compile_errors/async/async_function_indirectly_depends_on_its_own_frame.zig b/test/cases/compile_errors/async/async_function_indirectly_depends_on_its_own_frame.zig
index 4dac0d4fa3..4e7341bff5 100644
--- a/test/cases/compile_errors/async/async_function_indirectly_depends_on_its_own_frame.zig
+++ b/test/cases/compile_errors/async/async_function_indirectly_depends_on_its_own_frame.zig
@@ -6,7 +6,7 @@ fn amain() callconv(.Async) void {
}
fn other() void {
var x: [@sizeOf(@Frame(amain))]u8 = undefined;
- _ = x;
+ _ = &x;
}
// error
diff --git a/test/cases/compile_errors/async/bad_alignment_in_asynccall.zig b/test/cases/compile_errors/async/bad_alignment_in_asynccall.zig
index 3999140009..da00a0eeb7 100644
--- a/test/cases/compile_errors/async/bad_alignment_in_asynccall.zig
+++ b/test/cases/compile_errors/async/bad_alignment_in_asynccall.zig
@@ -2,6 +2,7 @@ export fn entry() void {
var ptr: fn () callconv(.Async) void = func;
var bytes: [64]u8 = undefined;
_ = @asyncCall(&bytes, {}, ptr, .{});
+ _ = &ptr;
}
fn func() callconv(.Async) void {}
diff --git a/test/cases/compile_errors/async/const_frame_cast_to_anyframe.zig b/test/cases/compile_errors/async/const_frame_cast_to_anyframe.zig
index affdb953d7..52b866afcf 100644
--- a/test/cases/compile_errors/async/const_frame_cast_to_anyframe.zig
+++ b/test/cases/compile_errors/async/const_frame_cast_to_anyframe.zig
@@ -5,7 +5,7 @@ export fn a() void {
export fn b() void {
const f = async func();
var x: anyframe = &f;
- _ = x;
+ _ = &x;
}
fn func() void {
suspend {}
diff --git a/test/cases/compile_errors/async/indirect_recursion_of_async_functions_detected.zig b/test/cases/compile_errors/async/indirect_recursion_of_async_functions_detected.zig
index d845dc7930..804baed45f 100644
--- a/test/cases/compile_errors/async/indirect_recursion_of_async_functions_detected.zig
+++ b/test/cases/compile_errors/async/indirect_recursion_of_async_functions_detected.zig
@@ -12,7 +12,7 @@ fn rangeSum(x: i32) i32 {
frame = null;
if (x == 0) return 0;
- var child = rangeSumIndirect(x - 1);
+ const child = rangeSumIndirect(x - 1);
return child + 1;
}
@@ -23,7 +23,7 @@ fn rangeSumIndirect(x: i32) i32 {
frame = null;
if (x == 0) return 0;
- var child = rangeSum(x - 1);
+ const child = rangeSum(x - 1);
return child + 1;
}
@@ -32,5 +32,5 @@ fn rangeSumIndirect(x: i32) i32 {
// target=native
//
// tmp.zig:8:1: error: '@Frame(rangeSum)' depends on itself
-// tmp.zig:15:33: note: when analyzing type '@Frame(rangeSum)' here
-// tmp.zig:26:25: note: when analyzing type '@Frame(rangeSumIndirect)' here
+// tmp.zig:15:35: note: when analyzing type '@Frame(rangeSum)' here
+// tmp.zig:28:25: note: when analyzing type '@Frame(rangeSumIndirect)' here
diff --git a/test/cases/compile_errors/async/invalid_suspend_in_exported_function.zig b/test/cases/compile_errors/async/invalid_suspend_in_exported_function.zig
index cfcbfba889..fb3488ce95 100644
--- a/test/cases/compile_errors/async/invalid_suspend_in_exported_function.zig
+++ b/test/cases/compile_errors/async/invalid_suspend_in_exported_function.zig
@@ -1,7 +1,7 @@
export fn entry() void {
var frame = async func();
var result = await frame;
- _ = result;
+ _ = &result;
}
fn func() void {
suspend {}
diff --git a/test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig b/test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig
index 97bc6a09bd..b62524f6de 100644
--- a/test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig
+++ b/test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig
@@ -2,6 +2,7 @@ export fn entry() void {
var ptr = afunc;
var bytes: [100]u8 align(16) = undefined;
_ = @asyncCall(&bytes, {}, ptr, .{});
+ _ = &ptr;
}
fn afunc() void {}
diff --git a/test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig b/test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig
index bdf7bec458..6ab99bf00d 100644
--- a/test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig
+++ b/test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig
@@ -1,17 +1,17 @@
export fn a() void {
var x: anyframe = undefined;
var y: anyframe->i32 = x;
- _ = y;
+ _ = .{ &x, &y };
}
export fn b() void {
var x: i32 = undefined;
var y: anyframe->i32 = x;
- _ = y;
+ _ = .{ &x, &y };
}
export fn c() void {
var x: @Frame(func) = undefined;
var y: anyframe->i32 = &x;
- _ = y;
+ _ = .{ &x, &y };
}
fn func() void {}
diff --git a/test/cases/compile_errors/async/runtime-known_async_function_called.zig b/test/cases/compile_errors/async/runtime-known_async_function_called.zig
index 90685ce566..8a5ef27d62 100644
--- a/test/cases/compile_errors/async/runtime-known_async_function_called.zig
+++ b/test/cases/compile_errors/async/runtime-known_async_function_called.zig
@@ -4,6 +4,7 @@ export fn entry() void {
fn amain() void {
var ptr = afunc;
_ = ptr();
+ _ = &ptr;
}
fn afunc() callconv(.Async) void {}
diff --git a/test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig b/test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig
index bfc22cca25..9933c95435 100644
--- a/test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig
+++ b/test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig
@@ -1,6 +1,7 @@
export fn entry() void {
var ptr = afunc;
_ = async ptr();
+ _ = &ptr;
}
fn afunc() callconv(.Async) void {}
diff --git a/test/cases/compile_errors/attempted_implicit_cast_from_const_T_to_array_len_1_T.zig b/test/cases/compile_errors/attempted_implicit_cast_from_const_T_to_array_len_1_T.zig
index b553d492ae..912bf6ba3c 100644
--- a/test/cases/compile_errors/attempted_implicit_cast_from_const_T_to_array_len_1_T.zig
+++ b/test/cases/compile_errors/attempted_implicit_cast_from_const_T_to_array_len_1_T.zig
@@ -1,9 +1,9 @@
-export fn entry(byte: u8) void {
+export fn entry() void {
const w: i32 = 1234;
var x: *const i32 = &w;
var y: *[1]i32 = x;
y[0] += 1;
- _ = byte;
+ _ = &x;
}
// error
diff --git a/test/cases/compile_errors/bad_alignment_in_implicit_cast_from_array_pointer_to_slice.zig b/test/cases/compile_errors/bad_alignment_in_implicit_cast_from_array_pointer_to_slice.zig
index 0641d8e3f9..cbc380c8fe 100644
--- a/test/cases/compile_errors/bad_alignment_in_implicit_cast_from_array_pointer_to_slice.zig
+++ b/test/cases/compile_errors/bad_alignment_in_implicit_cast_from_array_pointer_to_slice.zig
@@ -1,6 +1,6 @@
export fn a() void {
var x: [10]u8 = undefined;
- var y: []align(16) u8 = &x;
+ const y: []align(16) u8 = &x;
_ = y;
}
@@ -8,5 +8,5 @@ export fn a() void {
// backend=stage2
// target=native
//
-// :3:29: error: expected type '[]align(16) u8', found '*[10]u8'
-// :3:29: note: pointer alignment '1' cannot cast into pointer alignment '16'
+// :3:31: error: expected type '[]align(16) u8', found '*[10]u8'
+// :3:31: note: pointer alignment '1' cannot cast into pointer alignment '16'
diff --git a/test/cases/compile_errors/bad_alignment_type.zig b/test/cases/compile_errors/bad_alignment_type.zig
index 523ee2491a..c85eb8427d 100644
--- a/test/cases/compile_errors/bad_alignment_type.zig
+++ b/test/cases/compile_errors/bad_alignment_type.zig
@@ -1,9 +1,9 @@
export fn entry1() void {
- var x: []align(true) i32 = undefined;
+ const x: []align(true) i32 = undefined;
_ = x;
}
export fn entry2() void {
- var x: *align(@as(f64, 12.34)) i32 = undefined;
+ const x: *align(@as(f64, 12.34)) i32 = undefined;
_ = x;
}
@@ -11,5 +11,5 @@ export fn entry2() void {
// backend=stage2
// target=native
//
-// :2:20: error: expected type 'u32', found 'bool'
-// :6:19: error: fractional component prevents float value '12.34' from coercion to type 'u32'
+// :2:22: error: expected type 'u32', found 'bool'
+// :6:21: error: fractional component prevents float value '12.34' from coercion to type 'u32'
diff --git a/test/cases/compile_errors/bad_usage_of_call.zig b/test/cases/compile_errors/bad_usage_of_call.zig
index 3669cda3bf..3b7abe53f6 100644
--- a/test/cases/compile_errors/bad_usage_of_call.zig
+++ b/test/cases/compile_errors/bad_usage_of_call.zig
@@ -11,7 +11,7 @@ export fn entry4() void {
@call(.never_inline, bar, .{});
}
export fn entry5(c: bool) void {
- var baz = if (c) &baz1 else &baz2;
+ const baz = if (c) &baz1 else &baz2;
@call(.compile_time, baz, .{});
}
export fn entry6() void {
@@ -22,6 +22,7 @@ export fn entry7() void {
}
pub export fn entry() void {
var call_me: *const fn () void = undefined;
+ _ = &call_me;
@call(.always_inline, call_me, .{});
}
@@ -45,4 +46,4 @@ noinline fn dummy2() void {}
// :15:26: error: modifier 'compile_time' requires a comptime-known function
// :18:9: error: 'always_inline' call of noinline function
// :21:9: error: 'always_inline' call of noinline function
-// :25:27: error: modifier 'always_inline' requires a comptime-known function
+// :26:27: error: modifier 'always_inline' requires a comptime-known function
diff --git a/test/cases/compile_errors/binary_OR_operator_on_error_sets.zig b/test/cases/compile_errors/binary_OR_operator_on_error_sets.zig
index 9955194f95..ae239d300e 100644
--- a/test/cases/compile_errors/binary_OR_operator_on_error_sets.zig
+++ b/test/cases/compile_errors/binary_OR_operator_on_error_sets.zig
@@ -1,7 +1,7 @@
pub const A = error.A;
pub const AB = A | error.B;
export fn entry() void {
- var x: AB = undefined;
+ const x: AB = undefined;
_ = x;
}
diff --git a/test/cases/compile_errors/bitCast_same_size_but_bit_count_mismatch.zig b/test/cases/compile_errors/bitCast_same_size_but_bit_count_mismatch.zig
index e366e0cb03..1a7305904b 100644
--- a/test/cases/compile_errors/bitCast_same_size_but_bit_count_mismatch.zig
+++ b/test/cases/compile_errors/bitCast_same_size_but_bit_count_mismatch.zig
@@ -1,5 +1,5 @@
export fn entry(byte: u8) void {
- var oops: u7 = @bitCast(byte);
+ const oops: u7 = @bitCast(byte);
_ = oops;
}
@@ -7,4 +7,4 @@ export fn entry(byte: u8) void {
// backend=stage2
// target=native
//
-// :2:20: error: @bitCast size mismatch: destination type 'u7' has 7 bits but source type 'u8' has 8 bits
+// :2:22: error: @bitCast size mismatch: destination type 'u7' has 7 bits but source type 'u8' has 8 bits
diff --git a/test/cases/compile_errors/bitCast_with_different_sizes_inside_an_expression.zig b/test/cases/compile_errors/bitCast_with_different_sizes_inside_an_expression.zig
index f73dfeb38a..e1a16be60a 100644
--- a/test/cases/compile_errors/bitCast_with_different_sizes_inside_an_expression.zig
+++ b/test/cases/compile_errors/bitCast_with_different_sizes_inside_an_expression.zig
@@ -1,5 +1,6 @@
export fn entry() void {
- var foo = (@as(u8, @bitCast(@as(f32, 1.0))) == 0xf);
+ const f: f32 = 1.0;
+ const foo = (@as(u8, @bitCast(f)) == 0xf);
_ = foo;
}
@@ -7,4 +8,4 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :2:24: error: @bitCast size mismatch: destination type 'u8' has 8 bits but source type 'f32' has 32 bits
+// :3:26: error: @bitCast size mismatch: destination type 'u8' has 8 bits but source type 'f32' has 32 bits
diff --git a/test/cases/compile_errors/branch_in_comptime_only_scope_uses_condbr_inline.zig b/test/cases/compile_errors/branch_in_comptime_only_scope_uses_condbr_inline.zig
index 8c0166ad2d..c072c7ef9d 100644
--- a/test/cases/compile_errors/branch_in_comptime_only_scope_uses_condbr_inline.zig
+++ b/test/cases/compile_errors/branch_in_comptime_only_scope_uses_condbr_inline.zig
@@ -1,5 +1,6 @@
pub export fn entry1() void {
var x: u32 = 3;
+ _ = &x;
_ = @shuffle(u32, [_]u32{0}, @as(@Vector(1, u32), @splat(0)), [_]i8{
if (x > 1) 1 else -1,
});
@@ -7,6 +8,7 @@ pub export fn entry1() void {
pub export fn entry2() void {
var y: ?i8 = -1;
+ _ = &y;
_ = @shuffle(u32, [_]u32{0}, @as(@Vector(1, u32), @splat(0)), [_]i8{
y orelse 1,
});
@@ -16,6 +18,6 @@ pub export fn entry2() void {
// backend=stage2
// target=native
//
-// :4:15: error: unable to evaluate comptime expression
-// :4:13: note: operation is runtime due to this operand
-// :11:11: error: unable to evaluate comptime expression
+// :5:15: error: unable to evaluate comptime expression
+// :5:13: note: operation is runtime due to this operand
+// :13:11: error: unable to evaluate comptime expression
diff --git a/test/cases/compile_errors/break_void_result_location.zig b/test/cases/compile_errors/break_void_result_location.zig
index 140ddb6ed1..24a7644ce1 100644
--- a/test/cases/compile_errors/break_void_result_location.zig
+++ b/test/cases/compile_errors/break_void_result_location.zig
@@ -10,6 +10,7 @@ export fn f2() void {
}
export fn f3() void {
var t: bool = true;
+ _ = &t;
const x: usize = while (t) {
break;
};
@@ -28,5 +29,5 @@ export fn f4() void {
//
// :2:22: error: expected type 'usize', found 'void'
// :7:9: error: expected type 'usize', found 'void'
-// :14:9: error: expected type 'usize', found 'void'
-// :20:9: error: expected type 'usize', found 'void'
+// :15:9: error: expected type 'usize', found 'void'
+// :21:9: error: expected type 'usize', found 'void'
diff --git a/test/cases/compile_errors/c_pointer_to_void.zig b/test/cases/compile_errors/c_pointer_to_void.zig
index 116f5a8948..502feb4326 100644
--- a/test/cases/compile_errors/c_pointer_to_void.zig
+++ b/test/cases/compile_errors/c_pointer_to_void.zig
@@ -1,5 +1,5 @@
export fn entry() void {
- var a: [*c]void = undefined;
+ const a: [*c]void = undefined;
_ = a;
}
@@ -7,5 +7,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :2:16: error: C pointers cannot point to non-C-ABI-compatible type 'void'
-// :2:16: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
+// :2:18: error: C pointers cannot point to non-C-ABI-compatible type 'void'
+// :2:18: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
diff --git a/test/cases/compile_errors/callconv_stdcall_fastcall_thiscall_on_unsupported_platform.zig b/test/cases/compile_errors/callconv_stdcall_fastcall_thiscall_on_unsupported_platform.zig
index 9813df24db..3480dc8aa7 100644
--- a/test/cases/compile_errors/callconv_stdcall_fastcall_thiscall_on_unsupported_platform.zig
+++ b/test/cases/compile_errors/callconv_stdcall_fastcall_thiscall_on_unsupported_platform.zig
@@ -2,15 +2,15 @@ const F1 = fn () callconv(.Stdcall) void;
const F2 = fn () callconv(.Fastcall) void;
const F3 = fn () callconv(.Thiscall) void;
export fn entry1() void {
- var a: F1 = undefined;
+ const a: F1 = undefined;
_ = a;
}
export fn entry2() void {
- var a: F2 = undefined;
+ const a: F2 = undefined;
_ = a;
}
export fn entry3() void {
- var a: F3 = undefined;
+ const a: F3 = undefined;
_ = a;
}
diff --git a/test/cases/compile_errors/cast_between_optional_T_where_T_is_not_a_pointer.zig b/test/cases/compile_errors/cast_between_optional_T_where_T_is_not_a_pointer.zig
index fa1fc21568..1698fdeaed 100644
--- a/test/cases/compile_errors/cast_between_optional_T_where_T_is_not_a_pointer.zig
+++ b/test/cases/compile_errors/cast_between_optional_T_where_T_is_not_a_pointer.zig
@@ -4,6 +4,7 @@ export fn entry1() void {
var a: fnty1 = undefined;
var b: fnty2 = undefined;
a = b;
+ _ = &b;
}
pub const fnty3 = ?*const fn (u63) void;
@@ -11,6 +12,7 @@ export fn entry2() void {
var a: fnty3 = undefined;
var b: fnty2 = undefined;
a = b;
+ _ = &b;
}
// error
@@ -21,6 +23,6 @@ export fn entry2() void {
// :6:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (i8) void'
// :6:9: note: parameter 0 'u64' cannot cast into 'i8'
// :6:9: note: unsigned 64-bit int cannot represent all possible signed 8-bit values
-// :13:9: error: expected type '?*const fn (u63) void', found '?*const fn (u64) void'
-// :13:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (u63) void'
-// :13:9: note: parameter 0 'u64' cannot cast into 'u63'
+// :14:9: error: expected type '?*const fn (u63) void', found '?*const fn (u64) void'
+// :14:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (u63) void'
+// :14:9: note: parameter 0 'u64' cannot cast into 'u63'
diff --git a/test/cases/compile_errors/cast_error_union_of_global_error_set_to_error_union_of_smaller_error_set.zig b/test/cases/compile_errors/cast_error_union_of_global_error_set_to_error_union_of_smaller_error_set.zig
index 36a17d734b..792fd9fb0d 100644
--- a/test/cases/compile_errors/cast_error_union_of_global_error_set_to_error_union_of_smaller_error_set.zig
+++ b/test/cases/compile_errors/cast_error_union_of_global_error_set_to_error_union_of_smaller_error_set.zig
@@ -1,6 +1,6 @@
const SmallErrorSet = error{A};
export fn entry() void {
- var x: SmallErrorSet!i32 = foo();
+ const x: SmallErrorSet!i32 = foo();
_ = x;
}
fn foo() anyerror!i32 {
@@ -11,5 +11,5 @@ fn foo() anyerror!i32 {
// backend=stage2
// target=native
//
-// :3:35: error: expected type 'error{A}!i32', found 'anyerror!i32'
-// :3:35: note: global error set cannot cast into a smaller set
+// :3:37: error: expected type 'error{A}!i32', found 'anyerror!i32'
+// :3:37: note: global error set cannot cast into a smaller set
diff --git a/test/cases/compile_errors/cast_global_error_set_to_error_set.zig b/test/cases/compile_errors/cast_global_error_set_to_error_set.zig
index 39d9474016..3d6628b799 100644
--- a/test/cases/compile_errors/cast_global_error_set_to_error_set.zig
+++ b/test/cases/compile_errors/cast_global_error_set_to_error_set.zig
@@ -1,6 +1,6 @@
const SmallErrorSet = error{A};
export fn entry() void {
- var x: SmallErrorSet = foo();
+ const x: SmallErrorSet = foo();
_ = x;
}
fn foo() anyerror {
@@ -11,5 +11,5 @@ fn foo() anyerror {
// backend=stage2
// target=native
//
-// :3:31: error: expected type 'error{A}', found 'anyerror'
-// :3:31: note: global error set cannot cast into a smaller set
+// :3:33: error: expected type 'error{A}', found 'anyerror'
+// :3:33: note: global error set cannot cast into a smaller set
diff --git a/test/cases/compile_errors/catch_on_undefined_value.zig b/test/cases/compile_errors/catch_on_undefined_value.zig
index ef041c9539..0fb11fc05f 100644
--- a/test/cases/compile_errors/catch_on_undefined_value.zig
+++ b/test/cases/compile_errors/catch_on_undefined_value.zig
@@ -1,5 +1,5 @@
comptime {
- var a: anyerror!bool = undefined;
+ const a: anyerror!bool = undefined;
if (a catch false) {}
}
diff --git a/test/cases/compile_errors/compare_optional_to_non_optional_with_incomparable_type.zig b/test/cases/compile_errors/compare_optional_to_non_optional_with_incomparable_type.zig
index 653b7ffcfb..e9746f7e16 100644
--- a/test/cases/compile_errors/compare_optional_to_non_optional_with_incomparable_type.zig
+++ b/test/cases/compile_errors/compare_optional_to_non_optional_with_incomparable_type.zig
@@ -1,6 +1,6 @@
export fn entry() void {
- var x: ?[3]i32 = undefined;
- var y: [3]i32 = undefined;
+ const x: ?[3]i32 = undefined;
+ const y: [3]i32 = undefined;
_ = (x == y);
}
diff --git a/test/cases/compile_errors/comparison_operators_with_undefined_value.zig b/test/cases/compile_errors/comparison_operators_with_undefined_value.zig
index b7b40d3178..d4dda81788 100644
--- a/test/cases/compile_errors/comparison_operators_with_undefined_value.zig
+++ b/test/cases/compile_errors/comparison_operators_with_undefined_value.zig
@@ -1,36 +1,36 @@
// operator ==
comptime {
- var a: i64 = undefined;
+ const a: i64 = undefined;
var x: i32 = 0;
if (a == a) x += 1;
}
// operator !=
comptime {
- var a: i64 = undefined;
+ const a: i64 = undefined;
var x: i32 = 0;
if (a != a) x += 1;
}
// operator >
comptime {
- var a: i64 = undefined;
+ const a: i64 = undefined;
var x: i32 = 0;
if (a > a) x += 1;
}
// operator <
comptime {
- var a: i64 = undefined;
+ const a: i64 = undefined;
var x: i32 = 0;
if (a < a) x += 1;
}
// operator >=
comptime {
- var a: i64 = undefined;
+ const a: i64 = undefined;
var x: i32 = 0;
if (a >= a) x += 1;
}
// operator <=
comptime {
- var a: i64 = undefined;
+ const a: i64 = undefined;
var x: i32 = 0;
if (a <= a) x += 1;
}
diff --git a/test/cases/compile_errors/compile_error_in_struct_init_expression.zig b/test/cases/compile_errors/compile_error_in_struct_init_expression.zig
index 64a97a7a5b..9813951a8b 100644
--- a/test/cases/compile_errors/compile_error_in_struct_init_expression.zig
+++ b/test/cases/compile_errors/compile_error_in_struct_init_expression.zig
@@ -3,7 +3,7 @@ const Foo = struct {
b: i32,
};
export fn entry() void {
- var x = Foo{
+ const x: Foo = .{
.b = 5,
};
_ = x;
diff --git a/test/cases/compile_errors/compile_time_null_ptr_cast.zig b/test/cases/compile_errors/compile_time_null_ptr_cast.zig
index 7d25931aaa..2142521fd1 100644
--- a/test/cases/compile_errors/compile_time_null_ptr_cast.zig
+++ b/test/cases/compile_errors/compile_time_null_ptr_cast.zig
@@ -1,5 +1,5 @@
comptime {
- var opt_ptr: ?*i32 = null;
+ const opt_ptr: ?*i32 = null;
const ptr: *i32 = @ptrCast(opt_ptr);
_ = ptr;
}
diff --git a/test/cases/compile_errors/compile_time_undef_ptr_cast.zig b/test/cases/compile_errors/compile_time_undef_ptr_cast.zig
index d93e8bc73d..9e6bfd8003 100644
--- a/test/cases/compile_errors/compile_time_undef_ptr_cast.zig
+++ b/test/cases/compile_errors/compile_time_undef_ptr_cast.zig
@@ -1,6 +1,7 @@
comptime {
var undef_ptr: *i32 = undefined;
const ptr: *i32 = @ptrCast(undef_ptr);
+ _ = &undef_ptr;
_ = ptr;
}
diff --git a/test/cases/compile_errors/comptime_cast_enum_to_union_but_field_has_payload.zig b/test/cases/compile_errors/comptime_cast_enum_to_union_but_field_has_payload.zig
index d38738dae7..465a0f466e 100644
--- a/test/cases/compile_errors/comptime_cast_enum_to_union_but_field_has_payload.zig
+++ b/test/cases/compile_errors/comptime_cast_enum_to_union_but_field_has_payload.zig
@@ -6,7 +6,7 @@ const Value = union(Letter) {
};
export fn entry() void {
var x: Value = Letter.A;
- _ = x;
+ _ = &x;
}
// error
diff --git a/test/cases/compile_errors/comptime_continue_inside_runtime_if_bool.zig b/test/cases/compile_errors/comptime_continue_inside_runtime_if_bool.zig
index b2a7312c52..d3462ed898 100644
--- a/test/cases/compile_errors/comptime_continue_inside_runtime_if_bool.zig
+++ b/test/cases/compile_errors/comptime_continue_inside_runtime_if_bool.zig
@@ -1,5 +1,6 @@
export fn entry() void {
var p: usize = undefined;
+ _ = &p;
comptime var q = true;
inline while (q) {
if (p == 11) continue;
@@ -11,5 +12,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :5:22: error: comptime control flow inside runtime block
-// :5:15: note: runtime control flow here
+// :6:22: error: comptime control flow inside runtime block
+// :6:15: note: runtime control flow here
diff --git a/test/cases/compile_errors/comptime_continue_inside_runtime_if_error.zig b/test/cases/compile_errors/comptime_continue_inside_runtime_if_error.zig
index 194274a1ed..fb1e60cb3d 100644
--- a/test/cases/compile_errors/comptime_continue_inside_runtime_if_error.zig
+++ b/test/cases/compile_errors/comptime_continue_inside_runtime_if_error.zig
@@ -1,5 +1,6 @@
export fn entry() void {
var p: anyerror!i32 = undefined;
+ _ = &p;
comptime var q = true;
inline while (q) {
if (p) |_| continue else |_| {}
@@ -11,5 +12,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :5:20: error: comptime control flow inside runtime block
-// :5:13: note: runtime control flow here
+// :6:20: error: comptime control flow inside runtime block
+// :6:13: note: runtime control flow here
diff --git a/test/cases/compile_errors/comptime_continue_inside_runtime_if_optional.zig b/test/cases/compile_errors/comptime_continue_inside_runtime_if_optional.zig
index 965454ef03..f4837c812e 100644
--- a/test/cases/compile_errors/comptime_continue_inside_runtime_if_optional.zig
+++ b/test/cases/compile_errors/comptime_continue_inside_runtime_if_optional.zig
@@ -1,5 +1,6 @@
export fn entry() void {
var p: ?i32 = undefined;
+ _ = &p;
comptime var q = true;
inline while (q) {
if (p) |_| continue;
@@ -11,5 +12,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :5:20: error: comptime control flow inside runtime block
-// :5:13: note: runtime control flow here
+// :6:20: error: comptime control flow inside runtime block
+// :6:13: note: runtime control flow here
diff --git a/test/cases/compile_errors/comptime_continue_inside_runtime_switch.zig b/test/cases/compile_errors/comptime_continue_inside_runtime_switch.zig
index 391ecbdf1a..6a23da4cb6 100644
--- a/test/cases/compile_errors/comptime_continue_inside_runtime_switch.zig
+++ b/test/cases/compile_errors/comptime_continue_inside_runtime_switch.zig
@@ -1,5 +1,6 @@
export fn entry() void {
var p: i32 = undefined;
+ _ = &p;
comptime var q = true;
inline while (q) {
switch (p) {
@@ -14,5 +15,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :6:19: error: comptime control flow inside runtime block
-// :5:17: note: runtime control flow here
+// :7:19: error: comptime control flow inside runtime block
+// :6:17: note: runtime control flow here
diff --git a/test/cases/compile_errors/comptime_continue_inside_runtime_while_bool.zig b/test/cases/compile_errors/comptime_continue_inside_runtime_while_bool.zig
index 54d62e6d37..55b8b1bde7 100644
--- a/test/cases/compile_errors/comptime_continue_inside_runtime_while_bool.zig
+++ b/test/cases/compile_errors/comptime_continue_inside_runtime_while_bool.zig
@@ -1,5 +1,6 @@
export fn entry() void {
var p: usize = undefined;
+ _ = &p;
comptime var q = true;
outer: inline while (q) {
while (p == 11) continue :outer;
@@ -11,5 +12,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :5:25: error: comptime control flow inside runtime block
-// :5:18: note: runtime control flow here
+// :6:25: error: comptime control flow inside runtime block
+// :6:18: note: runtime control flow here
diff --git a/test/cases/compile_errors/comptime_continue_inside_runtime_while_error.zig b/test/cases/compile_errors/comptime_continue_inside_runtime_while_error.zig
index 0eef1c3374..fe6f3c202e 100644
--- a/test/cases/compile_errors/comptime_continue_inside_runtime_while_error.zig
+++ b/test/cases/compile_errors/comptime_continue_inside_runtime_while_error.zig
@@ -1,5 +1,6 @@
export fn entry() void {
var p: anyerror!usize = undefined;
+ _ = &p;
comptime var q = true;
outer: inline while (q) {
while (p) |_| {
@@ -13,5 +14,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :6:13: error: comptime control flow inside runtime block
-// :5:16: note: runtime control flow here
+// :7:13: error: comptime control flow inside runtime block
+// :6:16: note: runtime control flow here
diff --git a/test/cases/compile_errors/comptime_continue_inside_runtime_while_optional.zig b/test/cases/compile_errors/comptime_continue_inside_runtime_while_optional.zig
index e6753a5911..2724af3059 100644
--- a/test/cases/compile_errors/comptime_continue_inside_runtime_while_optional.zig
+++ b/test/cases/compile_errors/comptime_continue_inside_runtime_while_optional.zig
@@ -1,5 +1,6 @@
export fn entry() void {
var p: ?usize = undefined;
+ _ = &p;
comptime var q = true;
outer: inline while (q) {
while (p) |_| continue :outer;
@@ -11,5 +12,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :5:23: error: comptime control flow inside runtime block
-// :5:16: note: runtime control flow here
+// :6:23: error: comptime control flow inside runtime block
+// :6:16: note: runtime control flow here
diff --git a/test/cases/compile_errors/comptime_continue_to_outer_inline_loop.zig b/test/cases/compile_errors/comptime_continue_to_outer_inline_loop.zig
index 5e6a321db2..e9fb8c0066 100644
--- a/test/cases/compile_errors/comptime_continue_to_outer_inline_loop.zig
+++ b/test/cases/compile_errors/comptime_continue_to_outer_inline_loop.zig
@@ -1,5 +1,6 @@
pub export fn entry() void {
var a = false;
+ _ = &a;
const arr1 = .{ 1, 2, 3 };
loop: inline for (arr1) |val1| {
_ = val1;
@@ -17,5 +18,5 @@ pub export fn entry() void {
// backend=stage2
// target=native
//
-// :9:30: error: comptime control flow inside runtime block
-// :6:13: note: runtime control flow here
+// :10:30: error: comptime control flow inside runtime block
+// :7:13: note: runtime control flow here
diff --git a/test/cases/compile_errors/comptime_if_inside_runtime_for.zig b/test/cases/compile_errors/comptime_if_inside_runtime_for.zig
index 40055a70b9..425eb99e9c 100644
--- a/test/cases/compile_errors/comptime_if_inside_runtime_for.zig
+++ b/test/cases/compile_errors/comptime_if_inside_runtime_for.zig
@@ -1,8 +1,9 @@
export fn entry() void {
var x: u32 = 0;
+ _ = &x;
for (0..1, 1..2) |_, _| {
var y = x + if (x == 0) 1 else 0;
- _ = y;
+ _ = &y;
}
}
@@ -10,5 +11,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :4:21: error: value with comptime-only type 'comptime_int' depends on runtime control flow
-// :3:10: note: runtime control flow here
+// :5:21: error: value with comptime-only type 'comptime_int' depends on runtime control flow
+// :4:10: note: runtime control flow here
diff --git a/test/cases/compile_errors/comptime_slice_of_an_undefined_slice.zig b/test/cases/compile_errors/comptime_slice_of_an_undefined_slice.zig
index d1b22d86b7..aa3719816c 100644
--- a/test/cases/compile_errors/comptime_slice_of_an_undefined_slice.zig
+++ b/test/cases/compile_errors/comptime_slice_of_an_undefined_slice.zig
@@ -1,7 +1,7 @@
comptime {
var a: []u8 = undefined;
var b = a[0..10];
- _ = b;
+ _ = &b;
}
// error
diff --git a/test/cases/compile_errors/comptime_struct_field_no_init_value.zig b/test/cases/compile_errors/comptime_struct_field_no_init_value.zig
index c0cb470eee..95ace47530 100644
--- a/test/cases/compile_errors/comptime_struct_field_no_init_value.zig
+++ b/test/cases/compile_errors/comptime_struct_field_no_init_value.zig
@@ -3,7 +3,7 @@ const Foo = struct {
};
export fn entry() void {
var f: Foo = undefined;
- _ = f;
+ _ = &f;
}
// error
diff --git a/test/cases/compile_errors/comptime_vector_overflow_shows_the_index.zig b/test/cases/compile_errors/comptime_vector_overflow_shows_the_index.zig
index fda8ffe453..ace946453e 100644
--- a/test/cases/compile_errors/comptime_vector_overflow_shows_the_index.zig
+++ b/test/cases/compile_errors/comptime_vector_overflow_shows_the_index.zig
@@ -2,7 +2,7 @@ comptime {
var a: @Vector(4, u8) = [_]u8{ 1, 2, 255, 4 };
var b: @Vector(4, u8) = [_]u8{ 5, 6, 1, 8 };
var x = a + b;
- _ = x;
+ _ = .{ &a, &b, &x };
}
// error
diff --git a/test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig b/test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig
index 1ce744d6d7..6efed3eb81 100644
--- a/test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig
+++ b/test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig
@@ -1,9 +1,7 @@
const ContextAllocator = MemoryPool(usize);
pub fn MemoryPool(comptime T: type) type {
- const free_list_t = @compileError(
- "aoeu",
- );
+ const free_list_t = @compileError("aoeu");
_ = T;
return struct {
@@ -12,7 +10,7 @@ pub fn MemoryPool(comptime T: type) type {
}
export fn entry() void {
- var allocator: ContextAllocator = undefined;
+ const allocator: ContextAllocator = undefined;
_ = allocator;
}
diff --git a/test/cases/compile_errors/deref_on_undefined_value.zig b/test/cases/compile_errors/deref_on_undefined_value.zig
index fa12e2824c..81d0fbda1b 100644
--- a/test/cases/compile_errors/deref_on_undefined_value.zig
+++ b/test/cases/compile_errors/deref_on_undefined_value.zig
@@ -1,5 +1,5 @@
comptime {
- var a: *u8 = undefined;
+ const a: *u8 = undefined;
_ = a.*;
}
diff --git a/test/cases/compile_errors/deref_slice_and_get_len_field.zig b/test/cases/compile_errors/deref_slice_and_get_len_field.zig
index 1ba03c6d50..2550c88d27 100644
--- a/test/cases/compile_errors/deref_slice_and_get_len_field.zig
+++ b/test/cases/compile_errors/deref_slice_and_get_len_field.zig
@@ -1,6 +1,7 @@
export fn entry() void {
var a: []u8 = undefined;
_ = a.*.len;
+ _ = &a;
}
// error
diff --git a/test/cases/compile_errors/dereference_an_array.zig b/test/cases/compile_errors/dereference_an_array.zig
index 27e4d81e55..7c71da914d 100644
--- a/test/cases/compile_errors/dereference_an_array.zig
+++ b/test/cases/compile_errors/dereference_an_array.zig
@@ -1,6 +1,7 @@
var s_buffer: [10]u8 = undefined;
pub fn pass(in: []u8) []u8 {
var out = &s_buffer;
+ _ = &out;
out.*.* = in[0];
return out.*[0..1];
}
@@ -13,4 +14,4 @@ export fn entry() usize {
// backend=stage2
// target=native
//
-// :4:10: error: cannot dereference non-pointer type '[10]u8'
+// :5:10: error: cannot dereference non-pointer type '[10]u8'
diff --git a/test/cases/compile_errors/dereferencing_invalid_payload_ptr_at_comptime.zig b/test/cases/compile_errors/dereferencing_invalid_payload_ptr_at_comptime.zig
index 69457965bb..17117713ed 100644
--- a/test/cases/compile_errors/dereferencing_invalid_payload_ptr_at_comptime.zig
+++ b/test/cases/compile_errors/dereferencing_invalid_payload_ptr_at_comptime.zig
@@ -16,7 +16,7 @@ comptime {
_ = payload_ptr.*;
}
comptime {
- var val: u8 = 15;
+ const val: u8 = 15;
var err_union: anyerror!u8 = val;
const payload_ptr = &(err_union catch unreachable);
diff --git a/test/cases/compile_errors/directly_embedding_opaque_type_in_struct_and_union.zig b/test/cases/compile_errors/directly_embedding_opaque_type_in_struct_and_union.zig
index d9f27da4aa..7fc562fd69 100644
--- a/test/cases/compile_errors/directly_embedding_opaque_type_in_struct_and_union.zig
+++ b/test/cases/compile_errors/directly_embedding_opaque_type_in_struct_and_union.zig
@@ -8,11 +8,11 @@ const Bar = union {
};
export fn a() void {
var foo: Foo = undefined;
- _ = foo;
+ _ = &foo;
}
export fn b() void {
var bar: Bar = undefined;
- _ = bar;
+ _ = &bar;
}
export fn c() void {
const baz = &@as(O, undefined);
diff --git a/test/cases/compile_errors/div_on_undefined_value.zig b/test/cases/compile_errors/div_on_undefined_value.zig
index 8365cdfa73..bc2cfa158d 100644
--- a/test/cases/compile_errors/div_on_undefined_value.zig
+++ b/test/cases/compile_errors/div_on_undefined_value.zig
@@ -1,6 +1,7 @@
comptime {
var a: i64 = undefined;
_ = a / a;
+ _ = &a;
}
// error
diff --git a/test/cases/compile_errors/double_pointer_to_anyopaque_pointer.zig b/test/cases/compile_errors/double_pointer_to_anyopaque_pointer.zig
index c695b7393d..dbebf07e0b 100644
--- a/test/cases/compile_errors/double_pointer_to_anyopaque_pointer.zig
+++ b/test/cases/compile_errors/double_pointer_to_anyopaque_pointer.zig
@@ -11,12 +11,13 @@ pub export fn entry2() void {
fn func(_: ?*anyopaque) void {}
pub export fn entry3() void {
var x: *?*usize = undefined;
-
+ _ = &x;
const ptr: *const anyopaque = x;
_ = ptr;
}
export fn entry4() void {
var a: []*u32 = undefined;
+ _ = &a;
var b: []anyopaque = undefined;
b = a;
}
@@ -32,5 +33,5 @@ export fn entry4() void {
// :11:12: note: parameter type declared here
// :15:35: error: expected type '*const anyopaque', found '*?*usize'
// :15:35: note: cannot implicitly cast double pointer '*?*usize' to anyopaque pointer '*const anyopaque'
-// :21:9: error: expected type '[]anyopaque', found '[]*u32'
-// :21:9: note: cannot implicitly cast double pointer '[]*u32' to anyopaque pointer '[]anyopaque'
+// :22:9: error: expected type '[]anyopaque', found '[]*u32'
+// :22:9: note: cannot implicitly cast double pointer '[]*u32' to anyopaque pointer '[]anyopaque'
diff --git a/test/cases/compile_errors/empty_switch_on_an_integer.zig b/test/cases/compile_errors/empty_switch_on_an_integer.zig
index 6ba69f8d3e..5ac9ed454f 100644
--- a/test/cases/compile_errors/empty_switch_on_an_integer.zig
+++ b/test/cases/compile_errors/empty_switch_on_an_integer.zig
@@ -1,5 +1,5 @@
export fn entry() void {
- var x: u32 = 0;
+ const x: u32 = 0;
switch (x) {}
}
diff --git a/test/cases/compile_errors/enum_backed_by_comptime_int_must_be_comptime.zig b/test/cases/compile_errors/enum_backed_by_comptime_int_must_be_comptime.zig
index 7dab294d4a..498a0c80b7 100644
--- a/test/cases/compile_errors/enum_backed_by_comptime_int_must_be_comptime.zig
+++ b/test/cases/compile_errors/enum_backed_by_comptime_int_must_be_comptime.zig
@@ -1,7 +1,7 @@
pub export fn entry() void {
const E = enum(comptime_int) { a, b, c, _ };
var e: E = .a;
- _ = e;
+ _ = &e;
}
// error
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 b2b73b1524..7c258adce7 100644
--- a/test/cases/compile_errors/enum_field_value_references_enum.zig
+++ b/test/cases/compile_errors/enum_field_value_references_enum.zig
@@ -3,7 +3,7 @@ pub const Foo = enum(c_int) {
C = D,
};
export fn entry() void {
- var s: Foo = Foo.E;
+ const s: Foo = Foo.E;
_ = s;
}
const D = 1;
diff --git a/test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig b/test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig
index 3e1190cc32..74df2d3de9 100644
--- a/test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig
+++ b/test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig
@@ -3,7 +3,7 @@ const Foo = enum(u32) {
B = 11,
};
export fn entry() void {
- var x: Foo = @enumFromInt(0);
+ const x: Foo = @enumFromInt(0);
_ = x;
}
@@ -11,5 +11,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :6:18: error: enum 'tmp.Foo' has no tag with value '0'
+// :6:20: error: enum 'tmp.Foo' has no tag with value '0'
// :1:13: note: enum declared here
diff --git a/test/cases/compile_errors/enum_value_already_taken.zig b/test/cases/compile_errors/enum_value_already_taken.zig
index 733585a748..e3a13785e1 100644
--- a/test/cases/compile_errors/enum_value_already_taken.zig
+++ b/test/cases/compile_errors/enum_value_already_taken.zig
@@ -6,7 +6,7 @@ const MultipleChoice = enum(u32) {
E = 60,
};
export fn entry() void {
- var x = MultipleChoice.C;
+ const x = MultipleChoice.C;
_ = x;
}
diff --git a/test/cases/compile_errors/error_in_struct_initializer_doesnt_crash_the_compiler.zig b/test/cases/compile_errors/error_in_struct_initializer_doesnt_crash_the_compiler.zig
index c0b1193fb1..515ac855ce 100644
--- a/test/cases/compile_errors/error_in_struct_initializer_doesnt_crash_the_compiler.zig
+++ b/test/cases/compile_errors/error_in_struct_initializer_doesnt_crash_the_compiler.zig
@@ -4,7 +4,7 @@ pub export fn entry() void {
e: u8,
};
var a = .{@sizeOf(bitfield)};
- _ = a;
+ _ = &a;
}
// error
diff --git a/test/cases/compile_errors/error_union_operator_with_non_error_set_LHS.zig b/test/cases/compile_errors/error_union_operator_with_non_error_set_LHS.zig
index cafca1ee55..e20b2861cc 100644
--- a/test/cases/compile_errors/error_union_operator_with_non_error_set_LHS.zig
+++ b/test/cases/compile_errors/error_union_operator_with_non_error_set_LHS.zig
@@ -1,6 +1,6 @@
comptime {
const z = i32!i32;
- var x: z = undefined;
+ const x: z = undefined;
_ = x;
}
diff --git a/test/cases/compile_errors/error_when_evaluating_return_type.zig b/test/cases/compile_errors/error_when_evaluating_return_type.zig
index 647b51b475..08e19cd46a 100644
--- a/test/cases/compile_errors/error_when_evaluating_return_type.zig
+++ b/test/cases/compile_errors/error_when_evaluating_return_type.zig
@@ -6,7 +6,7 @@ const Foo = struct {
}
};
export fn entry() void {
- var rule_set = try Foo.init();
+ const rule_set = try Foo.init();
_ = rule_set;
}
diff --git a/test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig b/test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig
index 701241a403..aada601c79 100644
--- a/test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig
+++ b/test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig
@@ -11,12 +11,13 @@ fn foo(a: u8, comptime PtrTy: type) S(PtrTy) {
}
pub export fn entry() void {
var a: u8 = 1;
+ _ = &a;
_ = foo(a, fn () void);
}
// error
// backend=stage2
// target=native
//
-// :14:13: error: unable to resolve comptime value
-// :14:13: note: argument to function being called at comptime must be comptime-known
+// :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
diff --git a/test/cases/compile_errors/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig b/test/cases/compile_errors/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig
index fedfaf2d07..a1beac65f2 100644
--- a/test/cases/compile_errors/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig
+++ b/test/cases/compile_errors/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig
@@ -1,8 +1,8 @@
const Set1 = error{ A, B };
const Set2 = error{ A, C };
comptime {
- var x = Set1.B;
- var y: Set2 = @errorCast(x);
+ const x = Set1.B;
+ const y: Set2 = @errorCast(x);
_ = y;
}
@@ -10,4 +10,4 @@ comptime {
// backend=stage2
// target=native
//
-// :5:19: error: 'error.B' not a member of error set 'error{C,A}'
+// :5:21: error: 'error.B' not a member of error set 'error{C,A}'
diff --git a/test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig b/test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig
index bb920138e1..05189c7b0c 100644
--- a/test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig
+++ b/test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig
@@ -7,7 +7,7 @@ const Small = enum(u2) {
export fn entry() void {
var y = @as(f32, 3);
- var x: Small = @enumFromInt(y);
+ const x: Small = @enumFromInt((&y).*);
_ = x;
}
@@ -15,4 +15,4 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :10:33: error: expected integer type, found 'f32'
+// :10:39: error: expected integer type, found 'f32'
diff --git a/test/cases/compile_errors/extern_union_field_missing_type.zig b/test/cases/compile_errors/extern_union_field_missing_type.zig
index fde58f69e5..9720ff90f1 100644
--- a/test/cases/compile_errors/extern_union_field_missing_type.zig
+++ b/test/cases/compile_errors/extern_union_field_missing_type.zig
@@ -2,7 +2,7 @@ const Letter = extern union {
A,
};
export fn entry() void {
- var a = Letter{ .A = {} };
+ const a: Letter = .{ .A = {} };
_ = a;
}
diff --git a/test/cases/compile_errors/extern_union_given_enum_tag_type.zig b/test/cases/compile_errors/extern_union_given_enum_tag_type.zig
index 4aa0e623c7..93eefea144 100644
--- a/test/cases/compile_errors/extern_union_given_enum_tag_type.zig
+++ b/test/cases/compile_errors/extern_union_given_enum_tag_type.zig
@@ -9,7 +9,7 @@ const Payload = extern union(Letter) {
C: bool,
};
export fn entry() void {
- var a = Payload{ .A = 1234 };
+ const a: Payload = .{ .A = 1234 };
_ = a;
}
diff --git a/test/cases/compile_errors/field_access_of_slices.zig b/test/cases/compile_errors/field_access_of_slices.zig
index 1fbfda9646..c7fe0d8b40 100644
--- a/test/cases/compile_errors/field_access_of_slices.zig
+++ b/test/cases/compile_errors/field_access_of_slices.zig
@@ -1,5 +1,6 @@
export fn entry() void {
var slice: []i32 = undefined;
+ _ = &slice;
const info = @TypeOf(slice).unknown;
_ = info;
}
@@ -8,5 +9,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :3:32: error: type '[]i32' has no members
-// :3:32: note: slice values have 'len' and 'ptr' members
+// :4:32: error: type '[]i32' has no members
+// :4:32: note: slice values have 'len' and 'ptr' members
diff --git a/test/cases/compile_errors/for.zig b/test/cases/compile_errors/for.zig
index 568c416062..4c25f9d93f 100644
--- a/test/cases/compile_errors/for.zig
+++ b/test/cases/compile_errors/for.zig
@@ -17,6 +17,7 @@ export fn c() void {
for (buf) |*byte| {
_ = byte;
}
+ _ = &buf;
}
export fn d() void {
const x: [*]const u8 = "hello";
@@ -39,6 +40,6 @@ export fn d() void {
// :10:14: note: for loop operand must be a range, array, slice, tuple, or vector
// :17:16: error: pointer capture of non pointer type '[10]u8'
// :17:10: note: consider using '&' here
-// :24:5: error: unbounded for loop
-// :24:10: note: type '[*]const u8' has no upper bound
-// :24:18: note: type '[*]const u8' has no upper bound
+// :25:5: error: unbounded for loop
+// :25:10: note: type '[*]const u8' has no upper bound
+// :25:18: note: type '[*]const u8' has no upper bound
diff --git a/test/cases/compile_errors/for_loop_body_expression_ignored.zig b/test/cases/compile_errors/for_loop_body_expression_ignored.zig
index 3ce73a9fab..a0247139ea 100644
--- a/test/cases/compile_errors/for_loop_body_expression_ignored.zig
+++ b/test/cases/compile_errors/for_loop_body_expression_ignored.zig
@@ -7,7 +7,7 @@ export fn f1() void {
export fn f2() void {
var x: anyerror!i32 = error.Bad;
for ("hello") |_| returns() else unreachable;
- _ = x;
+ _ = &x;
}
export fn f3() void {
for ("hello") |_| {} else true;
diff --git a/test/cases/compile_errors/function_ptr_alignment.zig b/test/cases/compile_errors/function_ptr_alignment.zig
index fabee524c7..995ef8d9b1 100644
--- a/test/cases/compile_errors/function_ptr_alignment.zig
+++ b/test/cases/compile_errors/function_ptr_alignment.zig
@@ -1,24 +1,24 @@
comptime {
var a: *align(2) @TypeOf(foo) = undefined;
- _ = a;
+ _ = &a;
}
fn foo() void {}
comptime {
var a: *align(1) fn () void = undefined;
- _ = a;
+ _ = &a;
}
comptime {
var a: *align(2) fn () align(2) void = undefined;
- _ = a;
+ _ = &a;
}
comptime {
var a: *align(2) fn () void = undefined;
- _ = a;
+ _ = &a;
}
comptime {
var a: *align(1) fn () align(2) void = undefined;
- _ = a;
+ _ = &a;
}
// error
diff --git a/test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig b/test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig
index c730f80e6f..9a8d765c04 100644
--- a/test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig
+++ b/test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig
@@ -3,6 +3,7 @@ const std = @import("std");
pub export fn entry() void {
var ohnoes: *usize = undefined;
_ = sliceAsBytes(ohnoes);
+ _ = &ohnoes;
}
fn sliceAsBytes(slice: anytype) std.meta.trait.isPtrTo(.Array)(@TypeOf(slice)) {}
@@ -10,4 +11,4 @@ fn sliceAsBytes(slice: anytype) std.meta.trait.isPtrTo(.Array)(@TypeOf(slice)) {
// backend=llvm
// target=native
//
-// :7:63: error: expected type 'type', found 'bool'
+// :8:63: error: expected type 'type', found 'bool'
diff --git a/test/cases/compile_errors/generic_method_call_with_invalid_param.zig b/test/cases/compile_errors/generic_method_call_with_invalid_param.zig
index ccea6708e4..6ce431461b 100644
--- a/test/cases/compile_errors/generic_method_call_with_invalid_param.zig
+++ b/test/cases/compile_errors/generic_method_call_with_invalid_param.zig
@@ -11,6 +11,7 @@ export fn callVoidMethodWithBool() void {
export fn callComptimeBoolMethodWithRuntimeBool() void {
const s = S{};
var arg = true;
+ _ = &arg;
s.comptimeBoolMethod(arg);
}
@@ -25,8 +26,8 @@ const S = struct {
// target=native
//
// :3:18: error: expected type 'bool', found 'void'
-// :18:43: note: parameter type declared here
-// :8:18: error: expected type 'void', found 'bool'
// :19:43: note: parameter type declared here
-// :14:26: error: runtime-known argument passed to comptime parameter
-// :20:57: note: declared comptime here
+// :8:18: error: expected type 'void', found 'bool'
+// :20:43: note: parameter type declared here
+// :15:26: error: runtime-known argument passed to comptime parameter
+// :21:57: note: declared comptime here
diff --git a/test/cases/compile_errors/ignored_expression_in_while_continuation.zig b/test/cases/compile_errors/ignored_expression_in_while_continuation.zig
index d108903c82..4fa396190a 100644
--- a/test/cases/compile_errors/ignored_expression_in_while_continuation.zig
+++ b/test/cases/compile_errors/ignored_expression_in_while_continuation.zig
@@ -3,10 +3,12 @@ export fn a() void {
}
export fn b() void {
var x: anyerror!i32 = 1234;
+ _ = &x;
while (x) |_| : (bad()) {} else |_| {}
}
export fn c() void {
var x: ?i32 = 1234;
+ _ = &x;
while (x) |_| : (bad()) {}
}
fn bad() anyerror!void {
@@ -19,7 +21,7 @@ fn bad() anyerror!void {
//
// :2:24: error: error is ignored
// :2:24: note: consider using 'try', 'catch', or 'if'
-// :6:25: error: error is ignored
-// :6:25: note: consider using 'try', 'catch', or 'if'
-// :10:25: error: error is ignored
-// :10:25: note: consider using 'try', 'catch', or 'if'
+// :7:25: error: error is ignored
+// :7:25: note: consider using 'try', 'catch', or 'if'
+// :12:25: error: error is ignored
+// :12:25: note: consider using 'try', 'catch', or 'if'
diff --git a/test/cases/compile_errors/implicit_cast_between_C_pointer_and_Zig_pointer-bad_const-align-child.zig b/test/cases/compile_errors/implicit_cast_between_C_pointer_and_Zig_pointer-bad_const-align-child.zig
index 78261f182f..d30db5733d 100644
--- a/test/cases/compile_errors/implicit_cast_between_C_pointer_and_Zig_pointer-bad_const-align-child.zig
+++ b/test/cases/compile_errors/implicit_cast_between_C_pointer_and_Zig_pointer-bad_const-align-child.zig
@@ -1,32 +1,32 @@
export fn a() void {
var x: [*c]u8 = undefined;
var y: *align(4) u8 = x;
- _ = y;
+ _ = .{ &x, &y };
}
export fn b() void {
var x: [*c]const u8 = undefined;
var y: *u8 = x;
- _ = y;
+ _ = .{ &x, &y };
}
export fn c() void {
var x: [*c]u8 = undefined;
var y: *u32 = x;
- _ = y;
+ _ = .{ &x, &y };
}
export fn d() void {
var y: *align(1) u32 = undefined;
var x: [*c]u32 = y;
- _ = x;
+ _ = .{ &x, &y };
}
export fn e() void {
var y: *const u8 = undefined;
var x: [*c]u8 = y;
- _ = x;
+ _ = .{ &x, &y };
}
export fn f() void {
var y: *u8 = undefined;
var x: [*c]u32 = y;
- _ = x;
+ _ = .{ &x, &y };
}
// error
diff --git a/test/cases/compile_errors/implicit_cast_from_f64_to_f32.zig b/test/cases/compile_errors/implicit_cast_from_f64_to_f32.zig
index da4503cefe..a8d4675ac8 100644
--- a/test/cases/compile_errors/implicit_cast_from_f64_to_f32.zig
+++ b/test/cases/compile_errors/implicit_cast_from_f64_to_f32.zig
@@ -7,7 +7,7 @@ export fn entry() void {
export fn entry2() void {
var x1: f64 = 1.0;
var y2: f32 = x1;
- _ = y2;
+ _ = .{ &x1, &y2 };
}
// error
diff --git a/test/cases/compile_errors/implicit_cast_of_error_set_not_a_subset.zig b/test/cases/compile_errors/implicit_cast_of_error_set_not_a_subset.zig
index 5e5b57680c..617e638627 100644
--- a/test/cases/compile_errors/implicit_cast_of_error_set_not_a_subset.zig
+++ b/test/cases/compile_errors/implicit_cast_of_error_set_not_a_subset.zig
@@ -4,7 +4,7 @@ export fn entry() void {
foo(Set1.B);
}
fn foo(set1: Set1) void {
- var x: Set2 = set1;
+ const x: Set2 = set1;
_ = x;
}
@@ -12,5 +12,5 @@ fn foo(set1: Set1) void {
// backend=stage2
// target=native
//
-// :7:19: error: expected type 'error{C,A}', found 'error{A,B}'
-// :7:19: note: 'error.B' not a member of destination error set
+// :7:21: error: expected type 'error{C,A}', found 'error{A,B}'
+// :7:21: note: 'error.B' not a member of destination error set
diff --git a/test/cases/compile_errors/implicit_casting_C_pointers_which_would_mess_up_null_semantics.zig b/test/cases/compile_errors/implicit_casting_C_pointers_which_would_mess_up_null_semantics.zig
index ecdc6c14c9..ed3c402ef9 100644
--- a/test/cases/compile_errors/implicit_casting_C_pointers_which_would_mess_up_null_semantics.zig
+++ b/test/cases/compile_errors/implicit_casting_C_pointers_which_would_mess_up_null_semantics.zig
@@ -4,6 +4,9 @@ export fn entry() void {
var ptr_opt_many_ptr = &opt_many_ptr;
var c_ptr: [*c]const [*c]const u8 = ptr_opt_many_ptr;
ptr_opt_many_ptr = c_ptr;
+ _ = &slice;
+ _ = &ptr_opt_many_ptr;
+ _ = &c_ptr;
}
export fn entry2() void {
var buf: [4]u8 = "aoeu".*;
@@ -11,7 +14,9 @@ export fn entry2() void {
var opt_many_ptr: [*]u8 = slice.ptr;
var ptr_opt_many_ptr = &opt_many_ptr;
var c_ptr: [*c][*c]const u8 = ptr_opt_many_ptr;
- _ = c_ptr;
+ _ = &slice;
+ _ = &ptr_opt_many_ptr;
+ _ = &c_ptr;
}
// error
@@ -21,6 +26,6 @@ export fn entry2() void {
// :6:24: error: expected type '*const [*]const u8', found '[*c]const [*c]const u8'
// :6:24: note: pointer type child '[*c]const u8' cannot cast into pointer type child '[*]const u8'
// :6:24: note: '[*c]const u8' could have null values which are illegal in type '[*]const u8'
-// :13:35: error: expected type '[*c][*c]const u8', found '*[*]u8'
-// :13:35: note: pointer type child '[*]u8' cannot cast into pointer type child '[*c]const u8'
-// :13:35: note: mutable '[*]u8' allows illegal null values stored to type '[*c]const u8'
+// :16:35: error: expected type '[*c][*c]const u8', found '*[*]u8'
+// :16:35: note: pointer type child '[*]u8' cannot cast into pointer type child '[*c]const u8'
+// :16:35: note: mutable '[*]u8' allows illegal null values stored to type '[*c]const u8'
diff --git a/test/cases/compile_errors/implicit_casting_null_c_pointer_to_zig_pointer.zig b/test/cases/compile_errors/implicit_casting_null_c_pointer_to_zig_pointer.zig
index b51635ad30..3738f89492 100644
--- a/test/cases/compile_errors/implicit_casting_null_c_pointer_to_zig_pointer.zig
+++ b/test/cases/compile_errors/implicit_casting_null_c_pointer_to_zig_pointer.zig
@@ -1,6 +1,7 @@
comptime {
var c_ptr: [*c]u8 = 0;
- var zig_ptr: *u8 = c_ptr;
+ const zig_ptr: *u8 = c_ptr;
+ _ = &c_ptr;
_ = zig_ptr;
}
@@ -8,4 +9,4 @@ comptime {
// backend=stage2
// target=native
//
-// :3:24: error: null pointer casted to type '*u8'
+// :3:26: error: null pointer casted to type '*u8'
diff --git a/test/cases/compile_errors/implicitly_casting_enum_to_tag_type.zig b/test/cases/compile_errors/implicitly_casting_enum_to_tag_type.zig
index 2f7686c93d..28d3c2445e 100644
--- a/test/cases/compile_errors/implicitly_casting_enum_to_tag_type.zig
+++ b/test/cases/compile_errors/implicitly_casting_enum_to_tag_type.zig
@@ -7,7 +7,7 @@ const Small = enum(u2) {
export fn entry() void {
var x: u2 = Small.Two;
- _ = x;
+ _ = &x;
}
// error
diff --git a/test/cases/compile_errors/incompatible sub-byte fields.zig b/test/cases/compile_errors/incompatible sub-byte fields.zig
index dc6f715c2f..caadf6c5d9 100644
--- a/test/cases/compile_errors/incompatible sub-byte fields.zig
+++ b/test/cases/compile_errors/incompatible sub-byte fields.zig
@@ -11,6 +11,7 @@ export fn entry() void {
var a = A{ .a = 2, .b = 2 };
var b = B{ .q = 22, .a = 3, .b = 2 };
var t: usize = 0;
+ _ = &t;
const ptr = switch (t) {
0 => &a.a,
1 => &b.a,
@@ -24,6 +25,6 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :14:17: error: incompatible types: '*align(1:0:1) u2' and '*align(2:8:2) u2'
-// :15:14: note: type '*align(1:0:1) u2' here
-// :16:14: note: type '*align(2:8:2) u2' here
+// :15:17: error: incompatible types: '*align(1:0:1) u2' and '*align(2:8:2) u2'
+// :16:14: note: type '*align(1:0:1) u2' here
+// :17:14: note: type '*align(2:8:2) u2' here
diff --git a/test/cases/compile_errors/incompatible_sentinels.zig b/test/cases/compile_errors/incompatible_sentinels.zig
index 821a0a8c69..169a69a75a 100644
--- a/test/cases/compile_errors/incompatible_sentinels.zig
+++ b/test/cases/compile_errors/incompatible_sentinels.zig
@@ -8,11 +8,11 @@ export fn entry2(ptr: [*]u8) [*:0]u8 {
}
export fn entry3() void {
var array: [2:0]u8 = [_:255]u8{ 1, 2 };
- _ = array;
+ _ = &array;
}
export fn entry4() void {
var array: [2:0]u8 = [_]u8{ 1, 2 };
- _ = array;
+ _ = &array;
}
// error
diff --git a/test/cases/compile_errors/incorrect_pointer_dereference_syntax.zig b/test/cases/compile_errors/incorrect_pointer_dereference_syntax.zig
index 33b5d1f3b6..4f80b61865 100644
--- a/test/cases/compile_errors/incorrect_pointer_dereference_syntax.zig
+++ b/test/cases/compile_errors/incorrect_pointer_dereference_syntax.zig
@@ -1,6 +1,7 @@
pub export fn entry() void {
var a: *u32 = undefined;
_ = *a;
+ _ = &a;
}
// error
diff --git a/test/cases/compile_errors/incorrect_type_to_memset_memcpy.zig b/test/cases/compile_errors/incorrect_type_to_memset_memcpy.zig
index 55af9c1185..26b31dd506 100644
--- a/test/cases/compile_errors/incorrect_type_to_memset_memcpy.zig
+++ b/test/cases/compile_errors/incorrect_type_to_memset_memcpy.zig
@@ -1,17 +1,17 @@
pub export fn entry() void {
var buf: [5]u8 = .{ 1, 2, 3, 4, 5 };
- var slice: []u8 = &buf;
+ const slice: []u8 = &buf;
const a: u32 = 1234;
@memcpy(slice.ptr, @as([*]const u8, @ptrCast(&a)));
}
pub export fn entry1() void {
var buf: [5]u8 = .{ 1, 2, 3, 4, 5 };
- var ptr: *u8 = &buf[0];
+ const ptr: *u8 = &buf[0];
@memcpy(ptr, 0);
}
pub export fn entry2() void {
var buf: [5]u8 = .{ 1, 2, 3, 4, 5 };
- var ptr: *u8 = &buf[0];
+ const ptr: *u8 = &buf[0];
@memset(ptr, 0);
}
pub export fn non_matching_lengths() void {
@@ -29,7 +29,7 @@ pub export fn memcpy_const_dest_ptr() void {
@memcpy(&buf1, &buf2);
}
pub export fn memset_array() void {
- var buf: [5]u8 = .{ 1, 2, 3, 4, 5 };
+ const buf: [5]u8 = .{ 1, 2, 3, 4, 5 };
@memcpy(buf, 1);
}
diff --git a/test/cases/compile_errors/indexing_an_array_of_size_zero_with_runtime_index.zig b/test/cases/compile_errors/indexing_an_array_of_size_zero_with_runtime_index.zig
index eceb5db50e..21991c66eb 100644
--- a/test/cases/compile_errors/indexing_an_array_of_size_zero_with_runtime_index.zig
+++ b/test/cases/compile_errors/indexing_an_array_of_size_zero_with_runtime_index.zig
@@ -1,6 +1,7 @@
const array = [_]u8{};
export fn foo() void {
var index: usize = 0;
+ _ = &index;
const pointer = &array[index];
_ = pointer;
}
@@ -9,4 +10,4 @@ export fn foo() void {
// backend=stage2
// target=native
//
-// :4:27: error: indexing into empty array is not allowed
+// :5:27: error: indexing into empty array is not allowed
diff --git a/test/cases/compile_errors/inline_call_runtime_value_to_comptime_param.zig b/test/cases/compile_errors/inline_call_runtime_value_to_comptime_param.zig
index cddd91384b..2b3738cd2f 100644
--- a/test/cases/compile_errors/inline_call_runtime_value_to_comptime_param.zig
+++ b/test/cases/compile_errors/inline_call_runtime_value_to_comptime_param.zig
@@ -6,7 +6,7 @@ fn acceptRuntime(value: u64) void {
}
pub export fn entry() void {
var value: u64 = 0;
- acceptRuntime(value);
+ acceptRuntime((&value).*);
}
// error
diff --git a/test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig b/test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig
index 7724632069..d6bf372a88 100644
--- a/test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig
+++ b/test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig
@@ -1,9 +1,11 @@
export fn foo() void {
var a: f32 = 2;
+ _ = &a;
_ = @as(comptime_int, @intFromFloat(a));
}
export fn bar() void {
var a: u32 = 2;
+ _ = &a;
_ = @as(comptime_float, @floatFromInt(a));
}
@@ -11,7 +13,7 @@ export fn bar() void {
// backend=stage2
// target=native
//
-// :3:41: error: unable to resolve comptime value
-// :3:41: note: value being casted to 'comptime_int' must be comptime-known
-// :7:43: error: unable to resolve comptime value
-// :7:43: note: value being casted to 'comptime_float' must be comptime-known
+// :4:41: error: unable to resolve comptime value
+// :4:41: note: value being 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
diff --git a/test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig b/test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig
index e443b3daa9..1c2a8215d7 100644
--- a/test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig
+++ b/test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig
@@ -1,5 +1,5 @@
export fn entry() void {
- var b: *i32 = @ptrFromInt(0);
+ const b: *i32 = @ptrFromInt(0);
_ = b;
}
@@ -7,4 +7,4 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :2:31: error: pointer type '*i32' does not allow address zero
+// :2:33: error: pointer type '*i32' does not allow address zero
diff --git a/test/cases/compile_errors/int_to_err_global_invalid_number.zig b/test/cases/compile_errors/int_to_err_global_invalid_number.zig
index 000b5d1e6a..82056640fd 100644
--- a/test/cases/compile_errors/int_to_err_global_invalid_number.zig
+++ b/test/cases/compile_errors/int_to_err_global_invalid_number.zig
@@ -5,7 +5,7 @@ const Set1 = error{
comptime {
var x: u16 = 3;
var y = @errorFromInt(x);
- _ = y;
+ _ = .{ &x, &y };
}
// error
diff --git a/test/cases/compile_errors/int_to_err_non_global_invalid_number.zig b/test/cases/compile_errors/int_to_err_non_global_invalid_number.zig
index 23c3917b44..c9f6c1e2e4 100644
--- a/test/cases/compile_errors/int_to_err_non_global_invalid_number.zig
+++ b/test/cases/compile_errors/int_to_err_non_global_invalid_number.zig
@@ -7,8 +7,8 @@ const Set2 = error{
C,
};
comptime {
- var x = @intFromError(Set1.B);
- var y: Set2 = @errorCast(@errorFromInt(x));
+ const x = @intFromError(Set1.B);
+ const y: Set2 = @errorCast(@errorFromInt(x));
_ = y;
}
@@ -16,4 +16,4 @@ comptime {
// backend=llvm
// target=native
//
-// :11:19: error: 'error.B' not a member of error set 'error{C,A}'
+// :11:21: error: 'error.B' not a member of error set 'error{C,A}'
diff --git a/test/cases/compile_errors/integer_cast_truncates_bits.zig b/test/cases/compile_errors/integer_cast_truncates_bits.zig
index a230dd3e5b..afe3484a41 100644
--- a/test/cases/compile_errors/integer_cast_truncates_bits.zig
+++ b/test/cases/compile_errors/integer_cast_truncates_bits.zig
@@ -11,12 +11,12 @@ export fn entry2() void {
export fn entry3() void {
var spartan_count: u16 = 300;
var byte: u8 = spartan_count;
- _ = byte;
+ _ = .{ &spartan_count, &byte };
}
export fn entry4() void {
var signed: i8 = -1;
var unsigned: u64 = signed;
- _ = unsigned;
+ _ = .{ &signed, &unsigned };
}
// error
diff --git a/test/cases/compile_errors/invalid_compare_string.zig b/test/cases/compile_errors/invalid_compare_string.zig
index a5c7f041a5..95f6fa4122 100644
--- a/test/cases/compile_errors/invalid_compare_string.zig
+++ b/test/cases/compile_errors/invalid_compare_string.zig
@@ -1,20 +1,20 @@
comptime {
- var a = "foo";
+ const a = "foo";
if (a == "foo") unreachable;
}
comptime {
- var a = "foo";
+ const a = "foo";
if (a == ("foo")) unreachable; // intentionally allow
}
comptime {
- var a = "foo";
+ const a = "foo";
switch (a) {
"foo" => unreachable,
else => {},
}
}
comptime {
- var a = "foo";
+ const a = "foo";
switch (a) {
("foo") => unreachable, // intentionally allow
else => {},
diff --git a/test/cases/compile_errors/invalid_deref_on_switch_target.zig b/test/cases/compile_errors/invalid_deref_on_switch_target.zig
index a880b16fca..70fab8e8c1 100644
--- a/test/cases/compile_errors/invalid_deref_on_switch_target.zig
+++ b/test/cases/compile_errors/invalid_deref_on_switch_target.zig
@@ -1,5 +1,5 @@
comptime {
- var tile = Tile.Empty;
+ const tile = Tile.Empty;
switch (tile.*) {
Tile.Empty => {},
Tile.Filled => {},
diff --git a/test/cases/compile_errors/invalid_float_casts.zig b/test/cases/compile_errors/invalid_float_casts.zig
index 2b09c722be..332fc0d895 100644
--- a/test/cases/compile_errors/invalid_float_casts.zig
+++ b/test/cases/compile_errors/invalid_float_casts.zig
@@ -1,17 +1,21 @@
export fn foo() void {
var a: f32 = 2;
+ _ = &a;
_ = @as(comptime_float, @floatCast(a));
}
export fn bar() void {
var a: f32 = 2;
+ _ = &a;
_ = @as(f32, @intFromFloat(a));
}
export fn baz() void {
var a: f32 = 2;
+ _ = &a;
_ = @as(f32, @floatFromInt(a));
}
export fn qux() void {
var a: u32 = 2;
+ _ = &a;
_ = @as(f32, @floatCast(a));
}
@@ -19,7 +23,7 @@ export fn qux() void {
// backend=stage2
// target=native
//
-// :3:40: error: unable to cast runtime value to 'comptime_float'
-// :7:18: error: expected integer type, found 'f32'
-// :11:32: error: expected integer type, found 'f32'
-// :15:29: error: expected float or vector type, found 'u32'
+// :4:40: error: unable to cast runtime value to 'comptime_float'
+// :9:18: error: expected integer type, found 'f32'
+// :14:32: error: expected integer type, found 'f32'
+// :19:29: error: expected float or vector type, found 'u32'
diff --git a/test/cases/compile_errors/invalid_inline_else_type.zig b/test/cases/compile_errors/invalid_inline_else_type.zig
index 2d52fca43e..5d3205e3f7 100644
--- a/test/cases/compile_errors/invalid_inline_else_type.zig
+++ b/test/cases/compile_errors/invalid_inline_else_type.zig
@@ -1,5 +1,6 @@
pub export fn entry1() void {
var a: anyerror = undefined;
+ _ = &a;
switch (a) {
inline else => {},
}
@@ -7,12 +8,14 @@ pub export fn entry1() void {
const E = enum(u8) { a, _ };
pub export fn entry2() void {
var a: E = undefined;
+ _ = &a;
switch (a) {
inline else => {},
}
}
pub export fn entry3() void {
var a: *u32 = undefined;
+ _ = &a;
switch (a) {
inline else => {},
}
@@ -22,6 +25,6 @@ pub export fn entry3() void {
// backend=stage2
// target=native
//
-// :4:21: error: cannot enumerate values of type 'anyerror' for 'inline else'
-// :11:21: error: cannot enumerate values of type 'tmp.E' for 'inline else'
-// :17:21: error: cannot enumerate values of type '*u32' for 'inline else'
+// :5:21: error: cannot enumerate values of type 'anyerror' for 'inline else'
+// :13:21: error: cannot enumerate values of type 'tmp.E' for 'inline else'
+// :20:21: error: cannot enumerate values of type '*u32' for 'inline else'
diff --git a/test/cases/compile_errors/invalid_int_casts.zig b/test/cases/compile_errors/invalid_int_casts.zig
index 1e52c52609..71fcbb1892 100644
--- a/test/cases/compile_errors/invalid_int_casts.zig
+++ b/test/cases/compile_errors/invalid_int_casts.zig
@@ -1,17 +1,21 @@
export fn foo() void {
var a: u32 = 2;
+ _ = &a;
_ = @as(comptime_int, @intCast(a));
}
export fn bar() void {
var a: u32 = 2;
+ _ = &a;
_ = @as(u32, @floatFromInt(a));
}
export fn baz() void {
var a: u32 = 2;
+ _ = &a;
_ = @as(u32, @intFromFloat(a));
}
export fn qux() void {
var a: f32 = 2;
+ _ = &a;
_ = @as(u32, @intCast(a));
}
@@ -19,7 +23,7 @@ export fn qux() void {
// backend=stage2
// target=native
//
-// :3:36: error: unable to cast runtime value to 'comptime_int'
-// :7:18: error: expected float type, found 'u32'
-// :11:32: error: expected float type, found 'u32'
-// :15:27: error: expected integer or vector, found 'f32'
+// :4:36: error: unable to cast runtime value to 'comptime_int'
+// :9:18: error: expected float type, found 'u32'
+// :14:32: error: expected float type, found 'u32'
+// :19:27: error: expected integer or vector, found 'f32'
diff --git a/test/cases/compile_errors/invalid_multiple_dereferences.zig b/test/cases/compile_errors/invalid_multiple_dereferences.zig
index 3edebf7b1f..0c94bdf11e 100644
--- a/test/cases/compile_errors/invalid_multiple_dereferences.zig
+++ b/test/cases/compile_errors/invalid_multiple_dereferences.zig
@@ -1,11 +1,12 @@
export fn a() void {
var box = Box{ .field = 0 };
+ _ = &box;
box.*.field = 1;
}
export fn b() void {
var box = Box{ .field = 0 };
- var boxPtr = &box;
- boxPtr.*.*.field = 1;
+ const box_ptr = &box;
+ box_ptr.*.*.field = 1;
}
pub const Box = struct {
field: i32,
@@ -15,5 +16,5 @@ pub const Box = struct {
// backend=stage2
// target=native
//
-// :3:8: error: cannot dereference non-pointer type 'tmp.Box'
-// :8:13: error: cannot dereference non-pointer type 'tmp.Box'
+// :4:8: error: cannot dereference non-pointer type 'tmp.Box'
+// :9:14: error: cannot dereference non-pointer type 'tmp.Box'
diff --git a/test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig b/test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig
index d7a93edfcd..05b6855582 100644
--- a/test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig
+++ b/test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig
@@ -10,12 +10,12 @@ const U = union(E) {
export fn foo() void {
var e: E = @enumFromInt(15);
var u: U = e;
- _ = u;
+ _ = .{ &e, &u };
}
export fn bar() void {
const e: E = @enumFromInt(15);
var u: U = e;
- _ = u;
+ _ = &u;
}
// error
diff --git a/test/cases/compile_errors/invalid_peer_type_resolution.zig b/test/cases/compile_errors/invalid_peer_type_resolution.zig
index d82986a60a..e96caecfb6 100644
--- a/test/cases/compile_errors/invalid_peer_type_resolution.zig
+++ b/test/cases/compile_errors/invalid_peer_type_resolution.zig
@@ -1,11 +1,13 @@
export fn optionalVector() void {
var x: ?@Vector(10, i32) = undefined;
var y: @Vector(11, i32) = undefined;
+ _ = .{ &x, &y };
_ = @TypeOf(x, y);
}
export fn badTupleField() void {
var x = .{ @as(u8, 0), @as(u32, 1) };
var y = .{ @as(u8, 1), "hello" };
+ _ = .{ &x, &y };
_ = @TypeOf(x, y);
}
export fn badNestedField() void {
@@ -30,21 +32,21 @@ export fn incompatiblePointers4() void {
// backend=llvm
// target=native
//
-// :4:9: error: incompatible types: '?@Vector(10, i32)' and '@Vector(11, i32)'
-// :4:17: note: type '?@Vector(10, i32)' here
-// :4:20: note: type '@Vector(11, i32)' here
-// :9:9: error: struct field '1' has conflicting types
-// :9:9: note: incompatible types: 'u32' and '*const [5:0]u8'
-// :9:17: note: type 'u32' here
-// :9:20: note: type '*const [5:0]u8' here
-// :14:9: error: struct field 'bar' has conflicting types
-// :14:9: note: struct field '1' has conflicting types
-// :14:9: note: incompatible types: 'comptime_int' and '*const [2:0]u8'
-// :14:17: note: type 'comptime_int' here
-// :14:20: note: type '*const [2:0]u8' here
-// :19:9: error: incompatible types: '[]const u8' and '[*:0]const u8'
-// :19:17: note: type '[]const u8' here
-// :19:20: note: type '[*:0]const u8' here
-// :26:9: error: incompatible types: '[]const u8' and '[*]const u8'
-// :26:23: note: type '[]const u8' here
-// :26:26: note: type '[*]const u8' here
+// :5:9: error: incompatible types: '?@Vector(10, i32)' and '@Vector(11, i32)'
+// :5:17: note: type '?@Vector(10, i32)' here
+// :5:20: note: type '@Vector(11, i32)' here
+// :11:9: error: struct field '1' has conflicting types
+// :11:9: note: incompatible types: 'u32' and '*const [5:0]u8'
+// :11:17: note: type 'u32' here
+// :11:20: note: type '*const [5:0]u8' here
+// :16:9: error: struct field 'bar' has conflicting types
+// :16:9: note: struct field '1' has conflicting types
+// :16:9: note: incompatible types: 'comptime_int' and '*const [2:0]u8'
+// :16:17: note: type 'comptime_int' here
+// :16:20: note: type '*const [2:0]u8' here
+// :21:9: error: incompatible types: '[]const u8' and '[*:0]const u8'
+// :21:17: note: type '[]const u8' here
+// :21:20: note: type '[*:0]const u8' here
+// :28:9: error: incompatible types: '[]const u8' and '[*]const u8'
+// :28:23: note: type '[]const u8' here
+// :28:26: note: type '[*]const u8' here
diff --git a/test/cases/compile_errors/invalid_store_to_comptime_field.zig b/test/cases/compile_errors/invalid_store_to_comptime_field.zig
index 672eea8ddc..6703ac14ca 100644
--- a/test/cases/compile_errors/invalid_store_to_comptime_field.zig
+++ b/test/cases/compile_errors/invalid_store_to_comptime_field.zig
@@ -17,8 +17,9 @@ pub export fn entry2() void {
var list = .{ 1, 2, 3 };
var list2 = @TypeOf(list){ .@"0" = 1, .@"1" = 2, .@"2" = 3 };
var list3 = @TypeOf(list){ 1, 2, 4 };
- _ = list2;
- _ = list3;
+ _ = &list;
+ _ = &list2;
+ _ = &list3;
}
pub export fn entry3() void {
const U = struct {
@@ -46,6 +47,7 @@ pub export fn entry5() void {
}
pub export fn entry6() void {
var x: u32 = 15;
+ _ = &x;
const T = @TypeOf(.{ @as(i32, -1234), @as(u32, 5678), x });
const S = struct {
fn foo(_: T) void {}
@@ -74,12 +76,12 @@ pub export fn entry8() void {
// :6:9: error: value stored in comptime field does not match the default value of the field
// :14:9: error: value stored in comptime field does not match the default value of the field
// :19:38: error: value stored in comptime field does not match the default value of the field
-// :31:19: error: value stored in comptime field does not match the default value of the field
-// :25:29: note: default value set here
-// :41:19: error: value stored in comptime field does not match the default value of the field
-// :35:29: note: default value set here
-// :45:12: error: value stored in comptime field does not match the default value of the field
-// :53:25: error: value stored in comptime field does not match the default value of the field
-// :66:36: error: value stored in comptime field does not match the default value of the field
-// :59:30: error: value stored in comptime field does not match the default value of the field
-// :57:29: note: default value set here
+// :32:19: error: value stored in comptime field does not match the default value of the field
+// :26:29: note: default value set here
+// :42:19: error: value stored in comptime field does not match the default value of the field
+// :36:29: note: default value set here
+// :46:12: error: value stored in comptime field does not match the default value of the field
+// :55:25: error: value stored in comptime field does not match the default value of the field
+// :68:36: error: value stored in comptime field does not match the default value of the field
+// :61:30: error: value stored in comptime field does not match the default value of the field
+// :59:29: note: default value set here
diff --git a/test/cases/compile_errors/invalid_struct_field.zig b/test/cases/compile_errors/invalid_struct_field.zig
index ff8c96a0b6..7a3922dd1f 100644
--- a/test/cases/compile_errors/invalid_struct_field.zig
+++ b/test/cases/compile_errors/invalid_struct_field.zig
@@ -8,6 +8,7 @@ export fn f() void {
export fn g() void {
var a: A = undefined;
const y = a.bar;
+ _ = &a;
_ = y;
}
export fn e() void {
@@ -26,5 +27,5 @@ export fn e() void {
// :1:11: note: struct declared here
// :10:17: error: no field named 'bar' in struct 'tmp.A'
// :1:11: note: struct declared here
-// :18:45: error: no field named 'f' in struct 'tmp.e.B'
-// :14:15: note: struct declared here
+// :19:45: error: no field named 'f' in struct 'tmp.e.B'
+// :15:15: note: struct declared here
diff --git a/test/cases/compile_errors/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig b/test/cases/compile_errors/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig
index d78891bb2b..886b9687d4 100644
--- a/test/cases/compile_errors/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig
+++ b/test/cases/compile_errors/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig
@@ -1,5 +1,5 @@
export fn entry() void {
- var foo: u32 = @This(){};
+ const foo: u32 = @This(){};
_ = foo;
}
@@ -7,5 +7,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :2:27: error: expected type 'u32', found 'tmp'
+// :2:29: error: expected type 'u32', found 'tmp'
// :1:1: note: struct declared here
diff --git a/test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig b/test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig
index c6566bb46a..6792be129a 100644
--- a/test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig
+++ b/test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig
@@ -4,7 +4,7 @@ export fn foo1() void {
_ = word;
}
export fn foo2() void {
- var bytes: []const u8 = &[_]u8{ 1, 2 };
+ const bytes: []const u8 = &[_]u8{ 1, 2 };
const word: u16 = @bitCast(bytes);
_ = word;
}
diff --git a/test/cases/compile_errors/issue_5618_coercion_of_optional_anyopaque_to_anyopaque_must_fail.zig b/test/cases/compile_errors/issue_5618_coercion_of_optional_anyopaque_to_anyopaque_must_fail.zig
index 95bba054b3..7d397c85b3 100644
--- a/test/cases/compile_errors/issue_5618_coercion_of_optional_anyopaque_to_anyopaque_must_fail.zig
+++ b/test/cases/compile_errors/issue_5618_coercion_of_optional_anyopaque_to_anyopaque_must_fail.zig
@@ -1,14 +1,14 @@
export fn foo() void {
var u: ?*anyopaque = null;
var v: *anyopaque = undefined;
- v = u;
+ v = (&u).*;
}
// error
// backend=stage2
// target=native
//
-// :4:9: error: expected type '*anyopaque', found '?*anyopaque'
-// :4:9: note: cannot convert optional to payload type
-// :4:9: note: consider using '.?', 'orelse', or 'if'
-// :4:9: note: '?*anyopaque' could have null values which are illegal in type '*anyopaque'
+// :4:13: error: expected type '*anyopaque', found '?*anyopaque'
+// :4:13: note: cannot convert optional to payload type
+// :4:13: note: consider using '.?', 'orelse', or 'if'
+// :4:13: note: '?*anyopaque' could have null values which are illegal in type '*anyopaque'
diff --git a/test/cases/compile_errors/lazy_pointer_with_undefined_element_type.zig b/test/cases/compile_errors/lazy_pointer_with_undefined_element_type.zig
index bffaa770ec..a1ae3f937b 100644
--- a/test/cases/compile_errors/lazy_pointer_with_undefined_element_type.zig
+++ b/test/cases/compile_errors/lazy_pointer_with_undefined_element_type.zig
@@ -1,5 +1,6 @@
export fn foo() void {
comptime var T: type = undefined;
+ _ = &T;
const S = struct { x: *T };
const I = @typeInfo(S);
_ = I;
@@ -9,4 +10,4 @@ export fn foo() void {
// backend=stage2
// target=native
//
-// :3:28: error: use of undefined value here causes undefined behavior
+// :4:28: error: use of undefined value here causes undefined behavior
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 d2182d8ad0..7cef1c7516 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
@@ -3,7 +3,7 @@ export fn entry() void {
var i: u32 = 0;
var x = loadv(&v[i]);
- _ = x;
+ _ = .{ &i, &x };
}
fn loadv(ptr: anytype) i31 {
diff --git a/test/cases/compile_errors/memset_no_length.zig b/test/cases/compile_errors/memset_no_length.zig
index 0355971cf9..23e77a08c1 100644
--- a/test/cases/compile_errors/memset_no_length.zig
+++ b/test/cases/compile_errors/memset_no_length.zig
@@ -1,9 +1,11 @@
export fn foo() void {
var ptr: [*]u8 = undefined;
+ _ = &ptr;
@memset(ptr, 123);
}
export fn bar() void {
var ptr: [*c]bool = undefined;
+ _ = &ptr;
@memset(ptr, true);
}
@@ -11,7 +13,7 @@ export fn bar() void {
// backend=stage2
// target=native
//
-// :3:5: error: unknown @memset length
-// :3:13: note: destination type '[*]u8' provides no length
-// :7:5: error: unknown @memset length
-// :7:13: note: destination type '[*c]bool' provides no length
+// :4:5: error: unknown @memset length
+// :4:13: note: destination type '[*]u8' provides no length
+// :9:5: error: unknown @memset length
+// :9:13: note: destination type '[*c]bool' provides no length
diff --git a/test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig b/test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig
index 4043f305a0..8285d344e2 100644
--- a/test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig
+++ b/test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig
@@ -7,7 +7,7 @@ pub fn getGeo3DTex2D() Geo3DTex2D {
};
}
export fn entry() void {
- var geo_data = getGeo3DTex2D();
+ const geo_data = getGeo3DTex2D();
_ = geo_data;
}
diff --git a/test/cases/compile_errors/missing_else_clause.zig b/test/cases/compile_errors/missing_else_clause.zig
index 965d8e2177..5ce8c76f4d 100644
--- a/test/cases/compile_errors/missing_else_clause.zig
+++ b/test/cases/compile_errors/missing_else_clause.zig
@@ -14,7 +14,7 @@ fn h() void {
// https://github.com/ziglang/zig/issues/12743
const T = struct { oh_no: *u32 };
var x: T = if (false) {};
- _ = x;
+ _ = &x;
}
fn k(b: bool) void {
// block_ptr case
@@ -22,7 +22,7 @@ fn k(b: bool) void {
var x = if (b) blk: {
break :blk if (false) T{ .oh_no = 2 };
} else T{ .oh_no = 1 };
- _ = x;
+ _ = &x;
}
export fn entry() void {
f(true);
diff --git a/test/cases/compile_errors/missing_parameter_name_of_generic_function.zig b/test/cases/compile_errors/missing_parameter_name_of_generic_function.zig
index edd19bd7de..ba7b30186e 100644
--- a/test/cases/compile_errors/missing_parameter_name_of_generic_function.zig
+++ b/test/cases/compile_errors/missing_parameter_name_of_generic_function.zig
@@ -1,7 +1,7 @@
fn dump(anytype) void {}
export fn entry() void {
var a: u8 = 9;
- dump(a);
+ dump((&a).*);
}
// error
diff --git a/test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig b/test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig
index ca8adade01..9d22dba037 100644
--- a/test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig
+++ b/test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig
@@ -24,7 +24,7 @@ pub const JsonNode = struct {
fn foo() void {
var jll: JasonList = undefined;
jll.init(1234);
- var jd = JsonNode{ .kind = JsonType.JSONArray, .jobject = JsonOA.JSONArray{jll} };
+ const jd = JsonNode{ .kind = JsonType.JSONArray, .jobject = JsonOA.JSONArray{jll} };
_ = jd;
}
diff --git a/test/cases/compile_errors/mod_on_undefined_value.zig b/test/cases/compile_errors/mod_on_undefined_value.zig
index 31f6f37815..3641b0e71c 100644
--- a/test/cases/compile_errors/mod_on_undefined_value.zig
+++ b/test/cases/compile_errors/mod_on_undefined_value.zig
@@ -1,6 +1,7 @@
comptime {
var a: i64 = undefined;
_ = a % a;
+ _ = &a;
}
// error
diff --git a/test/cases/compile_errors/mult_on_undefined_value.zig b/test/cases/compile_errors/mult_on_undefined_value.zig
index 1ef459421a..1e65797153 100644
--- a/test/cases/compile_errors/mult_on_undefined_value.zig
+++ b/test/cases/compile_errors/mult_on_undefined_value.zig
@@ -1,5 +1,5 @@
comptime {
- var a: i64 = undefined;
+ const a: i64 = undefined;
_ = a * a;
}
diff --git a/test/cases/compile_errors/negate_on_undefined_value.zig b/test/cases/compile_errors/negate_on_undefined_value.zig
index 2e0ee4ed3b..3f54800db1 100644
--- a/test/cases/compile_errors/negate_on_undefined_value.zig
+++ b/test/cases/compile_errors/negate_on_undefined_value.zig
@@ -1,5 +1,5 @@
comptime {
- var a: i64 = undefined;
+ const a: i64 = undefined;
_ = -a;
}
diff --git a/test/cases/compile_errors/nested_vectors.zig b/test/cases/compile_errors/nested_vectors.zig
index 29934668b0..500de6bcf0 100644
--- a/test/cases/compile_errors/nested_vectors.zig
+++ b/test/cases/compile_errors/nested_vectors.zig
@@ -1,7 +1,7 @@
export fn entry() void {
const V1 = @Vector(4, u8);
const V2 = @Type(.{ .Vector = .{ .len = 4, .child = V1 } });
- var v: V2 = undefined;
+ const v: V2 = undefined;
_ = v;
}
diff --git a/test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig b/test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig
index 7064ebb1b6..0b3d02a224 100644
--- a/test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig
+++ b/test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig
@@ -1,30 +1,30 @@
export fn entry1() void {
var m2 = &2;
- _ = m2;
+ _ = &m2;
}
export fn entry2() void {
var a = undefined;
- _ = a;
+ _ = &a;
}
export fn entry3() void {
var b = 1;
- _ = b;
+ _ = &b;
}
export fn entry4() void {
var c = 1.0;
- _ = c;
+ _ = &c;
}
export fn entry5() void {
var d = null;
- _ = d;
+ _ = &d;
}
export fn entry6(opaque_: *Opaque) void {
var e = opaque_.*;
- _ = e;
+ _ = &e;
}
export fn entry7() void {
var f = i32;
- _ = f;
+ _ = &f;
}
const Opaque = opaque {};
export fn entry8() void {
diff --git a/test/cases/compile_errors/non-integer_tag_type_to_enum.zig b/test/cases/compile_errors/non-integer_tag_type_to_enum.zig
index 85ffc5b4b6..9f14492b57 100644
--- a/test/cases/compile_errors/non-integer_tag_type_to_enum.zig
+++ b/test/cases/compile_errors/non-integer_tag_type_to_enum.zig
@@ -3,7 +3,7 @@ const Foo = enum(f32) {
};
export fn entry() void {
var f: Foo = undefined;
- _ = f;
+ _ = &f;
}
// error
diff --git a/test/cases/compile_errors/non_void_error_union_payload_ignored.zig b/test/cases/compile_errors/non_void_error_union_payload_ignored.zig
index 41b5b6803d..63c116b7bc 100644
--- a/test/cases/compile_errors/non_void_error_union_payload_ignored.zig
+++ b/test/cases/compile_errors/non_void_error_union_payload_ignored.zig
@@ -5,6 +5,7 @@ pub export fn entry1() void {
} else |_| {
// bar
}
+ _ = &x;
}
pub export fn entry2() void {
var x: anyerror!usize = 5;
@@ -13,6 +14,7 @@ pub export fn entry2() void {
} else |_| {
// bar
}
+ _ = &x;
}
// error
@@ -21,5 +23,5 @@ pub export fn entry2() void {
//
// :3:5: error: error union payload is ignored
// :3:5: note: payload value can be explicitly ignored with '|_|'
-// :11:5: error: error union payload is ignored
-// :11:5: note: payload value can be explicitly ignored with '|_|'
+// :12:5: error: error union payload is ignored
+// :12:5: note: payload value can be explicitly ignored with '|_|'
diff --git a/test/cases/compile_errors/not_an_enum_type.zig b/test/cases/compile_errors/not_an_enum_type.zig
index bdd03c8db7..51f0e458a9 100644
--- a/test/cases/compile_errors/not_an_enum_type.zig
+++ b/test/cases/compile_errors/not_an_enum_type.zig
@@ -1,6 +1,6 @@
export fn entry() void {
var self: Error = undefined;
- switch (self) {
+ switch ((&self).*) {
InvalidToken => |x| return x.token,
ExpectedVarDeclOrFn => |x| return x.token,
}
diff --git a/test/cases/compile_errors/or_on_undefined_value.zig b/test/cases/compile_errors/or_on_undefined_value.zig
index b40c1beddd..ee04a43844 100644
--- a/test/cases/compile_errors/or_on_undefined_value.zig
+++ b/test/cases/compile_errors/or_on_undefined_value.zig
@@ -1,5 +1,6 @@
comptime {
var a: bool = undefined;
+ _ = &a;
_ = a or a;
}
@@ -7,4 +8,4 @@ comptime {
// backend=stage2
// target=native
//
-// :3:9: error: use of undefined value here causes undefined behavior
+// :4:9: error: use of undefined value here causes undefined behavior
diff --git a/test/cases/compile_errors/orelse_on_undefined_value.zig b/test/cases/compile_errors/orelse_on_undefined_value.zig
index e67cd952d3..de460bf35c 100644
--- a/test/cases/compile_errors/orelse_on_undefined_value.zig
+++ b/test/cases/compile_errors/orelse_on_undefined_value.zig
@@ -1,5 +1,5 @@
comptime {
- var a: ?bool = undefined;
+ const a: ?bool = undefined;
_ = a orelse false;
}
diff --git a/test/cases/compile_errors/out_of_bounds_index.zig b/test/cases/compile_errors/out_of_bounds_index.zig
index 3f5b71d530..29b5c7d7d1 100644
--- a/test/cases/compile_errors/out_of_bounds_index.zig
+++ b/test/cases/compile_errors/out_of_bounds_index.zig
@@ -1,29 +1,29 @@
comptime {
var array = [_:0]u8{ 1, 2, 3, 4 };
var src_slice: [:0]u8 = &array;
- var slice = src_slice[2..6];
+ const slice = src_slice[2..6];
_ = slice;
}
comptime {
var array = [_:0]u8{ 1, 2, 3, 4 };
- var slice = array[2..6];
+ const slice = array[2..6];
_ = slice;
}
comptime {
var array = [_]u8{ 1, 2, 3, 4 };
- var slice = array[2..5];
+ const slice = array[2..5];
_ = slice;
}
comptime {
var array = [_:0]u8{ 1, 2, 3, 4 };
- var slice = array[3..2];
+ const slice = array[3..2];
_ = slice;
}
// error
// target=native
//
-// :4:30: error: end index 6 out of bounds for slice of length 4 +1 (sentinel)
-// :9:26: error: end index 6 out of bounds for array of length 4 +1 (sentinel)
-// :14:26: error: end index 5 out of bounds for array of length 4
-// :19:23: error: start index 3 is larger than end index 2
+// :4:32: error: end index 6 out of bounds for slice of length 4 +1 (sentinel)
+// :9:28: error: end index 6 out of bounds for array of length 4 +1 (sentinel)
+// :14:28: error: end index 5 out of bounds for array of length 4
+// :19:25: error: start index 3 is larger than end index 2
diff --git a/test/cases/compile_errors/overflow_in_enum_value_allocation.zig b/test/cases/compile_errors/overflow_in_enum_value_allocation.zig
index 821ac6c256..d2f8fc4536 100644
--- a/test/cases/compile_errors/overflow_in_enum_value_allocation.zig
+++ b/test/cases/compile_errors/overflow_in_enum_value_allocation.zig
@@ -3,7 +3,7 @@ const Moo = enum(u8) {
Over,
};
pub export fn entry() void {
- var y = Moo.Last;
+ const y = Moo.Last;
_ = y;
}
diff --git a/test/cases/compile_errors/packed_union_given_enum_tag_type.zig b/test/cases/compile_errors/packed_union_given_enum_tag_type.zig
index 2e69afd0a9..cab4c6bdfb 100644
--- a/test/cases/compile_errors/packed_union_given_enum_tag_type.zig
+++ b/test/cases/compile_errors/packed_union_given_enum_tag_type.zig
@@ -9,7 +9,7 @@ const Payload = packed union(Letter) {
C: bool,
};
export fn entry() void {
- var a = Payload{ .A = 1234 };
+ const a: Payload = .{ .A = 1234 };
_ = a;
}
diff --git a/test/cases/compile_errors/packed_union_with_automatic_layout_field.zig b/test/cases/compile_errors/packed_union_with_automatic_layout_field.zig
index 26d224de85..210f30a1b3 100644
--- a/test/cases/compile_errors/packed_union_with_automatic_layout_field.zig
+++ b/test/cases/compile_errors/packed_union_with_automatic_layout_field.zig
@@ -7,7 +7,7 @@ const Payload = packed union {
B: bool,
};
export fn entry() void {
- var a = Payload{ .B = true };
+ const a: Payload = .{ .B = true };
_ = a;
}
diff --git a/test/cases/compile_errors/pointer_arithmetic_on_pointer-to-array.zig b/test/cases/compile_errors/pointer_arithmetic_on_pointer-to-array.zig
index e97a098f40..931028dd2f 100644
--- a/test/cases/compile_errors/pointer_arithmetic_on_pointer-to-array.zig
+++ b/test/cases/compile_errors/pointer_arithmetic_on_pointer-to-array.zig
@@ -1,7 +1,7 @@
export fn foo() void {
var x: [10]u8 = undefined;
- var y = &x;
- var z = y + 1;
+ const y = &x;
+ const z = y + 1;
_ = z;
}
@@ -9,6 +9,6 @@ export fn foo() void {
// backend=stage2
// target=native
//
-// :4:15: error: incompatible types: '*[10]u8' and 'comptime_int'
-// :4:13: note: type '*[10]u8' here
-// :4:17: note: type 'comptime_int' here
+// :4:17: error: incompatible types: '*[10]u8' and 'comptime_int'
+// :4:15: note: type '*[10]u8' here
+// :4:19: note: type 'comptime_int' here
diff --git a/test/cases/compile_errors/pointer_to_anyopaque_slice.zig b/test/cases/compile_errors/pointer_to_anyopaque_slice.zig
index 2c7334bedb..1e37caa556 100644
--- a/test/cases/compile_errors/pointer_to_anyopaque_slice.zig
+++ b/test/cases/compile_errors/pointer_to_anyopaque_slice.zig
@@ -2,6 +2,7 @@ export fn x() void {
var a: *u32 = undefined;
var b: []anyopaque = undefined;
b = a;
+ _ = &a;
}
// error
diff --git a/test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig b/test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig
index dfcbf6849c..cc008ea9ee 100644
--- a/test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig
+++ b/test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig
@@ -1,6 +1,6 @@
pub export fn entry() void {
var y: [*]align(4) u8 = @ptrFromInt(5);
- _ = y;
+ _ = &y;
}
// error
diff --git a/test/cases/compile_errors/recursive_inline_fn.zig b/test/cases/compile_errors/recursive_inline_fn.zig
index 67184271eb..1cecfdbada 100644
--- a/test/cases/compile_errors/recursive_inline_fn.zig
+++ b/test/cases/compile_errors/recursive_inline_fn.zig
@@ -8,6 +8,7 @@ inline fn foo(x: i32) i32 {
pub export fn entry() void {
var x: i32 = 4;
+ _ = &x;
_ = foo(x) == 20;
}
@@ -32,4 +33,4 @@ pub export fn entry2() void {
// target=native
//
// :5:27: error: inline call is recursive
-// :23:10: error: inline call is recursive
+// :24:10: error: inline call is recursive
diff --git a/test/cases/compile_errors/reference_to_const_data.zig b/test/cases/compile_errors/reference_to_const_data.zig
index e773cdb4a0..ae8dc121c6 100644
--- a/test/cases/compile_errors/reference_to_const_data.zig
+++ b/test/cases/compile_errors/reference_to_const_data.zig
@@ -5,10 +5,12 @@ export fn foo() void {
export fn bar() void {
var ptr = &@as(u32, 2);
ptr.* = 2;
+ _ = &ptr;
}
export fn baz() void {
var ptr = &true;
ptr.* = false;
+ _ = &ptr;
}
export fn qux() void {
const S = struct {
@@ -21,6 +23,7 @@ export fn qux() void {
export fn quux() void {
var x = &@returnAddress();
x.* = 6;
+ _ = &x;
}
// error
@@ -29,6 +32,6 @@ export fn quux() void {
//
// :3:8: error: cannot assign to constant
// :7:8: error: cannot assign to constant
-// :11:8: error: cannot assign to constant
-// :19:8: error: cannot assign to constant
-// :23:6: error: cannot assign to constant
+// :12:8: error: cannot assign to constant
+// :21:8: error: cannot assign to constant
+// :25:6: error: cannot assign to constant
diff --git a/test/cases/compile_errors/reify_typeOf_with_incompatible_arguments.zig b/test/cases/compile_errors/reify_typeOf_with_incompatible_arguments.zig
index ee688c362b..6b21cd2759 100644
--- a/test/cases/compile_errors/reify_typeOf_with_incompatible_arguments.zig
+++ b/test/cases/compile_errors/reify_typeOf_with_incompatible_arguments.zig
@@ -2,6 +2,7 @@ export fn entry() void {
var var_1: f32 = undefined;
var var_2: u32 = undefined;
_ = @TypeOf(var_1, var_2);
+ _ = .{ &var_1, &var_2 };
}
// error
diff --git a/test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr.zig b/test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr.zig
index ce140b64a8..02f9a57a2b 100644
--- a/test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr.zig
+++ b/test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr.zig
@@ -1,5 +1,5 @@
export fn entry() void {
- var damn = Container{
+ const damn = Container{
.not_optional = getOptional(),
};
_ = damn;
diff --git a/test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr_generic_call.zig b/test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr_generic_call.zig
index e813ea1d55..4bfa1a81a2 100644
--- a/test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr_generic_call.zig
+++ b/test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr_generic_call.zig
@@ -2,7 +2,7 @@ export fn entry() void {
var damn = Container{
.not_optional = getOptional(i32),
};
- _ = damn;
+ _ = &damn;
}
pub fn getOptional(comptime T: type) ?T {
return 0;
diff --git a/test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig b/test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig
index e99f093c95..c2bec83afd 100644
--- a/test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig
+++ b/test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig
@@ -5,6 +5,7 @@ const Foo = struct {
export fn f() void {
var x: u8 = 0;
const foo = Foo{ .Bar = x, .Baz = u8 };
+ _ = &x;
_ = foo;
}
diff --git a/test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig b/test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig
index b0528e17bd..21b00ac545 100644
--- a/test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig
+++ b/test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig
@@ -4,6 +4,7 @@ const Foo = union {
};
export fn f() void {
var x: u8 = 0;
+ _ = &x;
const foo = Foo{ .Bar = x };
_ = foo;
}
@@ -12,5 +13,5 @@ export fn f() void {
// backend=stage2
// target=native
//
-// :7:23: error: unable to resolve comptime value
-// :7:23: note: initializer of comptime only union must be comptime-known
+// :8:23: error: unable to resolve comptime value
+// :8:23: note: initializer of comptime only union must be comptime-known
diff --git a/test/cases/compile_errors/runtime_cast_to_union_which_has_non-void_fields.zig b/test/cases/compile_errors/runtime_cast_to_union_which_has_non-void_fields.zig
index 0142f422f4..300e67827b 100644
--- a/test/cases/compile_errors/runtime_cast_to_union_which_has_non-void_fields.zig
+++ b/test/cases/compile_errors/runtime_cast_to_union_which_has_non-void_fields.zig
@@ -8,7 +8,7 @@ export fn entry() void {
foo(Letter.A);
}
fn foo(l: Letter) void {
- var x: Value = l;
+ const x: Value = l;
_ = x;
}
@@ -16,6 +16,6 @@ fn foo(l: Letter) void {
// backend=stage2
// target=native
//
-// :11:20: error: runtime coercion from enum 'tmp.Letter' to union 'tmp.Value' which has non-void fields
+// :11:22: error: runtime coercion from enum 'tmp.Letter' to union 'tmp.Value' which has non-void fields
// :3:5: note: field 'A' has type 'i32'
// :2:15: note: union declared here
diff --git a/test/cases/compile_errors/runtime_indexing_comptime_array.zig b/test/cases/compile_errors/runtime_indexing_comptime_array.zig
index d3e747822b..fb2145b3ad 100644
--- a/test/cases/compile_errors/runtime_indexing_comptime_array.zig
+++ b/test/cases/compile_errors/runtime_indexing_comptime_array.zig
@@ -13,12 +13,14 @@ pub export fn entry2() void {
const test_fns = [_]TestFn{ foo, bar };
var i: usize = 0;
_ = test_fns[i];
+ _ = &i;
}
pub export fn entry3() void {
const TestFn = fn () void;
const test_fns = [_]TestFn{ foo, bar };
var i: usize = 0;
_ = &test_fns[i];
+ _ = &i;
}
// error
// target=native
@@ -28,5 +30,5 @@ pub export fn entry3() void {
// :7:10: note: use '*const fn () void' for a function pointer type
// :15:18: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
// :15:17: note: use '*const fn () void' for a function pointer type
-// :21:19: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
-// :21:18: note: use '*const fn () void' for a function pointer type
+// :22:19: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
+// :22:18: note: use '*const fn () void' for a function pointer type
diff --git a/test/cases/compile_errors/runtime_to_comptime_num.zig b/test/cases/compile_errors/runtime_to_comptime_num.zig
index 8d4a3fb999..eb5d5fc630 100644
--- a/test/cases/compile_errors/runtime_to_comptime_num.zig
+++ b/test/cases/compile_errors/runtime_to_comptime_num.zig
@@ -1,19 +1,23 @@
pub export fn entry() void {
var a: u32 = 0;
+ _ = &a;
_ = @as(comptime_int, a);
}
pub export fn entry2() void {
var a: u32 = 0;
+ _ = &a;
_ = @as(comptime_float, a);
}
pub export fn entry3() void {
comptime var aa: comptime_float = 0.0;
var a: f32 = 4;
+ _ = &a;
aa = a;
}
pub export fn entry4() void {
comptime var aa: comptime_int = 0.0;
var a: f32 = 4;
+ _ = &a;
aa = a;
}
@@ -21,11 +25,11 @@ pub export fn entry4() void {
// backend=stage2
// target=native
//
-// :3:27: error: unable to resolve comptime value
-// :3:27: note: value being casted to 'comptime_int' must be comptime-known
-// :7:29: error: unable to resolve comptime value
-// :7:29: note: value being casted to 'comptime_float' must be comptime-known
-// :12:10: error: unable to resolve comptime value
-// :12:10: note: value being casted to 'comptime_float' must be comptime-known
-// :17:10: error: unable to resolve comptime value
-// :17:10: note: value being casted to 'comptime_int' must be comptime-known
+// :4:27: error: unable to resolve comptime value
+// :4:27: note: value being 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
+// :15:10: error: unable to resolve comptime value
+// :15:10: note: value being 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
diff --git a/test/cases/compile_errors/runtime_value_in_switch_prong.zig b/test/cases/compile_errors/runtime_value_in_switch_prong.zig
index 6fe7112aab..a49ebb4b81 100644
--- a/test/cases/compile_errors/runtime_value_in_switch_prong.zig
+++ b/test/cases/compile_errors/runtime_value_in_switch_prong.zig
@@ -1,6 +1,6 @@
pub export fn entry() void {
var byte: u8 = 1;
- switch (byte) {
+ switch ((&byte).*) {
byte => {},
else => {},
}
diff --git a/test/cases/compile_errors/self_referential_struct_requires_comptime.zig b/test/cases/compile_errors/self_referential_struct_requires_comptime.zig
index 5051dfbbe0..ec3b4c1795 100644
--- a/test/cases/compile_errors/self_referential_struct_requires_comptime.zig
+++ b/test/cases/compile_errors/self_referential_struct_requires_comptime.zig
@@ -4,7 +4,7 @@ const S = struct {
};
pub export fn entry() void {
var s: S = undefined;
- _ = s;
+ _ = &s;
}
// error
diff --git a/test/cases/compile_errors/self_referential_union_requires_comptime.zig b/test/cases/compile_errors/self_referential_union_requires_comptime.zig
index 0e57481d35..5eda780431 100644
--- a/test/cases/compile_errors/self_referential_union_requires_comptime.zig
+++ b/test/cases/compile_errors/self_referential_union_requires_comptime.zig
@@ -4,7 +4,7 @@ const U = union {
};
pub export fn entry() void {
var u: U = undefined;
- _ = u;
+ _ = &u;
}
// error
diff --git a/test/cases/compile_errors/shift_by_negative_comptime_integer.zig b/test/cases/compile_errors/shift_by_negative_comptime_integer.zig
index 7d3a740e16..7794571353 100644
--- a/test/cases/compile_errors/shift_by_negative_comptime_integer.zig
+++ b/test/cases/compile_errors/shift_by_negative_comptime_integer.zig
@@ -1,5 +1,5 @@
comptime {
- var a = 1 >> -1;
+ const a = 1 >> -1;
_ = a;
}
@@ -7,4 +7,4 @@ comptime {
// backend=stage2
// target=native
//
-// :2:18: error: shift by negative amount '-1'
+// :2:20: error: shift by negative amount '-1'
diff --git a/test/cases/compile_errors/shift_on_type_with_non-power-of-two_size.zig b/test/cases/compile_errors/shift_on_type_with_non-power-of-two_size.zig
index 9f606b0426..08c8635c0e 100644
--- a/test/cases/compile_errors/shift_on_type_with_non-power-of-two_size.zig
+++ b/test/cases/compile_errors/shift_on_type_with_non-power-of-two_size.zig
@@ -2,18 +2,22 @@ export fn entry() void {
const S = struct {
fn a() void {
var x: u24 = 42;
+ _ = &x;
_ = x >> 24;
}
fn b() void {
var x: u24 = 42;
+ _ = &x;
_ = x << 24;
}
fn c() void {
var x: u24 = 42;
+ _ = &x;
_ = @shlExact(x, 24);
}
fn d() void {
var x: u24 = 42;
+ _ = &x;
_ = @shrExact(x, 24);
}
};
@@ -27,7 +31,7 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :5:22: error: shift amount '24' is too large for operand type 'u24'
-// :9:22: error: shift amount '24' is too large for operand type 'u24'
-// :13:30: error: shift amount '24' is too large for operand type 'u24'
-// :17:30: error: shift amount '24' is too large for operand type 'u24'
+// :6:22: error: shift amount '24' is too large for operand type 'u24'
+// :11:22: error: shift amount '24' is too large for operand type 'u24'
+// :16:30: error: shift amount '24' is too large for operand type 'u24'
+// :21:30: error: shift amount '24' is too large for operand type 'u24'
diff --git a/test/cases/compile_errors/shifting_without_int_type_or_comptime_known.zig b/test/cases/compile_errors/shifting_without_int_type_or_comptime_known.zig
index 7518165e93..c1595aa67f 100644
--- a/test/cases/compile_errors/shifting_without_int_type_or_comptime_known.zig
+++ b/test/cases/compile_errors/shifting_without_int_type_or_comptime_known.zig
@@ -6,10 +6,12 @@ export fn entry1(x: u8) u8 {
}
export fn entry2() void {
var x: u5 = 1;
+ _ = &x;
_ = @shlExact(12345, x);
}
export fn entry3() void {
var x: u5 = 1;
+ _ = &x;
_ = @shrExact(12345, x);
}
@@ -19,5 +21,5 @@ export fn entry3() void {
//
// :2:17: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
// :5:17: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
-// :9:9: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
-// :13:9: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
+// :10:9: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
+// :15:9: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
diff --git a/test/cases/compile_errors/shuffle_with_selected_index_past_first_vector_length.zig b/test/cases/compile_errors/shuffle_with_selected_index_past_first_vector_length.zig
index 893d3c4e01..c1594d55fb 100644
--- a/test/cases/compile_errors/shuffle_with_selected_index_past_first_vector_length.zig
+++ b/test/cases/compile_errors/shuffle_with_selected_index_past_first_vector_length.zig
@@ -1,7 +1,7 @@
export fn entry() void {
const v: @Vector(4, u32) = [4]u32{ 10, 11, 12, 13 };
const x: @Vector(4, u32) = [4]u32{ 14, 15, 16, 17 };
- var z = @shuffle(u32, v, x, [8]i32{ 0, 1, 2, 3, 7, 6, 5, 4 });
+ const z = @shuffle(u32, v, x, [8]i32{ 0, 1, 2, 3, 7, 6, 5, 4 });
_ = z;
}
@@ -9,6 +9,6 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :4:39: error: mask index '4' has out-of-bounds selection
-// :4:27: note: selected index '7' out of bounds of '@Vector(4, u32)'
-// :4:30: note: selections from the second vector are specified with negative numbers
+// :4:41: error: mask index '4' has out-of-bounds selection
+// :4:29: note: selected index '7' out of bounds of '@Vector(4, u32)'
+// :4:32: note: selections from the second vector are specified with negative numbers
diff --git a/test/cases/compile_errors/slice_cannot_have_its_bytes_reinterpreted.zig b/test/cases/compile_errors/slice_cannot_have_its_bytes_reinterpreted.zig
index 85fb0065d1..31fe909a4b 100644
--- a/test/cases/compile_errors/slice_cannot_have_its_bytes_reinterpreted.zig
+++ b/test/cases/compile_errors/slice_cannot_have_its_bytes_reinterpreted.zig
@@ -1,11 +1,10 @@
export fn foo() void {
const bytes align(@alignOf([]const u8)) = [1]u8{0xfa} ** 16;
- var value = @as(*const []const u8, @ptrCast(&bytes)).*;
- _ = value;
+ _ = @as(*const []const u8, @ptrCast(&bytes)).*;
}
// error
// backend=stage2
// target=native
//
-// :3:57: error: comptime dereference requires '[]const u8' to have a well-defined layout, but it does not.
+// :3:49: error: comptime dereference requires '[]const u8' to have a well-defined layout, but it does not.
diff --git a/test/cases/compile_errors/slice_of_null_pointer.zig b/test/cases/compile_errors/slice_of_null_pointer.zig
index 7f2c74a8a6..18c4ee8a6b 100644
--- a/test/cases/compile_errors/slice_of_null_pointer.zig
+++ b/test/cases/compile_errors/slice_of_null_pointer.zig
@@ -1,11 +1,11 @@
comptime {
var x: [*c]u8 = null;
var runtime_len: usize = 0;
- var y = x[0..runtime_len];
- _ = y;
+ _ = &runtime_len;
+ _ = x[0..runtime_len];
}
// error
// target=native
//
-// :4:14: error: slice of null pointer
+// :5:10: error: slice of null pointer
diff --git a/test/cases/compile_errors/slice_sentinel_mismatch-2.zig b/test/cases/compile_errors/slice_sentinel_mismatch-2.zig
index 42c1328bb6..76da6949b1 100644
--- a/test/cases/compile_errors/slice_sentinel_mismatch-2.zig
+++ b/test/cases/compile_errors/slice_sentinel_mismatch-2.zig
@@ -1,5 +1,5 @@
fn foo() [:0]u8 {
- var x: []u8 = undefined;
+ const x: []u8 = undefined;
return x;
}
comptime {
diff --git a/test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig b/test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig
index 3024f1dee8..9502032a93 100644
--- a/test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig
+++ b/test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig
@@ -7,8 +7,7 @@ const Small = enum(u2) {
};
export fn entry() void {
- var x = Small.One;
- _ = x;
+ _ = Small.One;
}
// error
diff --git a/test/cases/compile_errors/specify_non-integer_enum_tag_type.zig b/test/cases/compile_errors/specify_non-integer_enum_tag_type.zig
index 4fa7691a11..e9d761b714 100644
--- a/test/cases/compile_errors/specify_non-integer_enum_tag_type.zig
+++ b/test/cases/compile_errors/specify_non-integer_enum_tag_type.zig
@@ -5,7 +5,7 @@ const Small = enum(f32) {
};
export fn entry() void {
- var x = Small.One;
+ const x = Small.One;
_ = x;
}
diff --git a/test/cases/compile_errors/stage1/obj/variable_in_inline_assembly_template_cannot_be_found.zig b/test/cases/compile_errors/stage1/obj/variable_in_inline_assembly_template_cannot_be_found.zig
index 7636b501fd..70313fa5f5 100644
--- a/test/cases/compile_errors/stage1/obj/variable_in_inline_assembly_template_cannot_be_found.zig
+++ b/test/cases/compile_errors/stage1/obj/variable_in_inline_assembly_template_cannot_be_found.zig
@@ -2,7 +2,7 @@ export fn entry() void {
var sp = asm volatile ("mov %[foo], sp"
: [bar] "=r" (-> usize),
);
- _ = sp;
+ _ = &sp;
}
// error
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 0007ff1327..0a00ebcf14 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
@@ -2,6 +2,7 @@ export fn entry() void {
var v: @Vector(4, i31) = [_]i31{ 1, 5, 3, undefined };
var i: u32 = 0;
+ _ = &i;
storev(&v[i], 42);
}
@@ -13,4 +14,4 @@ fn storev(ptr: anytype, val: i31) void {
// backend=llvm
// target=native
//
-// :9:8: error: unable to determine vector element index of type '*align(16:0:4:?) i31'
+// :10:8: error: unable to determine vector element index of type '*align(16:0:4:?) i31'
diff --git a/test/cases/compile_errors/sub_on_undefined_value.zig b/test/cases/compile_errors/sub_on_undefined_value.zig
index f198a72efe..de305be576 100644
--- a/test/cases/compile_errors/sub_on_undefined_value.zig
+++ b/test/cases/compile_errors/sub_on_undefined_value.zig
@@ -1,5 +1,5 @@
comptime {
- var a: i64 = undefined;
+ const a: i64 = undefined;
_ = a - a;
}
diff --git a/test/cases/compile_errors/switch_capture_incompatible_types.zig b/test/cases/compile_errors/switch_capture_incompatible_types.zig
index b6de7d5bf5..967307441b 100644
--- a/test/cases/compile_errors/switch_capture_incompatible_types.zig
+++ b/test/cases/compile_errors/switch_capture_incompatible_types.zig
@@ -1,7 +1,7 @@
export fn f() void {
const U = union(enum) { a: u32, b: *u8 };
var u: U = undefined;
- switch (u) {
+ switch ((&u).*) {
.a, .b => |val| _ = val,
}
}
@@ -9,7 +9,7 @@ export fn f() void {
export fn g() void {
const U = union(enum) { a: u64, b: u32 };
var u: U = undefined;
- switch (u) {
+ switch ((&u).*) {
.a, .b => |*ptr| _ = ptr,
}
}
diff --git a/test/cases/compile_errors/switch_on_enum_with_1_field_with_no_prongs.zig b/test/cases/compile_errors/switch_on_enum_with_1_field_with_no_prongs.zig
index cf6fc141de..096cab16ad 100644
--- a/test/cases/compile_errors/switch_on_enum_with_1_field_with_no_prongs.zig
+++ b/test/cases/compile_errors/switch_on_enum_with_1_field_with_no_prongs.zig
@@ -1,7 +1,7 @@
const Foo = enum { M };
export fn entry() void {
- var f = Foo.M;
+ const f = Foo.M;
switch (f) {}
}
diff --git a/test/cases/compile_errors/switch_on_slice.zig b/test/cases/compile_errors/switch_on_slice.zig
index c2b28f67ab..04960635a0 100644
--- a/test/cases/compile_errors/switch_on_slice.zig
+++ b/test/cases/compile_errors/switch_on_slice.zig
@@ -1,5 +1,6 @@
pub export fn entry() void {
var a: [:0]const u8 = "foo";
+ _ = &a;
switch (a) {
("--version"), ("version") => unreachable,
else => {},
@@ -10,4 +11,4 @@ pub export fn entry() void {
// backend=stage2
// target=native
//
-// :3:13: error: switch on type '[:0]const u8'
+// :4:13: error: switch on type '[:0]const u8'
diff --git a/test/cases/compile_errors/switch_ranges_endpoints_are_validated.zig b/test/cases/compile_errors/switch_ranges_endpoints_are_validated.zig
index 72c17929c0..b32e707ebd 100644
--- a/test/cases/compile_errors/switch_ranges_endpoints_are_validated.zig
+++ b/test/cases/compile_errors/switch_ranges_endpoints_are_validated.zig
@@ -1,12 +1,12 @@
pub export fn entry1() void {
- var x: i32 = 0;
+ const x: i32 = 0;
switch (x) {
6...1 => {},
else => unreachable,
}
}
pub export fn entr2() void {
- var x: i32 = 0;
+ const x: i32 = 0;
switch (x) {
-1...-5 => {},
else => unreachable,
diff --git a/test/cases/compile_errors/switch_with_overlapping_case_ranges.zig b/test/cases/compile_errors/switch_with_overlapping_case_ranges.zig
index 46dc08be62..72f05b92a6 100644
--- a/test/cases/compile_errors/switch_with_overlapping_case_ranges.zig
+++ b/test/cases/compile_errors/switch_with_overlapping_case_ranges.zig
@@ -1,6 +1,6 @@
export fn entry() void {
var q: u8 = 0;
- switch (q) {
+ switch ((&q).*) {
1...2 => {},
0...255 => {},
}
diff --git a/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig b/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig
index 32aa446f9a..2ca3f0be24 100644
--- a/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig
+++ b/test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig
@@ -3,7 +3,7 @@ const E = enum {
b,
};
pub export fn entry() void {
- var e: E = .b;
+ const e: E = .b;
switch (e) {
.a => {},
.b => {},
diff --git a/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig b/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig
index a88393b99f..ea6f2c9fd3 100644
--- a/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig
+++ b/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig
@@ -8,21 +8,21 @@ const U = union(E) {
b: u32,
};
pub export fn entry1() void {
- var e: E = .b;
+ const e: E = .b;
switch (e) { // error: switch not handling the tag `b`
.a => {},
_ => {},
}
}
pub export fn entry2() void {
- var e: E = .b;
+ const e: E = .b;
switch (e) { // error: switch on non-exhaustive enum must include `else` or `_` prong
.a => {},
.b => {},
}
}
pub export fn entry3() void {
- var u = U{ .a = 2 };
+ const u = U{ .a = 2 };
switch (u) { // error: `_` prong not allowed when switching on tagged union
.a => {},
.b => {},
diff --git a/test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig b/test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig
index 28eaa9bad8..4538a8e269 100644
--- a/test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig
+++ b/test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig
@@ -3,14 +3,13 @@ const FloatInt = extern union {
Int: i32,
};
export fn entry() void {
- var fi = FloatInt{ .Float = 123.45 };
- var tagName = @tagName(fi);
- _ = tagName;
+ const fi: FloatInt = .{ .Float = 123.45 };
+ _ = @tagName(fi);
}
// error
// backend=stage2
// target=native
//
-// :7:19: error: union 'tmp.FloatInt' is untagged
+// :7:9: error: union 'tmp.FloatInt' is untagged
// :1:25: note: union declared here
diff --git a/test/cases/compile_errors/truncate_sign_mismatch.zig b/test/cases/compile_errors/truncate_sign_mismatch.zig
index b34dfa8e07..d4d64dc8ba 100644
--- a/test/cases/compile_errors/truncate_sign_mismatch.zig
+++ b/test/cases/compile_errors/truncate_sign_mismatch.zig
@@ -1,25 +1,25 @@
export fn entry1() i8 {
var x: u32 = 10;
- return @truncate(x);
+ return @truncate((&x).*);
}
export fn entry2() u8 {
var x: i32 = -10;
- return @truncate(x);
+ return @truncate((&x).*);
}
export fn entry3() i8 {
comptime var x: u32 = 10;
- return @truncate(x);
+ return @truncate((&x).*);
}
export fn entry4() u8 {
comptime var x: i32 = -10;
- return @truncate(x);
+ return @truncate((&x).*);
}
// error
// backend=stage2
// target=native
//
-// :3:22: error: expected signed integer type, found 'u32'
-// :7:22: error: expected unsigned integer type, found 'i32'
-// :11:22: error: expected signed integer type, found 'u32'
-// :15:22: error: expected unsigned integer type, found 'i32'
+// :3:26: error: expected signed integer type, found 'u32'
+// :7:26: error: expected unsigned integer type, found 'i32'
+// :11:26: error: expected signed integer type, found 'u32'
+// :15:26: error: expected unsigned integer type, found 'i32'
diff --git a/test/cases/compile_errors/tuple_init_edge_cases.zig b/test/cases/compile_errors/tuple_init_edge_cases.zig
index aae7370851..24f4ff9bdd 100644
--- a/test/cases/compile_errors/tuple_init_edge_cases.zig
+++ b/test/cases/compile_errors/tuple_init_edge_cases.zig
@@ -1,49 +1,54 @@
pub export fn entry1() void {
const T = @TypeOf(.{ 123, 3 });
var b = T{ .@"1" = 3 };
- _ = b;
+ _ = &b;
var c = T{ 123, 3 };
- _ = c;
+ _ = &c;
var d = T{};
- _ = d;
+ _ = &d;
}
pub export fn entry2() void {
var a: u32 = 2;
+ _ = &a;
const T = @TypeOf(.{ 123, a });
var b = T{ .@"1" = 3 };
- _ = b;
+ _ = &b;
var c = T{ 123, 3 };
- _ = c;
+ _ = &c;
var d = T{};
- _ = d;
+ _ = &d;
}
pub export fn entry3() void {
var a: u32 = 2;
+ _ = &a;
const T = @TypeOf(.{ 123, a });
var b = T{ .@"0" = 123 };
- _ = b;
+ _ = &b;
}
comptime {
var a: u32 = 2;
+ _ = &a;
const T = @TypeOf(.{ 123, a });
var b = T{ .@"0" = 123 };
- _ = b;
+ _ = &b;
var c = T{ 123, 2 };
- _ = c;
+ _ = &c;
var d = T{};
- _ = d;
+ _ = &d;
}
pub export fn entry4() void {
var a: u32 = 2;
+ _ = &a;
const T = @TypeOf(.{ 123, a });
var b = T{ 123, 4, 5 };
- _ = b;
+ _ = &b;
}
pub export fn entry5() void {
var a: u32 = 2;
+ _ = &a;
const T = @TypeOf(.{ 123, a });
var b = T{ .@"0" = 123, .@"2" = 123, .@"1" = 123 };
- _ = b;
+ _ = &b;
}
pub const Consideration = struct {
curve: Curve,
@@ -64,9 +69,9 @@ pub export fn entry6() void {
// backend=stage2
// target=native
//
-// :17:14: error: missing tuple field with index 1
-// :23:14: error: missing tuple field with index 1
-// :39:14: error: expected at most 2 tuple fields; found 3
-// :45:30: error: index '2' out of bounds of tuple 'struct{comptime comptime_int = 123, u32}'
-// :58:37: error: missing tuple field with index 3
-// :53:32: note: struct declared here
+// :18:14: error: missing tuple field with index 1
+// :25:14: error: missing tuple field with index 1
+// :43:14: error: expected at most 2 tuple fields; found 3
+// :50:30: error: index '2' out of bounds of tuple 'struct{comptime comptime_int = 123, u32}'
+// :63:37: error: missing tuple field with index 3
+// :58:32: note: struct declared here
diff --git a/test/cases/compile_errors/union_access_of_inactive_field.zig b/test/cases/compile_errors/union_access_of_inactive_field.zig
index 4f72914216..a1475fafe7 100644
--- a/test/cases/compile_errors/union_access_of_inactive_field.zig
+++ b/test/cases/compile_errors/union_access_of_inactive_field.zig
@@ -5,6 +5,7 @@ const U = union {
comptime {
var u: U = .{ .a = {} };
const v = u.b;
+ _ = &u;
_ = v;
}
diff --git a/test/cases/compile_errors/union_auto-enum_value_already_taken.zig b/test/cases/compile_errors/union_auto-enum_value_already_taken.zig
index da2fefbad5..31a027b7c0 100644
--- a/test/cases/compile_errors/union_auto-enum_value_already_taken.zig
+++ b/test/cases/compile_errors/union_auto-enum_value_already_taken.zig
@@ -6,7 +6,7 @@ const MultipleChoice = union(enum(u32)) {
E = 60,
};
export fn entry() void {
- var x = MultipleChoice{ .C = {} };
+ const x: MultipleChoice = .{ .C = {} };
_ = x;
}
diff --git a/test/cases/compile_errors/union_duplicate_enum_field.zig b/test/cases/compile_errors/union_duplicate_enum_field.zig
index 44eb58e014..6a5fafbb25 100644
--- a/test/cases/compile_errors/union_duplicate_enum_field.zig
+++ b/test/cases/compile_errors/union_duplicate_enum_field.zig
@@ -5,7 +5,7 @@ const U = union(E) {
};
export fn foo() void {
- var u: U = .{ .a = 123 };
+ const u: U = .{ .a = 123 };
_ = u;
}
diff --git a/test/cases/compile_errors/union_enum_field_does_not_match_enum.zig b/test/cases/compile_errors/union_enum_field_does_not_match_enum.zig
index 6b70c0eaf4..ad04f9b1a7 100644
--- a/test/cases/compile_errors/union_enum_field_does_not_match_enum.zig
+++ b/test/cases/compile_errors/union_enum_field_does_not_match_enum.zig
@@ -10,7 +10,7 @@ const Payload = union(Letter) {
D: bool,
};
export fn entry() void {
- var a = Payload{ .A = 1234 };
+ const a: Payload = .{ .A = 1234 };
_ = a;
}
diff --git a/test/cases/compile_errors/union_noreturn_field_initialized.zig b/test/cases/compile_errors/union_noreturn_field_initialized.zig
index df0a2df093..341256afef 100644
--- a/test/cases/compile_errors/union_noreturn_field_initialized.zig
+++ b/test/cases/compile_errors/union_noreturn_field_initialized.zig
@@ -9,7 +9,7 @@ pub export fn entry1() void {
};
var a = U{ .b = undefined };
- _ = a;
+ _ = &a;
}
pub export fn entry2() void {
const U = union(enum) {
@@ -25,7 +25,7 @@ pub export fn entry3() void {
};
var e = @typeInfo(U).Union.tag_type.?.a;
var u: U = undefined;
- u = e;
+ u = (&e).*;
}
// error
@@ -38,6 +38,6 @@ pub export fn entry3() void {
// :19:10: error: cannot initialize 'noreturn' field of union
// :16:9: note: field 'a' declared here
// :15:15: note: union declared here
-// :28:9: error: runtime coercion from enum '@typeInfo(tmp.entry3.U).Union.tag_type.?' to union 'tmp.entry3.U' which has a 'noreturn' field
+// :28:13: error: runtime coercion from enum '@typeInfo(tmp.entry3.U).Union.tag_type.?' to union 'tmp.entry3.U' which has a 'noreturn' field
// :23:9: note: 'noreturn' field here
// :22:15: note: union declared here
diff --git a/test/cases/compile_errors/union_runtime_coercion_from_enum.zig b/test/cases/compile_errors/union_runtime_coercion_from_enum.zig
index 9020e9d5d7..206b00800e 100644
--- a/test/cases/compile_errors/union_runtime_coercion_from_enum.zig
+++ b/test/cases/compile_errors/union_runtime_coercion_from_enum.zig
@@ -11,7 +11,7 @@ fn foo() E {
}
export fn doTheTest() u64 {
var u: U = foo();
- return u.b;
+ return (&u).b;
}
// error
diff --git a/test/cases/compile_errors/uncreachable_else_prong_err_set.zig b/test/cases/compile_errors/unreachable_else_prong_err_set.zig
index 4b0ae462d6..29ff47a5bf 100644
--- a/test/cases/compile_errors/uncreachable_else_prong_err_set.zig
+++ b/test/cases/compile_errors/unreachable_else_prong_err_set.zig
@@ -1,5 +1,6 @@
pub export fn complex() void {
var a: error{ Foo, Bar } = error.Foo;
+ _ = &a;
switch (a) {
error.Foo => unreachable,
error.Bar => unreachable,
@@ -11,6 +12,7 @@ pub export fn complex() void {
pub export fn simple() void {
var a: error{ Foo, Bar } = error.Foo;
+ _ = &a;
switch (a) {
error.Foo => unreachable,
error.Bar => unreachable,
@@ -22,4 +24,4 @@ pub export fn simple() void {
// backend=llvm
// target=native
//
-// :6:14: error: unreachable else prong; all cases already handled
+// :7:14: error: unreachable else prong; all cases already handled
diff --git a/test/cases/compile_errors/use_implicit_casts_to_assign_null_to_non-nullable_pointer.zig b/test/cases/compile_errors/use_implicit_casts_to_assign_null_to_non-nullable_pointer.zig
index 0842e98895..d3b7e45f18 100644
--- a/test/cases/compile_errors/use_implicit_casts_to_assign_null_to_non-nullable_pointer.zig
+++ b/test/cases/compile_errors/use_implicit_casts_to_assign_null_to_non-nullable_pointer.zig
@@ -1,16 +1,15 @@
export fn entry() void {
var x: i32 = 1234;
var p: *i32 = &x;
- var pp: *?*i32 = &p;
+ const pp: *?*i32 = &p;
pp.* = null;
- var y = p.*;
- _ = y;
+ _ = p.*;
}
// error
// backend=stage2
// target=native
//
-// :4:22: error: expected type '*?*i32', found '**i32'
-// :4:22: note: pointer type child '*i32' cannot cast into pointer type child '?*i32'
-// :4:22: note: mutable '*i32' allows illegal null values stored to type '?*i32'
+// :4:24: error: expected type '*?*i32', found '**i32'
+// :4:24: note: pointer type child '*i32' cannot cast into pointer type child '?*i32'
+// :4:24: note: mutable '*i32' allows illegal null values stored to type '?*i32'
diff --git a/test/cases/compile_errors/use_invalid_number_literal_as_array_index.zig b/test/cases/compile_errors/use_invalid_number_literal_as_array_index.zig
index c52f614657..437d100c0e 100644
--- a/test/cases/compile_errors/use_invalid_number_literal_as_array_index.zig
+++ b/test/cases/compile_errors/use_invalid_number_literal_as_array_index.zig
@@ -1,7 +1,7 @@
var v = 25;
export fn entry() void {
var arr: [v]u8 = undefined;
- _ = arr;
+ _ = &arr;
}
// error
diff --git a/test/cases/compile_errors/variable_with_type_noreturn.zig b/test/cases/compile_errors/variable_with_type_noreturn.zig
index 837a6e6965..0b04e1eacb 100644
--- a/test/cases/compile_errors/variable_with_type_noreturn.zig
+++ b/test/cases/compile_errors/variable_with_type_noreturn.zig
@@ -1,6 +1,6 @@
export fn entry9() void {
var z: noreturn = return;
- _ = z;
+ _ = &z;
}
// error
diff --git a/test/cases/compile_errors/variadic_arg_validation.zig b/test/cases/compile_errors/variadic_arg_validation.zig
index 2e47a4fc1e..0dd0e60ee8 100644
--- a/test/cases/compile_errors/variadic_arg_validation.zig
+++ b/test/cases/compile_errors/variadic_arg_validation.zig
@@ -7,6 +7,7 @@ pub export fn entry() void {
pub export fn entry1() void {
var arr: [2]u8 = undefined;
_ = printf("%d\n", arr);
+ _ = &arr;
}
pub export fn entry2() void {
@@ -23,7 +24,7 @@ pub export fn entry3() void {
//
// :4:33: error: integer and float literals passed to variadic function must be casted to a fixed-size number type
// :9:24: error: arrays must be passed by reference to variadic function
-// :13:24: error: cannot pass 'u48' to variadic function
-// :13:24: note: only integers with 0 or power of two bits are extern compatible
-// :17:24: error: cannot pass 'void' to variadic function
-// :17:24: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
+// :14:24: error: cannot pass 'u48' to variadic function
+// :14:24: note: only integers with 0 or power of two bits are extern compatible
+// :18:24: error: cannot pass 'void' to variadic function
+// :18:24: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
diff --git a/test/cases/compile_errors/while_loop_body_expression_ignored.zig b/test/cases/compile_errors/while_loop_body_expression_ignored.zig
index e33f48e6a5..b3e83f202a 100644
--- a/test/cases/compile_errors/while_loop_body_expression_ignored.zig
+++ b/test/cases/compile_errors/while_loop_body_expression_ignored.zig
@@ -6,18 +6,22 @@ export fn f1() void {
}
export fn f2() void {
var x: ?i32 = null;
+ _ = &x;
while (x) |_| returns();
}
export fn f3() void {
var x: anyerror!i32 = error.Bad;
+ _ = &x;
while (x) |_| returns() else |_| unreachable;
}
export fn f4() void {
var a = true;
+ _ = &a;
while (a) {} else true;
}
export fn f5() void {
var a = true;
+ _ = &a;
const foo = while (a) returns() else true;
_ = foo;
}
@@ -29,15 +33,15 @@ export fn f5() void {
// :5:25: error: value of type 'usize' ignored
// :5:25: note: all non-void values must be used
// :5:25: note: this error can be suppressed by assigning the value to '_'
-// :9:26: error: value of type 'usize' ignored
-// :9:26: note: all non-void values must be used
-// :9:26: note: this error can be suppressed by assigning the value to '_'
-// :13:26: error: value of type 'usize' ignored
-// :13:26: note: all non-void values must be used
-// :13:26: note: this error can be suppressed by assigning the value to '_'
-// :17:23: error: value of type 'bool' ignored
-// :17:23: note: all non-void values must be used
-// :17:23: note: this error can be suppressed by assigning the value to '_'
-// :21:34: error: value of type 'usize' ignored
-// :21:34: note: all non-void values must be used
-// :21:34: note: this error can be suppressed by assigning the value to '_'
+// :10:26: error: value of type 'usize' ignored
+// :10:26: note: all non-void values must be used
+// :10:26: note: this error can be suppressed by assigning the value to '_'
+// :15:26: error: value of type 'usize' ignored
+// :15:26: note: all non-void values must be used
+// :15:26: note: this error can be suppressed by assigning the value to '_'
+// :20:23: error: value of type 'bool' ignored
+// :20:23: note: all non-void values must be used
+// :20:23: note: this error can be suppressed by assigning the value to '_'
+// :25:34: error: value of type 'usize' ignored
+// :25:34: note: all non-void values must be used
+// :25:34: note: this error can be suppressed by assigning the value to '_'
diff --git a/test/cases/compile_errors/while_loop_break_value_ignored.zig b/test/cases/compile_errors/while_loop_break_value_ignored.zig
index e2f81d2b5f..37f5fcb018 100644
--- a/test/cases/compile_errors/while_loop_break_value_ignored.zig
+++ b/test/cases/compile_errors/while_loop_break_value_ignored.zig
@@ -7,6 +7,7 @@ export fn f1() void {
while (a) {
break returns();
}
+ _ = &a;
}
export fn f2() void {
@@ -16,6 +17,7 @@ export fn f2() void {
break :outer returns();
}
}
+ _ = &x;
}
// error
@@ -24,5 +26,5 @@ export fn f2() void {
//
// :7:5: error: incompatible types: 'usize' and 'void'
// :8:22: note: type 'usize' here
-// :14:12: error: incompatible types: 'usize' and 'void'
-// :16:33: note: type 'usize' here
+// :15:12: error: incompatible types: 'usize' and 'void'
+// :17:33: note: type 'usize' here
diff --git a/test/cases/compile_errors/wrong_type_passed_to_panic.zig b/test/cases/compile_errors/wrong_type_passed_to_panic.zig
index d6f142f24a..bebaffb748 100644
--- a/test/cases/compile_errors/wrong_type_passed_to_panic.zig
+++ b/test/cases/compile_errors/wrong_type_passed_to_panic.zig
@@ -1,5 +1,5 @@
export fn entry() void {
- var e = error.Foo;
+ const e = error.Foo;
@panic(e);
}