From 21fa187abc2a06c9bd5cfe4355c5edbfb3177f6b Mon Sep 17 00:00:00 2001 From: mlugg Date: Sat, 11 Nov 2023 07:27:31 +0000 Subject: [PATCH] test: update cases to silence 'var is never mutated' errors --- ...ding_numbers_at_runtime_and_comptime.2.zig | 1 + test/cases/array_in_anon_struct.zig | 1 + test/cases/assert_function.17.zig | 1 + test/cases/bad_inferred_variable_type.zig | 2 +- test/cases/binary_operands.1.zig | 1 + test/cases/binary_operands.10.zig | 1 + test/cases/binary_operands.11.zig | 1 + test/cases/binary_operands.12.zig | 1 + test/cases/binary_operands.13.zig | 1 + test/cases/binary_operands.14.zig | 2 +- test/cases/binary_operands.2.zig | 1 + test/cases/binary_operands.3.zig | 1 + test/cases/binary_operands.4.zig | 2 +- test/cases/binary_operands.6.zig | 1 + test/cases/binary_operands.7.zig | 1 + test/cases/binary_operands.8.zig | 1 + test/cases/binary_operands.9.zig | 1 + ...n_of_non-tagged_union_and_enum_literal.zig | 3 +- ..._known_struct_is_resolved_before_error.zig | 2 +- ..._ABI_compatible_type_or_has_align_attr.zig | 2 +- .../compile_errors/C_pointer_to_anyopaque.zig | 2 +- ..._runtime_parameter_from_outer_function.zig | 4 +- .../compile_errors/add_on_undefined_value.zig | 2 +- .../alignment_of_enum_field_specified.zig | 2 +- ...mbiguous_coercion_of_division_operands.zig | 12 +++--- .../compile_errors/and_on_undefined_value.zig | 3 +- .../array_access_of_non_array.zig | 2 +- .../compile_errors/array_access_of_type.zig | 2 +- .../array_access_with_non_integer_index.zig | 4 +- .../array_init_invalid_elem_count.zig | 12 +++--- .../assign_inline_fn_to_non-comptime_var.zig | 2 +- .../assign_local_bad_coercion.zig | 2 +- .../assign_too_big_number_to_u16.zig | 4 +- ...th_a_function_that_returns_an_optional.zig | 4 +- .../async/Frame_of_generic_function.zig | 4 +- ...sync_function_depends_on_its_own_frame.zig | 2 +- ...on_indirectly_depends_on_its_own_frame.zig | 2 +- .../async/bad_alignment_in_asynccall.zig | 1 + .../async/const_frame_cast_to_anyframe.zig | 2 +- ..._recursion_of_async_functions_detected.zig | 8 ++-- .../invalid_suspend_in_exported_function.zig | 2 +- ...c_function_pointer_passed_to_asyncCall.zig | 1 + ...bad_implicit_casting_of_anyframe_types.zig | 6 +-- .../runtime-known_async_function_called.zig | 1 + ...own_function_called_with_async_keyword.zig | 1 + ...cit_cast_from_const_T_to_array_len_1_T.zig | 4 +- ...licit_cast_from_array_pointer_to_slice.zig | 6 +-- .../compile_errors/bad_alignment_type.zig | 8 ++-- .../compile_errors/bad_usage_of_call.zig | 5 ++- .../binary_OR_operator_on_error_sets.zig | 2 +- ...tCast_same_size_but_bit_count_mismatch.zig | 4 +- ...h_different_sizes_inside_an_expression.zig | 5 ++- ...comptime_only_scope_uses_condbr_inline.zig | 8 ++-- .../break_void_result_location.zig | 5 ++- .../compile_errors/c_pointer_to_void.zig | 6 +-- ...tcall_thiscall_on_unsupported_platform.zig | 6 +-- ...en_optional_T_where_T_is_not_a_pointer.zig | 8 ++-- ...et_to_error_union_of_smaller_error_set.zig | 6 +-- .../cast_global_error_set_to_error_set.zig | 6 +-- .../catch_on_undefined_value.zig | 2 +- ...to_non_optional_with_incomparable_type.zig | 4 +- ...parison_operators_with_undefined_value.zig | 12 +++--- ...ompile_error_in_struct_init_expression.zig | 2 +- .../compile_time_null_ptr_cast.zig | 2 +- .../compile_time_undef_ptr_cast.zig | 1 + ...st_enum_to_union_but_field_has_payload.zig | 2 +- ...mptime_continue_inside_runtime_if_bool.zig | 5 ++- ...ptime_continue_inside_runtime_if_error.zig | 5 ++- ...me_continue_inside_runtime_if_optional.zig | 5 ++- ...omptime_continue_inside_runtime_switch.zig | 5 ++- ...ime_continue_inside_runtime_while_bool.zig | 5 ++- ...me_continue_inside_runtime_while_error.zig | 5 ++- ...continue_inside_runtime_while_optional.zig | 5 ++- ...comptime_continue_to_outer_inline_loop.zig | 5 ++- .../comptime_if_inside_runtime_for.zig | 7 ++-- .../comptime_slice_of_an_undefined_slice.zig | 2 +- .../comptime_struct_field_no_init_value.zig | 2 +- ...mptime_vector_overflow_shows_the_index.zig | 2 +- ...de_comptime_function_has_compile_error.zig | 6 +-- .../deref_on_undefined_value.zig | 2 +- .../deref_slice_and_get_len_field.zig | 1 + .../compile_errors/dereference_an_array.zig | 3 +- ...encing_invalid_payload_ptr_at_comptime.zig | 2 +- ...edding_opaque_type_in_struct_and_union.zig | 4 +- .../compile_errors/div_on_undefined_value.zig | 1 + .../double_pointer_to_anyopaque_pointer.zig | 7 ++-- .../empty_switch_on_an_integer.zig | 2 +- ...acked_by_comptime_int_must_be_comptime.zig | 2 +- .../enum_field_value_references_enum.zig | 2 +- ...field_count_range_but_not_matching_tag.zig | 4 +- .../enum_value_already_taken.zig | 2 +- ..._initializer_doesnt_crash_the_compiler.zig | 2 +- ..._union_operator_with_non_error_set_LHS.zig | 2 +- .../error_when_evaluating_return_type.zig | 2 +- ...n_why_generic_fn_is_called_at_comptime.zig | 5 ++- ..._known_at_comptime_violates_error_sets.zig | 6 +-- ...xplicitly_casting_non_tag_type_to_enum.zig | 4 +- .../extern_union_field_missing_type.zig | 2 +- .../extern_union_given_enum_tag_type.zig | 2 +- .../compile_errors/field_access_of_slices.zig | 5 ++- test/cases/compile_errors/for.zig | 7 ++-- .../for_loop_body_expression_ignored.zig | 2 +- .../compile_errors/function_ptr_alignment.zig | 10 ++--- ...ailure_in_generic_function_return_type.zig | 3 +- ...generic_method_call_with_invalid_param.zig | 9 ++-- ...nored_expression_in_while_continuation.zig | 10 +++-- ..._and_Zig_pointer-bad_const-align-child.zig | 12 +++--- .../implicit_cast_from_f64_to_f32.zig | 2 +- ...mplicit_cast_of_error_set_not_a_subset.zig | 6 +-- ...ers_which_would_mess_up_null_semantics.zig | 13 ++++-- ..._casting_null_c_pointer_to_zig_pointer.zig | 5 ++- .../implicitly_casting_enum_to_tag_type.zig | 2 +- .../incompatible sub-byte fields.zig | 7 ++-- .../compile_errors/incompatible_sentinels.zig | 4 +- .../incorrect_pointer_dereference_syntax.zig | 1 + .../incorrect_type_to_memset_memcpy.zig | 8 ++-- ..._array_of_size_zero_with_runtime_index.zig | 3 +- ...e_call_runtime_value_to_comptime_param.zig | 2 +- ...float_conversion_to_comptime_int-float.zig | 10 +++-- .../intFromPtr_0_to_non_optional_pointer.zig | 4 +- .../int_to_err_global_invalid_number.zig | 2 +- .../int_to_err_non_global_invalid_number.zig | 6 +-- .../integer_cast_truncates_bits.zig | 4 +- .../compile_errors/invalid_compare_string.zig | 8 ++-- .../invalid_deref_on_switch_target.zig | 2 +- .../compile_errors/invalid_float_casts.zig | 12 ++++-- .../invalid_inline_else_type.zig | 9 ++-- .../compile_errors/invalid_int_casts.zig | 12 ++++-- .../invalid_multiple_dereferences.zig | 9 ++-- .../invalid_non-exhaustive_enum_to_union.zig | 4 +- .../invalid_peer_type_resolution.zig | 38 +++++++++-------- .../invalid_store_to_comptime_field.zig | 24 ++++++----- .../compile_errors/invalid_struct_field.zig | 5 ++- ...gnostic_string_for_top_level_decl_type.zig | 4 +- ..._3818_bitcast_from_parray-slice_to_u16.zig | 2 +- ...ional_anyopaque_to_anyopaque_must_fail.zig | 10 ++--- ...zy_pointer_with_undefined_element_type.zig | 3 +- ...tor_pointer_with_unknown_runtime_index.zig | 2 +- .../cases/compile_errors/memset_no_length.zig | 10 +++-- ..._const_in_slice_with_nested_array_type.zig | 2 +- .../compile_errors/missing_else_clause.zig | 4 +- ...ing_parameter_name_of_generic_function.zig | 2 +- ...elled_type_with_pointer_only_reference.zig | 2 +- .../compile_errors/mod_on_undefined_value.zig | 1 + .../mult_on_undefined_value.zig | 2 +- .../negate_on_undefined_value.zig | 2 +- test/cases/compile_errors/nested_vectors.zig | 2 +- ...of_things_that_require_const_variables.zig | 14 +++---- .../non-integer_tag_type_to_enum.zig | 2 +- .../non_void_error_union_payload_ignored.zig | 6 ++- .../cases/compile_errors/not_an_enum_type.zig | 2 +- .../compile_errors/or_on_undefined_value.zig | 3 +- .../orelse_on_undefined_value.zig | 2 +- .../compile_errors/out_of_bounds_index.zig | 16 ++++---- .../overflow_in_enum_value_allocation.zig | 2 +- .../packed_union_given_enum_tag_type.zig | 2 +- ...cked_union_with_automatic_layout_field.zig | 2 +- ...pointer_arithmetic_on_pointer-to-array.zig | 10 ++--- .../pointer_to_anyopaque_slice.zig | 1 + .../ptrFromInt_with_misaligned_address.zig | 2 +- .../compile_errors/recursive_inline_fn.zig | 3 +- .../reference_to_const_data.zig | 9 ++-- ...ify_typeOf_with_incompatible_arguments.zig | 1 + ...ompatibility_mismatching_handle_is_ptr.zig | 2 +- ...mismatching_handle_is_ptr_generic_call.zig | 2 +- ...ime_assignment_to_comptime_struct_type.zig | 1 + ...time_assignment_to_comptime_union_type.zig | 5 ++- ...ast_to_union_which_has_non-void_fields.zig | 4 +- .../runtime_indexing_comptime_array.zig | 6 ++- .../runtime_to_comptime_num.zig | 20 +++++---- .../runtime_value_in_switch_prong.zig | 2 +- ...f_referential_struct_requires_comptime.zig | 2 +- ...lf_referential_union_requires_comptime.zig | 2 +- .../shift_by_negative_comptime_integer.zig | 4 +- ...ift_on_type_with_non-power-of-two_size.zig | 12 ++++-- ...ing_without_int_type_or_comptime_known.zig | 6 ++- ...elected_index_past_first_vector_length.zig | 8 ++-- ...ce_cannot_have_its_bytes_reinterpreted.zig | 5 +-- .../compile_errors/slice_of_null_pointer.zig | 6 +-- .../slice_sentinel_mismatch-2.zig | 2 +- ...pecify_enum_tag_type_that_is_too_small.zig | 3 +- .../specify_non-integer_enum_tag_type.zig | 2 +- ...line_assembly_template_cannot_be_found.zig | 2 +- ...tor_pointer_with_unknown_runtime_index.zig | 3 +- .../compile_errors/sub_on_undefined_value.zig | 2 +- .../switch_capture_incompatible_types.zig | 4 +- ...ch_on_enum_with_1_field_with_no_prongs.zig | 2 +- test/cases/compile_errors/switch_on_slice.zig | 3 +- .../switch_ranges_endpoints_are_validated.zig | 4 +- .../switch_with_overlapping_case_ranges.zig | 2 +- ...hing_with_exhaustive_enum_has___prong_.zig | 2 +- .../switching_with_non-exhaustive_enums.zig | 6 +-- ...d_on_union_with_no_associated_enum_tag.zig | 7 ++-- .../compile_errors/truncate_sign_mismatch.zig | 16 ++++---- .../compile_errors/tuple_init_edge_cases.zig | 41 +++++++++++-------- .../union_access_of_inactive_field.zig | 1 + .../union_auto-enum_value_already_taken.zig | 2 +- .../union_duplicate_enum_field.zig | 2 +- .../union_enum_field_does_not_match_enum.zig | 2 +- .../union_noreturn_field_initialized.zig | 6 +-- .../union_runtime_coercion_from_enum.zig | 2 +- ...zig => unreachable_else_prong_err_set.zig} | 4 +- ...to_assign_null_to_non-nullable_pointer.zig | 11 +++-- ..._invalid_number_literal_as_array_index.zig | 2 +- .../variable_with_type_noreturn.zig | 2 +- .../variadic_arg_validation.zig | 9 ++-- .../while_loop_body_expression_ignored.zig | 28 +++++++------ .../while_loop_break_value_ignored.zig | 6 ++- .../wrong_type_passed_to_panic.zig | 2 +- test/cases/compile_log.0.zig | 2 +- test/cases/compile_log.1.zig | 1 + test/cases/comptime_var.0.zig | 5 ++- test/cases/comptime_var.1.zig | 1 + test/cases/comptime_var.5.zig | 1 + test/cases/conditions.5.zig | 1 + test/cases/decl_value_arena.zig | 2 +- test/cases/enum_values.0.zig | 4 +- test/cases/enum_values.1.zig | 3 ++ test/cases/error_in_nested_declaration.zig | 2 +- test/cases/error_unions.0.zig | 1 + test/cases/error_unions.1.zig | 1 + test/cases/error_unions.2.zig | 1 + test/cases/error_unions.3.zig | 1 + test/cases/error_unions.4.zig | 1 + test/cases/error_unions.5.zig | 1 + test/cases/f32_passed_to_variadic_fn.zig | 4 +- test/cases/inner_func_accessing_outer_var.zig | 5 ++- test/cases/llvm/blocks.zig | 1 + ...ment_address_space_reading_and_writing.zig | 1 + test/cases/llvm/nested_blocks.zig | 2 +- test/cases/llvm/optionals.zig | 4 ++ .../llvm/simple_addition_and_subtraction.zig | 1 + test/cases/locals.0.zig | 4 +- test/cases/locals.1.zig | 3 +- ...ying_numbers_at_runtime_and_comptime.2.zig | 1 + .../only_1_function_and_it_gets_updated.1.zig | 2 +- test/cases/optionals.0.zig | 1 + test/cases/optionals.1.zig | 1 + test/cases/optionals.2.zig | 1 + test/cases/optionals.3.zig | 1 + test/cases/runtime_bitwise_and.zig | 1 + test/cases/runtime_bitwise_or.zig | 1 + .../@asyncCall with too small a frame.zig | 3 +- test/cases/safety/@intCast to u0.zig | 2 +- ...o to non-optional byte-aligned pointer.zig | 3 +- ...t address zero to non-optional pointer.zig | 3 +- .../@ptrFromInt with misaligned address.zig | 3 +- .../@tagName on corrupted enum value.zig | 2 +- .../@tagName on corrupted union value.zig | 4 +- ...ray slice sentinel mismatch non-scalar.zig | 2 +- .../exact division failure - vectors.zig | 4 +- test/cases/safety/for_len_mismatch.zig | 1 + test/cases/safety/for_len_mismatch_three.zig | 1 + .../integer division by zero - vectors.zig | 4 +- test/cases/safety/memcpy_alias.zig | 1 + test/cases/safety/memcpy_len_mismatch.zig | 1 + .../safety/memset_slice_undefined_bytes.zig | 1 + .../safety/memset_slice_undefined_large.zig | 1 + .../optional unwrap operator on C pointer.zig | 3 +- ...tional unwrap operator on null pointer.zig | 3 +- ...r casting null to non-optional pointer.zig | 3 +- ...n which has been suspended and resumed.zig | 2 +- ...ed function which never been suspended.zig | 2 +- .../safety/shift left by huge amount.zig | 3 +- .../safety/shift right by huge amount.zig | 3 +- ...ed integer division overflow - vectors.zig | 4 +- ...in cast to unsigned integer - widening.zig | 3 +- .../safety/signed-unsigned vector cast.zig | 3 +- ...ice start index greater than end index.zig | 1 + ...h sentinel out of bounds - runtime len.zig | 1 + .../slicing null C pointer - runtime len.zig | 3 +- test/cases/safety/slicing null C pointer.zig | 3 +- test/cases/safety/truncating vector cast.zig | 3 +- ...ast to signed integer - same bit count.zig | 3 +- .../safety/unsigned-signed vector cast.zig | 3 +- .../vector integer addition overflow.zig | 4 +- ...vector integer multiplication overflow.zig | 4 +- .../vector integer negation overflow.zig | 1 + .../vector integer subtraction overflow.zig | 4 +- test/cases/structs.0.zig | 1 + test/cases/structs.2.zig | 1 + test/cases/structs.3.zig | 1 + test/cases/switch.0.zig | 3 +- test/cases/switch.1.zig | 2 + test/cases/switch.2.zig | 3 +- test/cases/switch.3.zig | 3 +- test/cases/type_of.0.zig | 1 + test/cases/while_loops.1.zig | 1 + test/cases/while_loops.2.zig | 1 + 289 files changed, 671 insertions(+), 489 deletions(-) rename test/cases/compile_errors/{uncreachable_else_prong_err_set.zig => unreachable_else_prong_err_set.zig} (84%) diff --git a/test/cases/adding_numbers_at_runtime_and_comptime.2.zig b/test/cases/adding_numbers_at_runtime_and_comptime.2.zig index 6643d811fc7edd946d27adac4302439093fb2603..d6d8755dc3ca614d588dc9ad460e4fb806845941 100644 --- a/test/cases/adding_numbers_at_runtime_and_comptime.2.zig +++ b/test/cases/adding_numbers_at_runtime_and_comptime.2.zig @@ -1,5 +1,6 @@ pub fn main() void { var x: usize = 3; + _ = &x; const y = add(1, 2, x); if (y - 6 != 0) unreachable; } diff --git a/test/cases/array_in_anon_struct.zig b/test/cases/array_in_anon_struct.zig index 43e815d621e7f6e4dbdea464f127db853e42608f..6164e7056918ea077be4d3c56c4ad277053e7918 100644 --- a/test/cases/array_in_anon_struct.zig +++ b/test/cases/array_in_anon_struct.zig @@ -2,6 +2,7 @@ const std = @import("std"); noinline fn outer() u32 { var a: u32 = 42; + _ = &a; return inner(.{ .unused = a, .value = [1]u32{0}, diff --git a/test/cases/assert_function.17.zig b/test/cases/assert_function.17.zig index ac9dce3079f6444476afd65757675726390946cf..01c4a5ca3cbe016f2fcf75688b7d7dc1cbd95d1f 100644 --- a/test/cases/assert_function.17.zig +++ b/test/cases/assert_function.17.zig @@ -1,5 +1,6 @@ pub fn main() void { var i: u64 = 0xFFEEDDCCBBAA9988; + _ = &i; assert(i == 0xFFEEDDCCBBAA9988); } diff --git a/test/cases/bad_inferred_variable_type.zig b/test/cases/bad_inferred_variable_type.zig index 7c464f48c91211e650eff61d70013a64757b1253..e84129960616fbdbde5b5a49f69d1c9ca7b22ecd 100644 --- a/test/cases/bad_inferred_variable_type.zig +++ b/test/cases/bad_inferred_variable_type.zig @@ -1,6 +1,6 @@ pub fn main() void { var x = null; - _ = x; + _ = &x; } // error diff --git a/test/cases/binary_operands.1.zig b/test/cases/binary_operands.1.zig index fdee492d227abb71eca039c996d32c6a24568d43..2b244b194a8b695934c4917d14e137414d4b0b15 100644 --- a/test/cases/binary_operands.1.zig +++ b/test/cases/binary_operands.1.zig @@ -1,5 +1,6 @@ pub fn main() void { var i: i32 = 2147483647; + _ = &i; if (i +% 1 != -2147483648) unreachable; return; } diff --git a/test/cases/binary_operands.10.zig b/test/cases/binary_operands.10.zig index 63e045c258199ca9127804d16969e7ba2d4c9a64..721a9217437bcf92dfb9d5f859d3ac53f91def9e 100644 --- a/test/cases/binary_operands.10.zig +++ b/test/cases/binary_operands.10.zig @@ -2,6 +2,7 @@ pub fn main() void { var i: u32 = 5; i *= 7; var result: u32 = foo(i, 10); + _ = &result; if (result != 350) unreachable; return; } diff --git a/test/cases/binary_operands.11.zig b/test/cases/binary_operands.11.zig index f461bcc0af9ba6cb1cae194c078fb53bcd6b24bd..f6a87551781872317d72c17a6b74bbd8b1f258b5 100644 --- a/test/cases/binary_operands.11.zig +++ b/test/cases/binary_operands.11.zig @@ -1,5 +1,6 @@ pub fn main() void { var i: i32 = 2147483647; + _ = &i; const result = i *% 2; if (result != -2) unreachable; return; diff --git a/test/cases/binary_operands.12.zig b/test/cases/binary_operands.12.zig index 0ffb5e22309d4642af7b59c80999f2ce465d7c45..d8b369764fb38b5e12a7379cdbdae1979b1386f7 100644 --- a/test/cases/binary_operands.12.zig +++ b/test/cases/binary_operands.12.zig @@ -1,5 +1,6 @@ pub fn main() void { var i: u3 = 3; + _ = &i; if (i *% 3 != 1) unreachable; return; } diff --git a/test/cases/binary_operands.13.zig b/test/cases/binary_operands.13.zig index d626059e1034a9b09eeae9ae69509c8f6c44cd2c..680d82a91985140dfdb4c071e0d3b3504b7b0bee 100644 --- a/test/cases/binary_operands.13.zig +++ b/test/cases/binary_operands.13.zig @@ -1,5 +1,6 @@ pub fn main() void { var i: i4 = 3; + _ = &i; if (i *% 3 != -7) unreachable; return; } diff --git a/test/cases/binary_operands.14.zig b/test/cases/binary_operands.14.zig index fcc7245ad97d3606a1d364981bbae5c1339cc8d7..aa1d62bcde45beffdd81be488d2773e378e766d8 100644 --- a/test/cases/binary_operands.14.zig +++ b/test/cases/binary_operands.14.zig @@ -1,7 +1,7 @@ pub fn main() void { var i: u32 = 352; i /= 7; // i = 50 - var result: u32 = foo(i, 7); + const result: u32 = foo(i, 7); if (result != 7) unreachable; return; } diff --git a/test/cases/binary_operands.2.zig b/test/cases/binary_operands.2.zig index 78c10f56b76f4bce803dea768d77530c16479cb1..5b08fecc04482d097242cb0b3736396baaafecbe 100644 --- a/test/cases/binary_operands.2.zig +++ b/test/cases/binary_operands.2.zig @@ -1,5 +1,6 @@ pub fn main() void { var i: i4 = 7; + _ = &i; if (i +% 1 != -8) unreachable; return; } diff --git a/test/cases/binary_operands.3.zig b/test/cases/binary_operands.3.zig index 0297f1e7a48a877295b059a36e0fc958e2033f61..75d78d522a6de9d6bb550de5e99ed4dfb10c40dc 100644 --- a/test/cases/binary_operands.3.zig +++ b/test/cases/binary_operands.3.zig @@ -1,5 +1,6 @@ pub fn main() u8 { var i: u8 = 255; + _ = &i; return i +% 1; } diff --git a/test/cases/binary_operands.4.zig b/test/cases/binary_operands.4.zig index f0f8910e1463b4127d7da741907491cbbee4394a..b3fd9fc289aeb8084d239fe4bef28fb832975cc3 100644 --- a/test/cases/binary_operands.4.zig +++ b/test/cases/binary_operands.4.zig @@ -1,7 +1,7 @@ pub fn main() u8 { var i: u8 = 5; i += 20; - var result: u8 = foo(i, 10); + const result: u8 = foo(i, 10); return result - 35; } fn foo(x: u8, y: u8) u8 { diff --git a/test/cases/binary_operands.6.zig b/test/cases/binary_operands.6.zig index 5c9c5be68aa1364a8f782aaab099532cd6dde297..b6e04e609e57ce5c1e4dead30ee174c0af87a427 100644 --- a/test/cases/binary_operands.6.zig +++ b/test/cases/binary_operands.6.zig @@ -1,5 +1,6 @@ pub fn main() void { var i: i32 = -2147483648; + _ = &i; if (i -% 1 != 2147483647) unreachable; return; } diff --git a/test/cases/binary_operands.7.zig b/test/cases/binary_operands.7.zig index 634a47fb0ce4042bd71d386044a2077109f39356..ae69df2c550908835e281571e0d9bd89690c87e9 100644 --- a/test/cases/binary_operands.7.zig +++ b/test/cases/binary_operands.7.zig @@ -1,5 +1,6 @@ pub fn main() void { var i: i7 = -64; + _ = &i; if (i -% 1 != 63) unreachable; return; } diff --git a/test/cases/binary_operands.8.zig b/test/cases/binary_operands.8.zig index a20f6646944d35e89980743212ce060d9b3e5930..fb2741cab6d9161c01aabc18e0f5c41a40dee315 100644 --- a/test/cases/binary_operands.8.zig +++ b/test/cases/binary_operands.8.zig @@ -1,5 +1,6 @@ pub fn main() void { var i: u4 = 0; + _ = &i; if (i -% 1 != 15) unreachable; } diff --git a/test/cases/binary_operands.9.zig b/test/cases/binary_operands.9.zig index e6c4f5d52b491158f629ec74f7b0f16f624f94ac..a9d62b96e340506748f0e320e6063d81f2378686 100644 --- a/test/cases/binary_operands.9.zig +++ b/test/cases/binary_operands.9.zig @@ -2,6 +2,7 @@ pub fn main() u8 { var i: u8 = 5; i -= 3; var result: u8 = foo(i, 10); + _ = &result; return result - 8; } fn foo(x: u8, y: u8) u8 { diff --git a/test/cases/comparison_of_non-tagged_union_and_enum_literal.zig b/test/cases/comparison_of_non-tagged_union_and_enum_literal.zig index 621b8ead259868e26f9532a831e2b014d685ce35..3e529d5e302898d9b5717a4bf039efab8526b6b1 100644 --- a/test/cases/comparison_of_non-tagged_union_and_enum_literal.zig +++ b/test/cases/comparison_of_non-tagged_union_and_enum_literal.zig @@ -2,7 +2,8 @@ export fn entry() void { const U = union { A: u32, B: u64 }; var u = U{ .A = 42 }; var ok = u == .A; - _ = ok; + _ = &u; + _ = &ok; } // error 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 3ec79c7c53637119f4747d36beca692030562514..0764dc9472be9884f94abc187ecdc52086fd5257 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 c10a146cf08f70fae0bc502e379371b57297d2e5..c0188477b85c45ffb98233af27d6ef72647d23d9 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 c2a0ad088dea41d979bccefa6235441766aa0fb6..21c67e151cff436e7a5fefa0521818bd0951cc1d 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 49ef3b4d4d9f026943c2b40cd7a1b3743422d21c..176ace28db9143e47fce79e1e88fae4e9c6a4adc 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 404f5019be58e43978e93d509e33c466e78231b3..b59de233c57cd3ab1e0affccf188bbee978f43c4 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 ecb06aa2543bdaf116bb244e2c08a4d0f5363e77..409a8e0f934bce1429e4de31a12d72910fa716ad 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 f3e51a1bed2459b067e42f966e0b6ba4b4afe328..5defb463c2f860f6f6770df56b0c7db1cdb872d3 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 cee23d054061351e516fb85a7081f2596804183c..416ba800976a63cdd7d9f30811fbdc0bec04a8a6 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 0f06bae1dd011a84551c8a0cbf2454014dd810f0..4bcb9bd237974c6998c84739a7d24f6d8019f42d 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 1e66ca3776d24467c74a4d3f73f0a51427de6594..b9e6f24a5547c71a7a00e0758ddfc37c19638188 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 3d7bde7364df1c727af3bb7d47841335a31131fc..0189d0f09ca6936ad4e29c515064adc675af55be 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 23e00cd057464735f9049e0c3370ff8c09840a74..ce281452698940aef17b36fb456d2f6c07b6f110 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 b2da9f32d9857107ab212c6f0499c34941153094..155df733fbbf8c3ed28c627601416d1c0ea6eea8 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 0aa93f48bdcd33e8785d966ad61ad2c9c1573839..405af4f23534c93627cb78343c9d6019ef0a59c4 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 1f8b097ae2329e49e24e17bee22b7546546206fc..4f595a95da5f956f1dc6cba28c2c5aabc26e6460 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 6a7de57352b624d57866f13c7a03ef2e4e6e9308..f91b6a4ef22b81a6350e2b528dc025e3c90f5eb9 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 d90e53eb4683dba5f55a8e99388d04f47aa91390..af0fb5c72edeaf840439695f1530312357cf4d55 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 4dde5860bafc4709d376e1703df95b14ce58420f..b266d86ed807f16487194bac04bac6ac5b980bf1 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 4dac0d4fa33fbc45db20184af0c0734552b9df81..4e7341bff59841643916c573dde47ad7f55c0f23 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 399914000994b76b44c91e8200b74dafcd7aa1be..da00a0eeb7e305fb058cc540033509b5ffab86c6 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 affdb953d72f317ea094a806b6c08aa05c135256..52b866afcffe2a820fd23bacf90c4c916e6c6864 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 d845dc7930a73e4c85f24b57f9c6432a64bae4d3..804baed45fbdc72cbdae4df649a7d29401868296 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 cfcbfba889dfd57b1260ee14df08d354f4973de4..fb3488ce9500d7df4fde80712f53a7587d7e98e0 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 97bc6a09bddb71cc196d7261ff474769cb61cb03..b62524f6de11afb5be59ceb2a5d1ba75c6edf277 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 bdf7bec45816cff736f401e4c05ecfbaf9c50bbc..6ab99bf00dc0f52d613a8d7a399cc1c5c38f55de 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 90685ce566297391b6924ec1a56cddc2db28aa9a..8a5ef27d62dbd9190e2eaa3b888f9460066a9637 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 bfc22cca255d0aadfc0e6645ffcba7429a53ac72..9933c95435c9fd3d64abbd45ae73c9b8379654e1 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 b553d492aeb42fffacaa401a4f6b14dfd95dbeba..912bf6ba3c40df16b35d229381069ee9954b99d4 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 0641d8e3f9605a9a0a60efdfa8f33ad74dc732a5..cbc380c8fec74122bc580614fc5321c34db7d85a 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 523ee2491ae0ca2ea388c2998b2673a1701d5302..c85eb8427d76d7c30ceee947a96468109c665148 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 3669cda3bf2935f2f697072e5bfd6814fe16a148..3b7abe53f69fbde6d908c98d106926af595b6c52 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 9955194f95a3f63567becc471e5b1f119347dfe9..ae239d300e85c4695d5a7a28e84988808541d4e8 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 e366e0cb03f548b76c8f9b99e81615fc5e87b145..1a7305904b2e5e304bc63af343ba9d7c70ad13d8 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 f73dfeb38a46c7d1efb993211c6816f93e4a0b2e..e1a16be60a1a38a534b2aa8a11597dc5dc0398b7 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 8c0166ad2dccb6fac8f8e11eefb851129efc28fe..c072c7ef9d977c4ae5efb84f2021d247b68cdd24 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 140ddb6ed13eaa2235c8f3fdab317291bcad992b..24a7644ce10029354dfa88b52fbf579ce27a1be5 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 116f5a89486f9f1a93ff73ac961270d83d45b4d0..502feb4326b2a06e585ba1b7dff0bd725c061528 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 9813df24db7cfa32d1c509cc3800a3bc9846affd..3480dc8aa7d32b6bc56f1a55bf09b8a68fe91b34 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 fa1fc21568cfebd2651baddaf4e88fd06e4c9e59..1698fdeaedf9fe3df8b2e0d401d0e5fbb6205e66 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 36a17d734b20575642811277b2ddfd9a97c9eb82..792fd9fb0d05edc3e70012e3bcc0c3c45946c3d4 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 39d94740161d37db7d49909f41a72de3c168649c..3d6628b7995b742d8853252700b00b3c4662686c 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 ef041c95391dab4bad402e41bba2d8e64d5e0b71..0fb11fc05f942565c294ba0587fe125faeb840c6 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 653b7ffcfbbc855ef71047eb07def1add048b7f3..e9746f7e166878836a8fc0becd0d604400e670c9 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 b7b40d3178bcbfbc71a03954ac9a1bfe6a22c0ca..d4dda81788c240dbf2ed624d1c957b3ec52433d2 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 64a97a7a5b0c6d2c29f2cf46066a6ca8d09c9158..9813951a8ba83f5fec4f3dc37517bc345ce38210 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 7d25931aaaad8ea176407d8c95bb037e6b874360..2142521fd172f61c277036d7013e1d5ff352ded0 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 d93e8bc73d1beb3417fe87e7031d910b6a4a33a6..9e6bfd8003412d59edf1385e998c7c71629cf541 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 d38738dae727d50d17be0012d115cad073c10aeb..465a0f466e7b5012d06b90d5203a4681a71e829f 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 b2a7312c529301e7f6371d8350f8b9683defecbb..d3462ed8984310a44042bbd277eda439bb9ab139 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 194274a1edf82f3a7a8edea31e242f2a1437a6ba..fb1e60cb3db1ffccf6b08b0db285282fe1cca777 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 965454ef03f0bf51b2e5cc8dea46486675aa612b..f4837c812e975f9e6a453a90c2f956d745fe2c7a 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 391ecbdf1a2bc48d09427ec4ca905180a8c07cc8..6a23da4cb641f8cae8e83b85fc3ec2a52d115e36 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 54d62e6d371cf1ff3602b6d9e4f3a4e6d61fe28c..55b8b1bde7149ebca3132d335c67282bb80b442a 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 0eef1c33745ec04619b57f79ecb0f15bd42c70f1..fe6f3c202e93752ab94b0c11a956da86fce15059 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 e6753a5911e34415c90f42589bfcc9c19ae355eb..2724af30596cf5bcc44b58d3571df814b490ded3 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 5e6a321db26c77ef23c42c0bf33ec715970893b9..e9fb8c0066de0d6feacd95244a35be2be774eaa9 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 40055a70b9b86d7142359cc4c133bd7fa19b3482..425eb99e9c9faad90d5a2f022c5cb135c9f8e411 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 d1b22d86b7f1f08db6257c4d98138e518bd2b389..aa3719816c692d88f96fdeb66d51b6557ebaef1e 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 c0cb470eeeb3ba05e618362e532204ded04f1d3f..95ace475305870ed16cb5435d385f537926a14c5 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 fda8ffe4537402c0e723ba985303dbd444a22723..ace946453ecf1c11c522342fb6f0c5ac7b68686c 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 1ce744d6d7e09ff89b667510cbd477b7d72d37da..6efed3eb8131fd4c85b1b9e105d523efd47bbf94 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 fa12e2824cad3e1794a6d1bad893d4d8f8198af6..81d0fbda1b503038ee97a09b88da6c291af30651 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 1ba03c6d50cf90ad0c647ec3552f24fb0d5bcc5e..2550c88d27404bc015257b4e61a2b5ab6caccf9a 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 27e4d81e5550148c4c21eedb28a01d34d300ba99..7c71da914def49b7127c04df865a178b4c9cf48c 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 69457965bb28a5f2d910ef2c30ab3ec337c9f8fc..17117713ed60f41f29e78556242d0fa848ee8126 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 d9f27da4aa66d647893922243b834c69358a90b1..7fc562fd69240a6a32353edcfa299e6026074407 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 8365cdfa73d1a7cbc18a2a1aeee49c419a347919..bc2cfa158d1137a03429a5a36ed296d3d5fef315 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 c695b7393dcbb94f1528673288a7386e28fbc4ad..dbebf07e0b01c2e2ab51b6f96b19bfb079dae51d 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 6ba69f8d3e8762797e11aaf50648117a69db96a0..5ac9ed454fa38471155086c51d05aa96345d07ce 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 7dab294d4a109e7d27f7d68ce659c2adbedd9280..498a0c80b7ab271d5a2e68e8a0bdc907cb5c0978 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 b2b73b15247f740cc0d634a40f647899f334468f..7c258adce71f4296c9c2dc30a83f64f576015d1c 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 3e1190cc32d224ee4b6836f9bf1dc792aec24df5..74df2d3de948cbd93226e7633fc616f62bf95522 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 733585a7488dcebb3db8556e95ba9551520219a5..e3a13785e1dd62438bbe900fa7f4b0f25e066b61 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 c0b1193fb1331f66f87d3c105704584d9f2814bf..515ac855ce2ca6956eacaa5759bdb3aa238d5088 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 cafca1ee55bd6c15afc4d3590d5974955c3a9af2..e20b2861cc2579649dcac4bee76bf5313867c428 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 647b51b475895df5652e34942dfcd26a477a34bd..08e19cd46ae0672bdf180b0809490d89ded6361e 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 701241a403b1eedabbcf6e59594fb433b8a9f9e0..aada601c79bf49a4183292a28b23610bedfddb59 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 fedfaf2d07067cf12a6218bc7c076d01481394bf..a1beac65f2f228e0593990eeec62cbd977c9d414 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 bb920138e1b3e1bb7ccc6b31e3d8da6ace77ff18..05189c7b0c6fe50f88bdf67c0cdb1e0ac8130822 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 fde58f69e5e288b91cb1508f4d772e4f4bb46786..9720ff90f1074ed3fa96d31bf199ac8b7e22cb85 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 4aa0e623c796428b97e6ed616c1b9dde442f531c..93eefea1447cda40c4c75739075c80d1f04b430e 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 1fbfda9646916ac61a61afe496065ca012a3dbeb..c7fe0d8b40c3e85664cb49059cc91c0da96c5383 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 568c416062f19e4050b6f8cb48a0f5b18255ddfa..4c25f9d93f05abf597e3ebb555191882e3468b45 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 3ce73a9fabaa369041270fa40c340b423e06a531..a0247139ea18361b2f37642e3559fa8bb8f32d7d 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 fabee524c7c7725ba58b1595c1ea4e9f9cc89700..995ef8d9b1cbf8035e36a3745287146d5fe416f1 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 c730f80e6f4282478e344a63a82ed7f659b5b555..9a8d765c0416ec906c646fc976457ffde6834390 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 ccea6708e4e565e436dc89b054b63162c86f0de5..6ce431461b78562e0a73bc3d5a17f54611567e24 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 d108903c82189767de44dc831f4bae600feb3419..4fa396190a58501cc9b65bc527113d3470e17225 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 78261f182fdd3966b0d21d95bea8f27f116425ef..d30db5733d8ee4c5a8b980022a5a48be3ea194ea 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 da4503cefea742222bdb12851e27fc217a2c8d2a..a8d4675ac897c52cea2253d334c274970a8df4d6 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 5e5b57680c806c387d8dbde1dbfbd48df4bada6d..617e6386274df81ab05fb26b2296da442312d55c 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 ecdc6c14c9bb7f2e60a026ebbb96c9639f76d3a0..ed3c402ef9273190ea34a344b1864e87e044dc13 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 b51635ad30c0329b2275b538e53490dabb5b6ee4..3738f89492c1b1b3f389a1c9c16bcbd16925da39 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 2f7686c93d7e001fe67ae47f88576ed790df7f7c..28d3c2445ec2fa58988bb1e91077cc37376b7175 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 dc6f715c2f2e976c2f2519d3bbe007ca0181b847..caadf6c5d95e76c20dbe4747c651881f221b12ac 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 821a0a8c6993a7873443f92e5df3635ae21efbfe..169a69a75a510a17e54eaf0a78873ae10dc94881 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 33b5d1f3b633e16ed657c697af9ee726e8843613..4f80b6186507f588894d291821a3a189ca388052 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 55af9c1185fd9714c2f9af84bed12b08afc9a6c5..26b31dd50662807e514adf041bd07c844d10443a 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 eceb5db50e18423a4b9480e887b6d49b12af4e82..21991c66ebc7dd448d888bfd674d3dbe9569e281 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 cddd91384b2e928cb0af5c4a34dec88917feaa04..2b3738cd2f7e6f0e37f3617f4f709ed701e8e713 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 772463206992de543c5045ec33127658541d3bc4..d6bf372a88ce5554f3da12d2768bc132cde3555c 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 e443b3daa962a34feadbdf7b6d0e5594705470ce..1c2a8215d76b13de21c8f5c714a217fee8922ec0 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 000b5d1e6abd5dd6ec4875e67a09d1db2463b117..82056640fdcba7557543e6a79dcb04488c3885af 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 23c3917b445a4fff38b4bba04900106e1d6560f7..c9f6c1e2e4a05107aeacf5084fa2b85d133f00b5 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 a230dd3e5bae3a03522335537bc1c0b3fa20d995..afe3484a418f7871bbf6c636f0285f7dfeea8c6e 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 a5c7f041a5649d9608ce6d65ec2b1f43c0864799..95f6fa4122d3faedbc8e5446c7c47c040f55cbec 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 a880b16fca8579d4cf982582834aa3c349a31857..70fab8e8c16259535e88f9334a508d9ae5ad9526 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 2b09c722be87114d4c54c7f8db9a805e9e4fe988..332fc0d895cef8ee3a2c0a44ca3b446c69b91780 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 2d52fca43ebbfe0144c66cd54f2f245b9ed35f1b..5d3205e3f72046534027c385656226b8641d3399 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 1e52c52609560209fe561d545135a48014253ca5..71fcbb18924470774a22c78c0148d023ca8512e9 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 3edebf7b1f79383e73e669bae0f1f82ccc13a00c..0c94bdf11e24c88fd67d1c9b2c714b82c9faf4fe 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 d7a93edfcda4c52152ade45472d505b0885f789e..05b685558206d9bab8e2f1399d8494c644896856 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 d82986a60a27439451cd81c2dc3e7c11922d9572..e96caecfb65ba7bf247b3675622c23345c59ae88 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 672eea8ddc9dec208ae57c0fec79be637c47a3b4..6703ac14ca38a72130c11a82471bcd970dfe6a7d 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 ff8c96a0b6ac4c19ebd50f7274a2f002c2c2b3ea..7a3922dd1fcd25e7e48b0c45aa8fb9e469dac906 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 d78891bb2b86763228a2802f649b23eb45011b56..886b9687d40d2de3f1b6d2823906fde429a91bd1 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 c6566bb46a0ce06ed8b5b3214cb5aa8e96107166..6792be129a26bf65e10b8e6bf104053bd0f50e25 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 95bba054b3afbc8b337d43e5ae630be740e6f07f..7d397c85b34e97d05ccb441fcdf554a52db94606 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 bffaa770ec38b619f12d820d77ab41639dc95ab7..a1ae3f937b1f5779bd201f8d4873672332c97fe5 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 d2182d8ad03eeef7dd2f0bdc7a11712899ae483c..7cef1c75160469e4a21f45f80e079550e8026cef 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 0355971cf95b38ee93664d2cf6c71b1adc49555b..23e77a08c153af0b0774d4bdfd3468214f73adfe 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 4043f305a0579be158a097a64b171c088e949400..8285d344e211eb450465bb3809e1effbd13024a0 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 965d8e21777f2f4ac0f1933163df9f07c079c62b..5ce8c76f4d22a41674b3e78c157f14f80c6e9702 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 edd19bd7de071f1d6111bf6113f120719a1e1523..ba7b30186e77eaf48f01b10a2d55779394cb4b34 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 ca8adade01983049acc45e10540e6f1f114f68de..9d22dba0373429f4f24473d65235203e144b338e 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 31f6f37815537fe26e224b231a8e8512e9fb6a6a..3641b0e71c169aa2a2de170cfc2d7d704bc2233a 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 1ef459421a97e80768ff7423753b82e39af31d6e..1e65797153526d45b1acd9d0aeb71a717b89e4a2 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 2e0ee4ed3b2df3d6869489bf418a60210bc02b6e..3f54800db143e81de00787f9467a6def412c6c11 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 29934668b07f0bb5d8e00eb1d75c54b976bd1ec3..500de6bcf069e4198cd7383acb20e8959530b8c5 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 7064ebb1b672000e823da27a91c7549fd6affb0f..0b3d02a224b1c36b935162e3cd403f25083b78d5 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 85ffc5b4b69739179c6f57607cd5f94b12fb92ae..9f14492b57256ffdd4c216097b16a76166c186ce 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 41b5b6803d19e2b72e91a4bccac4d216ab062ad7..63c116b7bc7d364ab2a8eecd3949325694c6b89f 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 bdd03c8db7fe54490e4342f4e3d64af7b4b79899..51f0e458a93a0508e4eb9221f62a2e0abd395cba 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 b40c1beddd6a9f4bf6fccbb0795db2371c702d44..ee04a43844c8fb4c41e99525d711c9d21637375e 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 e67cd952d30cabe735aebfbf792146af86f33929..de460bf35c8e6427c9daf1602f2eeeee30ae0e84 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 3f5b71d530fdbe6f29ba8f2435a13a57f3e7b504..29b5c7d7d1247e51d979c9fb3e34c5d59b453540 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 821ac6c2563e8f76d189ff9ff4599f346d3e2233..d2f8fc4536e964f72f29b79e50cc31070e47d3bc 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 2e69afd0a9ec46c5d15b3f4b469e93df77ec61e8..cab4c6bdfb61af88f8714ba01e7ddca359c6d6a6 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 26d224de85942b2ab7dfba8f4f8300f8f69f2f88..210f30a1b395aed504c2d06a252692b689192225 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 e97a098f40ce53338c19b61addb8dad48fa24d3e..931028dd2fb075239b40cf14e8683a5d3308d1bd 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 2c7334bedb931a2971d4bb0d7a2cb41ffadc6a1a..1e37caa5563551ba7ad902528121d17909148ffe 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 dfcbf6849c31bee514dba58f67164090a2101246..cc008ea9ee410f103277f6dc02f6de8903f04908 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 67184271ebf94927f31a1711b82219b642017413..1cecfdbada3caa847e288b64c2cf0995de0b5be5 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 e773cdb4a08827daa6585c9dfb78aabdd1ee0115..ae8dc121c6e6eea4c12594acccfc64af51d3c7af 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 ee688c362b63b99c81e7b747d13946a8e8982a6a..6b21cd275995903be00b7df647fd36315dab890c 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 ce140b64a8cc87c4d81ae379adaacfe5c076e69c..02f9a57a2b0392428f85d77a4831cc54abf14169 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 e813ea1d55abcab54cc84554cec76e9a0348c89f..4bfa1a81a26932563008bfd0924f1dae8a988f80 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 e99f093c951bd06e84a480d786aa54127623308d..c2bec83afdd3c2e1733256f63c52758a82561e03 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 b0528e17bde83f22283921208c7af46dbd011f4a..21b00ac545fc743ac473266f838a753528b7acdb 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 0142f422f475acc15df4048e77e714dbe230dd46..300e67827b6afd2f1d6103d512edb6535d6ccf0b 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 d3e747822bf5513f1353dfec3f3459cf315417ad..fb2145b3ad6c665719564902a00f8d8ae6747de8 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 8d4a3fb999f5f39bd852442526f191b29a496372..eb5d5fc6309d20ac65e00816a54cf07ffaf1e153 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 6fe7112aab77b78f8cdf1872344b25caec8a7481..a49ebb4b81f626c0d8bb6a080bf3b8dcca546a90 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 5051dfbbe0a35246ed130a03cbd43a24bb57f4ec..ec3b4c1795ba81862b28098034c93d11efaaa97b 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 0e57481d3593b853775921a8877d4fcfb9870753..5eda780431d7020cd209c699b60e58b9244d8cdc 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 7d3a740e1671c7d5d6382d0e2f80f444410ecb51..779457135311e94e5b4178e9e3f444252359249f 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 9f606b042629fc91dae1476e754e1d0f4dba157c..08c8635c0e622f52412f76aeb393d82e0176a015 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 7518165e9355d66c5c54b2ebc0699e6d5225d8b8..c1595aa67faf5a8de6490fcdff7a8187b8fc5908 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 893d3c4e01e7f3f940fb9e77e56b2d27cf13eda6..c1594d55fb34614e67604f7b5dd4f671c1c4e9e6 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 85fb0065d1e169414b52d0ac86441d57f96f0c4b..31fe909a4b879d2a835712979c6a0a76b9460b6e 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 7f2c74a8a62bfc65116889043afdcd75e1d04ddd..18c4ee8a6b17aa7ede76fb5bd39c44cf8b429647 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 42c1328bb6fca1bc3a20647e438f7c132e6dcedf..76da6949b18295135475923e29255b410dc587f7 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 3024f1dee8413f79b0ee5db2df30bb2329b8237d..9502032a932ecf0a0775389ace56bac698f42910 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 4fa7691a11743153435032cc0518bf3de16102d7..e9d761b714d197dd1bbd3d70dca158b0cdc916ae 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 7636b501fd0237702050f200014cd065a85a602c..70313fa5f5d32fbf2e27103b08b61127bfcfa392 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 0007ff13277a25b155c48894859bbb16125ee3e0..0a00ebcf14849042ed417f5b1b5133577d752082 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 f198a72efe669e75bf3093b6aad6a139e2b55216..de305be576c5db6dd05f37a9b65d32530ccba6aa 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 b6de7d5bf5b3b125e0781d967df8d97ab9941f1c..967307441b6780cbab1e3be7128da38b821aaa31 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 cf6fc141dec1add2ab31d2111ca5e0e7d8d519ec..096cab16ad3a275c292cb7c059f79acabf158188 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 c2b28f67abb931404b9bb5fa41cf606a1f622820..04960635a0decda894718c573972b8fd5701161f 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 72c17929c080d70f744e60fb070c46879776ebe1..b32e707ebde67230f6ad10f50d6a9b2aa277d6a1 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 46dc08be62da9815a2c8540a0845e33e0449092e..72f05b92a6ab7b13e6f555dd1a65cd6d637e60d7 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 32aa446f9a1be97d5e847543b1cc64b3846c5110..2ca3f0be24c6f5bfc62d60ff4d3a35a800850de1 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 a88393b99f013e4a35a5ce3314f4ae6442eed477..ea6f2c9fd3371f0375736fe87eca5ab848a6e804 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 28eaa9bad815a428efd87409c2e69c059d3c0359..4538a8e26964d8751fb9ed33f257d1f54ff0502a 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 b34dfa8e0754c2930780cb423a09bc71c2428d20..d4d64dc8bacfb89b197eed1e5cc6f8277a89390c 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 aae7370851ec78a01e0eac870f769aaef82afd38..24f4ff9bdde06d7bf790b9d2a67fd7a4ccd9e3df 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 4f72914216fce157fc689d84d177add5ade64fcc..a1475fafe7dcb632a80a8f7eda93421fd900116c 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 da2fefbad5a3035bc3d1c7beb403ef4f8e71ac05..31a027b7c023d86b39541c26199f1202939eba87 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 44eb58e01449d22d53bf6382c8e61d0cc69b9cb9..6a5fafbb2580da3bce182fbe43e195489ec41768 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 6b70c0eaf4b4cca3be373f7ce78234ce7489bce3..ad04f9b1a77fce57430bddbfb51845b11c45d618 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 df0a2df093a0b15284b2df0ac07309c87d680540..341256afef5d5fd82e548611facaba9aefa1b023 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 9020e9d5d7d202ef14c9c2660bee33df59508901..206b00800e864397f5e6ed81167dfaae3731c067 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 similarity index 84% rename from test/cases/compile_errors/uncreachable_else_prong_err_set.zig rename to test/cases/compile_errors/unreachable_else_prong_err_set.zig index 4b0ae462d6041943387f8cbca37367e7670ed5a9..29ff47a5bf39e0295e562a7fea8a9ca61e5aa9cc 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 0842e98895787448a8c3d0bdf84297eafeabfcf5..d3b7e45f185ad785e40b7a7216602ce5740856d0 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 c52f614657854db7a8274c0a9b402b3a64c306ed..437d100c0ef1534c10fb1c08be18c381b72f5d78 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 837a6e696599224d038cfbc541db11d0619b0714..0b04e1eacb834b2ec7e0f6bcfdbe925b707d99bb 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 2e47a4fc1ed4f6adb8209060c601953eefa9973d..0dd0e60ee80c08c45c47623f25afb9943c2742c5 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 e33f48e6a54c8cbd452cee95e6f1b5a621dcfbc1..b3e83f202ad03ccdf81e9fa5df3d8e723f072801 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 e2f81d2b5f042066b47a64820c4e0273456faa65..37f5fcb01884f556472bd0d720b29445f8b846cd 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 d6f142f24a15efd190390f05e41250ef1b30c8a8..bebaffb748cc6b29ff1eaca921f6ccd224b306ae 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); } diff --git a/test/cases/compile_log.0.zig b/test/cases/compile_log.0.zig index 7ca643f5918374a769da711694edf8c8e020ba07..07b7c715511adbe0517922489c2246c9ea41b891 100644 --- a/test/cases/compile_log.0.zig +++ b/test/cases/compile_log.0.zig @@ -4,7 +4,7 @@ export fn _start() noreturn { @compileLog(b, 20, f, x); @compileLog(1000); var bruh: usize = true; - _ = bruh; + _ = .{ &f, &bruh }; unreachable; } export fn other() void { diff --git a/test/cases/compile_log.1.zig b/test/cases/compile_log.1.zig index 2b64d8f906aeb403222dd097ad45b08f6202da8a..fa3e93bfbf1e3200edeb853ebe0cde9d872efbf4 100644 --- a/test/cases/compile_log.1.zig +++ b/test/cases/compile_log.1.zig @@ -1,6 +1,7 @@ export fn _start() noreturn { const b = true; var f: u32 = 1; + _ = &f; @compileLog(b, 20, f, x); @compileLog(1000); unreachable; diff --git a/test/cases/comptime_var.0.zig b/test/cases/comptime_var.0.zig index 14fb074c76ab2c079565e96a6b2847640115a3fb..7044e0fb2a935f6b2c8b3cb79688a3f517974825 100644 --- a/test/cases/comptime_var.0.zig +++ b/test/cases/comptime_var.0.zig @@ -1,5 +1,6 @@ pub fn main() void { var a: u32 = 0; + _ = &a; comptime var b: u32 = 0; if (a == 0) b = 3; } @@ -9,5 +10,5 @@ pub fn main() void { // target=x86_64-macos,x86_64-linux // link_libc=true // -// :4:19: error: store to comptime variable depends on runtime condition -// :4:11: note: runtime condition here +// :5:19: error: store to comptime variable depends on runtime condition +// :5:11: note: runtime condition here diff --git a/test/cases/comptime_var.1.zig b/test/cases/comptime_var.1.zig index 054d69250c38b5c2faba39e67db1b203d7b6eec7..d914ab45b54fe4340402eee07287fb08f476fcdd 100644 --- a/test/cases/comptime_var.1.zig +++ b/test/cases/comptime_var.1.zig @@ -1,5 +1,6 @@ pub fn main() void { var a: u32 = 0; + _ = &a; comptime var b: u32 = 0; switch (a) { 0 => {}, diff --git a/test/cases/comptime_var.5.zig b/test/cases/comptime_var.5.zig index 76a06f3d4b5931e8fd23271dcc593e07ff414a7f..bd3d878fa7e6ad1993b181c259393f1f7096fb71 100644 --- a/test/cases/comptime_var.5.zig +++ b/test/cases/comptime_var.5.zig @@ -1,5 +1,6 @@ pub fn main() void { var a: u32 = 0; + _ = &a; if (a == 0) { comptime var b: u32 = 0; b = 1; diff --git a/test/cases/conditions.5.zig b/test/cases/conditions.5.zig index 2d5ba338c7aea87a6f059d6f119bd1e0f7641793..9b2dfdb58e26689fa4966cd9aaffb67320c37314 100644 --- a/test/cases/conditions.5.zig +++ b/test/cases/conditions.5.zig @@ -10,6 +10,7 @@ fn assert(ok: bool) void { fn foo(ok: bool) i32 { const val: i32 = blk: { var x: i32 = 1; + _ = &x; if (!ok) break :blk x + @as(i32, 9); break :blk x + @as(i32, 19); }; diff --git a/test/cases/decl_value_arena.zig b/test/cases/decl_value_arena.zig index 9c7c12903b292695cf6f606a28176dfc7b94dcd9..42ed310b6f9d5f121a42b2d41cac30ccc6c31649 100644 --- a/test/cases/decl_value_arena.zig +++ b/test/cases/decl_value_arena.zig @@ -14,7 +14,7 @@ pub const Connection = struct { pub fn main() void { var conn: Connection = undefined; - _ = conn; + _ = &conn; } // run diff --git a/test/cases/enum_values.0.zig b/test/cases/enum_values.0.zig index 71c3e3521abe202f44ae8e2222a54a79cacabbf0..3e4ee609251af90712ead0f7d917f3801e37f982 100644 --- a/test/cases/enum_values.0.zig +++ b/test/cases/enum_values.0.zig @@ -4,8 +4,8 @@ pub fn main() void { var number1 = Number.One; var number2: Number = .Two; if (false) { - number1; - number2; + &number1; + &number2; } const number3: Number = @enumFromInt(2); if (@intFromEnum(number3) != 2) { diff --git a/test/cases/enum_values.1.zig b/test/cases/enum_values.1.zig index 934106dd7959d66fbb00f13d93789c9204379fd6..7679a8736181df789c317d34a0872f5705f521cd 100644 --- a/test/cases/enum_values.1.zig +++ b/test/cases/enum_values.1.zig @@ -2,7 +2,9 @@ const Number = enum { One, Two, Three }; pub fn main() void { var number1 = Number.One; + _ = &number1; var number2: Number = .Two; + _ = &number2; const number3: Number = @enumFromInt(2); assert(number1 != number2); assert(number2 != number3); @@ -10,6 +12,7 @@ pub fn main() void { assert(@intFromEnum(number2) == 1); assert(@intFromEnum(number3) == 2); var x: Number = .Two; + _ = &x; assert(number2 == x); return; diff --git a/test/cases/error_in_nested_declaration.zig b/test/cases/error_in_nested_declaration.zig index 20afacfb681c266c0bf0ce2693f3bbf9b99f2e39..c2dd7b9fa888860b80e1999c2e3279366013c8a9 100644 --- a/test/cases/error_in_nested_declaration.zig +++ b/test/cases/error_in_nested_declaration.zig @@ -19,7 +19,7 @@ const S2 = struct { pub export fn entry2() void { var s: S2 = undefined; - _ = s; + _ = &s; } // error diff --git a/test/cases/error_unions.0.zig b/test/cases/error_unions.0.zig index 355698e4b66b7e43c16c1c0b4c92b9161f1c9a11..89646e468105c10f79eb56ac585a943d9e59ec56 100644 --- a/test/cases/error_unions.0.zig +++ b/test/cases/error_unions.0.zig @@ -1,6 +1,7 @@ pub fn main() void { var e1 = error.Foo; var e2 = error.Bar; + _ = .{ &e1, &e2 }; assert(e1 != e2); assert(e1 == error.Foo); assert(e2 == error.Bar); diff --git a/test/cases/error_unions.1.zig b/test/cases/error_unions.1.zig index 526e1a110d4c74415d9c3036ae99b828efd133c7..792bc88412c62132e920699501abbb7d741747ad 100644 --- a/test/cases/error_unions.1.zig +++ b/test/cases/error_unions.1.zig @@ -1,5 +1,6 @@ pub fn main() u8 { var e: anyerror!u8 = 5; + _ = &e; const i = e catch 10; return i - 5; } diff --git a/test/cases/error_unions.2.zig b/test/cases/error_unions.2.zig index b66c7d78c073bb0ef4cd4365fed5873fb66901af..cc61263aa7d6d5e8ff564c79941e33af2af67afa 100644 --- a/test/cases/error_unions.2.zig +++ b/test/cases/error_unions.2.zig @@ -1,5 +1,6 @@ pub fn main() u8 { var e: anyerror!u8 = error.Foo; + _ = &e; const i = e catch 10; return i - 10; } diff --git a/test/cases/error_unions.3.zig b/test/cases/error_unions.3.zig index d37f826272dc32f990891837ed1a1a202a81fbd4..2661e3bc1921af305a003be488636bee1c480ed4 100644 --- a/test/cases/error_unions.3.zig +++ b/test/cases/error_unions.3.zig @@ -1,5 +1,6 @@ pub fn main() u8 { var e = foo(); + _ = &e; const i = e catch 69; return i - 5; } diff --git a/test/cases/error_unions.4.zig b/test/cases/error_unions.4.zig index bbc8dd34da3b637871424a45678b5f5c5f67620c..d6d121e1d6c29491f554f79b65567e3db8b3db74 100644 --- a/test/cases/error_unions.4.zig +++ b/test/cases/error_unions.4.zig @@ -1,5 +1,6 @@ pub fn main() u8 { var e = foo(); + _ = &e; const i = e catch 69; return i - 69; } diff --git a/test/cases/error_unions.5.zig b/test/cases/error_unions.5.zig index 96d52d1de1f3a3eb31741f0bfdd8f8791f92e232..0204cef9265b752da7d52ace190c9762f2e91b3f 100644 --- a/test/cases/error_unions.5.zig +++ b/test/cases/error_unions.5.zig @@ -1,5 +1,6 @@ pub fn main() u8 { var e = foo(); + _ = &e; const i = e catch 42; return i - 42; } diff --git a/test/cases/f32_passed_to_variadic_fn.zig b/test/cases/f32_passed_to_variadic_fn.zig index 16f95fdfe88ed8343b0522bdb9b57eff6e9c102c..3b3e034ab26ce1188f00118c16f823fb1df56c14 100644 --- a/test/cases/f32_passed_to_variadic_fn.zig +++ b/test/cases/f32_passed_to_variadic_fn.zig @@ -2,8 +2,8 @@ extern fn printf(format: [*:0]const u8, ...) c_int; pub fn main() void { var a: f64 = 2.0; var b: f32 = 10.0; - _ = printf("f64: %f\n", a); - _ = printf("f32: %f\n", b); + _ = printf("f64: %f\n", (&a).*); + _ = printf("f32: %f\n", (&b).*); } // run diff --git a/test/cases/inner_func_accessing_outer_var.zig b/test/cases/inner_func_accessing_outer_var.zig index e30cf58ef84d54e38ecfac903a7e47437d971a68..6b774ea9be51f48c6f5bf808da0f988d663a15ae 100644 --- a/test/cases/inner_func_accessing_outer_var.zig +++ b/test/cases/inner_func_accessing_outer_var.zig @@ -1,5 +1,6 @@ pub fn f() void { var bar: bool = true; + _ = &bar; const S = struct { fn baz() bool { return bar; @@ -10,6 +11,6 @@ pub fn f() void { // error // -// :5:20: error: mutable 'bar' not accessible from here +// :6:20: error: mutable 'bar' not accessible from here // :2:9: note: declared mutable here -// :3:15: note: crosses namespace boundary here +// :4:15: note: crosses namespace boundary here diff --git a/test/cases/llvm/blocks.zig b/test/cases/llvm/blocks.zig index c64909c7fea640a33c5fcf793f6ed82fe3189ba6..31a86c96e3f791e814adc39aea931050e5ac3d24 100644 --- a/test/cases/llvm/blocks.zig +++ b/test/cases/llvm/blocks.zig @@ -5,6 +5,7 @@ fn assert(ok: bool) void { fn foo(ok: bool) i32 { const val: i32 = blk: { var x: i32 = 1; + _ = &x; if (!ok) break :blk x + 9; break :blk x + 19; }; diff --git a/test/cases/llvm/f_segment_address_space_reading_and_writing.zig b/test/cases/llvm/f_segment_address_space_reading_and_writing.zig index ddcd41bf162a319d4aa5a76de273e1c7ca68d7d9..adf0a4da4d0ce7435a08e08425b78dd6bd4db434 100644 --- a/test/cases/llvm/f_segment_address_space_reading_and_writing.zig +++ b/test/cases/llvm/f_segment_address_space_reading_and_writing.zig @@ -35,6 +35,7 @@ pub fn main() void { assert(getFs() == @intFromPtr(&test_value)); var test_ptr: *allowzero addrspace(.fs) u64 = @ptrFromInt(0); + _ = &test_ptr; assert(test_ptr.* == 12345); test_ptr.* = 98765; assert(test_value == 98765); diff --git a/test/cases/llvm/nested_blocks.zig b/test/cases/llvm/nested_blocks.zig index 895f7e658b61fa5c381cf6902c150fe14ee5ea75..3a951f9361916bd5a646b873c902acbb3b6aa499 100644 --- a/test/cases/llvm/nested_blocks.zig +++ b/test/cases/llvm/nested_blocks.zig @@ -10,7 +10,7 @@ fn foo(ok: bool) i32 { }; break :blk val2 + 10; }; - return val; + return (&val).*; } pub fn main() void { diff --git a/test/cases/llvm/optionals.zig b/test/cases/llvm/optionals.zig index 7d52fc0f17d73b201c3aad46adf461cfe0fe5de2..110a9c511d56037225e8ec6192292875940b3bee 100644 --- a/test/cases/llvm/optionals.zig +++ b/test/cases/llvm/optionals.zig @@ -7,8 +7,10 @@ pub fn main() void { var null_val: ?i32 = null; var val1: i32 = opt_val.?; + _ = &val1; const val1_1: i32 = opt_val.?; var ptr_val1 = &(opt_val.?); + _ = &ptr_val1; const ptr_val1_1 = &(opt_val.?); var val2: i32 = null_val orelse 20; @@ -16,9 +18,11 @@ pub fn main() void { var value: i32 = 20; var ptr_val2 = &(null_val orelse value); + _ = &ptr_val2; const val3 = opt_val orelse 30; var val3_var = opt_val orelse 30; + _ = &val3_var; assert(val1 == 10); assert(val1_1 == 10); diff --git a/test/cases/llvm/simple_addition_and_subtraction.zig b/test/cases/llvm/simple_addition_and_subtraction.zig index 8a6f419f4a5c64649aa3f7618394c0264b667304..2c768d6be9d292c6bd179033a249f8ca808e078e 100644 --- a/test/cases/llvm/simple_addition_and_subtraction.zig +++ b/test/cases/llvm/simple_addition_and_subtraction.zig @@ -4,6 +4,7 @@ fn add(a: i32, b: i32) i32 { pub fn main() void { var a: i32 = -5; + _ = &a; const x = add(a, 7); var y = add(2, 0); y -= x; diff --git a/test/cases/locals.0.zig b/test/cases/locals.0.zig index f2df242792c6249864477ac4a69614f5032d6ceb..5698a66dcf498c4df55d3fa4c71566893d6e0952 100644 --- a/test/cases/locals.0.zig +++ b/test/cases/locals.0.zig @@ -3,8 +3,8 @@ pub fn main() void { var y: f32 = 42.0; var x: u8 = 10; if (false) { - y; - x; + &y; + &x / &i; } if (i != 5) unreachable; } diff --git a/test/cases/locals.1.zig b/test/cases/locals.1.zig index f7e59e1c02e8a328b3bc84e7d0f1820c92b22d22..0d0b63f6369fbdec0e01ff96773ea22531881122 100644 --- a/test/cases/locals.1.zig +++ b/test/cases/locals.1.zig @@ -1,8 +1,9 @@ pub fn main() void { var i: u8 = 5; var y: f32 = 42.0; - _ = y; + _ = &y; var x: u8 = 10; + _ = &x; foo(i, x); i = x; if (i != 10) unreachable; diff --git a/test/cases/multiplying_numbers_at_runtime_and_comptime.2.zig b/test/cases/multiplying_numbers_at_runtime_and_comptime.2.zig index 31093729baa7924f2f6461d8049ad5e2f40a2ba5..8afbc51f53fe5d3a85d341ab1e93f9407f7c0267 100644 --- a/test/cases/multiplying_numbers_at_runtime_and_comptime.2.zig +++ b/test/cases/multiplying_numbers_at_runtime_and_comptime.2.zig @@ -1,5 +1,6 @@ pub fn main() void { var x: usize = 5; + _ = &x; const y = mul(2, 3, x); if (y - 30 != 0) unreachable; } diff --git a/test/cases/only_1_function_and_it_gets_updated.1.zig b/test/cases/only_1_function_and_it_gets_updated.1.zig index 39909f93b8221f3085df667860dd63e7995f3e98..9982ca9ab813ed96d150af9870ee2402250a6738 100644 --- a/test/cases/only_1_function_and_it_gets_updated.1.zig +++ b/test/cases/only_1_function_and_it_gets_updated.1.zig @@ -1,6 +1,6 @@ pub export fn _start() noreturn { var dummy: u32 = 10; - _ = dummy; + _ = &dummy; while (true) {} } diff --git a/test/cases/optionals.0.zig b/test/cases/optionals.0.zig index e602bf1c8047d4b39bd8bb669df837b7842c3e5d..49841ac593228a17e7be03d81c903fccbc02e6e0 100644 --- a/test/cases/optionals.0.zig +++ b/test/cases/optionals.0.zig @@ -1,5 +1,6 @@ pub fn main() u8 { var x: ?u8 = 5; + _ = &x; var y: u8 = 0; if (x) |val| { y = val; diff --git a/test/cases/optionals.1.zig b/test/cases/optionals.1.zig index 26e81b890983755980f6e5701d04faec506ff49d..4bba10fc368d7ef8c65b5c10af069663cf2ccc31 100644 --- a/test/cases/optionals.1.zig +++ b/test/cases/optionals.1.zig @@ -1,5 +1,6 @@ pub fn main() u8 { var x: ?u8 = null; + _ = &x; var y: u8 = 0; if (x) |val| { y = val; diff --git a/test/cases/optionals.2.zig b/test/cases/optionals.2.zig index b610c6d2e9669ccbbe921cce11695c0200e2ba25..0464db35422bd67ac8a70392aa16608ed7dfc2bc 100644 --- a/test/cases/optionals.2.zig +++ b/test/cases/optionals.2.zig @@ -1,5 +1,6 @@ pub fn main() u8 { var x: ?u8 = 5; + _ = &x; return x.? - 5; } diff --git a/test/cases/optionals.3.zig b/test/cases/optionals.3.zig index d513c102827858be70c41f43bda1f6698fad19ed..849914fbb5c8cdfe6517d0286198b22ed5201094 100644 --- a/test/cases/optionals.3.zig +++ b/test/cases/optionals.3.zig @@ -1,6 +1,7 @@ pub fn main() u8 { var x: u8 = 5; var y: ?u8 = x; + _ = .{ &x, &y }; return y.? - 5; } diff --git a/test/cases/runtime_bitwise_and.zig b/test/cases/runtime_bitwise_and.zig index 3ba3d3124cc400d5ccd309f392c3fd2c593732e3..3e62c5346b00c1a7f2c782d8b3739f2a997033f4 100644 --- a/test/cases/runtime_bitwise_and.zig +++ b/test/cases/runtime_bitwise_and.zig @@ -7,6 +7,7 @@ pub fn main() void { var m2: u32 = 0b0000; assert(m1 & 0b1010 == 0b1010); assert(m2 & 0b1010 == 0b0000); + _ = .{ &i, &j, &m1, &m2 }; } fn assert(b: bool) void { if (!b) unreachable; diff --git a/test/cases/runtime_bitwise_or.zig b/test/cases/runtime_bitwise_or.zig index b97c2acf0228a3314eccb4ab859eee3a7dc2d77b..0cb702923719d2d8209d31953d41c65773813ed1 100644 --- a/test/cases/runtime_bitwise_or.zig +++ b/test/cases/runtime_bitwise_or.zig @@ -7,6 +7,7 @@ pub fn main() void { var m2: u32 = 0b0000; assert(m1 | 0b1010 == 0b1111); assert(m2 | 0b1010 == 0b1010); + _ = .{ &i, &j, &m1, &m2 }; } fn assert(b: bool) void { if (!b) unreachable; diff --git a/test/cases/safety/@asyncCall with too small a frame.zig b/test/cases/safety/@asyncCall with too small a frame.zig index 1a315930584ce83570bde72d2039b168935c20e4..3d7cdb3b1d02ff5dc53c829f51acbd2db2b40d41 100644 --- a/test/cases/safety/@asyncCall with too small a frame.zig +++ b/test/cases/safety/@asyncCall with too small a frame.zig @@ -13,8 +13,9 @@ pub fn main() !void { } var bytes: [1]u8 align(16) = undefined; var ptr = other; + _ = &ptr; var frame = @asyncCall(&bytes, {}, ptr, .{}); - _ = frame; + _ = &frame; return error.TestFailed; } fn other() callconv(.Async) void { diff --git a/test/cases/safety/@intCast to u0.zig b/test/cases/safety/@intCast to u0.zig index 8c9f76e2aa00f72b0dd75c1f578a7cbe7cd64bf3..a33da87f0fa8a0891b395be27ee7ac3c12fcec70 100644 --- a/test/cases/safety/@intCast to u0.zig +++ b/test/cases/safety/@intCast to u0.zig @@ -14,7 +14,7 @@ pub fn main() !void { } fn bar(one: u1, not_zero: i32) void { - var x = one << @as(u0, @intCast(not_zero)); + const x = one << @intCast(not_zero); _ = x; } // run diff --git a/test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig b/test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig index 41cff07e329c1375c5df0fb8fa3a74be6724c938..f8c448855e3422d93fd5686c414ee928231896fa 100644 --- a/test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig +++ b/test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig @@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { var zero: usize = 0; - var b: *u8 = @ptrFromInt(zero); + _ = &zero; + const b: *u8 = @ptrFromInt(zero); _ = b; return error.TestFailed; } diff --git a/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig b/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig index 92e98d4777d3982f1d93f2b501a7128656ec356b..c9ae253df7bafa45aea06a4f4985245d6ab5dc27 100644 --- a/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig +++ b/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig @@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { var zero: usize = 0; - var b: *i32 = @ptrFromInt(zero); + _ = &zero; + const b: *i32 = @ptrFromInt(zero); _ = b; return error.TestFailed; } diff --git a/test/cases/safety/@ptrFromInt with misaligned address.zig b/test/cases/safety/@ptrFromInt with misaligned address.zig index afb8aa7eb85375ddbde887aa2d5095ff8b61407f..3952ab9baa2f8efbdebb037abcea2ff58c440968 100644 --- a/test/cases/safety/@ptrFromInt with misaligned address.zig +++ b/test/cases/safety/@ptrFromInt with misaligned address.zig @@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { var x: usize = 5; - var y: [*]align(4) u8 = @ptrFromInt(x); + _ = &x; + const y: [*]align(4) u8 = @ptrFromInt(x); _ = y; return error.TestFailed; } diff --git a/test/cases/safety/@tagName on corrupted enum value.zig b/test/cases/safety/@tagName on corrupted enum value.zig index a541771df15727135d080ab3d2457d7fc0d0cc1d..e23cd1fcf6929a4b771c1cd271f3901ca31740b6 100644 --- a/test/cases/safety/@tagName on corrupted enum value.zig +++ b/test/cases/safety/@tagName on corrupted enum value.zig @@ -16,7 +16,7 @@ const E = enum(u32) { pub fn main() !void { var e: E = undefined; @memset(@as([*]u8, @ptrCast(&e))[0..@sizeOf(E)], 0x55); - var n = @tagName(e); + const n = @tagName(e); _ = n; return error.TestFailed; } diff --git a/test/cases/safety/@tagName on corrupted union value.zig b/test/cases/safety/@tagName on corrupted union value.zig index dd3d9bd3bffd2c5ad9eebfd89208b00d01a12f2c..f742834d15209bdd658370850674e86df9a57551 100644 --- a/test/cases/safety/@tagName on corrupted union value.zig +++ b/test/cases/safety/@tagName on corrupted union value.zig @@ -16,8 +16,8 @@ const U = union(enum(u32)) { pub fn main() !void { var u: U = undefined; @memset(@as([*]u8, @ptrCast(&u))[0..@sizeOf(U)], 0x55); - var t: @typeInfo(U).Union.tag_type.? = u; - var n = @tagName(t); + const t: @typeInfo(U).Union.tag_type.? = u; + const n = @tagName(t); _ = n; return error.TestFailed; } diff --git a/test/cases/safety/array slice sentinel mismatch non-scalar.zig b/test/cases/safety/array slice sentinel mismatch non-scalar.zig index 6ea136bc0140c0e926f26feca0b61806064b385b..5523970168e4d5fb13166ecda0e0e8d5f9e85fbd 100644 --- a/test/cases/safety/array slice sentinel mismatch non-scalar.zig +++ b/test/cases/safety/array slice sentinel mismatch non-scalar.zig @@ -11,7 +11,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { const S = struct { a: u32 }; var arr = [_]S{ .{ .a = 1 }, .{ .a = 2 } }; - var s = arr[0..1 :.{ .a = 1 }]; + const s = arr[0..1 :.{ .a = 1 }]; _ = s; return error.TestFailed; } diff --git a/test/cases/safety/exact division failure - vectors.zig b/test/cases/safety/exact division failure - vectors.zig index cc8c01db9e3b880d342894054b4468f3967ba175..c5df2b276f175ddc9f8bfa9875eb4425263d7821 100644 --- a/test/cases/safety/exact division failure - vectors.zig +++ b/test/cases/safety/exact division failure - vectors.zig @@ -9,8 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { - var a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 }; - var b: @Vector(4, i32) = [4]i32{ 111, 222, 333, 441 }; + const a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 }; + const b: @Vector(4, i32) = [4]i32{ 111, 222, 333, 441 }; const x = divExact(a, b); _ = x; return error.TestFailed; diff --git a/test/cases/safety/for_len_mismatch.zig b/test/cases/safety/for_len_mismatch.zig index 871e203f61c5d23cb2207516a5b6a7f529403133..ee21b947d7eeb22a8072ca1360e5a9b5659a3a3e 100644 --- a/test/cases/safety/for_len_mismatch.zig +++ b/test/cases/safety/for_len_mismatch.zig @@ -12,6 +12,7 @@ pub fn main() !void { var runtime_i: usize = 1; var j: usize = 3; var slice = "too long"; + _ = .{ &runtime_i, &j, &slice }; for (runtime_i..j, slice) |a, b| { _ = a; _ = b; diff --git a/test/cases/safety/for_len_mismatch_three.zig b/test/cases/safety/for_len_mismatch_three.zig index 0cfcddbfeecc9670cc1aea1e94dabd234306ffb3..70f854def51f8152e7255dcb034b1a8a322c5e50 100644 --- a/test/cases/safety/for_len_mismatch_three.zig +++ b/test/cases/safety/for_len_mismatch_three.zig @@ -10,6 +10,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var slice: []const u8 = "hello"; + _ = &slice; for (10..20, slice, 20..30) |a, b, c| { _ = a; _ = b; diff --git a/test/cases/safety/integer division by zero - vectors.zig b/test/cases/safety/integer division by zero - vectors.zig index a376b66fdb85e18f387e34890bcf539d8934e34e..6e2af616b9090d73ecd6b12885ad73d48017ac80 100644 --- a/test/cases/safety/integer division by zero - vectors.zig +++ b/test/cases/safety/integer division by zero - vectors.zig @@ -8,8 +8,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi std.process.exit(1); } pub fn main() !void { - var a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 }; - var b: @Vector(4, i32) = [4]i32{ 111, 0, 333, 444 }; + const a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 }; + const b: @Vector(4, i32) = [4]i32{ 111, 0, 333, 444 }; const x = div0(a, b); _ = x; return error.TestFailed; diff --git a/test/cases/safety/memcpy_alias.zig b/test/cases/safety/memcpy_alias.zig index cf2da08f0cd006586b18f48a382b4e6239fbb588..d87a7bf6aa4df1a6f7cb622e953d8bcf1a693c93 100644 --- a/test/cases/safety/memcpy_alias.zig +++ b/test/cases/safety/memcpy_alias.zig @@ -10,6 +10,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var buffer = [2]u8{ 1, 2 } ** 5; var len: usize = 5; + _ = &len; @memcpy(buffer[0..len], buffer[4 .. 4 + len]); } // run diff --git a/test/cases/safety/memcpy_len_mismatch.zig b/test/cases/safety/memcpy_len_mismatch.zig index b5cb887c31d7fb58a1f06a62b27c13b74c993b30..6ca36abccbbf5a3f7818b3483a4e156cf6a9c8ac 100644 --- a/test/cases/safety/memcpy_len_mismatch.zig +++ b/test/cases/safety/memcpy_len_mismatch.zig @@ -10,6 +10,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var buffer = [2]u8{ 1, 2 } ** 5; var len: usize = 5; + _ = &len; @memcpy(buffer[0..len], buffer[len .. len + 4]); } // run diff --git a/test/cases/safety/memset_slice_undefined_bytes.zig b/test/cases/safety/memset_slice_undefined_bytes.zig index 70acc5fa6522369775da8b399486b7c56d78649b..4214b5db4b761a629a34bbddbee79957123d8a9c 100644 --- a/test/cases/safety/memset_slice_undefined_bytes.zig +++ b/test/cases/safety/memset_slice_undefined_bytes.zig @@ -10,6 +10,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var buffer = [6]u8{ 1, 2, 3, 4, 5, 6 }; var len = buffer.len; + _ = &len; @memset(buffer[0..len], undefined); var x: u8 = buffer[1]; x += buffer[2]; diff --git a/test/cases/safety/memset_slice_undefined_large.zig b/test/cases/safety/memset_slice_undefined_large.zig index 66298993c091a0aafd5e69dae60c89b9ddb7055a..d1f4f651d33b7deec8fed32b8816d376ff723aaa 100644 --- a/test/cases/safety/memset_slice_undefined_large.zig +++ b/test/cases/safety/memset_slice_undefined_large.zig @@ -10,6 +10,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var buffer = [6]i32{ 1, 2, 3, 4, 5, 6 }; var len = buffer.len; + _ = &len; @memset(buffer[0..len], undefined); var x: i32 = buffer[1]; x += buffer[2]; diff --git a/test/cases/safety/optional unwrap operator on C pointer.zig b/test/cases/safety/optional unwrap operator on C pointer.zig index a4352192337cfaef773a0320cfd163a3bdbfb471..bd3313265a5012a5d37b6e7da55bbbfa9cdaccc9 100644 --- a/test/cases/safety/optional unwrap operator on C pointer.zig +++ b/test/cases/safety/optional unwrap operator on C pointer.zig @@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { var ptr: [*c]i32 = null; - var b = ptr.?; + _ = &ptr; + const b = ptr.?; _ = b; return error.TestFailed; } diff --git a/test/cases/safety/optional unwrap operator on null pointer.zig b/test/cases/safety/optional unwrap operator on null pointer.zig index 5749be9e36bafde0c4188a6464dd2da7449695cf..9dda4d0a9e07f7e717e0e954f7227f4c17a67675 100644 --- a/test/cases/safety/optional unwrap operator on null pointer.zig +++ b/test/cases/safety/optional unwrap operator on null pointer.zig @@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { var ptr: ?*i32 = null; - var b = ptr.?; + _ = &ptr; + const b = ptr.?; _ = b; return error.TestFailed; } diff --git a/test/cases/safety/pointer casting null to non-optional pointer.zig b/test/cases/safety/pointer casting null to non-optional pointer.zig index 6ec47f52fb76032f267c254df19595c41da65d77..fdf8dc17ce27db05de31bc32e1984ffeee8e41de 100644 --- a/test/cases/safety/pointer casting null to non-optional pointer.zig +++ b/test/cases/safety/pointer casting null to non-optional pointer.zig @@ -10,7 +10,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var c_ptr: [*c]u8 = 0; - var zig_ptr: *u8 = c_ptr; + _ = &c_ptr; + const zig_ptr: *u8 = c_ptr; _ = zig_ptr; return error.TestFailed; } diff --git a/test/cases/safety/resuming a non-suspended function which has been suspended and resumed.zig b/test/cases/safety/resuming a non-suspended function which has been suspended and resumed.zig index e03974f08d25692fbe523d3780bd8af6a8bb96e4..8970e0651629d59f5d5aa20f3e10715d062a622b 100644 --- a/test/cases/safety/resuming a non-suspended function which has been suspended and resumed.zig +++ b/test/cases/safety/resuming a non-suspended function which has been suspended and resumed.zig @@ -10,7 +10,7 @@ fn foo() void { global_frame = @frame(); } var f = async bar(@frame()); - _ = f; + _ = &f; std.os.exit(1); } diff --git a/test/cases/safety/resuming a non-suspended function which never been suspended.zig b/test/cases/safety/resuming a non-suspended function which never been suspended.zig index fb3f5aa307f0ca1b085ae08ff928e2c73a15e493..420da72a5c0d3b60794e56f4015073733b55bbdd 100644 --- a/test/cases/safety/resuming a non-suspended function which never been suspended.zig +++ b/test/cases/safety/resuming a non-suspended function which never been suspended.zig @@ -7,7 +7,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } fn foo() void { var f = async bar(@frame()); - _ = f; + _ = &f; std.os.exit(1); } diff --git a/test/cases/safety/shift left by huge amount.zig b/test/cases/safety/shift left by huge amount.zig index d89f7d4ebef9e0ee5f065895d3ba4f6d7d53ae7e..a038c0ee4442be2c969108f46c3030c0b48fe262 100644 --- a/test/cases/safety/shift left by huge amount.zig +++ b/test/cases/safety/shift left by huge amount.zig @@ -11,7 +11,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var x: u24 = 42; var y: u5 = 24; - var z = x >> y; + _ = .{ &x, &y }; + const z = x >> y; _ = z; return error.TestFailed; } diff --git a/test/cases/safety/shift right by huge amount.zig b/test/cases/safety/shift right by huge amount.zig index 8107bc17380bb856b73e6e70d7184b4781bfd555..ced81d948d48d2b801a4306a61f83efdb579f3b8 100644 --- a/test/cases/safety/shift right by huge amount.zig +++ b/test/cases/safety/shift right by huge amount.zig @@ -11,7 +11,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var x: u24 = 42; var y: u5 = 24; - var z = x << y; + _ = .{ &x, &y }; + const z = x << y; _ = z; return error.TestFailed; } diff --git a/test/cases/safety/signed integer division overflow - vectors.zig b/test/cases/safety/signed integer division overflow - vectors.zig index 53e72e90feefddf9f2f0381ff74eaa37b6aea5d8..6346d9f1a1dd363e755d1efe50fd1d80fa507eeb 100644 --- a/test/cases/safety/signed integer division overflow - vectors.zig +++ b/test/cases/safety/signed integer division overflow - vectors.zig @@ -9,8 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { - var a: @Vector(4, i16) = [_]i16{ 1, 2, -32768, 4 }; - var b: @Vector(4, i16) = [_]i16{ 1, 2, -1, 4 }; + const a: @Vector(4, i16) = [_]i16{ 1, 2, -32768, 4 }; + const b: @Vector(4, i16) = [_]i16{ 1, 2, -1, 4 }; const x = div(a, b); if (x[2] == 32767) return error.Whatever; return error.TestFailed; diff --git a/test/cases/safety/signed integer not fitting in cast to unsigned integer - widening.zig b/test/cases/safety/signed integer not fitting in cast to unsigned integer - widening.zig index 9052913691de9fe470463d75e92ead994b028ecd..87c812eddc20f28d255dd99eeeb7de2a032c5072 100644 --- a/test/cases/safety/signed integer not fitting in cast to unsigned integer - widening.zig +++ b/test/cases/safety/signed integer not fitting in cast to unsigned integer - widening.zig @@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { var value: c_short = -1; - var casted: u32 = @intCast(value); + _ = &value; + const casted: u32 = @intCast(value); _ = casted; return error.TestFailed; } diff --git a/test/cases/safety/signed-unsigned vector cast.zig b/test/cases/safety/signed-unsigned vector cast.zig index 71d0690b5d7662c58f7f9c08c55a80911fc235ea..2e3b4d25d52d3023a94093b4b755f3505d24748a 100644 --- a/test/cases/safety/signed-unsigned vector cast.zig +++ b/test/cases/safety/signed-unsigned vector cast.zig @@ -10,7 +10,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var x: @Vector(4, i32) = @splat(-2147483647); - var y: @Vector(4, u32) = @intCast(x); + _ = &x; + const y: @Vector(4, u32) = @intCast(x); _ = y; return error.TestFailed; } diff --git a/test/cases/safety/slice start index greater than end index.zig b/test/cases/safety/slice start index greater than end index.zig index ef0485ae6015d1c73184702aa86dbcfa419c0f5c..83d489ab5699f235dce5401e7491e25ae149a14d 100644 --- a/test/cases/safety/slice start index greater than end index.zig +++ b/test/cases/safety/slice start index greater than end index.zig @@ -11,6 +11,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var a: usize = 1; var b: usize = 10; + _ = .{ &a, &b }; var buf: [16]u8 = undefined; const slice = buf[b..a]; diff --git a/test/cases/safety/slice with sentinel out of bounds - runtime len.zig b/test/cases/safety/slice with sentinel out of bounds - runtime len.zig index 2f27bebd55c456a75cc040a4f2bf00d4193f9ae3..abb3cc42f092900af57e654016f31918c215407e 100644 --- a/test/cases/safety/slice with sentinel out of bounds - runtime len.zig +++ b/test/cases/safety/slice with sentinel out of bounds - runtime len.zig @@ -12,6 +12,7 @@ pub fn main() !void { var buf = [4]u8{ 'a', 'b', 'c', 0 }; const input: []u8 = &buf; var len: usize = 4; + _ = &len; const slice = input[0..len :0]; _ = slice; return error.TestFailed; diff --git a/test/cases/safety/slicing null C pointer - runtime len.zig b/test/cases/safety/slicing null C pointer - runtime len.zig index eda9de20d29b4d42aa72a3093ae7ec0dc6bec92b..dd73a5011205eb927e6cab8436b503e85714c43c 100644 --- a/test/cases/safety/slicing null C pointer - runtime len.zig +++ b/test/cases/safety/slicing null C pointer - runtime len.zig @@ -11,7 +11,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var ptr: [*c]const u32 = null; var len: usize = 3; - var slice = ptr[0..len]; + _ = &len; + const slice = ptr[0..len]; _ = slice; return error.TestFailed; } diff --git a/test/cases/safety/slicing null C pointer.zig b/test/cases/safety/slicing null C pointer.zig index 6ef049c6a1cc7cd3fd91b2466fe11c07a295743e..862f2dcfdba6c8a2c0a867c4192d5d5e88974839 100644 --- a/test/cases/safety/slicing null C pointer.zig +++ b/test/cases/safety/slicing null C pointer.zig @@ -10,7 +10,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var ptr: [*c]const u32 = null; - var slice = ptr[0..3]; + _ = &ptr; + const slice = ptr[0..3]; _ = slice; return error.TestFailed; } diff --git a/test/cases/safety/truncating vector cast.zig b/test/cases/safety/truncating vector cast.zig index ec56953730a666c95419168331ff44931452c8b3..ae76d4dec125d709752551a5013f1aaeecefb233 100644 --- a/test/cases/safety/truncating vector cast.zig +++ b/test/cases/safety/truncating vector cast.zig @@ -10,7 +10,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var x: @Vector(4, u32) = @splat(0xdeadbeef); - var y: @Vector(4, u16) = @intCast(x); + _ = &x; + const y: @Vector(4, u16) = @intCast(x); _ = y; return error.TestFailed; } diff --git a/test/cases/safety/unsigned integer not fitting in cast to signed integer - same bit count.zig b/test/cases/safety/unsigned integer not fitting in cast to signed integer - same bit count.zig index bd35f354226c199a5396aeb830925050cca05d69..9bd4c4200702247aaaae4e5998ed6bb5ef626f79 100644 --- a/test/cases/safety/unsigned integer not fitting in cast to signed integer - same bit count.zig +++ b/test/cases/safety/unsigned integer not fitting in cast to signed integer - same bit count.zig @@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { var value: u8 = 245; - var casted: i8 = @intCast(value); + _ = &value; + const casted: i8 = @intCast(value); _ = casted; return error.TestFailed; } diff --git a/test/cases/safety/unsigned-signed vector cast.zig b/test/cases/safety/unsigned-signed vector cast.zig index 6f42ad5aa44e37cb3ebfc595061cd03508daa828..32676f7c1cb61f5a1de619e337160ff8f345bcaa 100644 --- a/test/cases/safety/unsigned-signed vector cast.zig +++ b/test/cases/safety/unsigned-signed vector cast.zig @@ -10,7 +10,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi pub fn main() !void { var x: @Vector(4, u32) = @splat(0x80000000); - var y: @Vector(4, i32) = @intCast(x); + _ = &x; + const y: @Vector(4, i32) = @intCast(x); _ = y; return error.TestFailed; } diff --git a/test/cases/safety/vector integer addition overflow.zig b/test/cases/safety/vector integer addition overflow.zig index c553b4618937a083c83c3f1008481f039e4bb7c1..21c26eeb4e477673c751cce3bb477e22ac57ef12 100644 --- a/test/cases/safety/vector integer addition overflow.zig +++ b/test/cases/safety/vector integer addition overflow.zig @@ -8,8 +8,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi std.process.exit(1); } pub fn main() !void { - var a: @Vector(4, i32) = [_]i32{ 1, 2, 2147483643, 4 }; - var b: @Vector(4, i32) = [_]i32{ 5, 6, 7, 8 }; + const a: @Vector(4, i32) = [_]i32{ 1, 2, 2147483643, 4 }; + const b: @Vector(4, i32) = [_]i32{ 5, 6, 7, 8 }; const x = add(a, b); _ = x; return error.TestFailed; diff --git a/test/cases/safety/vector integer multiplication overflow.zig b/test/cases/safety/vector integer multiplication overflow.zig index 4549f7c3e3578243d89bb9bb77b841afbe004933..8678eccec6fecb65087e062dc04b3d64c997b209 100644 --- a/test/cases/safety/vector integer multiplication overflow.zig +++ b/test/cases/safety/vector integer multiplication overflow.zig @@ -8,8 +8,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi std.process.exit(1); } pub fn main() !void { - var a: @Vector(4, u8) = [_]u8{ 1, 2, 200, 4 }; - var b: @Vector(4, u8) = [_]u8{ 5, 6, 2, 8 }; + const a: @Vector(4, u8) = [_]u8{ 1, 2, 200, 4 }; + const b: @Vector(4, u8) = [_]u8{ 5, 6, 2, 8 }; const x = mul(b, a); _ = x; return error.TestFailed; diff --git a/test/cases/safety/vector integer negation overflow.zig b/test/cases/safety/vector integer negation overflow.zig index 8c2c160c680f96537a5097fdf8637c29e75b02c1..5f8becad177ce4cb58b0a7ec818f603a0b1c1cfd 100644 --- a/test/cases/safety/vector integer negation overflow.zig +++ b/test/cases/safety/vector integer negation overflow.zig @@ -9,6 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi } pub fn main() !void { var a: @Vector(4, i16) = [_]i16{ 1, -32768, 200, 4 }; + _ = &a; const x = neg(a); _ = x; return error.TestFailed; diff --git a/test/cases/safety/vector integer subtraction overflow.zig b/test/cases/safety/vector integer subtraction overflow.zig index bc475d9800dcced84a54e703f20d67604539e311..82c03421210496a4ef6861f3b73790680419f64a 100644 --- a/test/cases/safety/vector integer subtraction overflow.zig +++ b/test/cases/safety/vector integer subtraction overflow.zig @@ -8,8 +8,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi std.process.exit(1); } pub fn main() !void { - var a: @Vector(4, u32) = [_]u32{ 1, 2, 8, 4 }; - var b: @Vector(4, u32) = [_]u32{ 5, 6, 7, 8 }; + const a: @Vector(4, u32) = [_]u32{ 1, 2, 8, 4 }; + const b: @Vector(4, u32) = [_]u32{ 5, 6, 7, 8 }; const x = sub(b, a); _ = x; return error.TestFailed; diff --git a/test/cases/structs.0.zig b/test/cases/structs.0.zig index 03a8938d9ebcf80db462bb7f98d093b97a28003d..306cf73ebfa5a5b0becfb9c082d3d0b8915b2e5f 100644 --- a/test/cases/structs.0.zig +++ b/test/cases/structs.0.zig @@ -2,6 +2,7 @@ const Example = struct { x: u8 }; pub fn main() u8 { var example: Example = .{ .x = 5 }; + _ = &example; return example.x - 5; } diff --git a/test/cases/structs.2.zig b/test/cases/structs.2.zig index b1d3cbf080accc76edd40158f4f7c5946f9c7c79..7593284301b2508deab2e23aa6927e9b93c9c182 100644 --- a/test/cases/structs.2.zig +++ b/test/cases/structs.2.zig @@ -2,6 +2,7 @@ const Example = struct { x: u8, y: u8 }; pub fn main() u8 { var example: Example = .{ .x = 5, .y = 10 }; + _ = &example; return example.y + example.x - 15; } diff --git a/test/cases/structs.3.zig b/test/cases/structs.3.zig index 558b5a1e2d7109fdf53d0c9b862718588178440e..cfc064d67103a3009b128590ec98faf924647377 100644 --- a/test/cases/structs.3.zig +++ b/test/cases/structs.3.zig @@ -3,6 +3,7 @@ const Example = struct { x: u8, y: u8 }; pub fn main() u8 { var example: Example = .{ .x = 5, .y = 10 }; var example2: Example = .{ .x = 10, .y = 20 }; + _ = &example2; example = example2; return example.y + example.x - 30; diff --git a/test/cases/switch.0.zig b/test/cases/switch.0.zig index d0c0e43f8fb8d9a5cc41e1636c41ec24e9ffce71..f4a79fa772b36dcafeda9950f36a4caf7220e471 100644 --- a/test/cases/switch.0.zig +++ b/test/cases/switch.0.zig @@ -1,6 +1,7 @@ pub fn main() u8 { var val: u8 = 1; - var a: u8 = switch (val) { + _ = &val; + const a: u8 = switch (val) { 0, 1 => 2, 2 => 3, 3 => 4, diff --git a/test/cases/switch.1.zig b/test/cases/switch.1.zig index fe503bf212e45fb1c74940b227b33221868e146e..d93e1ccb4740b74081d7470597bb3957ba09446e 100644 --- a/test/cases/switch.1.zig +++ b/test/cases/switch.1.zig @@ -1,11 +1,13 @@ pub fn main() u8 { var val: u8 = 2; + _ = &val; var a: u8 = switch (val) { 0, 1 => 2, 2 => 3, 3 => 4, else => 5, }; + _ = &a; return a - 3; } diff --git a/test/cases/switch.2.zig b/test/cases/switch.2.zig index 24f40d8402ca658e294b45e1d771b9f5697efb90..1506d822d1c1552d085fa2edf4557f5ae7e328e2 100644 --- a/test/cases/switch.2.zig +++ b/test/cases/switch.2.zig @@ -1,6 +1,7 @@ pub fn main() u8 { var val: u8 = 10; - var a: u8 = switch (val) { + _ = &val; + const a: u8 = switch (val) { 0, 1 => 2, 2 => 3, 3 => 4, diff --git a/test/cases/switch.3.zig b/test/cases/switch.3.zig index e0b55db3bff6a6809e7ce5285ccce49f40b8c82b..6225dda3ff8792677e18b4877f51407a93efade1 100644 --- a/test/cases/switch.3.zig +++ b/test/cases/switch.3.zig @@ -2,7 +2,8 @@ const MyEnum = enum { One, Two, Three }; pub fn main() u8 { var val: MyEnum = .Two; - var a: u8 = switch (val) { + _ = &val; + const a: u8 = switch (val) { .One => 1, .Two => 2, .Three => 3, diff --git a/test/cases/type_of.0.zig b/test/cases/type_of.0.zig index 5f7702ef2cbd1a788b50973ca23b662772549896..823572c8636435afcf445143c4bf8b74c75cbbb9 100644 --- a/test/cases/type_of.0.zig +++ b/test/cases/type_of.0.zig @@ -1,5 +1,6 @@ pub fn main() void { var x: usize = 0; + _ = &x; const z = @TypeOf(x, @as(u128, 5)); assert(z == u128); } diff --git a/test/cases/while_loops.1.zig b/test/cases/while_loops.1.zig index 715a813b65e66c4b1f42e4b00b397b5933b0de35..283398adbce8469da74d8a2946539c0901a26ea1 100644 --- a/test/cases/while_loops.1.zig +++ b/test/cases/while_loops.1.zig @@ -2,6 +2,7 @@ pub fn main() u8 { var i: u8 = 0; while (i < @as(u8, 10)) { var x: u8 = 1; + _ = &x; i += x; } return i - 10; diff --git a/test/cases/while_loops.2.zig b/test/cases/while_loops.2.zig index 7ad8101c3777d2a94289fedd8406693f4b7c0861..fa4f9ed26c232656f38d6125095cb54a0805da68 100644 --- a/test/cases/while_loops.2.zig +++ b/test/cases/while_loops.2.zig @@ -2,6 +2,7 @@ pub fn main() u8 { var i: u8 = 0; while (i < @as(u8, 10)) { var x: u8 = 1; + _ = &x; i += x; if (i == @as(u8, 5)) break; } -- 2.54.0