aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/behavior.zig2
-rw-r--r--test/behavior/align.zig14
-rw-r--r--test/behavior/array.zig4
-rw-r--r--test/behavior/async_fn.zig6
-rw-r--r--test/behavior/bool.zig28
-rw-r--r--test/behavior/bugs/10138.zig2
-rw-r--r--test/behavior/bugs/12142.zig2
-rw-r--r--test/behavior/bugs/12450.zig2
-rw-r--r--test/behavior/bugs/12680_other_file.zig2
-rw-r--r--test/behavior/bugs/12723.zig4
-rw-r--r--test/behavior/bugs/1741.zig2
-rw-r--r--test/behavior/bugs/9584.zig2
-rw-r--r--test/behavior/builtin_functions_returning_void_or_noreturn.zig4
-rw-r--r--test/behavior/call.zig4
-rw-r--r--test/behavior/cast.zig100
-rw-r--r--test/behavior/comptime_memory.zig40
-rw-r--r--test/behavior/enum.zig60
-rw-r--r--test/behavior/error.zig10
-rw-r--r--test/behavior/eval.zig2
-rw-r--r--test/behavior/export.zig2
-rw-r--r--test/behavior/export_self_referential_type_info.zig2
-rw-r--r--test/behavior/floatop.zig4
-rw-r--r--test/behavior/fn_in_struct_in_comptime.zig4
-rw-r--r--test/behavior/generics.zig6
-rw-r--r--test/behavior/inline_switch.zig2
-rw-r--r--test/behavior/packed-struct.zig4
-rw-r--r--test/behavior/pointers.zig32
-rw-r--r--test/behavior/ptrfromint.zig (renamed from test/behavior/inttoptr.zig)16
-rw-r--r--test/behavior/sizeof_and_typeof.zig22
-rw-r--r--test/behavior/slice.zig14
-rw-r--r--test/behavior/struct.zig2
-rw-r--r--test/behavior/switch.zig10
-rw-r--r--test/behavior/translate_c_macros.zig2
-rw-r--r--test/behavior/type.zig10
-rw-r--r--test/behavior/union.zig18
-rw-r--r--test/behavior/vector.zig2
-rw-r--r--test/c_abi/main.zig10
-rw-r--r--test/cases/assert_function.18.zig2
-rw-r--r--test/cases/assert_function.7.zig2
-rw-r--r--test/cases/assert_function.8.zig2
-rw-r--r--test/cases/compile_errors/add_overflow_in_function_evaluation.zig4
-rw-r--r--test/cases/compile_errors/addition_with_non_numbers.zig8
-rw-r--r--test/cases/compile_errors/address_of_number_literal.zig12
-rw-r--r--test/cases/compile_errors/alignment_of_enum_field_specified.zig5
-rw-r--r--test/cases/compile_errors/array_concatenation_with_wrong_type.zig4
-rw-r--r--test/cases/compile_errors/array_mult_with_number_type.zig2
-rw-r--r--test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig2
-rw-r--r--test/cases/compile_errors/assign_null_to_non-optional_pointer.zig4
-rw-r--r--test/cases/compile_errors/assign_through_constant_pointer.zig6
-rw-r--r--test/cases/compile_errors/assign_through_constant_slice.zig6
-rw-r--r--test/cases/compile_errors/assign_to_constant_field.zig6
-rw-r--r--test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig2
-rw-r--r--test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig2
-rw-r--r--test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig2
-rw-r--r--test/cases/compile_errors/bad_alignCast_at_comptime.zig2
-rw-r--r--test/cases/compile_errors/bad_import.zig4
-rw-r--r--test/cases/compile_errors/binary_not_on_number_literal.zig4
-rw-r--r--test/cases/compile_errors/bitCast_to_enum_type.zig2
-rw-r--r--test/cases/compile_errors/bogus_compile_var.zig4
-rw-r--r--test/cases/compile_errors/bogus_method_call_on_slice.zig8
-rw-r--r--test/cases/compile_errors/branch_on_undefined_value.zig4
-rw-r--r--test/cases/compile_errors/calling_function_with_naked_calling_convention.zig2
-rw-r--r--test/cases/compile_errors/calling_var_args_extern_function_passing_array_instead_of_pointer.zig8
-rw-r--r--test/cases/compile_errors/cast_unreachable.zig4
-rw-r--r--test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig4
-rw-r--r--test/cases/compile_errors/colliding_invalid_top_level_functions.zig4
-rw-r--r--test/cases/compile_errors/compileError_shows_traceback_of_references_that_caused_it.zig4
-rw-r--r--test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig8
-rw-r--r--test/cases/compile_errors/compile_time_division_by_zero.zig4
-rw-r--r--test/cases/compile_errors/comptime_call_of_function_pointer.zig2
-rw-r--r--test/cases/compile_errors/comptime_if_inside_runtime_for.zig14
-rw-r--r--test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig4
-rw-r--r--test/cases/compile_errors/container_init_with_non-type.zig4
-rw-r--r--test/cases/compile_errors/control_flow_uses_comptime_var_at_runtime.zig2
-rw-r--r--test/cases/compile_errors/dereference_an_array.zig4
-rw-r--r--test/cases/compile_errors/direct_struct_loop.zig10
-rw-r--r--test/cases/compile_errors/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig2
-rw-r--r--test/cases/compile_errors/division_by_zero.zig16
-rw-r--r--test/cases/compile_errors/duplicate-unused_labels.zig32
-rw-r--r--test/cases/compile_errors/duplicate_error_value_in_error_set.zig2
-rw-r--r--test/cases/compile_errors/duplicate_field_in_struct_value_expression.zig8
-rw-r--r--test/cases/compile_errors/embedFile_with_bogus_file.zig6
-rw-r--r--test/cases/compile_errors/empty_switch_on_an_integer.zig2
-rw-r--r--test/cases/compile_errors/enumFromInt_on_non-exhaustive_enums_checks_int_in_range.zig (renamed from test/cases/compile_errors/intToEnum_on_non-exhaustive_enums_checks_int_in_range.zig)2
-rw-r--r--test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig2
-rw-r--r--test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig5
-rw-r--r--test/cases/compile_errors/error_not_handled_in_switch.zig6
-rw-r--r--test/cases/compile_errors/error_note_for_function_parameter_incompatibility.zig14
-rw-r--r--test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig4
-rw-r--r--test/cases/compile_errors/export_function_with_comptime_parameter.zig2
-rw-r--r--test/cases/compile_errors/export_with_empty_name_string.zig2
-rw-r--r--test/cases/compile_errors/extern_function_pointer_mismatch.zig22
-rw-r--r--test/cases/compile_errors/extern_function_with_comptime_parameter.zig12
-rw-r--r--test/cases/compile_errors/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig10
-rw-r--r--test/cases/compile_errors/extern_union_field_missing_type.zig2
-rw-r--r--test/cases/compile_errors/extern_union_given_enum_tag_type.zig2
-rw-r--r--test/cases/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig9
-rw-r--r--test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig7
-rw-r--r--test/cases/compile_errors/floatToInt_comptime_safety.zig17
-rw-r--r--test/cases/compile_errors/for.zig24
-rw-r--r--test/cases/compile_errors/for_extra_capture.zig9
-rw-r--r--test/cases/compile_errors/function_alignment_non_power_of_2.zig4
-rw-r--r--test/cases/compile_errors/function_call_assigned_to_incorrect_type.zig2
-rw-r--r--test/cases/compile_errors/function_parameter_is_opaque.zig10
-rw-r--r--test/cases/compile_errors/function_with_non-extern_non-packed_enum_parameter.zig4
-rw-r--r--test/cases/compile_errors/function_with_non-extern_non-packed_struct_parameter.zig4
-rw-r--r--test/cases/compile_errors/function_with_non-extern_non-packed_union_parameter.zig4
-rw-r--r--test/cases/compile_errors/generic_function_call_assigned_to_incorrect_type.zig2
-rw-r--r--test/cases/compile_errors/generic_function_instance_with_non-constant_expression.zig12
-rw-r--r--test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig1
-rw-r--r--test/cases/compile_errors/global_variable_alignment_non_power_of_2.zig4
-rw-r--r--test/cases/compile_errors/global_variable_initializer_must_be_constant_expression.zig4
-rw-r--r--test/cases/compile_errors/ignored_assert-err-ok_return_value.zig4
-rw-r--r--test/cases/compile_errors/ignored_comptime_statement_value.zig10
-rw-r--r--test/cases/compile_errors/ignored_deferred_function_call.zig4
-rw-r--r--test/cases/compile_errors/ignored_deferred_statement_value.zig10
-rw-r--r--test/cases/compile_errors/ignored_return_value.zig4
-rw-r--r--test/cases/compile_errors/illegal_comparison_of_types.zig8
-rw-r--r--test/cases/compile_errors/implicit_cast_from_array_to_mutable_slice.zig6
-rw-r--r--test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig2
-rw-r--r--test/cases/compile_errors/implicitly_increasing_slice_alignment.zig2
-rw-r--r--test/cases/compile_errors/import_outside_package_path.zig2
-rw-r--r--test/cases/compile_errors/incorrect_return_type.zig38
-rw-r--r--test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig2
-rw-r--r--test/cases/compile_errors/indirect_struct_loop.zig22
-rw-r--r--test/cases/compile_errors/inferred_array_size_invalid_here.zig2
-rw-r--r--test/cases/compile_errors/inferring_error_set_of_function_pointer.zig4
-rw-r--r--test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig12
-rw-r--r--test/cases/compile_errors/intFromFloat_comptime_safety.zig17
-rw-r--r--test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig10
-rw-r--r--test/cases/compile_errors/intToPtr_with_misaligned_address.zig10
-rw-r--r--test/cases/compile_errors/int_to_err_global_invalid_number.zig4
-rw-r--r--test/cases/compile_errors/int_to_err_non_global_invalid_number.zig4
-rw-r--r--test/cases/compile_errors/integer_overflow_error.zig8
-rw-r--r--test/cases/compile_errors/integer_underflow_error.zig4
-rw-r--r--test/cases/compile_errors/inttoptr_non_ptr_type.zig15
-rw-r--r--test/cases/compile_errors/invalid_builtin_fn.zig5
-rw-r--r--test/cases/compile_errors/invalid_capture_type.zig10
-rw-r--r--test/cases/compile_errors/invalid_comparison_for_function_pointers.zig4
-rw-r--r--test/cases/compile_errors/invalid_field_access_in_comptime.zig7
-rw-r--r--test/cases/compile_errors/invalid_field_in_struct_value_expression.zig9
-rw-r--r--test/cases/compile_errors/invalid_float_casts.zig8
-rw-r--r--test/cases/compile_errors/invalid_int_casts.zig8
-rw-r--r--test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig6
-rw-r--r--test/cases/compile_errors/invalid_optional_type_in_extern_struct.zig4
-rw-r--r--test/cases/compile_errors/invalid_pointer_with_reify_type.zig2
-rw-r--r--test/cases/compile_errors/invalid_shift_amount_error.zig6
-rw-r--r--test/cases/compile_errors/invalid_type.zig4
-rw-r--r--test/cases/compile_errors/invalid_type_in_builtin_extern.zig2
-rw-r--r--test/cases/compile_errors/invalid_variadic_function.zig8
-rw-r--r--test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig8
-rw-r--r--test/cases/compile_errors/local_variable_redeclaration.zig2
-rw-r--r--test/cases/compile_errors/local_variable_redeclares_parameter.zig6
-rw-r--r--test/cases/compile_errors/local_variable_shadowing_global.zig2
-rw-r--r--test/cases/compile_errors/main_function_with_bogus_args_type.zig4
-rw-r--r--test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig2
-rw-r--r--test/cases/compile_errors/missing_else_clause.zig22
-rw-r--r--test/cases/compile_errors/missing_field_in_struct_value_expression.zig10
-rw-r--r--test/cases/compile_errors/missing_main_fn_in_executable.zig2
-rw-r--r--test/cases/compile_errors/missing_param_name.zig4
-rw-r--r--test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig6
-rw-r--r--test/cases/compile_errors/mul_overflow_in_function_evaluation.zig5
-rw-r--r--test/cases/compile_errors/multiple_function_definitions.zig4
-rw-r--r--test/cases/compile_errors/negation_overflow_in_function_evaluation.zig4
-rw-r--r--test/cases/compile_errors/nested_vectors.zig1
-rw-r--r--test/cases/compile_errors/noalias_on_non_pointer_param.zig20
-rw-r--r--test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig3
-rw-r--r--test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig6
-rw-r--r--test/cases/compile_errors/non-const_expression_in_struct_literal_outside_function.zig6
-rw-r--r--test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig50
-rw-r--r--test/cases/compile_errors/non-exhaustive_enum_marker_assigned_a_value.zig5
-rw-r--r--test/cases/compile_errors/non-inline_for_loop_on_a_type_that_requires_comptime.zig4
-rw-r--r--test/cases/compile_errors/non_constant_expression_in_array_size.zig12
-rw-r--r--test/cases/compile_errors/non_float_passed_to_floatToInt.zig10
-rw-r--r--test/cases/compile_errors/non_float_passed_to_intFromFloat.zig10
-rw-r--r--test/cases/compile_errors/non_int_passed_to_floatFromInt.zig10
-rw-r--r--test/cases/compile_errors/non_int_passed_to_intToFloat.zig10
-rw-r--r--test/cases/compile_errors/non_pointer_given_to_intFromPtr.zig (renamed from test/cases/compile_errors/non_pointer_given_to_ptrToInt.zig)4
-rw-r--r--test/cases/compile_errors/offsetOf-bad_field_name.zig7
-rw-r--r--test/cases/compile_errors/offsetOf-non_struct.zig2
-rw-r--r--test/cases/compile_errors/old_fn_ptr_in_extern_context.zig2
-rw-r--r--test/cases/compile_errors/out_of_int_range_comptime_float_passed_to_intFromFloat.zig10
-rw-r--r--test/cases/compile_errors/out_of_range_comptime_int_passed_to_floatToInt.zig10
-rw-r--r--test/cases/compile_errors/overflow_in_enum_value_allocation.zig4
-rw-r--r--test/cases/compile_errors/packed_union_given_enum_tag_type.zig2
-rw-r--r--test/cases/compile_errors/packed_union_with_automatic_layout_field.zig2
-rw-r--r--test/cases/compile_errors/panic_called_at_compile_time.zig4
-rw-r--r--test/cases/compile_errors/parameter_redeclaration.zig7
-rw-r--r--test/cases/compile_errors/pass_const_ptr_to_mutable_ptr_fn.zig9
-rw-r--r--test/cases/compile_errors/passing_an_under-aligned_function_pointer.zig4
-rw-r--r--test/cases/compile_errors/pointer_to_noreturn.zig4
-rw-r--r--test/cases/compile_errors/ptrFromInt_non_ptr_type.zig15
-rw-r--r--test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig10
-rw-r--r--test/cases/compile_errors/ptrToInt_0_to_non_optional_pointer.zig10
-rw-r--r--test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig8
-rw-r--r--test/cases/compile_errors/reassign_to_array_parameter.zig4
-rw-r--r--test/cases/compile_errors/reassign_to_struct_parameter.zig4
-rw-r--r--test/cases/compile_errors/redefinition_of_enums.zig4
-rw-r--r--test/cases/compile_errors/redefinition_of_global_variables.zig4
-rw-r--r--test/cases/compile_errors/redefinition_of_struct.zig4
-rw-r--r--test/cases/compile_errors/reference_to_const_data.zig6
-rw-r--r--test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig4
-rw-r--r--test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig4
-rw-r--r--test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig4
-rw-r--r--test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig2
-rw-r--r--test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig2
-rw-r--r--test/cases/compile_errors/reify_type_union_payload_is_undefined.zig4
-rw-r--r--test/cases/compile_errors/return_from_defer_expression.zig6
-rw-r--r--test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig6
-rw-r--r--test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig6
-rw-r--r--test/cases/compile_errors/runtime_to_comptime_num.zig6
-rw-r--r--test/cases/compile_errors/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig8
-rw-r--r--test/cases/compile_errors/self_referential_struct_requires_comptime.zig1
-rw-r--r--test/cases/compile_errors/setAlignStack_in_inline_function.zig3
-rw-r--r--test/cases/compile_errors/slice_passed_as_array_init_type_with_elems.zig2
-rw-r--r--test/cases/compile_errors/slice_sentinel_mismatch-2.zig4
-rw-r--r--test/cases/compile_errors/slice_used_as_extern_fn_param.zig2
-rw-r--r--test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig2
-rw-r--r--test/cases/compile_errors/specify_non-integer_enum_tag_type.zig4
-rw-r--r--test/cases/compile_errors/src_fields_runtime.zig5
-rw-r--r--test/cases/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig6
-rw-r--r--test/cases/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig6
-rw-r--r--test/cases/compile_errors/std.fmt_error_for_unused_arguments.zig2
-rw-r--r--test/cases/compile_errors/struct_type_mismatch_in_arg.zig8
-rw-r--r--test/cases/compile_errors/struct_type_returned_from_non-generic_function.zig2
-rw-r--r--test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig4
-rw-r--r--test/cases/compile_errors/struct_with_invalid_field.zig10
-rw-r--r--test/cases/compile_errors/sub_overflow_in_function_evaluation.zig4
-rw-r--r--test/cases/compile_errors/suspend_inside_suspend_block.zig3
-rw-r--r--test/cases/compile_errors/switch_expression-duplicate_enumeration_prong.zig4
-rw-r--r--test/cases/compile_errors/switch_expression-duplicate_enumeration_prong_when_else_present.zig4
-rw-r--r--test/cases/compile_errors/switch_expression-duplicate_or_overlapping_integer_value.zig16
-rw-r--r--test/cases/compile_errors/switch_expression-duplicate_type.zig4
-rw-r--r--test/cases/compile_errors/switch_expression-duplicate_type_struct_alias.zig4
-rw-r--r--test/cases/compile_errors/switch_expression-missing_enumeration_prong.zig4
-rw-r--r--test/cases/compile_errors/switch_expression-non_exhaustive_integer_prongs.zig4
-rw-r--r--test/cases/compile_errors/switch_expression-switch_on_pointer_type_with_no_else.zig4
-rw-r--r--test/cases/compile_errors/switch_expression-unreachable_else_prong_bool.zig4
-rw-r--r--test/cases/compile_errors/switch_expression-unreachable_else_prong_enum.zig6
-rw-r--r--test/cases/compile_errors/switch_expression-unreachable_else_prong_range_i8.zig4
-rw-r--r--test/cases/compile_errors/switch_expression-unreachable_else_prong_range_u8.zig4
-rw-r--r--test/cases/compile_errors/switch_expression-unreachable_else_prong_u1.zig4
-rw-r--r--test/cases/compile_errors/switch_expression-unreachable_else_prong_u2.zig4
-rw-r--r--test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig2
-rw-r--r--test/cases/compile_errors/switching_with_non-exhaustive_enums.zig2
-rw-r--r--test/cases/compile_errors/tagName_on_invalid_value_of_non-exhaustive_enum.zig4
-rw-r--r--test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig2
-rw-r--r--test/cases/compile_errors/top_level_decl_dependency_loop.zig4
-rw-r--r--test/cases/compile_errors/try_in_function_with_non_error_return_type.zig2
-rw-r--r--test/cases/compile_errors/tuple_init_edge_cases.zig42
-rw-r--r--test/cases/compile_errors/type_checking_function_pointers.zig10
-rw-r--r--test/cases/compile_errors/undeclared_identifier.zig6
-rw-r--r--test/cases/compile_errors/union_auto-enum_value_already_taken.zig2
-rw-r--r--test/cases/compile_errors/union_enum_field_does_not_match_enum.zig2
-rw-r--r--test/cases/compile_errors/unreachable_parameter.zig8
-rw-r--r--test/cases/compile_errors/unreachable_with_return.zig10
-rw-r--r--test/cases/compile_errors/while_expected_bool_got_error_union.zig4
-rw-r--r--test/cases/compile_errors/while_expected_bool_got_optional.zig4
-rw-r--r--test/cases/compile_errors/while_expected_error_union_got_bool.zig10
-rw-r--r--test/cases/compile_errors/while_expected_error_union_got_optional.zig10
-rw-r--r--test/cases/compile_errors/while_expected_optional_got_bool.zig8
-rw-r--r--test/cases/compile_errors/while_expected_optional_got_error_union.zig8
-rw-r--r--test/cases/compile_errors/write_to_const_global_variable.zig6
-rw-r--r--test/cases/compile_errors/wrong_function_type.zig18
-rw-r--r--test/cases/compile_errors/wrong_number_of_arguments.zig6
-rw-r--r--test/cases/compile_errors/wrong_number_of_arguments_for_method_fn_call.zig12
-rw-r--r--test/cases/compile_errors/wrong_size_to_an_array_literal.zig2
-rw-r--r--test/cases/compile_errors/wrong_types_given_to_export.zig6
-rw-r--r--test/cases/comptime_var.2.zig2
-rw-r--r--test/cases/comptime_var.6.zig2
-rw-r--r--test/cases/conditional_branches.0.zig2
-rw-r--r--test/cases/conditional_branches.1.zig2
-rw-r--r--test/cases/decl_value_arena.zig18
-rw-r--r--test/cases/enum_values.0.zig4
-rw-r--r--test/cases/enum_values.1.zig8
-rw-r--r--test/cases/error_in_nested_declaration.zig2
-rw-r--r--test/cases/hello_world_with_updates.2.zig2
-rw-r--r--test/cases/hello_world_with_updates.3.zig2
-rw-r--r--test/cases/hello_world_with_updates.4.zig2
-rw-r--r--test/cases/hello_world_with_updates.5.zig2
-rw-r--r--test/cases/hello_world_with_updates.6.zig2
-rw-r--r--test/cases/int_to_ptr.0.zig2
-rw-r--r--test/cases/int_to_ptr.1.zig2
-rw-r--r--test/cases/llvm/f_segment_address_space_reading_and_writing.zig8
-rw-r--r--test/cases/safety/@alignCast misaligned.zig2
-rw-r--r--test/cases/safety/@enumFromInt - no matching tag value.zig (renamed from test/cases/safety/@intToEnum - no matching tag value.zig)2
-rw-r--r--test/cases/safety/@errSetCast error not present in destination.zig4
-rw-r--r--test/cases/safety/@intFromFloat cannot fit - negative out of range.zig (renamed from test/cases/safety/@floatToInt cannot fit - negative out of range.zig)4
-rw-r--r--test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig (renamed from test/cases/safety/@floatToInt cannot fit - negative to unsigned.zig)4
-rw-r--r--test/cases/safety/@intFromFloat cannot fit - positive out of range.zig (renamed from test/cases/safety/@floatToInt cannot fit - positive out of range.zig)4
-rw-r--r--test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig (renamed from test/cases/safety/@intToPtr address zero to non-optional byte-aligned pointer.zig)2
-rw-r--r--test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig (renamed from test/cases/safety/@intToPtr address zero to non-optional pointer.zig)2
-rw-r--r--test/cases/safety/@ptrFromInt with misaligned address.zig (renamed from test/cases/safety/intToPtr with misaligned address.zig)2
-rw-r--r--test/cases/safety/bad union field access.zig2
-rw-r--r--test/cases/safety/cast []u8 to bigger slice of wrong size.zig2
-rw-r--r--test/cases/safety/cast integer to global error and no code matches.zig2
-rw-r--r--test/cases/safety/error return trace across suspend points.zig3
-rw-r--r--test/cases/safety/exact division failure - vectors.zig4
-rw-r--r--test/cases/safety/for_len_mismatch_three.zig1
-rw-r--r--test/cases/safety/integer division by zero - vectors.zig4
-rw-r--r--test/cases/safety/pointer casting to null function pointer.zig2
-rw-r--r--test/cases/safety/slice sentinel mismatch - optional pointers.zig2
-rw-r--r--test/cases/safety/zero casted to error.zig2
-rw-r--r--test/cases/unused_labels.3.zig4
-rw-r--r--test/cases/variable_shadowing.3.zig3
-rw-r--r--test/cases/variable_shadowing.4.zig3
-rw-r--r--test/cases/variable_shadowing.5.zig3
-rw-r--r--test/cases/variable_shadowing.6.zig4
-rw-r--r--test/cases/x86_64-linux/inline_assembly.2.zig2
-rw-r--r--test/cases/x86_64-linux/inline_assembly.3.zig2
-rw-r--r--test/cbe.zig30
-rw-r--r--test/compare_output.zig4
-rw-r--r--test/gen_h.zig2
-rw-r--r--test/link/common_symbols_alignment/main.zig4
-rw-r--r--test/standalone/pie/main.zig2
-rw-r--r--test/translate_c.zig92
316 files changed, 1258 insertions, 943 deletions
diff --git a/test/behavior.zig b/test/behavior.zig
index 017b5b4824..6e9435c49e 100644
--- a/test/behavior.zig
+++ b/test/behavior.zig
@@ -174,7 +174,7 @@ test {
_ = @import("behavior/inline_switch.zig");
_ = @import("behavior/int128.zig");
_ = @import("behavior/int_comparison_elision.zig");
- _ = @import("behavior/inttoptr.zig");
+ _ = @import("behavior/ptrfromint.zig");
_ = @import("behavior/ir_block_deps.zig");
_ = @import("behavior/lower_strlit_to_vector.zig");
_ = @import("behavior/math.zig");
diff --git a/test/behavior/align.zig b/test/behavior/align.zig
index 4ce408e65d..d3e4d81250 100644
--- a/test/behavior/align.zig
+++ b/test/behavior/align.zig
@@ -24,7 +24,7 @@ test "slicing array of length 1 can not assume runtime index is always zero" {
const slice = @as(*align(4) [1]u8, &foo)[runtime_index..];
try expect(@TypeOf(slice) == []u8);
try expect(slice.len == 0);
- try expect(@truncate(u2, @ptrToInt(slice.ptr) - 1) == 0);
+ try expect(@truncate(u2, @intFromPtr(slice.ptr) - 1) == 0);
}
test "default alignment allows unspecified in type syntax" {
@@ -299,11 +299,11 @@ test "page aligned array on stack" {
var number1: u8 align(16) = 42;
var number2: u8 align(16) = 43;
- try expect(@ptrToInt(&array[0]) & 0xFFF == 0);
+ try expect(@intFromPtr(&array[0]) & 0xFFF == 0);
try expect(array[3] == 4);
- try expect(@truncate(u4, @ptrToInt(&number1)) == 0);
- try expect(@truncate(u4, @ptrToInt(&number2)) == 0);
+ try expect(@truncate(u4, @intFromPtr(&number1)) == 0);
+ try expect(@truncate(u4, @intFromPtr(&number2)) == 0);
try expect(number1 == 42);
try expect(number2 == 43);
}
@@ -518,7 +518,7 @@ test "struct field explicit alignment" {
node.massive_byte = 100;
try expect(node.massive_byte == 100);
try comptime expect(@TypeOf(&node.massive_byte) == *align(64) u8);
- try expect(@ptrToInt(&node.massive_byte) % 64 == 0);
+ try expect(@intFromPtr(&node.massive_byte) % 64 == 0);
}
test "align(@alignOf(T)) T does not force resolution of T" {
@@ -561,7 +561,7 @@ test "align(N) on functions" {
if (native_arch == .wasm32 or native_arch == .wasm64) return error.SkipZigTest;
if (native_arch == .thumb) return error.SkipZigTest;
- try expect((@ptrToInt(&overaligned_fn) & (0x1000 - 1)) == 0);
+ try expect((@intFromPtr(&overaligned_fn) & (0x1000 - 1)) == 0);
}
fn overaligned_fn() align(0x1000) i32 {
return 42;
@@ -578,7 +578,7 @@ test "comptime alloc alignment" {
_ = bytes1;
comptime var bytes2 align(256) = [_]u8{0};
- var bytes2_addr = @ptrToInt(&bytes2);
+ var bytes2_addr = @intFromPtr(&bytes2);
try expect(bytes2_addr & 0xff == 0);
}
diff --git a/test/behavior/array.zig b/test/behavior/array.zig
index cd4c81508a..9ef4a55b39 100644
--- a/test/behavior/array.zig
+++ b/test/behavior/array.zig
@@ -176,8 +176,8 @@ test "array with sentinels" {
var arr: [3:0x55]u8 = undefined;
// Make sure the sentinel pointer is pointing after the last element.
if (!is_ct) {
- const sentinel_ptr = @ptrToInt(&arr[3]);
- const last_elem_ptr = @ptrToInt(&arr[2]);
+ const sentinel_ptr = @intFromPtr(&arr[3]);
+ const last_elem_ptr = @intFromPtr(&arr[2]);
try expect((sentinel_ptr - last_elem_ptr) == 1);
}
// Make sure the sentinel is writeable.
diff --git a/test/behavior/async_fn.zig b/test/behavior/async_fn.zig
index 54609ac298..dcbe78b091 100644
--- a/test/behavior/async_fn.zig
+++ b/test/behavior/async_fn.zig
@@ -829,7 +829,7 @@ test "alignment of local variables in async functions" {
var y: u8 = 123;
_ = y;
var x: u8 align(128) = 1;
- try expect(@ptrToInt(&x) % 128 == 0);
+ try expect(@intFromPtr(&x) % 128 == 0);
}
};
try S.doTheTest();
@@ -1184,7 +1184,7 @@ test "using @TypeOf on a generic function call" {
global_frame = @frame();
}
const F = @TypeOf(async amain(x - 1));
- const frame = @intToPtr(*F, @ptrToInt(&buf));
+ const frame = @ptrFromInt(*F, @intFromPtr(&buf));
return await @asyncCall(frame, {}, amain, .{x - 1});
}
};
@@ -1212,7 +1212,7 @@ test "recursive call of await @asyncCall with struct return type" {
global_frame = @frame();
}
const F = @TypeOf(async amain(x - 1));
- const frame = @intToPtr(*F, @ptrToInt(&buf));
+ const frame = @ptrFromInt(*F, @intFromPtr(&buf));
return await @asyncCall(frame, {}, amain, .{x - 1});
}
diff --git a/test/behavior/bool.zig b/test/behavior/bool.zig
index a2636ecf42..50a098c111 100644
--- a/test/behavior/bool.zig
+++ b/test/behavior/bool.zig
@@ -13,22 +13,22 @@ test "cast bool to int" {
const t = true;
const f = false;
- try expectEqual(@as(u32, 1), @boolToInt(t));
- try expectEqual(@as(u32, 0), @boolToInt(f));
- try expectEqual(-1, @bitCast(i1, @boolToInt(t)));
- try expectEqual(0, @bitCast(i1, @boolToInt(f)));
- try expectEqual(u1, @TypeOf(@boolToInt(t)));
- try expectEqual(u1, @TypeOf(@boolToInt(f)));
- try nonConstCastBoolToInt(t, f);
+ try expectEqual(@as(u32, 1), @intFromBool(t));
+ try expectEqual(@as(u32, 0), @intFromBool(f));
+ try expectEqual(-1, @bitCast(i1, @intFromBool(t)));
+ try expectEqual(0, @bitCast(i1, @intFromBool(f)));
+ try expectEqual(u1, @TypeOf(@intFromBool(t)));
+ try expectEqual(u1, @TypeOf(@intFromBool(f)));
+ try nonConstCastIntFromBool(t, f);
}
-fn nonConstCastBoolToInt(t: bool, f: bool) !void {
- try expectEqual(@as(u32, 1), @boolToInt(t));
- try expectEqual(@as(u32, 0), @boolToInt(f));
- try expectEqual(@as(i1, -1), @bitCast(i1, @boolToInt(t)));
- try expectEqual(@as(i1, 0), @bitCast(i1, @boolToInt(f)));
- try expectEqual(u1, @TypeOf(@boolToInt(t)));
- try expectEqual(u1, @TypeOf(@boolToInt(f)));
+fn nonConstCastIntFromBool(t: bool, f: bool) !void {
+ try expectEqual(@as(u32, 1), @intFromBool(t));
+ try expectEqual(@as(u32, 0), @intFromBool(f));
+ try expectEqual(@as(i1, -1), @bitCast(i1, @intFromBool(t)));
+ try expectEqual(@as(i1, 0), @bitCast(i1, @intFromBool(f)));
+ try expectEqual(u1, @TypeOf(@intFromBool(t)));
+ try expectEqual(u1, @TypeOf(@intFromBool(f)));
}
test "bool cmp" {
diff --git a/test/behavior/bugs/10138.zig b/test/behavior/bugs/10138.zig
index 1ea2954777..1c8ff7cf7c 100644
--- a/test/behavior/bugs/10138.zig
+++ b/test/behavior/bugs/10138.zig
@@ -17,7 +17,7 @@ fn open() usize {
}
fn write(fd: usize, a: [*]const u8, len: usize) usize {
- return syscall4(.WRITE, fd, @ptrToInt(a), len);
+ return syscall4(.WRITE, fd, @intFromPtr(a), len);
}
fn syscall4(n: enum { WRITE }, a: usize, b: usize, c: usize) usize {
diff --git a/test/behavior/bugs/12142.zig b/test/behavior/bugs/12142.zig
index 4b9a4d9fa1..ca66b1f8f5 100644
--- a/test/behavior/bugs/12142.zig
+++ b/test/behavior/bugs/12142.zig
@@ -15,7 +15,7 @@ const Letter = enum(u8) {
};
fn letter(e: Letter) u8 {
- return @enumToInt(e);
+ return @intFromEnum(e);
}
test {
diff --git a/test/behavior/bugs/12450.zig b/test/behavior/bugs/12450.zig
index 368f055d05..db91529051 100644
--- a/test/behavior/bugs/12450.zig
+++ b/test/behavior/bugs/12450.zig
@@ -18,6 +18,6 @@ test {
var f1: *align(16) Foo = @alignCast(16, @ptrCast(*align(1) Foo, &buffer[0]));
try expect(@typeInfo(@TypeOf(f1)).Pointer.alignment == 16);
- try expect(@ptrToInt(f1) == @ptrToInt(&f1.a));
+ try expect(@intFromPtr(f1) == @intFromPtr(&f1.a));
try expect(@typeInfo(@TypeOf(&f1.a)).Pointer.alignment == 16);
}
diff --git a/test/behavior/bugs/12680_other_file.zig b/test/behavior/bugs/12680_other_file.zig
index 32b9dc1b27..5bcc9e1c16 100644
--- a/test/behavior/bugs/12680_other_file.zig
+++ b/test/behavior/bugs/12680_other_file.zig
@@ -1,6 +1,6 @@
// export this function twice
pub export fn testFunc() callconv(.C) usize {
- return @ptrToInt(&testFunc);
+ return @intFromPtr(&testFunc);
}
comptime {
diff --git a/test/behavior/bugs/12723.zig b/test/behavior/bugs/12723.zig
index 81e276218a..abecf89025 100644
--- a/test/behavior/bugs/12723.zig
+++ b/test/behavior/bugs/12723.zig
@@ -3,6 +3,6 @@ const expect = @import("std").testing.expect;
test "Non-exhaustive enum backed by comptime_int" {
const E = enum(comptime_int) { a, b, c, _ };
comptime var e: E = .a;
- e = @intToEnum(E, 378089457309184723749);
- try expect(@enumToInt(e) == 378089457309184723749);
+ e = @enumFromInt(E, 378089457309184723749);
+ try expect(@intFromEnum(e) == 378089457309184723749);
}
diff --git a/test/behavior/bugs/1741.zig b/test/behavior/bugs/1741.zig
index 6c36ba5e15..b4cf5577de 100644
--- a/test/behavior/bugs/1741.zig
+++ b/test/behavior/bugs/1741.zig
@@ -8,5 +8,5 @@ test "fixed" {
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const x: f32 align(128) = 12.34;
- try std.testing.expect(@ptrToInt(&x) % 128 == 0);
+ try std.testing.expect(@intFromPtr(&x) % 128 == 0);
}
diff --git a/test/behavior/bugs/9584.zig b/test/behavior/bugs/9584.zig
index 49139db899..6f3223c362 100644
--- a/test/behavior/bugs/9584.zig
+++ b/test/behavior/bugs/9584.zig
@@ -35,7 +35,7 @@ pub fn a(
_ = flag_a;
// With this bug present, `flag_b` would actually contain the value 17.
// Note: this bug only presents itself on debug mode.
- const flag_b_byte: u8 = @boolToInt(flag_b);
+ const flag_b_byte: u8 = @intFromBool(flag_b);
try std.testing.expect(flag_b_byte == 1);
}
diff --git a/test/behavior/builtin_functions_returning_void_or_noreturn.zig b/test/behavior/builtin_functions_returning_void_or_noreturn.zig
index ea53658888..ae369c4e9d 100644
--- a/test/behavior/builtin_functions_returning_void_or_noreturn.zig
+++ b/test/behavior/builtin_functions_returning_void_or_noreturn.zig
@@ -17,8 +17,8 @@ test {
try testing.expectEqual(void, @TypeOf(@breakpoint()));
try testing.expectEqual({}, @export(x, .{ .name = "x" }));
try testing.expectEqual({}, @fence(.Acquire));
- try testing.expectEqual({}, @memcpy(@intToPtr([*]u8, 1)[0..0], @intToPtr([*]u8, 1)[0..0]));
- try testing.expectEqual({}, @memset(@intToPtr([*]u8, 1)[0..0], undefined));
+ try testing.expectEqual({}, @memcpy(@ptrFromInt([*]u8, 1)[0..0], @ptrFromInt([*]u8, 1)[0..0]));
+ try testing.expectEqual({}, @memset(@ptrFromInt([*]u8, 1)[0..0], undefined));
try testing.expectEqual(noreturn, @TypeOf(if (true) @panic("") else {}));
try testing.expectEqual({}, @prefetch(&val, .{}));
try testing.expectEqual({}, @setAlignStack(16));
diff --git a/test/behavior/call.zig b/test/behavior/call.zig
index 64eca08c82..627df37e9b 100644
--- a/test/behavior/call.zig
+++ b/test/behavior/call.zig
@@ -364,11 +364,11 @@ test "Enum constructed by @Type passed as generic argument" {
alive: bool,
});
fn foo(comptime a: E, b: u32) !void {
- try expect(@enumToInt(a) == b);
+ try expect(@intFromEnum(a) == b);
}
};
inline for (@typeInfo(S.E).Enum.fields, 0..) |_, i| {
- try S.foo(@intToEnum(S.E, i), i);
+ try S.foo(@enumFromInt(S.E, i), i);
}
}
diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig
index 5123e190b6..d51d864ea1 100644
--- a/test/behavior/cast.zig
+++ b/test/behavior/cast.zig
@@ -10,14 +10,14 @@ const native_endian = builtin.target.cpu.arch.endian();
test "int to ptr cast" {
const x = @as(usize, 13);
- const y = @intToPtr(*u8, x);
- const z = @ptrToInt(y);
+ const y = @ptrFromInt(*u8, x);
+ const z = @intFromPtr(y);
try expect(z == 13);
}
test "integer literal to pointer cast" {
- const vga_mem = @intToPtr(*u16, 0xB8000);
- try expect(@ptrToInt(vga_mem) == 0xB8000);
+ const vga_mem = @ptrFromInt(*u16, 0xB8000);
+ try expect(@intFromPtr(vga_mem) == 0xB8000);
}
test "peer type resolution: ?T and T" {
@@ -66,37 +66,37 @@ test "implicit cast comptime_int to comptime_float" {
try expect(2 == 2.0);
}
-test "comptime_int @intToFloat" {
+test "comptime_int @floatFromInt" {
{
- const result = @intToFloat(f16, 1234);
+ const result = @floatFromInt(f16, 1234);
try expect(@TypeOf(result) == f16);
try expect(result == 1234.0);
}
{
- const result = @intToFloat(f32, 1234);
+ const result = @floatFromInt(f32, 1234);
try expect(@TypeOf(result) == f32);
try expect(result == 1234.0);
}
{
- const result = @intToFloat(f64, 1234);
+ const result = @floatFromInt(f64, 1234);
try expect(@TypeOf(result) == f64);
try expect(result == 1234.0);
}
{
- const result = @intToFloat(f128, 1234);
+ const result = @floatFromInt(f128, 1234);
try expect(@TypeOf(result) == f128);
try expect(result == 1234.0);
}
// big comptime_int (> 64 bits) to f128 conversion
{
- const result = @intToFloat(f128, 0x1_0000_0000_0000_0000);
+ const result = @floatFromInt(f128, 0x1_0000_0000_0000_0000);
try expect(@TypeOf(result) == f128);
try expect(result == 0x1_0000_0000_0000_0000.0);
}
}
-test "@intToFloat" {
+test "@floatFromInt" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
@@ -107,8 +107,8 @@ test "@intToFloat" {
}
fn testIntToFloat(k: i32) !void {
- const f = @intToFloat(f32, k);
- const i = @floatToInt(i32, f);
+ const f = @floatFromInt(f32, k);
+ const i = @intFromFloat(i32, f);
try expect(i == k);
}
};
@@ -116,7 +116,7 @@ test "@intToFloat" {
try comptime S.doTheTest();
}
-test "@intToFloat(f80)" {
+test "@floatFromInt(f80)" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
@@ -131,8 +131,8 @@ test "@intToFloat(f80)" {
fn testIntToFloat(comptime Int: type, k: Int) !void {
@setRuntimeSafety(false); // TODO
- const f = @intToFloat(f80, k);
- const i = @floatToInt(Int, f);
+ const f = @floatFromInt(f80, k);
+ const i = @intFromFloat(Int, f);
try expect(i == k);
}
};
@@ -152,28 +152,28 @@ test "@intToFloat(f80)" {
try comptime S.doTheTest(i256);
}
-test "@floatToInt" {
+test "@intFromFloat" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
- try testFloatToInts();
- try comptime testFloatToInts();
+ try testIntFromFloats();
+ try comptime testIntFromFloats();
}
-fn testFloatToInts() !void {
+fn testIntFromFloats() !void {
const x = @as(i32, 1e4);
try expect(x == 10000);
- const y = @floatToInt(i32, @as(f32, 1e4));
+ const y = @intFromFloat(i32, @as(f32, 1e4));
try expect(y == 10000);
- try expectFloatToInt(f32, 255.1, u8, 255);
- try expectFloatToInt(f32, 127.2, i8, 127);
- try expectFloatToInt(f32, -128.2, i8, -128);
+ try expectIntFromFloat(f32, 255.1, u8, 255);
+ try expectIntFromFloat(f32, 127.2, i8, 127);
+ try expectIntFromFloat(f32, -128.2, i8, -128);
}
-fn expectFloatToInt(comptime F: type, f: F, comptime I: type, i: I) !void {
- try expect(@floatToInt(I, f) == i);
+fn expectIntFromFloat(comptime F: type, f: F, comptime I: type, i: I) !void {
+ try expect(@intFromFloat(I, f) == i);
}
test "implicitly cast indirect pointer to maybe-indirect pointer" {
@@ -280,9 +280,9 @@ test "*usize to *void" {
v.* = {};
}
-test "@intToEnum passed a comptime_int to an enum with one item" {
+test "@enumFromInt passed a comptime_int to an enum with one item" {
const E = enum { A };
- const x = @intToEnum(E, 0);
+ const x = @enumFromInt(E, 0);
try expect(x == E.A);
}
@@ -420,8 +420,8 @@ test "explicit cast from integer to error type" {
try comptime testCastIntToErr(error.ItBroke);
}
fn testCastIntToErr(err: anyerror) !void {
- const x = @errorToInt(err);
- const y = @intToError(x);
+ const x = @intFromError(err);
+ const y = @errorFromInt(x);
try expect(error.ItBroke == y);
}
@@ -1093,15 +1093,15 @@ test "peer type resolve array pointer and unknown pointer" {
test "comptime float casts" {
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
- const a = @intToFloat(comptime_float, 1);
+ const a = @floatFromInt(comptime_float, 1);
try expect(a == 1);
try expect(@TypeOf(a) == comptime_float);
- const b = @floatToInt(comptime_int, 2);
+ const b = @intFromFloat(comptime_int, 2);
try expect(b == 2);
try expect(@TypeOf(b) == comptime_int);
- try expectFloatToInt(comptime_int, 1234, i16, 1234);
- try expectFloatToInt(comptime_float, 12.3, comptime_int, 12);
+ try expectIntFromFloat(comptime_int, 1234, i16, 1234);
+ try expectIntFromFloat(comptime_float, 12.3, comptime_int, 12);
}
test "pointer reinterpret const float to int" {
@@ -1146,11 +1146,11 @@ test "compile time int to ptr of function" {
// On some architectures function pointers must be aligned.
const hardcoded_fn_addr = maxInt(usize) & ~@as(usize, 0xf);
-pub const FUNCTION_CONSTANT = @intToPtr(PFN_void, hardcoded_fn_addr);
+pub const FUNCTION_CONSTANT = @ptrFromInt(PFN_void, hardcoded_fn_addr);
pub const PFN_void = *const fn (*anyopaque) callconv(.C) void;
fn foobar(func: PFN_void) !void {
- try std.testing.expect(@ptrToInt(func) == hardcoded_fn_addr);
+ try std.testing.expect(@intFromPtr(func) == hardcoded_fn_addr);
}
test "implicit ptr to *anyopaque" {
@@ -1285,11 +1285,11 @@ test "implicit cast *[0]T to E![]const u8" {
var global_array: [4]u8 = undefined;
test "cast from array reference to fn: comptime fn ptr" {
const f = @ptrCast(*align(1) const fn () callconv(.C) void, &global_array);
- try expect(@ptrToInt(f) == @ptrToInt(&global_array));
+ try expect(@intFromPtr(f) == @intFromPtr(&global_array));
}
test "cast from array reference to fn: runtime fn ptr" {
var f = @ptrCast(*align(1) const fn () callconv(.C) void, &global_array);
- try expect(@ptrToInt(f) == @ptrToInt(&global_array));
+ try expect(@intFromPtr(f) == @intFromPtr(&global_array));
}
test "*const [N]null u8 to ?[]const u8" {
@@ -1500,19 +1500,19 @@ test "coerce between pointers of compatible differently-named floats" {
}
test "peer type resolution of const and non-const pointer to array" {
- const a = @intToPtr(*[1024]u8, 42);
- const b = @intToPtr(*const [1024]u8, 42);
+ const a = @ptrFromInt(*[1024]u8, 42);
+ const b = @ptrFromInt(*const [1024]u8, 42);
try std.testing.expect(@TypeOf(a, b) == *const [1024]u8);
try std.testing.expect(a == b);
}
-test "floatToInt to zero-bit int" {
+test "intFromFloat to zero-bit int" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
const a: f32 = 0.0;
- try comptime std.testing.expect(@floatToInt(u0, a) == 0);
+ try comptime std.testing.expect(@intFromFloat(u0, a) == 0);
}
test "peer type resolution of function pointer and function body" {
@@ -1560,9 +1560,9 @@ test "optional pointer coerced to optional allowzero pointer" {
var p: ?*u32 = undefined;
var q: ?*allowzero u32 = undefined;
- p = @intToPtr(*u32, 4);
+ p = @ptrFromInt(*u32, 4);
q = p;
- try expect(@ptrToInt(q.?) == 4);
+ try expect(@intFromPtr(q.?) == 4);
}
test "single item pointer to pointer to array to slice" {
@@ -1623,8 +1623,8 @@ test "peer type resolution: const sentinel slice and mutable non-sentinel slice"
const S = struct {
fn doTheTest(comptime T: type, comptime s: T) !void {
- var a: [:s]const T = @intToPtr(*const [2:s]T, 0x1000);
- var b: []T = @intToPtr(*[3]T, 0x2000);
+ var a: [:s]const T = @ptrFromInt(*const [2:s]T, 0x1000);
+ var b: []T = @ptrFromInt(*[3]T, 0x2000);
comptime assert(@TypeOf(a, b) == []const T);
comptime assert(@TypeOf(b, a) == []const T);
@@ -1634,8 +1634,8 @@ test "peer type resolution: const sentinel slice and mutable non-sentinel slice"
const R = @TypeOf(r1);
- try expectEqual(@as(R, @intToPtr(*const [2:s]T, 0x1000)), r1);
- try expectEqual(@as(R, @intToPtr(*const [3]T, 0x2000)), r2);
+ try expectEqual(@as(R, @ptrFromInt(*const [2:s]T, 0x1000)), r1);
+ try expectEqual(@as(R, @ptrFromInt(*const [3]T, 0x2000)), r2);
}
};
@@ -1815,7 +1815,7 @@ test "peer type resolution: three-way resolution combines error set and optional
const E = error{Foo};
var a: E = error.Foo;
- var b: *const [5:0]u8 = @intToPtr(*const [5:0]u8, 0x1000);
+ var b: *const [5:0]u8 = @ptrFromInt(*const [5:0]u8, 0x1000);
var c: ?[*:0]u8 = null;
comptime assert(@TypeOf(a, b, c) == E!?[*:0]const u8);
comptime assert(@TypeOf(a, c, b) == E!?[*:0]const u8);
@@ -1844,7 +1844,7 @@ test "peer type resolution: three-way resolution combines error set and optional
const T = @TypeOf(r1);
try expectEqual(@as(T, error.Foo), r1);
- try expectEqual(@as(T, @intToPtr([*:0]u8, 0x1000)), r2);
+ try expectEqual(@as(T, @ptrFromInt([*:0]u8, 0x1000)), r2);
try expectEqual(@as(T, null), r3);
}
diff --git a/test/behavior/comptime_memory.zig b/test/behavior/comptime_memory.zig
index 646433a5c0..ade0f0dc42 100644
--- a/test/behavior/comptime_memory.zig
+++ b/test/behavior/comptime_memory.zig
@@ -192,9 +192,9 @@ test "basic pointer preservation" {
}
comptime {
- const lazy_address = @ptrToInt(&imports.global_u32);
- try testing.expectEqual(@ptrToInt(&imports.global_u32), lazy_address);
- try testing.expectEqual(&imports.global_u32, @intToPtr(*u32, lazy_address));
+ const lazy_address = @intFromPtr(&imports.global_u32);
+ try testing.expectEqual(@intFromPtr(&imports.global_u32), lazy_address);
+ try testing.expectEqual(&imports.global_u32, @ptrFromInt(*u32, lazy_address));
}
}
@@ -251,7 +251,7 @@ test "shuffle chunks of linker value" {
return error.SkipZigTest;
}
- const lazy_address = @ptrToInt(&imports.global_u32);
+ const lazy_address = @intFromPtr(&imports.global_u32);
const shuffled1_rt = shuffle(lazy_address, Bits, ShuffledBits);
const unshuffled1_rt = shuffle(shuffled1_rt, ShuffledBits, Bits);
try testing.expectEqual(lazy_address, unshuffled1_rt);
@@ -271,8 +271,8 @@ test "dance on linker values" {
comptime {
var arr: [2]usize = undefined;
- arr[0] = @ptrToInt(&imports.global_u32);
- arr[1] = @ptrToInt(&imports.global_u32);
+ arr[0] = @intFromPtr(&imports.global_u32);
+ arr[1] = @intFromPtr(&imports.global_u32);
const weird_ptr = @ptrCast([*]Bits, @ptrCast([*]u8, &arr) + @sizeOf(usize) - 3);
try doTypePunBitsTest(&weird_ptr[0]);
@@ -290,7 +290,7 @@ test "dance on linker values" {
rebuilt_bytes[i] = arr_bytes[1][i];
}
- try testing.expectEqual(&imports.global_u32, @intToPtr(*u32, @bitCast(usize, rebuilt_bytes)));
+ try testing.expectEqual(&imports.global_u32, @ptrFromInt(*u32, @bitCast(usize, rebuilt_bytes)));
}
}
@@ -309,14 +309,14 @@ test "offset array ptr by element size" {
.{ .x = bigToNativeEndian(u32, 0x03070b0f) },
};
- const address = @ptrToInt(&arr);
- try testing.expectEqual(@ptrToInt(&arr[0]), address);
- try testing.expectEqual(@ptrToInt(&arr[0]) + 10, address + 10);
- try testing.expectEqual(@ptrToInt(&arr[1]), address + @sizeOf(VirtualStruct));
- try testing.expectEqual(@ptrToInt(&arr[2]), address + 2 * @sizeOf(VirtualStruct));
- try testing.expectEqual(@ptrToInt(&arr[3]), address + @sizeOf(VirtualStruct) * 3);
+ const address = @intFromPtr(&arr);
+ try testing.expectEqual(@intFromPtr(&arr[0]), address);
+ try testing.expectEqual(@intFromPtr(&arr[0]) + 10, address + 10);
+ try testing.expectEqual(@intFromPtr(&arr[1]), address + @sizeOf(VirtualStruct));
+ try testing.expectEqual(@intFromPtr(&arr[2]), address + 2 * @sizeOf(VirtualStruct));
+ try testing.expectEqual(@intFromPtr(&arr[3]), address + @sizeOf(VirtualStruct) * 3);
- const secondElement = @intToPtr(*VirtualStruct, @ptrToInt(&arr[0]) + 2 * @sizeOf(VirtualStruct));
+ const secondElement = @ptrFromInt(*VirtualStruct, @intFromPtr(&arr[0]) + 2 * @sizeOf(VirtualStruct));
try testing.expectEqual(bigToNativeEndian(u32, 0x02060a0e), secondElement.x);
}
}
@@ -331,18 +331,18 @@ test "offset instance by field size" {
const VirtualStruct = struct { x: u32, y: u32, z: u32, w: u32 };
var inst = VirtualStruct{ .x = 0, .y = 1, .z = 2, .w = 3 };
- var ptr = @ptrToInt(&inst);
+ var ptr = @intFromPtr(&inst);
ptr -= 4;
ptr += @offsetOf(VirtualStruct, "x");
- try testing.expectEqual(@as(u32, 0), @intToPtr([*]u32, ptr)[1]);
+ try testing.expectEqual(@as(u32, 0), @ptrFromInt([*]u32, ptr)[1]);
ptr -= @offsetOf(VirtualStruct, "x");
ptr += @offsetOf(VirtualStruct, "y");
- try testing.expectEqual(@as(u32, 1), @intToPtr([*]u32, ptr)[1]);
+ try testing.expectEqual(@as(u32, 1), @ptrFromInt([*]u32, ptr)[1]);
ptr = ptr - @offsetOf(VirtualStruct, "y") + @offsetOf(VirtualStruct, "z");
- try testing.expectEqual(@as(u32, 2), @intToPtr([*]u32, ptr)[1]);
- ptr = @ptrToInt(&inst.z) - 4 - @offsetOf(VirtualStruct, "z");
+ try testing.expectEqual(@as(u32, 2), @ptrFromInt([*]u32, ptr)[1]);
+ ptr = @intFromPtr(&inst.z) - 4 - @offsetOf(VirtualStruct, "z");
ptr += @offsetOf(VirtualStruct, "w");
- try testing.expectEqual(@as(u32, 3), @intToPtr(*u32, ptr + 4).*);
+ try testing.expectEqual(@as(u32, 3), @ptrFromInt(*u32, ptr + 4).*);
}
}
diff --git a/test/behavior/enum.zig b/test/behavior/enum.zig
index a795d5f4b8..12926800e3 100644
--- a/test/behavior/enum.zig
+++ b/test/behavior/enum.zig
@@ -8,7 +8,7 @@ const Tag = std.meta.Tag;
const Number = enum { Zero, One, Two, Three, Four };
fn shouldEqual(n: Number, expected: u3) !void {
- try expect(@enumToInt(n) == expected);
+ try expect(@intFromEnum(n) == expected);
}
test "enum to int" {
@@ -20,7 +20,7 @@ test "enum to int" {
}
fn testIntToEnumEval(x: i32) !void {
- try expect(@intToEnum(IntToEnumNumber, x) == IntToEnumNumber.Three);
+ try expect(@enumFromInt(IntToEnumNumber, x) == IntToEnumNumber.Three);
}
const IntToEnumNumber = enum { Zero, One, Two, Three, Four };
@@ -597,7 +597,7 @@ const MultipleChoice = enum(u32) {
};
fn testEnumWithSpecifiedTagValues(x: MultipleChoice) !void {
- try expect(@enumToInt(x) == 60);
+ try expect(@intFromEnum(x) == 60);
try expect(1234 == switch (x) {
MultipleChoice.A => 1,
MultipleChoice.B => 2,
@@ -629,7 +629,7 @@ test "non-exhaustive enum" {
.b => true,
_ => false,
});
- e = @intToEnum(E, 12);
+ e = @enumFromInt(E, 12);
try expect(switch (e) {
.a => false,
.b => false,
@@ -648,10 +648,10 @@ test "non-exhaustive enum" {
});
try expect(@typeInfo(E).Enum.fields.len == 2);
- e = @intToEnum(E, 12);
- try expect(@enumToInt(e) == 12);
- e = @intToEnum(E, y);
- try expect(@enumToInt(e) == 52);
+ e = @enumFromInt(E, 12);
+ try expect(@intFromEnum(e) == 12);
+ e = @enumFromInt(E, y);
+ try expect(@intFromEnum(e) == 52);
try expect(@typeInfo(E).Enum.is_exhaustive == false);
}
};
@@ -666,11 +666,11 @@ test "empty non-exhaustive enum" {
const E = enum(u8) { _ };
fn doTheTest(y: u8) !void {
- var e = @intToEnum(E, y);
+ var e = @enumFromInt(E, y);
try expect(switch (e) {
_ => true,
});
- try expect(@enumToInt(e) == y);
+ try expect(@intFromEnum(e) == y);
try expect(@typeInfo(E).Enum.fields.len == 0);
try expect(@typeInfo(E).Enum.is_exhaustive == false);
@@ -693,7 +693,7 @@ test "single field non-exhaustive enum" {
.a => true,
_ => false,
});
- e = @intToEnum(E, 12);
+ e = @enumFromInt(E, 12);
try expect(switch (e) {
.a => false,
_ => true,
@@ -709,7 +709,7 @@ test "single field non-exhaustive enum" {
else => false,
});
- try expect(@enumToInt(@intToEnum(E, y)) == y);
+ try expect(@intFromEnum(@enumFromInt(E, y)) == y);
try expect(@typeInfo(E).Enum.fields.len == 1);
try expect(@typeInfo(E).Enum.is_exhaustive == false);
}
@@ -725,7 +725,7 @@ const EnumWithTagValues = enum(u4) {
D = 1 << 3,
};
test "enum with tag values don't require parens" {
- try expect(@enumToInt(EnumWithTagValues.C) == 0b0100);
+ try expect(@intFromEnum(EnumWithTagValues.C) == 0b0100);
}
const MultipleChoice2 = enum(u32) {
@@ -741,8 +741,8 @@ const MultipleChoice2 = enum(u32) {
};
test "cast integer literal to enum" {
- try expect(@intToEnum(MultipleChoice2, 0) == MultipleChoice2.Unspecified1);
- try expect(@intToEnum(MultipleChoice2, 40) == MultipleChoice2.B);
+ try expect(@enumFromInt(MultipleChoice2, 0) == MultipleChoice2.Unspecified1);
+ try expect(@enumFromInt(MultipleChoice2, 40) == MultipleChoice2.B);
}
test "enum with specified and unspecified tag values" {
@@ -754,7 +754,7 @@ test "enum with specified and unspecified tag values" {
}
fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: MultipleChoice2) !void {
- try expect(@enumToInt(x) == 1000);
+ try expect(@intFromEnum(x) == 1000);
try expect(1234 == switch (x) {
MultipleChoice2.A => 1,
MultipleChoice2.B => 2,
@@ -790,7 +790,7 @@ test "casting enum to its tag type" {
}
fn testCastEnumTag(value: Small2) !void {
- try expect(@enumToInt(value) == 1);
+ try expect(@intFromEnum(value) == 1);
}
test "enum with 1 field but explicit tag type should still have the tag type" {
@@ -807,27 +807,27 @@ test "signed integer as enum tag" {
A2 = 1,
};
- try expect(@enumToInt(SignedEnum.A0) == -1);
- try expect(@enumToInt(SignedEnum.A1) == 0);
- try expect(@enumToInt(SignedEnum.A2) == 1);
+ try expect(@intFromEnum(SignedEnum.A0) == -1);
+ try expect(@intFromEnum(SignedEnum.A1) == 0);
+ try expect(@intFromEnum(SignedEnum.A2) == 1);
}
test "enum with one member and custom tag type" {
const E = enum(u2) {
One,
};
- try expect(@enumToInt(E.One) == 0);
+ try expect(@intFromEnum(E.One) == 0);
const E2 = enum(u2) {
One = 2,
};
- try expect(@enumToInt(E2.One) == 2);
+ try expect(@intFromEnum(E2.One) == 2);
}
-test "enum with one member and u1 tag type @enumToInt" {
+test "enum with one member and u1 tag type @intFromEnum" {
const Enum = enum(u1) {
Test,
};
- try expect(@enumToInt(Enum.Test) == 0);
+ try expect(@intFromEnum(Enum.Test) == 0);
}
test "enum with comptime_int tag type" {
@@ -901,9 +901,9 @@ test "enum value allocation" {
A2,
};
- try expect(@enumToInt(LargeEnum.A0) == 0x80000000);
- try expect(@enumToInt(LargeEnum.A1) == 0x80000001);
- try expect(@enumToInt(LargeEnum.A2) == 0x80000002);
+ try expect(@intFromEnum(LargeEnum.A0) == 0x80000000);
+ try expect(@intFromEnum(LargeEnum.A1) == 0x80000001);
+ try expect(@intFromEnum(LargeEnum.A2) == 0x80000002);
}
test "enum literal casting to tagged union" {
@@ -1183,7 +1183,7 @@ test "Non-exhaustive enum with nonstandard int size behaves correctly" {
test "runtime int to enum with one possible value" {
const E = enum { one };
var runtime: usize = 0;
- if (@intToEnum(E, runtime) != .one) {
+ if (@enumFromInt(E, runtime) != .one) {
@compileError("test failed");
}
}
@@ -1194,6 +1194,6 @@ test "enum tag from a local variable" {
return enum(Inner) { _ };
}
};
- const i = @intToEnum(S.Int(u32), 0);
- try std.testing.expect(@enumToInt(i) == 0);
+ const i = @enumFromInt(S.Int(u32), 0);
+ try std.testing.expect(@intFromEnum(i) == 0);
}
diff --git a/test/behavior/error.zig b/test/behavior/error.zig
index c61cd70e6b..14b0eca030 100644
--- a/test/behavior/error.zig
+++ b/test/behavior/error.zig
@@ -16,8 +16,8 @@ fn expectError(expected_err: anyerror, observed_err_union: anytype) !void {
}
test "error values" {
- const a = @errorToInt(error.err1);
- const b = @errorToInt(error.err2);
+ const a = @intFromError(error.err1);
+ const b = @intFromError(error.err2);
try expect(a != b);
}
@@ -259,14 +259,14 @@ fn testComptimeTestErrorEmptySet(x: EmptyErrorSet!i32) !void {
}
test "comptime err to int of error set with only 1 possible value" {
- testErrToIntWithOnePossibleValue(error.A, @errorToInt(error.A));
- comptime testErrToIntWithOnePossibleValue(error.A, @errorToInt(error.A));
+ testErrToIntWithOnePossibleValue(error.A, @intFromError(error.A));
+ comptime testErrToIntWithOnePossibleValue(error.A, @intFromError(error.A));
}
fn testErrToIntWithOnePossibleValue(
x: error{A},
comptime value: u32,
) void {
- if (@errorToInt(x) != value) {
+ if (@intFromError(x) != value) {
@compileError("bad");
}
}
diff --git a/test/behavior/eval.zig b/test/behavior/eval.zig
index 2c2f1d72ff..85dc5e29b5 100644
--- a/test/behavior/eval.zig
+++ b/test/behavior/eval.zig
@@ -1372,7 +1372,7 @@ test "lazy value is resolved as slice operand" {
const ptr1 = a[0..@sizeOf(A)];
const ptr2 = @ptrCast([*]u8, &a)[0..@sizeOf(A)];
- try expect(@ptrToInt(ptr1) == @ptrToInt(ptr2));
+ try expect(@intFromPtr(ptr1) == @intFromPtr(ptr2));
try expect(ptr1.len == ptr2.len);
}
diff --git a/test/behavior/export.zig b/test/behavior/export.zig
index 6123aa593b..4928e86725 100644
--- a/test/behavior/export.zig
+++ b/test/behavior/export.zig
@@ -7,7 +7,7 @@ const builtin = @import("builtin");
// can't really run this test but we can make sure it has no compile error
// and generates code
-const vram = @intToPtr([*]volatile u8, 0x20000000)[0..0x8000];
+const vram = @ptrFromInt([*]volatile u8, 0x20000000)[0..0x8000];
export fn writeToVRam() void {
vram[0] = 'X';
}
diff --git a/test/behavior/export_self_referential_type_info.zig b/test/behavior/export_self_referential_type_info.zig
index 0982985cee..1b1bb35e5b 100644
--- a/test/behavior/export_self_referential_type_info.zig
+++ b/test/behavior/export_self_referential_type_info.zig
@@ -1 +1 @@
-export const self_referential_type_info: c_int = @boolToInt(@typeInfo(@This()).Struct.is_tuple);
+export const self_referential_type_info: c_int = @intFromBool(@typeInfo(@This()).Struct.is_tuple);
diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig
index 15033d5515..56f3885a4a 100644
--- a/test/behavior/floatop.zig
+++ b/test/behavior/floatop.zig
@@ -89,12 +89,12 @@ fn testDifferentSizedFloatComparisons() !void {
// }
//}
-test "negative f128 floatToInt at compile-time" {
+test "negative f128 intFromFloat at compile-time" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
const a: f128 = -2;
- var b = @floatToInt(i64, a);
+ var b = @intFromFloat(i64, a);
try expect(@as(i64, -2) == b);
}
diff --git a/test/behavior/fn_in_struct_in_comptime.zig b/test/behavior/fn_in_struct_in_comptime.zig
index a7d8e779cc..b31b377c04 100644
--- a/test/behavior/fn_in_struct_in_comptime.zig
+++ b/test/behavior/fn_in_struct_in_comptime.zig
@@ -5,7 +5,7 @@ fn get_foo() fn (*u8) usize {
comptime {
return struct {
fn func(ptr: *u8) usize {
- var u = @ptrToInt(ptr);
+ var u = @intFromPtr(ptr);
return u;
}
}.func;
@@ -14,5 +14,5 @@ fn get_foo() fn (*u8) usize {
test "define a function in an anonymous struct in comptime" {
const foo = get_foo();
- try expect(foo(@intToPtr(*u8, 12345)) == 12345);
+ try expect(foo(@ptrFromInt(*u8, 12345)) == 12345);
}
diff --git a/test/behavior/generics.zig b/test/behavior/generics.zig
index 7f22f63045..f0c8516f67 100644
--- a/test/behavior/generics.zig
+++ b/test/behavior/generics.zig
@@ -267,7 +267,7 @@ test "generic function instantiation turns into comptime call" {
.Enum => std.builtin.Type.EnumField,
else => void,
} {
- return @typeInfo(T).Enum.fields[@enumToInt(field)];
+ return @typeInfo(T).Enum.fields[@intFromEnum(field)];
}
pub fn FieldEnum(comptime T: type) type {
@@ -425,10 +425,10 @@ test "null sentinel pointer passed as generic argument" {
const S = struct {
fn doTheTest(a: anytype) !void {
- try std.testing.expect(@ptrToInt(a) == 8);
+ try std.testing.expect(@intFromPtr(a) == 8);
}
};
- try S.doTheTest((@intToPtr([*:null]const [*c]const u8, 8)));
+ try S.doTheTest((@ptrFromInt([*:null]const [*c]const u8, 8)));
}
test "generic function passed as comptime argument" {
diff --git a/test/behavior/inline_switch.zig b/test/behavior/inline_switch.zig
index 426026d826..fc2eae31be 100644
--- a/test/behavior/inline_switch.zig
+++ b/test/behavior/inline_switch.zig
@@ -103,7 +103,7 @@ test "inline else enum" {
var a: E2 = .a;
switch (a) {
.a, .b => {},
- inline else => |val| comptime if (@enumToInt(val) < 4) @compileError("bad"),
+ inline else => |val| comptime if (@intFromEnum(val) < 4) @compileError("bad"),
}
}
diff --git a/test/behavior/packed-struct.zig b/test/behavior/packed-struct.zig
index 5a6e92403b..037fee74ee 100644
--- a/test/behavior/packed-struct.zig
+++ b/test/behavior/packed-struct.zig
@@ -375,7 +375,7 @@ test "load pointer from packed struct" {
}
}
-test "@ptrToInt on a packed struct field" {
+test "@intFromPtr on a packed struct field" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
@@ -394,7 +394,7 @@ test "@ptrToInt on a packed struct field" {
.z = 0,
};
};
- try expect(@ptrToInt(&S.p0.z) - @ptrToInt(&S.p0.x) == 2);
+ try expect(@intFromPtr(&S.p0.z) - @intFromPtr(&S.p0.x) == 2);
}
test "optional pointer in packed struct" {
diff --git a/test/behavior/pointers.zig b/test/behavior/pointers.zig
index 32c2dc13ac..4e04fe580c 100644
--- a/test/behavior/pointers.zig
+++ b/test/behavior/pointers.zig
@@ -184,8 +184,8 @@ test "implicit cast error unions with non-optional to optional pointer" {
}
test "compare equality of optional and non-optional pointer" {
- const a = @intToPtr(*const usize, 0x12345678);
- const b = @intToPtr(?*usize, 0x12345678);
+ const a = @ptrFromInt(*const usize, 0x12345678);
+ const b = @ptrFromInt(?*usize, 0x12345678);
try expect(a == b);
try expect(b == a);
}
@@ -197,14 +197,14 @@ test "allowzero pointer and slice" {
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
- var ptr = @intToPtr([*]allowzero i32, 0);
+ var ptr = @ptrFromInt([*]allowzero i32, 0);
var opt_ptr: ?[*]allowzero i32 = ptr;
try expect(opt_ptr != null);
- try expect(@ptrToInt(ptr) == 0);
+ try expect(@intFromPtr(ptr) == 0);
var runtime_zero: usize = 0;
var slice = ptr[runtime_zero..10];
try comptime expect(@TypeOf(slice) == []allowzero i32);
- try expect(@ptrToInt(&slice[5]) == 20);
+ try expect(@intFromPtr(&slice[5]) == 20);
try comptime expect(@typeInfo(@TypeOf(ptr)).Pointer.is_allowzero);
try comptime expect(@typeInfo(@TypeOf(slice)).Pointer.is_allowzero);
@@ -367,10 +367,10 @@ test "pointer sentinel with +inf" {
}
test "pointer to array at fixed address" {
- const array = @intToPtr(*volatile [2]u32, 0x10);
+ const array = @ptrFromInt(*volatile [2]u32, 0x10);
// Silly check just to reference `array`
- try expect(@ptrToInt(&array[0]) == 0x10);
- try expect(@ptrToInt(&array[1]) == 0x14);
+ try expect(@intFromPtr(&array[0]) == 0x10);
+ try expect(@intFromPtr(&array[1]) == 0x14);
}
test "pointer arithmetic affects the alignment" {
@@ -404,16 +404,16 @@ test "pointer arithmetic affects the alignment" {
}
}
-test "@ptrToInt on null optional at comptime" {
+test "@intFromPtr on null optional at comptime" {
{
- const pointer = @intToPtr(?*u8, 0x000);
- const x = @ptrToInt(pointer);
+ const pointer = @ptrFromInt(?*u8, 0x000);
+ const x = @intFromPtr(pointer);
_ = x;
- try comptime expect(0 == @ptrToInt(pointer));
+ try comptime expect(0 == @intFromPtr(pointer));
}
{
- const pointer = @intToPtr(?*u8, 0xf00);
- try comptime expect(0xf00 == @ptrToInt(pointer));
+ const pointer = @ptrFromInt(?*u8, 0xf00);
+ try comptime expect(0xf00 == @intFromPtr(pointer));
}
}
@@ -516,7 +516,7 @@ test "ptrCast comptime known slice to C pointer" {
try std.testing.expectEqualStrings(s, std.mem.sliceTo(p, 0));
}
-test "ptrToInt on a generic function" {
+test "intFromPtr on a generic function" {
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
@@ -527,7 +527,7 @@ test "ptrToInt on a generic function" {
return i;
}
fn doTheTest(a: anytype) !void {
- try expect(@ptrToInt(a) != 0);
+ try expect(@intFromPtr(a) != 0);
}
};
try S.doTheTest(&S.generic);
diff --git a/test/behavior/inttoptr.zig b/test/behavior/ptrfromint.zig
index 5a3778b09f..c07a6df834 100644
--- a/test/behavior/inttoptr.zig
+++ b/test/behavior/ptrfromint.zig
@@ -9,10 +9,10 @@ test "casting integer address to function pointer" {
fn addressToFunction() void {
var addr: usize = 0xdeadbee0;
- _ = @intToPtr(*const fn () void, addr);
+ _ = @ptrFromInt(*const fn () void, addr);
}
-test "mutate through ptr initialized with constant intToPtr value" {
+test "mutate through ptr initialized with constant ptrFromInt value" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
@@ -21,7 +21,7 @@ test "mutate through ptr initialized with constant intToPtr value" {
}
fn forceCompilerAnalyzeBranchHardCodedPtrDereference(x: bool) void {
- const hardCodedP = @intToPtr(*volatile u8, 0xdeadbeef);
+ const hardCodedP = @ptrFromInt(*volatile u8, 0xdeadbeef);
if (x) {
hardCodedP.* = hardCodedP.* | 10;
} else {
@@ -29,20 +29,20 @@ fn forceCompilerAnalyzeBranchHardCodedPtrDereference(x: bool) void {
}
}
-test "@intToPtr creates null pointer" {
+test "@ptrFromInt creates null pointer" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
- const ptr = @intToPtr(?*u32, 0);
+ const ptr = @ptrFromInt(?*u32, 0);
try expectEqual(@as(?*u32, null), ptr);
}
-test "@intToPtr creates allowzero zero pointer" {
+test "@ptrFromInt creates allowzero zero pointer" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
- const ptr = @intToPtr(*allowzero u32, 0);
- try expectEqual(@as(usize, 0), @ptrToInt(ptr));
+ const ptr = @ptrFromInt(*allowzero u32, 0);
+ try expectEqual(@as(usize, 0), @intFromPtr(ptr));
}
diff --git a/test/behavior/sizeof_and_typeof.zig b/test/behavior/sizeof_and_typeof.zig
index a14ae1c6e7..3657e77e50 100644
--- a/test/behavior/sizeof_and_typeof.zig
+++ b/test/behavior/sizeof_and_typeof.zig
@@ -92,15 +92,15 @@ test "@offsetOf" {
// // Normal struct fields can be moved/padded
var a: A = undefined;
- try expect(@ptrToInt(&a.a) - @ptrToInt(&a) == @offsetOf(A, "a"));
- try expect(@ptrToInt(&a.b) - @ptrToInt(&a) == @offsetOf(A, "b"));
- try expect(@ptrToInt(&a.c) - @ptrToInt(&a) == @offsetOf(A, "c"));
- try expect(@ptrToInt(&a.d) - @ptrToInt(&a) == @offsetOf(A, "d"));
- try expect(@ptrToInt(&a.e) - @ptrToInt(&a) == @offsetOf(A, "e"));
- try expect(@ptrToInt(&a.f) - @ptrToInt(&a) == @offsetOf(A, "f"));
- try expect(@ptrToInt(&a.g) - @ptrToInt(&a) == @offsetOf(A, "g"));
- try expect(@ptrToInt(&a.h) - @ptrToInt(&a) == @offsetOf(A, "h"));
- try expect(@ptrToInt(&a.i) - @ptrToInt(&a) == @offsetOf(A, "i"));
+ try expect(@intFromPtr(&a.a) - @intFromPtr(&a) == @offsetOf(A, "a"));
+ try expect(@intFromPtr(&a.b) - @intFromPtr(&a) == @offsetOf(A, "b"));
+ try expect(@intFromPtr(&a.c) - @intFromPtr(&a) == @offsetOf(A, "c"));
+ try expect(@intFromPtr(&a.d) - @intFromPtr(&a) == @offsetOf(A, "d"));
+ try expect(@intFromPtr(&a.e) - @intFromPtr(&a) == @offsetOf(A, "e"));
+ try expect(@intFromPtr(&a.f) - @intFromPtr(&a) == @offsetOf(A, "f"));
+ try expect(@intFromPtr(&a.g) - @intFromPtr(&a) == @offsetOf(A, "g"));
+ try expect(@intFromPtr(&a.h) - @intFromPtr(&a) == @offsetOf(A, "h"));
+ try expect(@intFromPtr(&a.i) - @intFromPtr(&a) == @offsetOf(A, "i"));
}
test "@bitOffsetOf" {
@@ -231,7 +231,7 @@ test "@sizeOf comparison against zero" {
test "hardcoded address in typeof expression" {
const S = struct {
- fn func() @TypeOf(@intToPtr(*[]u8, 0x10).*[0]) {
+ fn func() @TypeOf(@ptrFromInt(*[]u8, 0x10).*[0]) {
return 0;
}
};
@@ -252,7 +252,7 @@ test "array access of generic param in typeof expression" {
test "lazy size cast to float" {
{
const S = struct { a: u8 };
- try expect(@intToFloat(f32, @sizeOf(S)) == 1.0);
+ try expect(@floatFromInt(f32, @sizeOf(S)) == 1.0);
}
{
const S = struct { a: u8 };
diff --git a/test/behavior/slice.zig b/test/behavior/slice.zig
index ae5fbf0951..fcbae214ac 100644
--- a/test/behavior/slice.zig
+++ b/test/behavior/slice.zig
@@ -138,10 +138,10 @@ fn memFree(comptime T: type, memory: []T) void {
test "slice of hardcoded address to pointer" {
const S = struct {
fn doTheTest() !void {
- const pointer = @intToPtr([*]u8, 0x04)[0..2];
+ const pointer = @ptrFromInt([*]u8, 0x04)[0..2];
try comptime expect(@TypeOf(pointer) == *[2]u8);
const slice: []const u8 = pointer;
- try expect(@ptrToInt(slice.ptr) == 4);
+ try expect(@intFromPtr(slice.ptr) == 4);
try expect(slice.len == 2);
}
};
@@ -197,13 +197,13 @@ test "slicing pointer by length" {
}
}
-const x = @intToPtr([*]i32, 0x1000)[0..0x500];
+const x = @ptrFromInt([*]i32, 0x1000)[0..0x500];
const y = x[0x100..];
test "compile time slice of pointer to hard coded address" {
- try expect(@ptrToInt(x) == 0x1000);
+ try expect(@intFromPtr(x) == 0x1000);
try expect(x.len == 0x500);
- try expect(@ptrToInt(y) == 0x1400);
+ try expect(@intFromPtr(y) == 0x1400);
try expect(y.len == 0x400);
}
@@ -838,13 +838,13 @@ test "empty slice ptr is non null" {
const empty_slice: []u8 = &[_]u8{};
const p: [*]u8 = empty_slice.ptr + 0;
const t = @ptrCast([*]i8, p);
- try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr));
+ try expect(@intFromPtr(t) == @intFromPtr(empty_slice.ptr));
}
{
const empty_slice: []u8 = &.{};
const p: [*]u8 = empty_slice.ptr + 0;
const t = @ptrCast([*]i8, p);
- try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr));
+ try expect(@intFromPtr(t) == @intFromPtr(empty_slice.ptr));
}
}
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig
index 6686c911a5..6ced42998e 100644
--- a/test/behavior/struct.zig
+++ b/test/behavior/struct.zig
@@ -838,7 +838,7 @@ test "non-packed struct with u128 entry in union" {
var sx: S = undefined;
var s = &sx;
- try expect(@ptrToInt(&s.f2) - @ptrToInt(&s.f1) == @offsetOf(S, "f2"));
+ try expect(@intFromPtr(&s.f2) - @intFromPtr(&s.f1) == @offsetOf(S, "f2"));
var v2 = U{ .Num = 123 };
s.f2 = v2;
try expect(s.f2.Num == 123);
diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig
index 02e3ef4dce..f9fb9c7659 100644
--- a/test/behavior/switch.zig
+++ b/test/behavior/switch.zig
@@ -590,9 +590,9 @@ test "switch on pointer type" {
field: u32,
};
- const P1 = @intToPtr(*X, 0x400);
- const P2 = @intToPtr(*X, 0x800);
- const P3 = @intToPtr(*X, 0xC00);
+ const P1 = @ptrFromInt(*X, 0x400);
+ const P2 = @ptrFromInt(*X, 0x800);
+ const P3 = @ptrFromInt(*X, 0xC00);
fn doTheTest(arg: *X) i32 {
switch (arg) {
@@ -682,9 +682,9 @@ test "enum value without tag name used as switch item" {
b = 2,
_,
};
- var e: E = @intToEnum(E, 0);
+ var e: E = @enumFromInt(E, 0);
switch (e) {
- @intToEnum(E, 0) => {},
+ @enumFromInt(E, 0) => {},
.a => return error.TestFailed,
.b => return error.TestFailed,
_ => return error.TestFailed,
diff --git a/test/behavior/translate_c_macros.zig b/test/behavior/translate_c_macros.zig
index b3d1a688fe..a69396c203 100644
--- a/test/behavior/translate_c_macros.zig
+++ b/test/behavior/translate_c_macros.zig
@@ -60,7 +60,7 @@ test "cast negative integer to pointer" {
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
- try expectEqual(@intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -1))), h.MAP_FAILED);
+ try expectEqual(@ptrFromInt(?*anyopaque, @bitCast(usize, @as(isize, -1))), h.MAP_FAILED);
}
test "casting to union with a macro" {
diff --git a/test/behavior/type.zig b/test/behavior/type.zig
index 94a6b460e4..9420b5d2fd 100644
--- a/test/behavior/type.zig
+++ b/test/behavior/type.zig
@@ -363,8 +363,8 @@ test "Type.Enum" {
},
});
try testing.expectEqual(true, @typeInfo(Foo).Enum.is_exhaustive);
- try testing.expectEqual(@as(u8, 1), @enumToInt(Foo.a));
- try testing.expectEqual(@as(u8, 5), @enumToInt(Foo.b));
+ try testing.expectEqual(@as(u8, 1), @intFromEnum(Foo.a));
+ try testing.expectEqual(@as(u8, 5), @intFromEnum(Foo.b));
const Bar = @Type(.{
.Enum = .{
.tag_type = u32,
@@ -377,9 +377,9 @@ test "Type.Enum" {
},
});
try testing.expectEqual(false, @typeInfo(Bar).Enum.is_exhaustive);
- try testing.expectEqual(@as(u32, 1), @enumToInt(Bar.a));
- try testing.expectEqual(@as(u32, 5), @enumToInt(Bar.b));
- try testing.expectEqual(@as(u32, 6), @enumToInt(@intToEnum(Bar, 6)));
+ try testing.expectEqual(@as(u32, 1), @intFromEnum(Bar.a));
+ try testing.expectEqual(@as(u32, 5), @intFromEnum(Bar.b));
+ try testing.expectEqual(@as(u32, 6), @intFromEnum(@enumFromInt(Bar, 6)));
}
test "Type.Union" {
diff --git a/test/behavior/union.zig b/test/behavior/union.zig
index c94695ff21..33cf1198ad 100644
--- a/test/behavior/union.zig
+++ b/test/behavior/union.zig
@@ -364,7 +364,7 @@ test "simple union(enum(u32))" {
var x = MultipleChoice.C;
try expect(x == MultipleChoice.C);
- try expect(@enumToInt(@as(Tag(MultipleChoice), x)) == 60);
+ try expect(@intFromEnum(@as(Tag(MultipleChoice), x)) == 60);
}
const PackedPtrOrInt = packed union {
@@ -655,7 +655,7 @@ const MultipleChoice2 = union(enum(u32)) {
};
fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: MultipleChoice2) !void {
- try expect(@enumToInt(@as(Tag(MultipleChoice2), x)) == 60);
+ try expect(@intFromEnum(@as(Tag(MultipleChoice2), x)) == 60);
try expect(1123 == switch (x) {
MultipleChoice2.A => 1,
MultipleChoice2.B => 2,
@@ -721,11 +721,11 @@ test "union with only 1 field casted to its enum type which has enum value speci
try comptime expect(Tag(ExprTag) == comptime_int);
comptime var t = @as(ExprTag, e);
try expect(t == Expr.Literal);
- try expect(@enumToInt(t) == 33);
- try comptime expect(@enumToInt(t) == 33);
+ try expect(@intFromEnum(t) == 33);
+ try comptime expect(@intFromEnum(t) == 33);
}
-test "@enumToInt works on unions" {
+test "@intFromEnum works on unions" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
@@ -739,9 +739,9 @@ test "@enumToInt works on unions" {
const a = Bar{ .A = true };
var b = Bar{ .B = undefined };
var c = Bar.C;
- try expect(@enumToInt(a) == 0);
- try expect(@enumToInt(b) == 1);
- try expect(@enumToInt(c) == 2);
+ try expect(@intFromEnum(a) == 0);
+ try expect(@intFromEnum(b) == 1);
+ try expect(@intFromEnum(c) == 2);
}
test "comptime union field value equality" {
@@ -1396,7 +1396,7 @@ test "@unionInit uses tag value instead of field index" {
var a = &u.b;
try expect(a.* == i);
}
- try expect(@enumToInt(u) == 255);
+ try expect(@intFromEnum(u) == 255);
}
test "union field ptr - zero sized payload" {
diff --git a/test/behavior/vector.zig b/test/behavior/vector.zig
index 367a21fc0a..47864a83c9 100644
--- a/test/behavior/vector.zig
+++ b/test/behavior/vector.zig
@@ -1173,7 +1173,7 @@ test "byte vector initialized in inline function" {
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
if (comptime builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .x86_64 and
- builtin.cpu.features.isEnabled(@enumToInt(std.Target.x86.Feature.avx512f)))
+ builtin.cpu.features.isEnabled(@intFromEnum(std.Target.x86.Feature.avx512f)))
{
// TODO https://github.com/ziglang/zig/issues/13279
return error.SkipZigTest;
diff --git a/test/c_abi/main.zig b/test/c_abi/main.zig
index db76697473..f06d455060 100644
--- a/test/c_abi/main.zig
+++ b/test/c_abi/main.zig
@@ -143,11 +143,11 @@ export fn zig_longdouble(x: c_longdouble) void {
extern fn c_ptr(*anyopaque) void;
test "C ABI pointer" {
- c_ptr(@intToPtr(*anyopaque, 0xdeadbeef));
+ c_ptr(@ptrFromInt(*anyopaque, 0xdeadbeef));
}
export fn zig_ptr(x: *anyopaque) void {
- expect(@ptrToInt(x) == 0xdeadbeef) catch @panic("test failure: zig_ptr");
+ expect(@intFromPtr(x) == 0xdeadbeef) catch @panic("test failure: zig_ptr");
}
extern fn c_bool(bool) void;
@@ -1058,14 +1058,14 @@ test "C function that takes byval struct called via function pointer" {
var fn_ptr = &c_func_ptr_byval;
fn_ptr(
- @intToPtr(*anyopaque, 1),
- @intToPtr(*anyopaque, 2),
+ @ptrFromInt(*anyopaque, 1),
+ @ptrFromInt(*anyopaque, 2),
ByVal{
.origin = .{ .x = 9, .y = 10, .z = 11 },
.size = .{ .width = 12, .height = 13, .depth = 14 },
},
@as(c_ulong, 3),
- @intToPtr(*anyopaque, 4),
+ @ptrFromInt(*anyopaque, 4),
@as(c_ulong, 5),
);
}
diff --git a/test/cases/assert_function.18.zig b/test/cases/assert_function.18.zig
index 5f05e4ae70..ac0f97c40f 100644
--- a/test/cases/assert_function.18.zig
+++ b/test/cases/assert_function.18.zig
@@ -7,7 +7,7 @@ pub fn main() void {
}
fn print() void {
- _ = write(1, @ptrToInt("hello\n"), 6);
+ _ = write(1, @intFromPtr("hello\n"), 6);
}
// run
diff --git a/test/cases/assert_function.7.zig b/test/cases/assert_function.7.zig
index 0004435db6..9db604d3b9 100644
--- a/test/cases/assert_function.7.zig
+++ b/test/cases/assert_function.7.zig
@@ -7,7 +7,7 @@ pub fn main() void {
}
fn print() void {
- _ = write(1, @ptrToInt("hello\n"), 6);
+ _ = write(1, @intFromPtr("hello\n"), 6);
}
pub fn assert(ok: bool) void {
diff --git a/test/cases/assert_function.8.zig b/test/cases/assert_function.8.zig
index 3e8e247dac..02b486a8cb 100644
--- a/test/cases/assert_function.8.zig
+++ b/test/cases/assert_function.8.zig
@@ -7,7 +7,7 @@ pub fn main() void {
}
fn print() void {
- _ = write(1, @ptrToInt("hello\n"), 6);
+ _ = write(1, @intFromPtr("hello\n"), 6);
}
pub fn assert(ok: bool) void {
diff --git a/test/cases/compile_errors/add_overflow_in_function_evaluation.zig b/test/cases/compile_errors/add_overflow_in_function_evaluation.zig
index 2f8a4678d3..ef1a016711 100644
--- a/test/cases/compile_errors/add_overflow_in_function_evaluation.zig
+++ b/test/cases/compile_errors/add_overflow_in_function_evaluation.zig
@@ -3,7 +3,9 @@ fn add(a: u16, b: u16) u16 {
return a + b;
}
-export fn entry() usize { return @sizeOf(@TypeOf(y)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(y));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/addition_with_non_numbers.zig b/test/cases/compile_errors/addition_with_non_numbers.zig
index 3687df914f..1b60d1ba9a 100644
--- a/test/cases/compile_errors/addition_with_non_numbers.zig
+++ b/test/cases/compile_errors/addition_with_non_numbers.zig
@@ -1,12 +1,14 @@
const Foo = struct {
field: i32,
};
-const x = Foo {.field = 1} + Foo {.field = 2};
+const x = Foo{ .field = 1 } + Foo{ .field = 2 };
-export fn entry() usize { return @sizeOf(@TypeOf(x)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(x));
+}
// error
// backend=llvm
// target=native
//
-// :4:28: error: invalid operands to binary expression: 'Struct' and 'Struct'
+// :4:29: error: invalid operands to binary expression: 'Struct' and 'Struct'
diff --git a/test/cases/compile_errors/address_of_number_literal.zig b/test/cases/compile_errors/address_of_number_literal.zig
index c6b41a1495..e41fbd229c 100644
--- a/test/cases/compile_errors/address_of_number_literal.zig
+++ b/test/cases/compile_errors/address_of_number_literal.zig
@@ -1,12 +1,16 @@
const x = 3;
const y = &x;
-fn foo() *const i32 { return y; }
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+fn foo() *const i32 {
+ return y;
+}
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=stage2
// target=native
//
-// :3:30: error: expected type '*const i32', found '*const comptime_int'
-// :3:30: note: pointer type child 'comptime_int' cannot cast into pointer type child 'i32'
+// :4:12: error: expected type '*const i32', found '*const comptime_int'
+// :4:12: note: pointer type child 'comptime_int' cannot cast into pointer type child 'i32'
// :3:10: note: function return type declared here
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 14ffa6f499..ecb06aa254 100644
--- a/test/cases/compile_errors/alignment_of_enum_field_specified.zig
+++ b/test/cases/compile_errors/alignment_of_enum_field_specified.zig
@@ -1,7 +1,10 @@
+// zig fmt: off
const Number = enum {
a,
b align(i32),
};
+// zig fmt: on
+
export fn entry1() void {
var x: Number = undefined;
_ = x;
@@ -11,4 +14,4 @@ export fn entry1() void {
// backend=stage2
// target=native
//
-// :3:13: error: enum fields cannot be aligned
+// :4:13: error: enum fields cannot be aligned
diff --git a/test/cases/compile_errors/array_concatenation_with_wrong_type.zig b/test/cases/compile_errors/array_concatenation_with_wrong_type.zig
index 6f2648f74b..5c634eceb0 100644
--- a/test/cases/compile_errors/array_concatenation_with_wrong_type.zig
+++ b/test/cases/compile_errors/array_concatenation_with_wrong_type.zig
@@ -2,7 +2,9 @@ const src = "aoeu";
const derp: usize = 1234;
const a = derp ++ "foo";
-export fn entry() usize { return @sizeOf(@TypeOf(a)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(a));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/array_mult_with_number_type.zig b/test/cases/compile_errors/array_mult_with_number_type.zig
index d3ec870f4e..bd47c3b56f 100644
--- a/test/cases/compile_errors/array_mult_with_number_type.zig
+++ b/test/cases/compile_errors/array_mult_with_number_type.zig
@@ -7,4 +7,4 @@ export fn entry(base: f32, exponent: f32) f32 {
// target=native
//
// :2:12: error: expected indexable; found 'f32'
-// :2:17: note: this operator multiplies arrays; use std.math.pow for exponentiation \ No newline at end of file
+// :2:17: note: this operator multiplies arrays; use std.math.pow for exponentiation
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 857123eae5..b16cb8f66e 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
@@ -2,7 +2,7 @@ export fn entry() void {
var a = &b;
_ = a;
}
-fn b() callconv(.Inline) void { }
+inline fn b() void {}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/assign_null_to_non-optional_pointer.zig b/test/cases/compile_errors/assign_null_to_non-optional_pointer.zig
index ca36dbfbfb..cc410e6228 100644
--- a/test/cases/compile_errors/assign_null_to_non-optional_pointer.zig
+++ b/test/cases/compile_errors/assign_null_to_non-optional_pointer.zig
@@ -1,6 +1,8 @@
const a: *u8 = null;
-export fn entry() usize { return @sizeOf(@TypeOf(a)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(a));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/assign_through_constant_pointer.zig b/test/cases/compile_errors/assign_through_constant_pointer.zig
index 674d0875aa..7cc7a4b6ab 100644
--- a/test/cases/compile_errors/assign_through_constant_pointer.zig
+++ b/test/cases/compile_errors/assign_through_constant_pointer.zig
@@ -1,10 +1,10 @@
export fn f() void {
- var cstr = "Hat";
- cstr[0] = 'W';
+ var cstr = "Hat";
+ cstr[0] = 'W';
}
// error
// backend=stage2
// target=native
//
-// :3:7: error: cannot assign to constant
+// :3:9: error: cannot assign to constant
diff --git a/test/cases/compile_errors/assign_through_constant_slice.zig b/test/cases/compile_errors/assign_through_constant_slice.zig
index 08910b6248..9ac006a1a4 100644
--- a/test/cases/compile_errors/assign_through_constant_slice.zig
+++ b/test/cases/compile_errors/assign_through_constant_slice.zig
@@ -1,10 +1,10 @@
export fn f() void {
- var cstr: []const u8 = "Hat";
- cstr[0] = 'W';
+ var cstr: []const u8 = "Hat";
+ cstr[0] = 'W';
}
// error
// backend=stage2
// target=native
//
-// :3:7: error: cannot assign to constant
+// :3:9: error: cannot assign to constant
diff --git a/test/cases/compile_errors/assign_to_constant_field.zig b/test/cases/compile_errors/assign_to_constant_field.zig
index 33f08344c4..312ff44e0e 100644
--- a/test/cases/compile_errors/assign_to_constant_field.zig
+++ b/test/cases/compile_errors/assign_to_constant_field.zig
@@ -2,7 +2,9 @@ const Foo = struct {
field: i32,
};
export fn derp() void {
- const f = Foo {.field = 1234,};
+ const f = Foo{
+ .field = 1234,
+ };
f.field = 0;
}
@@ -10,4 +12,4 @@ export fn derp() void {
// backend=stage2
// target=native
//
-// :6:6: error: cannot assign to constant
+// :8:6: error: cannot assign to constant
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 d8ab4087e0..82cbb4469a 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
@@ -3,7 +3,7 @@ export fn entry() void {
var bytes: [100]u8 align(16) = undefined;
_ = @asyncCall(&bytes, {}, ptr, .{});
}
-fn afunc() void { }
+fn afunc() void {}
// error
// backend=stage1
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 066bf1c107..bdf7bec458 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
@@ -21,4 +21,4 @@ fn func() void {}
//
// :3:28: error: expected type 'anyframe->i32', found 'anyframe'
// :8:28: error: expected type 'anyframe->i32', found 'i32'
-// tmp.zig:13:29: error: expected type 'anyframe->i32', found '*@Frame(func)' \ No newline at end of file
+// tmp.zig:13:29: error: expected type 'anyframe->i32', found '*@Frame(func)'
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 c66d0f9cbb..bfc22cca25 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
@@ -3,7 +3,7 @@ export fn entry() void {
_ = async ptr();
}
-fn afunc() callconv(.Async) void { }
+fn afunc() callconv(.Async) void {}
// error
// backend=stage1
diff --git a/test/cases/compile_errors/bad_alignCast_at_comptime.zig b/test/cases/compile_errors/bad_alignCast_at_comptime.zig
index 0d2d91ece3..885700ecac 100644
--- a/test/cases/compile_errors/bad_alignCast_at_comptime.zig
+++ b/test/cases/compile_errors/bad_alignCast_at_comptime.zig
@@ -1,5 +1,5 @@
comptime {
- const ptr = @intToPtr(*align(1) i32, 0x1);
+ const ptr = @ptrFromInt(*align(1) i32, 0x1);
const aligned = @alignCast(4, ptr);
_ = aligned;
}
diff --git a/test/cases/compile_errors/bad_import.zig b/test/cases/compile_errors/bad_import.zig
index e624d7104c..521331e345 100644
--- a/test/cases/compile_errors/bad_import.zig
+++ b/test/cases/compile_errors/bad_import.zig
@@ -1,4 +1,6 @@
-const bogus = @import("bogus-does-not-exist.zig",);
+const bogus = @import(
+ "bogus-does-not-exist.zig",
+);
// error
// backend=stage2
diff --git a/test/cases/compile_errors/binary_not_on_number_literal.zig b/test/cases/compile_errors/binary_not_on_number_literal.zig
index cb57ca9ee1..455b79130a 100644
--- a/test/cases/compile_errors/binary_not_on_number_literal.zig
+++ b/test/cases/compile_errors/binary_not_on_number_literal.zig
@@ -2,7 +2,9 @@ const TINY_QUANTUM_SHIFT = 4;
const TINY_QUANTUM_SIZE = 1 << TINY_QUANTUM_SHIFT;
var block_aligned_stuff: usize = (4 + TINY_QUANTUM_SIZE) & ~(TINY_QUANTUM_SIZE - 1);
-export fn entry() usize { return @sizeOf(@TypeOf(block_aligned_stuff)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(block_aligned_stuff));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/bitCast_to_enum_type.zig b/test/cases/compile_errors/bitCast_to_enum_type.zig
index a8fedb7d54..b3bc72c21b 100644
--- a/test/cases/compile_errors/bitCast_to_enum_type.zig
+++ b/test/cases/compile_errors/bitCast_to_enum_type.zig
@@ -9,4 +9,4 @@ export fn entry() void {
// target=native
//
// :3:24: error: cannot @bitCast to 'tmp.entry.E'
-// :3:24: note: use @intToEnum to cast from 'u32'
+// :3:24: note: use @enumFromInt to cast from 'u32'
diff --git a/test/cases/compile_errors/bogus_compile_var.zig b/test/cases/compile_errors/bogus_compile_var.zig
index be222e5393..4780423cae 100644
--- a/test/cases/compile_errors/bogus_compile_var.zig
+++ b/test/cases/compile_errors/bogus_compile_var.zig
@@ -1,5 +1,7 @@
const x = @import("builtin").bogus;
-export fn entry() usize { return @sizeOf(@TypeOf(x)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(x));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/bogus_method_call_on_slice.zig b/test/cases/compile_errors/bogus_method_call_on_slice.zig
index ed18f43f48..694993074c 100644
--- a/test/cases/compile_errors/bogus_method_call_on_slice.zig
+++ b/test/cases/compile_errors/bogus_method_call_on_slice.zig
@@ -2,7 +2,9 @@ var self = "aoeu";
fn f(m: []const u8) void {
m.copy(u8, self[0..], m);
}
-export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&f));
+}
pub export fn entry1() void {
.{}.bar();
}
@@ -14,6 +16,6 @@ pub export fn entry2() void {
// backend=stage2
// target=native
//
-// :7:8: error: no field or member function named 'bar' in '@TypeOf(.{})'
-// :10:18: error: no field or member function named 'bar' in 'struct{comptime foo: comptime_int = 1}'
+// :9:8: error: no field or member function named 'bar' in '@TypeOf(.{})'
+// :12:18: error: no field or member function named 'bar' in 'struct{comptime foo: comptime_int = 1}'
// :3:6: error: no field or member function named 'copy' in '[]const u8'
diff --git a/test/cases/compile_errors/branch_on_undefined_value.zig b/test/cases/compile_errors/branch_on_undefined_value.zig
index a0a3be83cf..fc30fe7d3c 100644
--- a/test/cases/compile_errors/branch_on_undefined_value.zig
+++ b/test/cases/compile_errors/branch_on_undefined_value.zig
@@ -1,6 +1,8 @@
const x = if (undefined) true else false;
-export fn entry() usize { return @sizeOf(@TypeOf(x)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(x));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/calling_function_with_naked_calling_convention.zig b/test/cases/compile_errors/calling_function_with_naked_calling_convention.zig
index 54bf585425..2bd0364d4f 100644
--- a/test/cases/compile_errors/calling_function_with_naked_calling_convention.zig
+++ b/test/cases/compile_errors/calling_function_with_naked_calling_convention.zig
@@ -1,7 +1,7 @@
export fn entry() void {
foo();
}
-fn foo() callconv(.Naked) void { }
+fn foo() callconv(.Naked) void {}
// error
// backend=llvm
diff --git a/test/cases/compile_errors/calling_var_args_extern_function_passing_array_instead_of_pointer.zig b/test/cases/compile_errors/calling_var_args_extern_function_passing_array_instead_of_pointer.zig
index c9e2e2e5eb..0960c35074 100644
--- a/test/cases/compile_errors/calling_var_args_extern_function_passing_array_instead_of_pointer.zig
+++ b/test/cases/compile_errors/calling_var_args_extern_function_passing_array_instead_of_pointer.zig
@@ -1,5 +1,7 @@
export fn entry() void {
- foo("hello".*,);
+ foo(
+ "hello".*,
+ );
}
pub extern fn foo(format: *const u8, ...) void;
@@ -7,5 +9,5 @@ pub extern fn foo(format: *const u8, ...) void;
// backend=stage2
// target=native
//
-// :2:16: error: expected type '*const u8', found '[5:0]u8'
-// :4:27: note: parameter type declared here
+// :3:16: error: expected type '*const u8', found '[5:0]u8'
+// :6:27: note: parameter type declared here
diff --git a/test/cases/compile_errors/cast_unreachable.zig b/test/cases/compile_errors/cast_unreachable.zig
index cf2331ff7e..39da655d7f 100644
--- a/test/cases/compile_errors/cast_unreachable.zig
+++ b/test/cases/compile_errors/cast_unreachable.zig
@@ -1,7 +1,9 @@
fn f() i32 {
return @as(i32, return 1);
}
-export fn entry() void { _ = f(); }
+export fn entry() void {
+ _ = f();
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig b/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig
index f9df19802a..8cf62c8ec0 100644
--- a/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig
+++ b/test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig
@@ -12,7 +12,9 @@ fn bar(x: *const u3) u3 {
return x.*;
}
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/colliding_invalid_top_level_functions.zig b/test/cases/compile_errors/colliding_invalid_top_level_functions.zig
index ee0711088d..8a2adb2f07 100644
--- a/test/cases/compile_errors/colliding_invalid_top_level_functions.zig
+++ b/test/cases/compile_errors/colliding_invalid_top_level_functions.zig
@@ -1,6 +1,8 @@
fn func() bogus {}
fn func() bogus {}
-export fn entry() usize { return @sizeOf(@TypeOf(func)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(func));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/compileError_shows_traceback_of_references_that_caused_it.zig b/test/cases/compile_errors/compileError_shows_traceback_of_references_that_caused_it.zig
index 092cbbd400..d5206671fb 100644
--- a/test/cases/compile_errors/compileError_shows_traceback_of_references_that_caused_it.zig
+++ b/test/cases/compile_errors/compileError_shows_traceback_of_references_that_caused_it.zig
@@ -1,4 +1,6 @@
-const foo = @compileError("aoeu",);
+const foo = @compileError(
+ "aoeu",
+);
const bar = baz + foo;
const baz = 1;
diff --git a/test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig b/test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig
index 4b31d9924a..2e2addbc2e 100644
--- a/test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig
+++ b/test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig
@@ -4,15 +4,17 @@ export fn entry() void {
}
fn inner(comptime n: usize) void {
comptime var i = 0;
- inline while (i < n) : (i += 1) { @compileLog("!@#$"); }
+ inline while (i < n) : (i += 1) {
+ @compileLog("!@#$");
+ }
}
// error
// backend=llvm
// target=native
//
-// :7:39: error: found compile log statement
-// :7:39: note: also here
+// :8:9: error: found compile log statement
+// :8:9: note: also here
//
// Compile Log Output:
// @as(*const [4:0]u8, "!@#$")
diff --git a/test/cases/compile_errors/compile_time_division_by_zero.zig b/test/cases/compile_errors/compile_time_division_by_zero.zig
index 281ccf28a1..8954ace9ab 100644
--- a/test/cases/compile_errors/compile_time_division_by_zero.zig
+++ b/test/cases/compile_errors/compile_time_division_by_zero.zig
@@ -3,7 +3,9 @@ fn foo(x: u32) u32 {
return 1 / x;
}
-export fn entry() usize { return @sizeOf(@TypeOf(y)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(y));
+}
// error
// backend=llvm
diff --git a/test/cases/compile_errors/comptime_call_of_function_pointer.zig b/test/cases/compile_errors/comptime_call_of_function_pointer.zig
index cf01f5ea2c..d6598aab39 100644
--- a/test/cases/compile_errors/comptime_call_of_function_pointer.zig
+++ b/test/cases/compile_errors/comptime_call_of_function_pointer.zig
@@ -1,5 +1,5 @@
export fn entry() void {
- const fn_ptr = @intToPtr(*align(1) fn () void, 0xffd2);
+ const fn_ptr = @ptrFromInt(*align(1) fn () void, 0xffd2);
comptime fn_ptr();
}
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 6200776d18..40055a70b9 100644
--- a/test/cases/compile_errors/comptime_if_inside_runtime_for.zig
+++ b/test/cases/compile_errors/comptime_if_inside_runtime_for.zig
@@ -1,14 +1,14 @@
export fn entry() void {
- var x: u32 = 0;
- for(0..1, 1..2) |_, _| {
- var y = x + if(x == 0) 1 else 0;
- _ = y;
- }
+ var x: u32 = 0;
+ for (0..1, 1..2) |_, _| {
+ var y = x + if (x == 0) 1 else 0;
+ _ = y;
+ }
}
// error
// backend=stage2
// target=native
//
-// :4:15: error: value with comptime-only type 'comptime_int' depends on runtime control flow
-// :3:6: note: runtime control flow here
+// :4:21: error: value with comptime-only type 'comptime_int' depends on runtime control flow
+// :3:10: note: runtime control flow here
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 2b67390b05..1ce744d6d7 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,7 +1,9 @@
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 {
diff --git a/test/cases/compile_errors/container_init_with_non-type.zig b/test/cases/compile_errors/container_init_with_non-type.zig
index aa62be6dc5..7bdf07a1ce 100644
--- a/test/cases/compile_errors/container_init_with_non-type.zig
+++ b/test/cases/compile_errors/container_init_with_non-type.zig
@@ -1,7 +1,9 @@
const zero: i32 = 0;
const a = zero{1};
-export fn entry() usize { return @sizeOf(@TypeOf(a)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(a));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/control_flow_uses_comptime_var_at_runtime.zig b/test/cases/compile_errors/control_flow_uses_comptime_var_at_runtime.zig
index a8058e8c75..5283239af6 100644
--- a/test/cases/compile_errors/control_flow_uses_comptime_var_at_runtime.zig
+++ b/test/cases/compile_errors/control_flow_uses_comptime_var_at_runtime.zig
@@ -5,7 +5,7 @@ export fn foo() void {
}
}
-fn bar() void { }
+fn bar() void {}
export fn baz() void {
comptime var idx: u32 = 0;
while (idx < 1) {
diff --git a/test/cases/compile_errors/dereference_an_array.zig b/test/cases/compile_errors/dereference_an_array.zig
index f5aabf081c..27e4d81e55 100644
--- a/test/cases/compile_errors/dereference_an_array.zig
+++ b/test/cases/compile_errors/dereference_an_array.zig
@@ -5,7 +5,9 @@ pub fn pass(in: []u8) []u8 {
return out.*[0..1];
}
-export fn entry() usize { return @sizeOf(@TypeOf(&pass)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&pass));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/direct_struct_loop.zig b/test/cases/compile_errors/direct_struct_loop.zig
index 0abc1a4f73..9fdda1bdc7 100644
--- a/test/cases/compile_errors/direct_struct_loop.zig
+++ b/test/cases/compile_errors/direct_struct_loop.zig
@@ -1,9 +1,13 @@
-const A = struct { a : A, };
-export fn entry() usize { return @sizeOf(A); }
+const A = struct {
+ a: A,
+};
+export fn entry() usize {
+ return @sizeOf(A);
+}
// error
// backend=stage2
// target=native
//
// :1:11: error: struct 'tmp.A' depends on itself
-// :1:20: note: while checking this field
+// :2:5: note: while checking this field
diff --git a/test/cases/compile_errors/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig b/test/cases/compile_errors/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig
index 3670def4ee..45fa4c14f5 100644
--- a/test/cases/compile_errors/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig
+++ b/test/cases/compile_errors/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig
@@ -1,6 +1,6 @@
extern fn puts(s: [*:0]const u8) c_int;
pub export fn entry() void {
- const no_zero_array = [_]u8{'h', 'e', 'l', 'l', 'o'};
+ const no_zero_array = [_]u8{ 'h', 'e', 'l', 'l', 'o' };
const no_zero_ptr: [*]const u8 = &no_zero_array;
_ = puts(no_zero_ptr);
}
diff --git a/test/cases/compile_errors/division_by_zero.zig b/test/cases/compile_errors/division_by_zero.zig
index 2e2f7e2be2..3019554fb8 100644
--- a/test/cases/compile_errors/division_by_zero.zig
+++ b/test/cases/compile_errors/division_by_zero.zig
@@ -3,10 +3,18 @@ const lit_float_x = 1.0 / 0.0;
const int_x = @as(u32, 1) / @as(u32, 0);
const float_x = @as(f32, 1.0) / @as(f32, 0.0);
-export fn entry1() usize { return @sizeOf(@TypeOf(lit_int_x)); }
-export fn entry2() usize { return @sizeOf(@TypeOf(lit_float_x)); }
-export fn entry3() usize { return @sizeOf(@TypeOf(int_x)); }
-export fn entry4() usize { return @sizeOf(@TypeOf(float_x)); } // no error on purpose
+export fn entry1() usize {
+ return @sizeOf(@TypeOf(lit_int_x));
+}
+export fn entry2() usize {
+ return @sizeOf(@TypeOf(lit_float_x));
+}
+export fn entry3() usize {
+ return @sizeOf(@TypeOf(int_x));
+}
+export fn entry4() usize {
+ return @sizeOf(@TypeOf(float_x));
+} // no error on purpose
// error
// backend=stage2
diff --git a/test/cases/compile_errors/duplicate-unused_labels.zig b/test/cases/compile_errors/duplicate-unused_labels.zig
index 4bfc6c5960..301d273bde 100644
--- a/test/cases/compile_errors/duplicate-unused_labels.zig
+++ b/test/cases/compile_errors/duplicate-unused_labels.zig
@@ -1,31 +1,37 @@
comptime {
- blk: { blk: while (false) {} }
+ blk: {
+ blk: while (false) {}
+ }
}
comptime {
- blk: while (false) { blk: for (@as([0]void, undefined)) |_| {} }
+ blk: while (false) {
+ blk: for (@as([0]void, undefined)) |_| {}
+ }
}
comptime {
- blk: for (@as([0]void, undefined)) |_| { blk: {} }
+ blk: for (@as([0]void, undefined)) |_| {
+ blk: {}
+ }
}
comptime {
blk: {}
}
comptime {
- blk: while(false) {}
+ blk: while (false) {}
}
comptime {
- blk: for(@as([0]void, undefined)) |_| {}
+ blk: for (@as([0]void, undefined)) |_| {}
}
// error
// target=native
//
-// :2:12: error: redefinition of label 'blk'
+// :3:9: error: redefinition of label 'blk'
// :2:5: note: previous definition here
-// :5:26: error: redefinition of label 'blk'
-// :5:5: note: previous definition here
-// :8:46: error: redefinition of label 'blk'
-// :8:5: note: previous definition here
-// :11:5: error: unused block label
-// :14:5: error: unused while loop label
-// :17:5: error: unused for loop label
+// :8:9: error: redefinition of label 'blk'
+// :7:5: note: previous definition here
+// :13:9: error: redefinition of label 'blk'
+// :12:5: note: previous definition here
+// :17:5: error: unused block label
+// :20:5: error: unused while loop label
+// :23:5: error: unused for loop label
diff --git a/test/cases/compile_errors/duplicate_error_value_in_error_set.zig b/test/cases/compile_errors/duplicate_error_value_in_error_set.zig
index 5e9cddb975..927537d952 100644
--- a/test/cases/compile_errors/duplicate_error_value_in_error_set.zig
+++ b/test/cases/compile_errors/duplicate_error_value_in_error_set.zig
@@ -1,4 +1,4 @@
-const Foo = error {
+const Foo = error{
Bar,
Bar,
};
diff --git a/test/cases/compile_errors/duplicate_field_in_struct_value_expression.zig b/test/cases/compile_errors/duplicate_field_in_struct_value_expression.zig
index fa5bc6fb4e..eda001c086 100644
--- a/test/cases/compile_errors/duplicate_field_in_struct_value_expression.zig
+++ b/test/cases/compile_errors/duplicate_field_in_struct_value_expression.zig
@@ -1,10 +1,10 @@
const A = struct {
- x : i32,
- y : i32,
- z : i32,
+ x: i32,
+ y: i32,
+ z: i32,
};
export fn f() void {
- const a = A {
+ const a = A{
.z = 1,
.y = 2,
.x = 3,
diff --git a/test/cases/compile_errors/embedFile_with_bogus_file.zig b/test/cases/compile_errors/embedFile_with_bogus_file.zig
index fa05d1ed49..956ea31f07 100644
--- a/test/cases/compile_errors/embedFile_with_bogus_file.zig
+++ b/test/cases/compile_errors/embedFile_with_bogus_file.zig
@@ -1,6 +1,8 @@
-const resource = @embedFile("bogus.txt",);
+const resource = @embedFile("bogus.txt");
-export fn entry() usize { return @sizeOf(@TypeOf(resource)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(resource));
+}
// error
// backend=stage2
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 de4d7e9c65..6ba69f8d3e 100644
--- a/test/cases/compile_errors/empty_switch_on_an_integer.zig
+++ b/test/cases/compile_errors/empty_switch_on_an_integer.zig
@@ -1,6 +1,6 @@
export fn entry() void {
var x: u32 = 0;
- switch(x) {}
+ switch (x) {}
}
// error
diff --git a/test/cases/compile_errors/intToEnum_on_non-exhaustive_enums_checks_int_in_range.zig b/test/cases/compile_errors/enumFromInt_on_non-exhaustive_enums_checks_int_in_range.zig
index b05c9f35d9..dfef66b628 100644
--- a/test/cases/compile_errors/intToEnum_on_non-exhaustive_enums_checks_int_in_range.zig
+++ b/test/cases/compile_errors/enumFromInt_on_non-exhaustive_enums_checks_int_in_range.zig
@@ -1,6 +1,6 @@
pub export fn entry() void {
const E = enum(u3) { a, b, c, _ };
- @compileLog(@intToEnum(E, 100));
+ @compileLog(@enumFromInt(E, 100));
}
// error
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 e79f6d478f..0cf9fcce01 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 = @intToEnum(Foo, 0);
+ var x = @enumFromInt(Foo, 0);
_ = x;
}
diff --git a/test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig b/test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig
index f23718c2ca..fb55a733e5 100644
--- a/test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig
+++ b/test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig
@@ -1,5 +1,8 @@
export fn entry() void {
- _ = @Type(@typeInfo(enum { foo, const bar = 1; }));
+ _ = @Type(@typeInfo(enum {
+ foo,
+ const bar = 1;
+ }));
}
// error
diff --git a/test/cases/compile_errors/error_not_handled_in_switch.zig b/test/cases/compile_errors/error_not_handled_in_switch.zig
index 8f0d26a4a9..04f122b11d 100644
--- a/test/cases/compile_errors/error_not_handled_in_switch.zig
+++ b/test/cases/compile_errors/error_not_handled_in_switch.zig
@@ -5,9 +5,9 @@ export fn entry() void {
}
fn foo(x: i32) !void {
switch (x) {
- 0 ... 10 => return error.Foo,
- 11 ... 20 => return error.Bar,
- 21 ... 30 => return error.Baz,
+ 0...10 => return error.Foo,
+ 11...20 => return error.Bar,
+ 21...30 => return error.Baz,
else => {},
}
}
diff --git a/test/cases/compile_errors/error_note_for_function_parameter_incompatibility.zig b/test/cases/compile_errors/error_note_for_function_parameter_incompatibility.zig
index 76543697a4..bbf8bcfa40 100644
--- a/test/cases/compile_errors/error_note_for_function_parameter_incompatibility.zig
+++ b/test/cases/compile_errors/error_note_for_function_parameter_incompatibility.zig
@@ -1,5 +1,9 @@
-fn do_the_thing(func: *const fn (arg: i32) void) void { _ = func; }
-fn bar(arg: bool) void { _ = arg; }
+fn do_the_thing(func: *const fn (arg: i32) void) void {
+ _ = func;
+}
+fn bar(arg: bool) void {
+ _ = arg;
+}
export fn entry() void {
do_the_thing(bar);
}
@@ -8,6 +12,6 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :4:18: error: expected type '*const fn(i32) void', found '*const fn(bool) void'
-// :4:18: note: pointer type child 'fn(bool) void' cannot cast into pointer type child 'fn(i32) void'
-// :4:18: note: parameter 0 'bool' cannot cast into 'i32'
+// :8:18: error: expected type '*const fn(i32) void', found '*const fn(bool) void'
+// :8:18: note: pointer type child 'fn(bool) void' cannot cast into pointer type child 'fn(i32) void'
+// :8:18: note: parameter 0 'bool' cannot cast into 'i32'
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 aac876e614..6ae39489a0 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 = @intToEnum(Small, y);
+ var x = @enumFromInt(Small, y);
_ = x;
}
@@ -15,4 +15,4 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :10:31: error: expected integer type, found 'f32'
+// :10:33: error: expected integer type, found 'f32'
diff --git a/test/cases/compile_errors/export_function_with_comptime_parameter.zig b/test/cases/compile_errors/export_function_with_comptime_parameter.zig
index 4491a98e9c..8d5dbef1c3 100644
--- a/test/cases/compile_errors/export_function_with_comptime_parameter.zig
+++ b/test/cases/compile_errors/export_function_with_comptime_parameter.zig
@@ -1,4 +1,4 @@
-export fn foo(comptime x: anytype, y: i32) i32{
+export fn foo(comptime x: anytype, y: i32) i32 {
return x + y;
}
diff --git a/test/cases/compile_errors/export_with_empty_name_string.zig b/test/cases/compile_errors/export_with_empty_name_string.zig
index f199c2632c..9f3b215bc2 100644
--- a/test/cases/compile_errors/export_with_empty_name_string.zig
+++ b/test/cases/compile_errors/export_with_empty_name_string.zig
@@ -1,4 +1,4 @@
-pub export fn entry() void { }
+pub export fn entry() void {}
comptime {
@export(entry, .{ .name = "" });
}
diff --git a/test/cases/compile_errors/extern_function_pointer_mismatch.zig b/test/cases/compile_errors/extern_function_pointer_mismatch.zig
index f10a3dbdb3..f4371303fb 100644
--- a/test/cases/compile_errors/extern_function_pointer_mismatch.zig
+++ b/test/cases/compile_errors/extern_function_pointer_mismatch.zig
@@ -1,13 +1,21 @@
-const fns = [_](fn(i32)i32) { a, b, c };
-pub fn a(x: i32) i32 {return x + 0;}
-pub fn b(x: i32) i32 {return x + 1;}
-export fn c(x: i32) i32 {return x + 2;}
+const fns = [_](fn (i32) i32){ a, b, c };
+pub fn a(x: i32) i32 {
+ return x + 0;
+}
+pub fn b(x: i32) i32 {
+ return x + 1;
+}
+export fn c(x: i32) i32 {
+ return x + 2;
+}
-export fn entry() usize { return @sizeOf(@TypeOf(fns)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(fns));
+}
// error
// backend=stage2
// target=native
//
-// :1:37: error: expected type 'fn(i32) i32', found 'fn(i32) callconv(.C) i32'
-// :1:37: note: calling convention 'C' cannot cast into calling convention 'Unspecified'
+// :1:38: error: expected type 'fn(i32) i32', found 'fn(i32) callconv(.C) i32'
+// :1:38: note: calling convention 'C' cannot cast into calling convention 'Unspecified'
diff --git a/test/cases/compile_errors/extern_function_with_comptime_parameter.zig b/test/cases/compile_errors/extern_function_with_comptime_parameter.zig
index 8ade9ca2aa..fac09cc265 100644
--- a/test/cases/compile_errors/extern_function_with_comptime_parameter.zig
+++ b/test/cases/compile_errors/extern_function_with_comptime_parameter.zig
@@ -4,9 +4,15 @@ fn f() i32 {
}
pub extern fn entry1(b: u32, comptime a: [2]u8, c: i32) void;
pub extern fn entry2(b: u32, noalias a: anytype, i43) void;
-comptime { _ = &f; }
-comptime { _ = &entry1; }
-comptime { _ = &entry2; }
+comptime {
+ _ = &f;
+}
+comptime {
+ _ = &entry1;
+}
+comptime {
+ _ = &entry2;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig b/test/cases/compile_errors/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig
index 6484e301a9..2faa7c8713 100644
--- a/test/cases/compile_errors/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig
+++ b/test/cases/compile_errors/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig
@@ -1,3 +1,4 @@
+// zig fmt: off
pub const E = enum {
@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",
@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",
@@ -27,6 +28,7 @@ pub const E = enum {
@"245",@"246",@"247",@"248",@"249",@"250",@"251",@"252",@"253",
@"254",@"255", @"256"
};
+// zig fmt: on
pub const S = extern struct {
e: E,
};
@@ -39,7 +41,7 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :31:8: error: extern structs cannot contain fields of type 'tmp.E'
-// :31:8: note: enum tag type 'u9' is not extern compatible
-// :31:8: note: only integers with power of two bits are extern compatible
-// :1:15: note: enum declared here
+// :33:8: error: extern structs cannot contain fields of type 'tmp.E'
+// :33:8: note: enum tag type 'u9' is not extern compatible
+// :33:8: note: only integers with power of two bits are extern compatible
+// :2:15: note: enum declared here
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 6890e65714..fde58f69e5 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 = {} };
+ var 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 6a691eb2e2..4aa0e623c7 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 };
+ var a = Payload{ .A = 1234 };
_ = a;
}
diff --git a/test/cases/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig b/test/cases/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig
index 7f57268f06..9fc8038d7a 100644
--- a/test/cases/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig
+++ b/test/cases/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig
@@ -2,10 +2,13 @@ const Foo = struct {
a: i32,
b: i32,
};
-const foo = Foo { .a = 1, .b = 2, };
+const foo = Foo{
+ .a = 1,
+ .b = 2,
+};
comptime {
- const field_ptr = @intToPtr(*i32, 0x1234);
+ const field_ptr = @ptrFromInt(*i32, 0x1234);
const another_foo_ptr = @fieldParentPtr(Foo, "b", field_ptr);
_ = another_foo_ptr;
}
@@ -14,4 +17,4 @@ comptime {
// backend=stage2
// target=native
//
-// :9:55: error: pointer value not based on parent struct
+// :12:55: error: pointer value not based on parent struct
diff --git a/test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig b/test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig
index a73409aea3..7a37eb2adc 100644
--- a/test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig
+++ b/test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig
@@ -2,7 +2,10 @@ const Foo = struct {
a: i32,
b: i32,
};
-const foo = Foo { .a = 1, .b = 2, };
+const foo = Foo{
+ .a = 1,
+ .b = 2,
+};
comptime {
const another_foo_ptr = @fieldParentPtr(Foo, "b", &foo.a);
@@ -13,5 +16,5 @@ comptime {
// backend=stage2
// target=native
//
-// :8:29: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo'
+// :11:29: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo'
// :1:13: note: struct declared here
diff --git a/test/cases/compile_errors/floatToInt_comptime_safety.zig b/test/cases/compile_errors/floatToInt_comptime_safety.zig
deleted file mode 100644
index 068d8e2d89..0000000000
--- a/test/cases/compile_errors/floatToInt_comptime_safety.zig
+++ /dev/null
@@ -1,17 +0,0 @@
-comptime {
- _ = @floatToInt(i8, @as(f32, -129.1));
-}
-comptime {
- _ = @floatToInt(u8, @as(f32, -1.1));
-}
-comptime {
- _ = @floatToInt(u8, @as(f32, 256.1));
-}
-
-// error
-// backend=stage2
-// target=native
-//
-// :2:25: error: float value '-129.10000610351562' cannot be stored in integer type 'i8'
-// :5:25: error: float value '-1.100000023841858' cannot be stored in integer type 'u8'
-// :8:25: error: float value '256.1000061035156' cannot be stored in integer type 'u8'
diff --git a/test/cases/compile_errors/for.zig b/test/cases/compile_errors/for.zig
index 435bb68607..568c416062 100644
--- a/test/cases/compile_errors/for.zig
+++ b/test/cases/compile_errors/for.zig
@@ -1,13 +1,15 @@
export fn a() void {
for (0..10, 10..21) |i, j| {
- _ = i; _ = j;
+ _ = i;
+ _ = j;
}
}
export fn b() void {
const s1 = "hello";
const s2 = true;
for (s1, s2) |i, j| {
- _ = i; _ = j;
+ _ = i;
+ _ = j;
}
}
export fn c() void {
@@ -20,7 +22,9 @@ export fn d() void {
const x: [*]const u8 = "hello";
const y: [*]const u8 = "world";
for (x, 0.., y) |x1, x2, x3| {
- _ = x1; _ = x2; _ = x3;
+ _ = x1;
+ _ = x2;
+ _ = x3;
}
}
@@ -31,10 +35,10 @@ export fn d() void {
// :2:5: error: non-matching for loop lengths
// :2:11: note: length 10 here
// :2:19: note: length 11 here
-// :9:14: error: type 'bool' is not indexable and not a range
-// :9:14: note: for loop operand must be a range, array, slice, tuple, or vector
-// :15:16: error: pointer capture of non pointer type '[10]u8'
-// :15:10: note: consider using '&' here
-// :22:5: error: unbounded for loop
-// :22:10: note: type '[*]const u8' has no upper bound
-// :22:18: note: type '[*]const u8' has no upper bound
+// :10:14: error: type 'bool' is not indexable and not a range
+// :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
diff --git a/test/cases/compile_errors/for_extra_capture.zig b/test/cases/compile_errors/for_extra_capture.zig
index a137b57d51..0a4ed724ad 100644
--- a/test/cases/compile_errors/for_extra_capture.zig
+++ b/test/cases/compile_errors/for_extra_capture.zig
@@ -1,12 +1,15 @@
+// zig fmt: off
export fn b() void {
for (0..10) |i, j| {
- _ = i; _ = j;
+ _ = i;
+ _ = j;
}
}
+// zig fmt: on
// error
// backend=stage2
// target=native
//
-// :2:21: error: extra capture in for loop
-// :2:21: note: run 'zig fmt' to upgrade your code automatically
+// :3:21: error: extra capture in for loop
+// :3:21: note: run 'zig fmt' to upgrade your code automatically
diff --git a/test/cases/compile_errors/function_alignment_non_power_of_2.zig b/test/cases/compile_errors/function_alignment_non_power_of_2.zig
index 11d6768dfd..e40ca022d2 100644
--- a/test/cases/compile_errors/function_alignment_non_power_of_2.zig
+++ b/test/cases/compile_errors/function_alignment_non_power_of_2.zig
@@ -1,5 +1,7 @@
extern fn foo() align(3) void;
-export fn entry() void { return foo(); }
+export fn entry() void {
+ return foo();
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/function_call_assigned_to_incorrect_type.zig b/test/cases/compile_errors/function_call_assigned_to_incorrect_type.zig
index fcbfabe297..1060987b9a 100644
--- a/test/cases/compile_errors/function_call_assigned_to_incorrect_type.zig
+++ b/test/cases/compile_errors/function_call_assigned_to_incorrect_type.zig
@@ -3,7 +3,7 @@ export fn entry() void {
arr = concat();
}
fn concat() [16]f32 {
- return [1]f32{0}**16;
+ return [1]f32{0} ** 16;
}
// error
diff --git a/test/cases/compile_errors/function_parameter_is_opaque.zig b/test/cases/compile_errors/function_parameter_is_opaque.zig
index 57c89bd7f4..61e15f9ae6 100644
--- a/test/cases/compile_errors/function_parameter_is_opaque.zig
+++ b/test/cases/compile_errors/function_parameter_is_opaque.zig
@@ -9,12 +9,16 @@ export fn entry2() void {
_ = someFuncPtr;
}
-fn foo(p: FooType) void {_ = p;}
+fn foo(p: FooType) void {
+ _ = p;
+}
export fn entry3() void {
_ = foo;
}
-fn bar(p: @TypeOf(null)) void {_ = p;}
+fn bar(p: @TypeOf(null)) void {
+ _ = p;
+}
export fn entry4() void {
_ = bar;
}
@@ -28,4 +32,4 @@ export fn entry4() void {
// :8:28: error: parameter of type '@TypeOf(null)' not allowed
// :12:8: error: parameter of opaque type 'tmp.FooType' not allowed
// :1:17: note: opaque declared here
-// :17:8: error: parameter of type '@TypeOf(null)' not allowed
+// :19:8: error: parameter of type '@TypeOf(null)' not allowed
diff --git a/test/cases/compile_errors/function_with_non-extern_non-packed_enum_parameter.zig b/test/cases/compile_errors/function_with_non-extern_non-packed_enum_parameter.zig
index c6412161e5..ae347470f2 100644
--- a/test/cases/compile_errors/function_with_non-extern_non-packed_enum_parameter.zig
+++ b/test/cases/compile_errors/function_with_non-extern_non-packed_enum_parameter.zig
@@ -1,5 +1,7 @@
const Foo = enum { A, B, C };
-export fn entry(foo: Foo) void { _ = foo; }
+export fn entry(foo: Foo) void {
+ _ = foo;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/function_with_non-extern_non-packed_struct_parameter.zig b/test/cases/compile_errors/function_with_non-extern_non-packed_struct_parameter.zig
index 55ee277641..137037f9e7 100644
--- a/test/cases/compile_errors/function_with_non-extern_non-packed_struct_parameter.zig
+++ b/test/cases/compile_errors/function_with_non-extern_non-packed_struct_parameter.zig
@@ -3,7 +3,9 @@ const Foo = struct {
B: f32,
C: bool,
};
-export fn entry(foo: Foo) void { _ = foo; }
+export fn entry(foo: Foo) void {
+ _ = foo;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/function_with_non-extern_non-packed_union_parameter.zig b/test/cases/compile_errors/function_with_non-extern_non-packed_union_parameter.zig
index f848392c90..d651329f72 100644
--- a/test/cases/compile_errors/function_with_non-extern_non-packed_union_parameter.zig
+++ b/test/cases/compile_errors/function_with_non-extern_non-packed_union_parameter.zig
@@ -3,7 +3,9 @@ const Foo = union {
B: f32,
C: bool,
};
-export fn entry(foo: Foo) void { _ = foo; }
+export fn entry(foo: Foo) void {
+ _ = foo;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/generic_function_call_assigned_to_incorrect_type.zig b/test/cases/compile_errors/generic_function_call_assigned_to_incorrect_type.zig
index a2e303670d..4ff2841282 100644
--- a/test/cases/compile_errors/generic_function_call_assigned_to_incorrect_type.zig
+++ b/test/cases/compile_errors/generic_function_call_assigned_to_incorrect_type.zig
@@ -2,7 +2,7 @@ pub export fn entry() void {
var res: []i32 = undefined;
res = myAlloc(i32);
}
-fn myAlloc(comptime arg: type) anyerror!arg{
+fn myAlloc(comptime arg: type) anyerror!arg {
unreachable;
}
diff --git a/test/cases/compile_errors/generic_function_instance_with_non-constant_expression.zig b/test/cases/compile_errors/generic_function_instance_with_non-constant_expression.zig
index 1317c4376a..18c60cd4aa 100644
--- a/test/cases/compile_errors/generic_function_instance_with_non-constant_expression.zig
+++ b/test/cases/compile_errors/generic_function_instance_with_non-constant_expression.zig
@@ -1,13 +1,17 @@
-fn foo(comptime x: i32, y: i32) i32 { return x + y; }
+fn foo(comptime x: i32, y: i32) i32 {
+ return x + y;
+}
fn test1(a: i32, b: i32) i32 {
return foo(a, b);
}
-export fn entry() usize { return @sizeOf(@TypeOf(&test1)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&test1));
+}
// error
// backend=stage2
// target=native
//
-// :3:16: error: unable to resolve comptime value
-// :3:16: note: parameter is comptime
+// :5:16: error: unable to resolve comptime value
+// :5:16: note: parameter is comptime
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 3146c38604..c730f80e6f 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
@@ -6,7 +6,6 @@ pub export fn entry() void {
}
fn sliceAsBytes(slice: anytype) std.meta.trait.isPtrTo(.Array)(@TypeOf(slice)) {}
-
// error
// backend=llvm
// target=native
diff --git a/test/cases/compile_errors/global_variable_alignment_non_power_of_2.zig b/test/cases/compile_errors/global_variable_alignment_non_power_of_2.zig
index b88d8aaf70..5110e41334 100644
--- a/test/cases/compile_errors/global_variable_alignment_non_power_of_2.zig
+++ b/test/cases/compile_errors/global_variable_alignment_non_power_of_2.zig
@@ -1,5 +1,7 @@
const some_data: [100]u8 align(3) = undefined;
-export fn entry() usize { return @sizeOf(@TypeOf(some_data)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(some_data));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/global_variable_initializer_must_be_constant_expression.zig b/test/cases/compile_errors/global_variable_initializer_must_be_constant_expression.zig
index e2694343e8..a87f628396 100644
--- a/test/cases/compile_errors/global_variable_initializer_must_be_constant_expression.zig
+++ b/test/cases/compile_errors/global_variable_initializer_must_be_constant_expression.zig
@@ -1,6 +1,8 @@
extern fn foo() i32;
const x = foo();
-export fn entry() i32 { return x; }
+export fn entry() i32 {
+ return x;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/ignored_assert-err-ok_return_value.zig b/test/cases/compile_errors/ignored_assert-err-ok_return_value.zig
index 39657badd4..1257636622 100644
--- a/test/cases/compile_errors/ignored_assert-err-ok_return_value.zig
+++ b/test/cases/compile_errors/ignored_assert-err-ok_return_value.zig
@@ -1,7 +1,9 @@
export fn foo() void {
bar() catch unreachable;
}
-fn bar() anyerror!i32 { return 0; }
+fn bar() anyerror!i32 {
+ return 0;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/ignored_comptime_statement_value.zig b/test/cases/compile_errors/ignored_comptime_statement_value.zig
index fc6cdfdd28..2067f3b716 100644
--- a/test/cases/compile_errors/ignored_comptime_statement_value.zig
+++ b/test/cases/compile_errors/ignored_comptime_statement_value.zig
@@ -1,11 +1,13 @@
export fn foo() void {
- comptime {1;}
+ comptime {
+ 1;
+ }
}
// error
// backend=stage2
// target=native
//
-// :2:15: error: value of type 'comptime_int' ignored
-// :2:15: note: all non-void values must be used
-// :2:15: note: this error can be suppressed by assigning the value to '_'
+// :3:9: error: value of type 'comptime_int' ignored
+// :3:9: note: all non-void values must be used
+// :3:9: note: this error can be suppressed by assigning the value to '_'
diff --git a/test/cases/compile_errors/ignored_deferred_function_call.zig b/test/cases/compile_errors/ignored_deferred_function_call.zig
index b318baa16c..9537255d33 100644
--- a/test/cases/compile_errors/ignored_deferred_function_call.zig
+++ b/test/cases/compile_errors/ignored_deferred_function_call.zig
@@ -1,7 +1,9 @@
export fn foo() void {
defer bar();
}
-fn bar() anyerror!i32 { return 0; }
+fn bar() anyerror!i32 {
+ return 0;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/ignored_deferred_statement_value.zig b/test/cases/compile_errors/ignored_deferred_statement_value.zig
index 9a270497af..1f42efc3f5 100644
--- a/test/cases/compile_errors/ignored_deferred_statement_value.zig
+++ b/test/cases/compile_errors/ignored_deferred_statement_value.zig
@@ -1,11 +1,13 @@
export fn foo() void {
- defer {1;}
+ defer {
+ 1;
+ }
}
// error
// backend=stage2
// target=native
//
-// :2:12: error: value of type 'comptime_int' ignored
-// :2:12: note: all non-void values must be used
-// :2:12: note: this error can be suppressed by assigning the value to '_'
+// :3:9: error: value of type 'comptime_int' ignored
+// :3:9: note: all non-void values must be used
+// :3:9: note: this error can be suppressed by assigning the value to '_'
diff --git a/test/cases/compile_errors/ignored_return_value.zig b/test/cases/compile_errors/ignored_return_value.zig
index 57f859e3d3..08424c4fe9 100644
--- a/test/cases/compile_errors/ignored_return_value.zig
+++ b/test/cases/compile_errors/ignored_return_value.zig
@@ -1,7 +1,9 @@
export fn foo() void {
bar();
}
-fn bar() i32 { return 0; }
+fn bar() i32 {
+ return 0;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/illegal_comparison_of_types.zig b/test/cases/compile_errors/illegal_comparison_of_types.zig
index 69d7a28fa4..5720aa05cc 100644
--- a/test/cases/compile_errors/illegal_comparison_of_types.zig
+++ b/test/cases/compile_errors/illegal_comparison_of_types.zig
@@ -9,8 +9,12 @@ fn bad_eql_2(a: *const EnumWithData, b: *const EnumWithData) bool {
return a.* == b.*;
}
-export fn entry1() usize { return @sizeOf(@TypeOf(&bad_eql_1)); }
-export fn entry2() usize { return @sizeOf(@TypeOf(&bad_eql_2)); }
+export fn entry1() usize {
+ return @sizeOf(@TypeOf(&bad_eql_1));
+}
+export fn entry2() usize {
+ return @sizeOf(@TypeOf(&bad_eql_2));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/implicit_cast_from_array_to_mutable_slice.zig b/test/cases/compile_errors/implicit_cast_from_array_to_mutable_slice.zig
index e7ae5d7277..1efc375425 100644
--- a/test/cases/compile_errors/implicit_cast_from_array_to_mutable_slice.zig
+++ b/test/cases/compile_errors/implicit_cast_from_array_to_mutable_slice.zig
@@ -1,5 +1,7 @@
var global_array: [10]i32 = undefined;
-fn foo(param: []i32) void {_ = param;}
+fn foo(param: []i32) void {
+ _ = param;
+}
export fn entry() void {
foo(global_array);
}
@@ -8,4 +10,4 @@ export fn entry() void {
// backend=llvm
// target=native
//
-// :4:9: error: array literal requires address-of operator (&) to coerce to slice type '[]i32'
+// :6:9: error: array literal requires address-of operator (&) to coerce to slice type '[]i32'
diff --git a/test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig b/test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig
index 13adba1b91..fcecfa8611 100644
--- a/test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig
+++ b/test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig
@@ -4,7 +4,7 @@ const Foo = packed struct {
};
export fn entry() void {
- var foo = Foo { .a = 1, .b = 10 };
+ var foo = Foo{ .a = 1, .b = 10 };
bar(&foo.b);
}
diff --git a/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig b/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig
index 84ec6464f4..171936097d 100644
--- a/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig
+++ b/test/cases/compile_errors/implicitly_increasing_slice_alignment.zig
@@ -4,7 +4,7 @@ const Foo = packed struct {
};
export fn entry() void {
- var foo = Foo { .a = 1, .b = 10 };
+ var foo = Foo{ .a = 1, .b = 10 };
foo.b += 1;
bar(@as(*[1]u32, &foo.b)[0..]);
}
diff --git a/test/cases/compile_errors/import_outside_package_path.zig b/test/cases/compile_errors/import_outside_package_path.zig
index 0c0df59419..34044e3b0f 100644
--- a/test/cases/compile_errors/import_outside_package_path.zig
+++ b/test/cases/compile_errors/import_outside_package_path.zig
@@ -1,4 +1,4 @@
-comptime{
+comptime {
_ = @import("../a.zig");
}
diff --git a/test/cases/compile_errors/incorrect_return_type.zig b/test/cases/compile_errors/incorrect_return_type.zig
index 57cf54a023..798b167dcb 100644
--- a/test/cases/compile_errors/incorrect_return_type.zig
+++ b/test/cases/compile_errors/incorrect_return_type.zig
@@ -1,24 +1,24 @@
- pub export fn entry() void{
- _ = foo();
- }
- const A = struct {
- a: u32,
- };
- fn foo() A {
- return bar();
- }
- const B = struct {
- a: u32,
- };
- fn bar() B {
- unreachable;
- }
+pub export fn entry() void {
+ _ = foo();
+}
+const A = struct {
+ a: u32,
+};
+fn foo() A {
+ return bar();
+}
+const B = struct {
+ a: u32,
+};
+fn bar() B {
+ unreachable;
+}
// error
// backend=stage2
// target=native
//
-// :8:16: error: expected type 'tmp.A', found 'tmp.B'
-// :10:12: note: struct declared here
-// :4:12: note: struct declared here
-// :7:11: note: function return type declared here
+// :8:15: error: expected type 'tmp.A', found 'tmp.B'
+// :10:11: note: struct declared here
+// :4:11: note: struct declared here
+// :7:10: note: function return type declared here
diff --git a/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig b/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig
index 242454e859..8d7e14acae 100644
--- a/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig
+++ b/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig
@@ -1,5 +1,5 @@
export fn entry() u32 {
- var bytes: [4]u8 = [_]u8{0x01, 0x02, 0x03, 0x04};
+ var bytes: [4]u8 = [_]u8{ 0x01, 0x02, 0x03, 0x04 };
const ptr = @ptrCast(*u32, &bytes[0]);
return ptr.*;
}
diff --git a/test/cases/compile_errors/indirect_struct_loop.zig b/test/cases/compile_errors/indirect_struct_loop.zig
index dca2b9c3f6..ef5526830e 100644
--- a/test/cases/compile_errors/indirect_struct_loop.zig
+++ b/test/cases/compile_errors/indirect_struct_loop.zig
@@ -1,13 +1,21 @@
-const A = struct { b : B, };
-const B = struct { c : C, };
-const C = struct { a : A, };
-export fn entry() usize { return @sizeOf(A); }
+const A = struct {
+ b: B,
+};
+const B = struct {
+ c: C,
+};
+const C = struct {
+ a: A,
+};
+export fn entry() usize {
+ return @sizeOf(A);
+}
// error
// backend=stage2
// target=native
//
// :1:11: error: struct 'tmp.A' depends on itself
-// :3:20: note: while checking this field
-// :2:20: note: while checking this field
-// :1:20: note: while checking this field
+// :8:5: note: while checking this field
+// :5:5: note: while checking this field
+// :2:5: note: while checking this field
diff --git a/test/cases/compile_errors/inferred_array_size_invalid_here.zig b/test/cases/compile_errors/inferred_array_size_invalid_here.zig
index 084057dc8e..0791540ed2 100644
--- a/test/cases/compile_errors/inferred_array_size_invalid_here.zig
+++ b/test/cases/compile_errors/inferred_array_size_invalid_here.zig
@@ -4,7 +4,7 @@ export fn entry() void {
}
export fn entry2() void {
const S = struct { a: *const [_]u8 };
- var a = .{ S{} };
+ var a = .{S{}};
_ = a;
}
diff --git a/test/cases/compile_errors/inferring_error_set_of_function_pointer.zig b/test/cases/compile_errors/inferring_error_set_of_function_pointer.zig
index 862e33906a..ce1b276360 100644
--- a/test/cases/compile_errors/inferring_error_set_of_function_pointer.zig
+++ b/test/cases/compile_errors/inferring_error_set_of_function_pointer.zig
@@ -1,9 +1,9 @@
comptime {
- const z: ?fn()!void = null;
+ const z: ?fn () !void = null;
}
// error
// backend=stage2
// target=native
//
-// :2:19: error: function prototype may not have inferred error set
+// :2:21: error: function prototype may not have inferred error set
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 4c3b3fc1ae..ecf8f61fc5 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,17 +1,17 @@
export fn foo() void {
var a: f32 = 2;
- _ = @floatToInt(comptime_int, a);
+ _ = @intFromFloat(comptime_int, a);
}
export fn bar() void {
var a: u32 = 2;
- _ = @intToFloat(comptime_float, a);
+ _ = @floatFromInt(comptime_float, a);
}
// error
// backend=stage2
// target=native
//
-// :3:35: error: unable to resolve comptime value
-// :3:35: note: value being casted to 'comptime_int' must be comptime-known
-// :7:37: error: unable to resolve comptime value
-// :7:37: note: value being casted to 'comptime_float' must be comptime-known
+// :3:37: error: unable to resolve comptime value
+// :3:37: note: value being casted to 'comptime_int' must be comptime-known
+// :7:39: error: unable to resolve comptime value
+// :7:39: note: value being casted to 'comptime_float' must be comptime-known
diff --git a/test/cases/compile_errors/intFromFloat_comptime_safety.zig b/test/cases/compile_errors/intFromFloat_comptime_safety.zig
new file mode 100644
index 0000000000..275f67006f
--- /dev/null
+++ b/test/cases/compile_errors/intFromFloat_comptime_safety.zig
@@ -0,0 +1,17 @@
+comptime {
+ _ = @intFromFloat(i8, @as(f32, -129.1));
+}
+comptime {
+ _ = @intFromFloat(u8, @as(f32, -1.1));
+}
+comptime {
+ _ = @intFromFloat(u8, @as(f32, 256.1));
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// :2:27: error: float value '-129.10000610351562' cannot be stored in integer type 'i8'
+// :5:27: error: float value '-1.100000023841858' cannot be stored in integer type 'u8'
+// :8:27: error: float value '256.1000061035156' cannot be stored in integer type 'u8'
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
new file mode 100644
index 0000000000..4a2ea05eaa
--- /dev/null
+++ b/test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig
@@ -0,0 +1,10 @@
+export fn entry() void {
+ var b = @ptrFromInt(*i32, 0);
+ _ = b;
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// :2:31: error: pointer type '*i32' does not allow address zero
diff --git a/test/cases/compile_errors/intToPtr_with_misaligned_address.zig b/test/cases/compile_errors/intToPtr_with_misaligned_address.zig
deleted file mode 100644
index 43f89ab3b5..0000000000
--- a/test/cases/compile_errors/intToPtr_with_misaligned_address.zig
+++ /dev/null
@@ -1,10 +0,0 @@
-pub export fn entry() void {
- var y = @intToPtr([*]align(4) u8, 5);
- _ = y;
-}
-
-// error
-// backend=stage2
-// target=native
-//
-// :2:39: error: pointer type '[*]align(4) u8' requires aligned address
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 5bb9b75a8e..000b5d1e6a 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
@@ -4,7 +4,7 @@ const Set1 = error{
};
comptime {
var x: u16 = 3;
- var y = @intToError(x);
+ var y = @errorFromInt(x);
_ = y;
}
@@ -12,4 +12,4 @@ comptime {
// backend=stage2
// target=native
//
-// :7:25: error: integer value '3' represents no error
+// :7:27: error: integer value '3' represents no 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 f837ccd532..6a1f2db531 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 = @errorToInt(Set1.B);
- var y = @errSetCast(Set2, @intToError(x));
+ var x = @intFromError(Set1.B);
+ var y = @errSetCast(Set2, @errorFromInt(x));
_ = y;
}
diff --git a/test/cases/compile_errors/integer_overflow_error.zig b/test/cases/compile_errors/integer_overflow_error.zig
index aa4725b7e7..9de1a2820f 100644
--- a/test/cases/compile_errors/integer_overflow_error.zig
+++ b/test/cases/compile_errors/integer_overflow_error.zig
@@ -1,8 +1,10 @@
-const x : u8 = 300;
-export fn entry() usize { return @sizeOf(@TypeOf(x)); }
+const x: u8 = 300;
+export fn entry() usize {
+ return @sizeOf(@TypeOf(x));
+}
// error
// backend=stage2
// target=native
//
-// :1:16: error: type 'u8' cannot represent integer value '300'
+// :1:15: error: type 'u8' cannot represent integer value '300'
diff --git a/test/cases/compile_errors/integer_underflow_error.zig b/test/cases/compile_errors/integer_underflow_error.zig
index 120edd0838..275b593ecc 100644
--- a/test/cases/compile_errors/integer_underflow_error.zig
+++ b/test/cases/compile_errors/integer_underflow_error.zig
@@ -1,9 +1,9 @@
export fn entry() void {
- _ = @intToPtr(*anyopaque, ~@as(usize, @import("std").math.maxInt(usize)) - 1);
+ _ = @ptrFromInt(*anyopaque, ~@as(usize, @import("std").math.maxInt(usize)) - 1);
}
// error
// backend=stage2
// target=native
//
-// :2:78: error: overflow of integer type 'usize' with value '-1'
+// :2:80: error: overflow of integer type 'usize' with value '-1'
diff --git a/test/cases/compile_errors/inttoptr_non_ptr_type.zig b/test/cases/compile_errors/inttoptr_non_ptr_type.zig
deleted file mode 100644
index fa308f677d..0000000000
--- a/test/cases/compile_errors/inttoptr_non_ptr_type.zig
+++ /dev/null
@@ -1,15 +0,0 @@
-pub export fn entry() void {
- _ = @intToPtr(i32, 10);
-}
-
-pub export fn entry2() void {
- _ = @intToPtr([]u8, 20);
-}
-
-// error
-// backend=stage2
-// target=native
-//
-// :2:19: error: expected pointer type, found 'i32'
-// :6:19: error: integer cannot be converted to slice type '[]u8'
-// :6:19: note: slice length cannot be inferred from address
diff --git a/test/cases/compile_errors/invalid_builtin_fn.zig b/test/cases/compile_errors/invalid_builtin_fn.zig
index 5b7b832177..3297525fd9 100644
--- a/test/cases/compile_errors/invalid_builtin_fn.zig
+++ b/test/cases/compile_errors/invalid_builtin_fn.zig
@@ -1,6 +1,7 @@
-fn f() @bogus(foo) {
+fn f() @bogus(foo) {}
+export fn entry() void {
+ _ = f();
}
-export fn entry() void { _ = f(); }
// error
// backend=stage2
diff --git a/test/cases/compile_errors/invalid_capture_type.zig b/test/cases/compile_errors/invalid_capture_type.zig
index 3813021c95..6f480df097 100644
--- a/test/cases/compile_errors/invalid_capture_type.zig
+++ b/test/cases/compile_errors/invalid_capture_type.zig
@@ -1,5 +1,7 @@
export fn f1() void {
- if (true) |x| { _ = x; }
+ if (true) |x| {
+ _ = x;
+ }
}
export fn f2() void {
if (@as(usize, 5)) |_| {}
@@ -19,6 +21,6 @@ export fn f5() void {
// target=native
//
// :2:9: error: expected optional type, found 'bool'
-// :5:9: error: expected optional type, found 'usize'
-// :8:9: error: expected error union type, found 'usize'
-// :14:9: error: expected error union type, found 'error{Foo}'
+// :7:9: error: expected optional type, found 'usize'
+// :10:9: error: expected error union type, found 'usize'
+// :16:9: error: expected error union type, found 'error{Foo}'
diff --git a/test/cases/compile_errors/invalid_comparison_for_function_pointers.zig b/test/cases/compile_errors/invalid_comparison_for_function_pointers.zig
index cd63c70259..3c76da2e38 100644
--- a/test/cases/compile_errors/invalid_comparison_for_function_pointers.zig
+++ b/test/cases/compile_errors/invalid_comparison_for_function_pointers.zig
@@ -1,7 +1,9 @@
fn foo() void {}
const invalid = foo > foo;
-export fn entry() usize { return @sizeOf(@TypeOf(invalid)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(invalid));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/invalid_field_access_in_comptime.zig b/test/cases/compile_errors/invalid_field_access_in_comptime.zig
index 672c2b74c9..74fada311d 100644
--- a/test/cases/compile_errors/invalid_field_access_in_comptime.zig
+++ b/test/cases/compile_errors/invalid_field_access_in_comptime.zig
@@ -1,7 +1,10 @@
-comptime { var x = doesnt_exist.whatever; _ = x; }
+comptime {
+ var x = doesnt_exist.whatever;
+ _ = x;
+}
// error
// backend=stage2
// target=native
//
-// :1:20: error: use of undeclared identifier 'doesnt_exist'
+// :2:13: error: use of undeclared identifier 'doesnt_exist'
diff --git a/test/cases/compile_errors/invalid_field_in_struct_value_expression.zig b/test/cases/compile_errors/invalid_field_in_struct_value_expression.zig
index 97f440da3b..f1cd96d8e7 100644
--- a/test/cases/compile_errors/invalid_field_in_struct_value_expression.zig
+++ b/test/cases/compile_errors/invalid_field_in_struct_value_expression.zig
@@ -1,10 +1,10 @@
const A = struct {
- x : i32,
- y : i32,
- z : i32,
+ x: i32,
+ y: i32,
+ z: i32,
};
export fn f() void {
- const a = A {
+ const a = A{
.z = 4,
.y = 2,
.foo = 42,
@@ -21,7 +21,6 @@ pub export fn entry() void {
dump(.{ .field_1 = 123, .field_3 = 456 });
}
-
// error
// backend=stage2
// target=native
diff --git a/test/cases/compile_errors/invalid_float_casts.zig b/test/cases/compile_errors/invalid_float_casts.zig
index 152c98182b..507ced1e57 100644
--- a/test/cases/compile_errors/invalid_float_casts.zig
+++ b/test/cases/compile_errors/invalid_float_casts.zig
@@ -4,11 +4,11 @@ export fn foo() void {
}
export fn bar() void {
var a: f32 = 2;
- _ = @floatToInt(f32, a);
+ _ = @intFromFloat(f32, a);
}
export fn baz() void {
var a: f32 = 2;
- _ = @intToFloat(f32, a);
+ _ = @floatFromInt(f32, a);
}
export fn qux() void {
var a: u32 = 2;
@@ -20,6 +20,6 @@ export fn qux() void {
// target=native
//
// :3:36: error: unable to cast runtime value to 'comptime_float'
-// :7:21: error: expected integer type, found 'f32'
-// :11:26: error: expected integer type, found 'f32'
+// :7:23: error: expected integer type, found 'f32'
+// :11:28: error: expected integer type, found 'f32'
// :15:25: error: expected float type, found 'u32'
diff --git a/test/cases/compile_errors/invalid_int_casts.zig b/test/cases/compile_errors/invalid_int_casts.zig
index d220869201..262a096bd9 100644
--- a/test/cases/compile_errors/invalid_int_casts.zig
+++ b/test/cases/compile_errors/invalid_int_casts.zig
@@ -4,11 +4,11 @@ export fn foo() void {
}
export fn bar() void {
var a: u32 = 2;
- _ = @intToFloat(u32, a);
+ _ = @floatFromInt(u32, a);
}
export fn baz() void {
var a: u32 = 2;
- _ = @floatToInt(u32, a);
+ _ = @intFromFloat(u32, a);
}
export fn qux() void {
var a: f32 = 2;
@@ -20,6 +20,6 @@ export fn qux() void {
// target=native
//
// :3:32: error: unable to cast runtime value to 'comptime_int'
-// :7:21: error: expected float type, found 'u32'
-// :11:26: error: expected float type, found 'u32'
+// :7:23: error: expected float type, found 'u32'
+// :11:28: error: expected float type, found 'u32'
// :15:23: error: expected integer or vector, found 'f32'
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 fa58c0845a..5457a61d3f 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
@@ -8,12 +8,12 @@ const U = union(E) {
b,
};
export fn foo() void {
- var e = @intToEnum(E, 15);
+ var e = @enumFromInt(E, 15);
var u: U = e;
_ = u;
}
export fn bar() void {
- const e = @intToEnum(E, 15);
+ const e = @enumFromInt(E, 15);
var u: U = e;
_ = u;
}
@@ -24,5 +24,5 @@ export fn bar() void {
//
// :12:16: error: runtime coercion to union 'tmp.U' from non-exhaustive enum
// :1:11: note: enum declared here
-// :17:16: error: union 'tmp.U' has no tag with value '@intToEnum(tmp.E, 15)'
+// :17:16: error: union 'tmp.U' has no tag with value '@enumFromInt(tmp.E, 15)'
// :6:11: note: union declared here
diff --git a/test/cases/compile_errors/invalid_optional_type_in_extern_struct.zig b/test/cases/compile_errors/invalid_optional_type_in_extern_struct.zig
index 10e140d881..c7d7b4233a 100644
--- a/test/cases/compile_errors/invalid_optional_type_in_extern_struct.zig
+++ b/test/cases/compile_errors/invalid_optional_type_in_extern_struct.zig
@@ -1,7 +1,9 @@
const stroo = extern struct {
moo: ?[*c]u8,
};
-export fn testf(fluff: *stroo) void { _ = fluff; }
+export fn testf(fluff: *stroo) void {
+ _ = fluff;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/invalid_pointer_with_reify_type.zig b/test/cases/compile_errors/invalid_pointer_with_reify_type.zig
index cac9e32894..dce09234d4 100644
--- a/test/cases/compile_errors/invalid_pointer_with_reify_type.zig
+++ b/test/cases/compile_errors/invalid_pointer_with_reify_type.zig
@@ -8,7 +8,7 @@ export fn entry() void {
.child = u8,
.is_allowzero = false,
.sentinel = &@as(u8, 0),
- }});
+ } });
}
// error
diff --git a/test/cases/compile_errors/invalid_shift_amount_error.zig b/test/cases/compile_errors/invalid_shift_amount_error.zig
index 49852b5b7d..9ea4c55d29 100644
--- a/test/cases/compile_errors/invalid_shift_amount_error.zig
+++ b/test/cases/compile_errors/invalid_shift_amount_error.zig
@@ -1,8 +1,10 @@
-const x : u8 = 2;
+const x: u8 = 2;
fn f() u16 {
return x << 8;
}
-export fn entry() u16 { return f(); }
+export fn entry() u16 {
+ return f();
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/invalid_type.zig b/test/cases/compile_errors/invalid_type.zig
index 902d3652e7..a7c7d81094 100644
--- a/test/cases/compile_errors/invalid_type.zig
+++ b/test/cases/compile_errors/invalid_type.zig
@@ -1,5 +1,7 @@
fn a() bogus {}
-export fn entry() void { _ = a(); }
+export fn entry() void {
+ _ = a();
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/invalid_type_in_builtin_extern.zig b/test/cases/compile_errors/invalid_type_in_builtin_extern.zig
index c3d35958ae..882febbb73 100644
--- a/test/cases/compile_errors/invalid_type_in_builtin_extern.zig
+++ b/test/cases/compile_errors/invalid_type_in_builtin_extern.zig
@@ -1,4 +1,4 @@
-const x = @extern(*comptime_int, .{.name="foo"});
+const x = @extern(*comptime_int, .{ .name = "foo" });
pub export fn entry() void {
_ = x;
}
diff --git a/test/cases/compile_errors/invalid_variadic_function.zig b/test/cases/compile_errors/invalid_variadic_function.zig
index 997db9fee8..7652cb329a 100644
--- a/test/cases/compile_errors/invalid_variadic_function.zig
+++ b/test/cases/compile_errors/invalid_variadic_function.zig
@@ -1,8 +1,12 @@
fn foo(...) void {}
fn bar(a: anytype, ...) callconv(a) void {}
-comptime { _ = foo; }
-comptime { _ = bar; }
+comptime {
+ _ = foo;
+}
+comptime {
+ _ = bar;
+}
// error
// backend=stage2
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 874f015ffb..7a4c0eb7e8 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
@@ -1,10 +1,10 @@
export fn foo1() void {
- var bytes = [_]u8{1, 2};
+ var bytes = [_]u8{ 1, 2 };
const word: u16 = @bitCast(u16, bytes[0..]);
_ = word;
}
export fn foo2() void {
- var bytes: []const u8 = &[_]u8{1, 2};
+ var bytes: []const u8 = &[_]u8{ 1, 2 };
const word: u16 = @bitCast(u16, bytes);
_ = word;
}
@@ -14,6 +14,6 @@ export fn foo2() void {
// target=native
//
// :3:42: error: cannot @bitCast from '*[2]u8'
-// :3:42: note: use @ptrToInt to cast to 'u16'
+// :3:42: note: use @intFromPtr to cast to 'u16'
// :8:37: error: cannot @bitCast from '[]const u8'
-// :8:37: note: use @ptrToInt to cast to 'u16'
+// :8:37: note: use @intFromPtr to cast to 'u16'
diff --git a/test/cases/compile_errors/local_variable_redeclaration.zig b/test/cases/compile_errors/local_variable_redeclaration.zig
index a0861ada49..5b81cd5fbc 100644
--- a/test/cases/compile_errors/local_variable_redeclaration.zig
+++ b/test/cases/compile_errors/local_variable_redeclaration.zig
@@ -1,5 +1,5 @@
export fn f() void {
- const a : i32 = 0;
+ const a: i32 = 0;
var a = 0;
}
diff --git a/test/cases/compile_errors/local_variable_redeclares_parameter.zig b/test/cases/compile_errors/local_variable_redeclares_parameter.zig
index 6e523c2c8f..f49b7f137e 100644
--- a/test/cases/compile_errors/local_variable_redeclares_parameter.zig
+++ b/test/cases/compile_errors/local_variable_redeclares_parameter.zig
@@ -1,7 +1,9 @@
-fn f(a : i32) void {
+fn f(a: i32) void {
const a = 0;
}
-export fn entry() void { f(1); }
+export fn entry() void {
+ f(1);
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/local_variable_shadowing_global.zig b/test/cases/compile_errors/local_variable_shadowing_global.zig
index 91df6a7c3d..e3f221d0c5 100644
--- a/test/cases/compile_errors/local_variable_shadowing_global.zig
+++ b/test/cases/compile_errors/local_variable_shadowing_global.zig
@@ -2,7 +2,7 @@ const Foo = struct {};
const Bar = struct {};
export fn entry() void {
- var Bar : i32 = undefined;
+ var Bar: i32 = undefined;
_ = Bar;
}
diff --git a/test/cases/compile_errors/main_function_with_bogus_args_type.zig b/test/cases/compile_errors/main_function_with_bogus_args_type.zig
index dd02e1af34..f0322e0484 100644
--- a/test/cases/compile_errors/main_function_with_bogus_args_type.zig
+++ b/test/cases/compile_errors/main_function_with_bogus_args_type.zig
@@ -1,4 +1,6 @@
-pub fn main(args: [][]bogus) !void {_ = args;}
+pub fn main(args: [][]bogus) !void {
+ _ = args;
+}
// error
// backend=stage2
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 1ef986935b..2f596db1ed 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
@@ -2,7 +2,7 @@ const Geo3DTex2D = struct { vertices: [][2]f32 };
pub fn getGeo3DTex2D() Geo3DTex2D {
return Geo3DTex2D{
.vertices = [_][2]f32{
- [_]f32{ -0.5, -0.5},
+ [_]f32{ -0.5, -0.5 },
},
};
}
diff --git a/test/cases/compile_errors/missing_else_clause.zig b/test/cases/compile_errors/missing_else_clause.zig
index e96363b9cd..13a164ddea 100644
--- a/test/cases/compile_errors/missing_else_clause.zig
+++ b/test/cases/compile_errors/missing_else_clause.zig
@@ -1,9 +1,13 @@
fn f(b: bool) void {
- const x : i32 = if (b) h: { break :h 1; };
+ const x: i32 = if (b) h: {
+ break :h 1;
+ };
_ = x;
}
fn g(b: bool) void {
- const y = if (b) h: { break :h @as(i32, 1); };
+ const y = if (b) h: {
+ break :h @as(i32, 1);
+ };
_ = y;
}
fn h() void {
@@ -30,10 +34,10 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :2:21: error: incompatible types: 'i32' and 'void'
-// :2:31: note: type 'i32' here
-// :6:15: error: incompatible types: 'i32' and 'void'
-// :6:25: note: type 'i32' here
-// :12:16: error: expected type 'tmp.h.T', found 'void'
-// :11:15: note: struct declared here
-// :18:9: error: incompatible types: 'void' and 'tmp.k.T'
+// :2:20: error: incompatible types: 'i32' and 'void'
+// :2:30: note: type 'i32' here
+// :8:15: error: incompatible types: 'i32' and 'void'
+// :8:25: note: type 'i32' here
+// :16:16: error: expected type 'tmp.h.T', found 'void'
+// :15:15: note: struct declared here
+// :22:9: error: incompatible types: 'void' and 'tmp.k.T'
diff --git a/test/cases/compile_errors/missing_field_in_struct_value_expression.zig b/test/cases/compile_errors/missing_field_in_struct_value_expression.zig
index 600540d1e0..eec50ee1af 100644
--- a/test/cases/compile_errors/missing_field_in_struct_value_expression.zig
+++ b/test/cases/compile_errors/missing_field_in_struct_value_expression.zig
@@ -1,12 +1,12 @@
const A = struct {
- x : i32,
- y : i32,
- z : i32,
+ x: i32,
+ y: i32,
+ z: i32,
};
export fn f() void {
// we want the error on the '{' not the 'A' because
// the A could be a complicated expression
- const a = A {
+ const a = A{
.z = 4,
.y = 2,
};
@@ -17,5 +17,5 @@ export fn f() void {
// backend=stage2
// target=native
//
-// :9:17: error: missing struct field: x
+// :9:16: error: missing struct field: x
// :1:11: note: struct 'tmp.A' declared here
diff --git a/test/cases/compile_errors/missing_main_fn_in_executable.zig b/test/cases/compile_errors/missing_main_fn_in_executable.zig
index 3c1ae631ac..9f243356b7 100644
--- a/test/cases/compile_errors/missing_main_fn_in_executable.zig
+++ b/test/cases/compile_errors/missing_main_fn_in_executable.zig
@@ -1,5 +1,3 @@
-
-
// error
// backend=llvm
// target=x86_64-linux
diff --git a/test/cases/compile_errors/missing_param_name.zig b/test/cases/compile_errors/missing_param_name.zig
index 88da902ea2..1f679ea1d8 100644
--- a/test/cases/compile_errors/missing_param_name.zig
+++ b/test/cases/compile_errors/missing_param_name.zig
@@ -1,5 +1,7 @@
fn f(i32) void {}
-export fn entry() usize { return @sizeOf(@TypeOf(f)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(f));
+}
// error
// backend=stage2
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 ef8fce6c80..ca8adade01 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,11 +24,13 @@ pub const JsonNode = struct {
fn foo() void {
var jll: JasonList = undefined;
jll.init(1234);
- var jd = JsonNode {.kind = JsonType.JSONArray , .jobject = JsonOA.JSONArray {jll} };
+ var jd = JsonNode{ .kind = JsonType.JSONArray, .jobject = JsonOA.JSONArray{jll} };
_ = jd;
}
-export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(foo));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/mul_overflow_in_function_evaluation.zig b/test/cases/compile_errors/mul_overflow_in_function_evaluation.zig
index 6be57f770e..c484df7540 100644
--- a/test/cases/compile_errors/mul_overflow_in_function_evaluation.zig
+++ b/test/cases/compile_errors/mul_overflow_in_function_evaluation.zig
@@ -3,7 +3,9 @@ fn mul(a: u16, b: u16) u16 {
return a * b;
}
-export fn entry() usize { return @sizeOf(@TypeOf(&y)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&y));
+}
// error
// backend=stage2
@@ -11,4 +13,3 @@ export fn entry() usize { return @sizeOf(@TypeOf(&y)); }
//
// :3:14: error: overflow of integer type 'u16' with value '1800000'
// :1:14: note: called from here
-
diff --git a/test/cases/compile_errors/multiple_function_definitions.zig b/test/cases/compile_errors/multiple_function_definitions.zig
index d07eaee257..134daaeaa4 100644
--- a/test/cases/compile_errors/multiple_function_definitions.zig
+++ b/test/cases/compile_errors/multiple_function_definitions.zig
@@ -1,6 +1,8 @@
fn a() void {}
fn a() void {}
-export fn entry() void { a(); }
+export fn entry() void {
+ a();
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/negation_overflow_in_function_evaluation.zig b/test/cases/compile_errors/negation_overflow_in_function_evaluation.zig
index abd8549fd2..208f761005 100644
--- a/test/cases/compile_errors/negation_overflow_in_function_evaluation.zig
+++ b/test/cases/compile_errors/negation_overflow_in_function_evaluation.zig
@@ -3,7 +3,9 @@ fn neg(x: i8) i8 {
return -x;
}
-export fn entry() usize { return @sizeOf(@TypeOf(&y)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&y));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/nested_vectors.zig b/test/cases/compile_errors/nested_vectors.zig
index 11b09971e9..29934668b0 100644
--- a/test/cases/compile_errors/nested_vectors.zig
+++ b/test/cases/compile_errors/nested_vectors.zig
@@ -10,4 +10,3 @@ export fn entry() void {
// target=native
//
// :3:16: error: expected integer, float, bool, or pointer for the vector element type; found '@Vector(4, u8)'
-
diff --git a/test/cases/compile_errors/noalias_on_non_pointer_param.zig b/test/cases/compile_errors/noalias_on_non_pointer_param.zig
index 65e6e141ce..45641fcabc 100644
--- a/test/cases/compile_errors/noalias_on_non_pointer_param.zig
+++ b/test/cases/compile_errors/noalias_on_non_pointer_param.zig
@@ -1,11 +1,19 @@
-fn f(noalias x: i32) void { _ = x; }
-export fn entry() void { f(1234); }
+fn f(noalias x: i32) void {
+ _ = x;
+}
+export fn entry() void {
+ f(1234);
+}
-fn generic(comptime T: type, noalias _: [*]T, noalias _: [*]const T, _: usize) void {}
-comptime { _ = &generic; }
+fn generic(comptime T: type, noalias _: [*]T, noalias _: [*]const T, _: usize) void {}
+comptime {
+ _ = &generic;
+}
-fn slice(noalias _: []u8) void {}
-comptime { _ = &slice; }
+fn slice(noalias _: []u8) void {}
+comptime {
+ _ = &slice;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig b/test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig
index de5a3830eb..f5eba9ee62 100644
--- a/test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig
+++ b/test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig
@@ -5,8 +5,7 @@ export fn entry() void {
_ = llamas2;
}
-fn makeLlamas(count: usize) [count]u8 {
-}
+fn makeLlamas(count: usize) [count]u8 {}
// error
// target=native
diff --git a/test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig b/test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig
index 4acd0afb81..d9bd0dd2b2 100644
--- a/test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig
+++ b/test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig
@@ -4,11 +4,13 @@ const Foo = struct {
const a = get_it();
fn get_it() Foo {
global_side_effect = true;
- return Foo {.x = 13};
+ return Foo{ .x = 13 };
}
var global_side_effect = false;
-export fn entry() usize { return @sizeOf(@TypeOf(a)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(a));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/non-const_expression_in_struct_literal_outside_function.zig b/test/cases/compile_errors/non-const_expression_in_struct_literal_outside_function.zig
index 2e0043c5ec..c6d4e04fc1 100644
--- a/test/cases/compile_errors/non-const_expression_in_struct_literal_outside_function.zig
+++ b/test/cases/compile_errors/non-const_expression_in_struct_literal_outside_function.zig
@@ -1,10 +1,12 @@
const Foo = struct {
x: i32,
};
-const a = Foo {.x = get_it()};
+const a = Foo{ .x = get_it() };
extern fn get_it() i32;
-export fn entry() usize { return @sizeOf(@TypeOf(a)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(a));
+}
// error
// backend=stage2
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 cf65131a1f..48b92460c4 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;
+ var m2 = &2;
+ _ = m2;
}
export fn entry2() void {
- var a = undefined;
- _ = a;
+ var a = undefined;
+ _ = a;
}
export fn entry3() void {
- var b = 1;
- _ = b;
+ var b = 1;
+ _ = b;
}
export fn entry4() void {
- var c = 1.0;
- _ = c;
+ var c = 1.0;
+ _ = c;
}
export fn entry5() void {
- var d = null;
- _ = d;
+ var d = null;
+ _ = d;
}
export fn entry6(opaque_: *Opaque) void {
- var e = opaque_.*;
- _ = e;
+ var e = opaque_.*;
+ _ = e;
}
export fn entry7() void {
- var f = i32;
- _ = f;
+ var f = i32;
+ _ = f;
}
const Opaque = opaque {};
@@ -32,14 +32,14 @@ const Opaque = opaque {};
// backend=stage2
// target=native
//
-// :2:8: error: variable of type '*const comptime_int' must be const or comptime
-// :6:8: error: variable of type '@TypeOf(undefined)' must be const or comptime
-// :10:8: error: variable of type 'comptime_int' must be const or comptime
-// :10:8: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
-// :14:8: error: variable of type 'comptime_float' must be const or comptime
-// :14:8: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
-// :18:8: error: variable of type '@TypeOf(null)' must be const or comptime
-// :22:19: error: values of type 'tmp.Opaque' must be comptime-known, but operand value is runtime-known
-// :22:19: note: opaque type 'tmp.Opaque' has undefined size
-// :26:8: error: variable of type 'type' must be const or comptime
-// :26:8: note: types are not available at runtime
+// :2:9: error: variable of type '*const comptime_int' must be const or comptime
+// :6:9: error: variable of type '@TypeOf(undefined)' must be const or comptime
+// :10:9: error: variable of type 'comptime_int' must be const or comptime
+// :10:9: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
+// :14:9: error: variable of type 'comptime_float' must be const or comptime
+// :14:9: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
+// :18:9: error: variable of type '@TypeOf(null)' must be const or comptime
+// :22:20: error: values of type 'tmp.Opaque' must be comptime-known, but operand value is runtime-known
+// :22:20: note: opaque type 'tmp.Opaque' has undefined size
+// :26:9: error: variable of type 'type' must be const or comptime
+// :26:9: note: types are not available at runtime
diff --git a/test/cases/compile_errors/non-exhaustive_enum_marker_assigned_a_value.zig b/test/cases/compile_errors/non-exhaustive_enum_marker_assigned_a_value.zig
index c9ebb6af71..831845722b 100644
--- a/test/cases/compile_errors/non-exhaustive_enum_marker_assigned_a_value.zig
+++ b/test/cases/compile_errors/non-exhaustive_enum_marker_assigned_a_value.zig
@@ -8,7 +8,10 @@ const B = enum {
b,
_,
};
-comptime { _ = A; _ = B; }
+comptime {
+ _ = A;
+ _ = B;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/non-inline_for_loop_on_a_type_that_requires_comptime.zig b/test/cases/compile_errors/non-inline_for_loop_on_a_type_that_requires_comptime.zig
index ce72f912b8..2bb3f84cb9 100644
--- a/test/cases/compile_errors/non-inline_for_loop_on_a_type_that_requires_comptime.zig
+++ b/test/cases/compile_errors/non-inline_for_loop_on_a_type_that_requires_comptime.zig
@@ -4,7 +4,9 @@ const Foo = struct {
};
export fn entry() void {
const xx: [2]Foo = .{ .{ .name = "", .T = u8 }, .{ .name = "", .T = u8 } };
- for (xx) |f| { _ = f;}
+ for (xx) |f| {
+ _ = f;
+ }
}
// error
diff --git a/test/cases/compile_errors/non_constant_expression_in_array_size.zig b/test/cases/compile_errors/non_constant_expression_in_array_size.zig
index 07facfa0f2..7c4594a3e3 100644
--- a/test/cases/compile_errors/non_constant_expression_in_array_size.zig
+++ b/test/cases/compile_errors/non_constant_expression_in_array_size.zig
@@ -2,14 +2,18 @@ const Foo = struct {
y: [get()]u8,
};
var global_var: usize = 1;
-fn get() usize { return global_var; }
+fn get() usize {
+ return global_var;
+}
-export fn entry() usize { return @offsetOf(Foo, "y"); }
+export fn entry() usize {
+ return @offsetOf(Foo, "y");
+}
// error
// backend=stage2
// target=native
//
-// :5:18: error: unable to resolve comptime value
-// :5:18: note: value being returned at comptime must be comptime-known
+// :6:5: error: unable to resolve comptime value
+// :6:5: note: value being returned at comptime must be comptime-known
// :2:12: note: called from here
diff --git a/test/cases/compile_errors/non_float_passed_to_floatToInt.zig b/test/cases/compile_errors/non_float_passed_to_floatToInt.zig
deleted file mode 100644
index 2d4e0315be..0000000000
--- a/test/cases/compile_errors/non_float_passed_to_floatToInt.zig
+++ /dev/null
@@ -1,10 +0,0 @@
-export fn entry() void {
- const x = @floatToInt(i32, @as(i32, 54));
- _ = x;
-}
-
-// error
-// backend=stage2
-// target=native
-//
-// :2:32: error: expected float type, found 'i32'
diff --git a/test/cases/compile_errors/non_float_passed_to_intFromFloat.zig b/test/cases/compile_errors/non_float_passed_to_intFromFloat.zig
new file mode 100644
index 0000000000..fac51c59c8
--- /dev/null
+++ b/test/cases/compile_errors/non_float_passed_to_intFromFloat.zig
@@ -0,0 +1,10 @@
+export fn entry() void {
+ const x = @intFromFloat(i32, @as(i32, 54));
+ _ = x;
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// :2:34: error: expected float type, found 'i32'
diff --git a/test/cases/compile_errors/non_int_passed_to_floatFromInt.zig b/test/cases/compile_errors/non_int_passed_to_floatFromInt.zig
new file mode 100644
index 0000000000..63e6753a53
--- /dev/null
+++ b/test/cases/compile_errors/non_int_passed_to_floatFromInt.zig
@@ -0,0 +1,10 @@
+export fn entry() void {
+ const x = @floatFromInt(f32, 1.1);
+ _ = x;
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// :2:34: error: expected integer type, found 'comptime_float'
diff --git a/test/cases/compile_errors/non_int_passed_to_intToFloat.zig b/test/cases/compile_errors/non_int_passed_to_intToFloat.zig
deleted file mode 100644
index f40fa93df0..0000000000
--- a/test/cases/compile_errors/non_int_passed_to_intToFloat.zig
+++ /dev/null
@@ -1,10 +0,0 @@
-export fn entry() void {
- const x = @intToFloat(f32, 1.1);
- _ = x;
-}
-
-// error
-// backend=stage2
-// target=native
-//
-// :2:32: error: expected integer type, found 'comptime_float'
diff --git a/test/cases/compile_errors/non_pointer_given_to_ptrToInt.zig b/test/cases/compile_errors/non_pointer_given_to_intFromPtr.zig
index 27b5d6d1f7..cb8ea24f63 100644
--- a/test/cases/compile_errors/non_pointer_given_to_ptrToInt.zig
+++ b/test/cases/compile_errors/non_pointer_given_to_intFromPtr.zig
@@ -1,9 +1,9 @@
export fn entry(x: i32) usize {
- return @ptrToInt(x);
+ return @intFromPtr(x);
}
// error
// backend=stage2
// target=native
//
-// :2:22: error: expected pointer, found 'i32'
+// :2:24: error: expected pointer, found 'i32'
diff --git a/test/cases/compile_errors/offsetOf-bad_field_name.zig b/test/cases/compile_errors/offsetOf-bad_field_name.zig
index eb04da3c68..ceded4f618 100644
--- a/test/cases/compile_errors/offsetOf-bad_field_name.zig
+++ b/test/cases/compile_errors/offsetOf-bad_field_name.zig
@@ -2,12 +2,15 @@ const Foo = struct {
derp: i32,
};
export fn foo() usize {
- return @offsetOf(Foo, "a",);
+ return @offsetOf(
+ Foo,
+ "a",
+ );
}
// error
// backend=stage2
// target=native
//
-// :5:27: error: no field named 'a' in struct 'tmp.Foo'
+// :7:9: error: no field named 'a' in struct 'tmp.Foo'
// :1:13: note: struct declared here
diff --git a/test/cases/compile_errors/offsetOf-non_struct.zig b/test/cases/compile_errors/offsetOf-non_struct.zig
index 45e9cf9518..8970fa86d9 100644
--- a/test/cases/compile_errors/offsetOf-non_struct.zig
+++ b/test/cases/compile_errors/offsetOf-non_struct.zig
@@ -1,6 +1,6 @@
const Foo = i32;
export fn foo() usize {
- return @offsetOf(Foo, "a",);
+ return @offsetOf(Foo, "a");
}
// error
diff --git a/test/cases/compile_errors/old_fn_ptr_in_extern_context.zig b/test/cases/compile_errors/old_fn_ptr_in_extern_context.zig
index 4f957a827c..7983ed8ec8 100644
--- a/test/cases/compile_errors/old_fn_ptr_in_extern_context.zig
+++ b/test/cases/compile_errors/old_fn_ptr_in_extern_context.zig
@@ -5,7 +5,7 @@ comptime {
_ = @sizeOf(S) == 1;
}
comptime {
- _ = [*c][4]fn() callconv(.C) void;
+ _ = [*c][4]fn () callconv(.C) void;
}
// error
diff --git a/test/cases/compile_errors/out_of_int_range_comptime_float_passed_to_intFromFloat.zig b/test/cases/compile_errors/out_of_int_range_comptime_float_passed_to_intFromFloat.zig
new file mode 100644
index 0000000000..574ffc5a20
--- /dev/null
+++ b/test/cases/compile_errors/out_of_int_range_comptime_float_passed_to_intFromFloat.zig
@@ -0,0 +1,10 @@
+export fn entry() void {
+ const x = @intFromFloat(i8, 200);
+ _ = x;
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// :2:33: error: float value '200' cannot be stored in integer type 'i8'
diff --git a/test/cases/compile_errors/out_of_range_comptime_int_passed_to_floatToInt.zig b/test/cases/compile_errors/out_of_range_comptime_int_passed_to_floatToInt.zig
deleted file mode 100644
index 426e0c95cb..0000000000
--- a/test/cases/compile_errors/out_of_range_comptime_int_passed_to_floatToInt.zig
+++ /dev/null
@@ -1,10 +0,0 @@
-export fn entry() void {
- const x = @floatToInt(i8, 200);
- _ = x;
-}
-
-// error
-// backend=stage2
-// target=native
-//
-// :2:31: error: float value '200' cannot be stored in integer type 'i8'
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 2a5b55e86d..821ac6c256 100644
--- a/test/cases/compile_errors/overflow_in_enum_value_allocation.zig
+++ b/test/cases/compile_errors/overflow_in_enum_value_allocation.zig
@@ -3,8 +3,8 @@ const Moo = enum(u8) {
Over,
};
pub export fn entry() void {
- var y = Moo.Last;
- _ = y;
+ var y = Moo.Last;
+ _ = y;
}
// error
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 03aaef0d8c..2e69afd0a9 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 };
+ var 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 0db9d83dfb..26d224de85 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 };
+ var a = Payload{ .B = true };
_ = a;
}
diff --git a/test/cases/compile_errors/panic_called_at_compile_time.zig b/test/cases/compile_errors/panic_called_at_compile_time.zig
index 220161930b..8198cd8e5d 100644
--- a/test/cases/compile_errors/panic_called_at_compile_time.zig
+++ b/test/cases/compile_errors/panic_called_at_compile_time.zig
@@ -1,6 +1,8 @@
export fn entry() void {
comptime {
- @panic("aoeu",);
+ @panic(
+ "aoeu",
+ );
}
}
diff --git a/test/cases/compile_errors/parameter_redeclaration.zig b/test/cases/compile_errors/parameter_redeclaration.zig
index 89c7c4bd2a..1805c9ac75 100644
--- a/test/cases/compile_errors/parameter_redeclaration.zig
+++ b/test/cases/compile_errors/parameter_redeclaration.zig
@@ -1,10 +1,11 @@
-fn f(a : i32, a : i32) void {
+fn f(a: i32, a: i32) void {}
+export fn entry() void {
+ f(1, 2);
}
-export fn entry() void { f(1, 2); }
// error
// backend=stage2
// target=native
//
-// :1:15: error: redeclaration of function parameter 'a'
+// :1:14: error: redeclaration of function parameter 'a'
// :1:6: note: previous declaration here
diff --git a/test/cases/compile_errors/pass_const_ptr_to_mutable_ptr_fn.zig b/test/cases/compile_errors/pass_const_ptr_to_mutable_ptr_fn.zig
index fd24b58f55..7914a82518 100644
--- a/test/cases/compile_errors/pass_const_ptr_to_mutable_ptr_fn.zig
+++ b/test/cases/compile_errors/pass_const_ptr_to_mutable_ptr_fn.zig
@@ -1,14 +1,17 @@
fn foo() bool {
- const a = @as([]const u8, "a",);
+ const a = @as([]const u8, "a");
const b = &a;
return ptrEql(b, b);
}
fn ptrEql(a: *[]const u8, b: *[]const u8) bool {
- _ = a; _ = b;
+ _ = a;
+ _ = b;
return true;
}
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/passing_an_under-aligned_function_pointer.zig b/test/cases/compile_errors/passing_an_under-aligned_function_pointer.zig
index 3e3500e71f..6d3e2e871d 100644
--- a/test/cases/compile_errors/passing_an_under-aligned_function_pointer.zig
+++ b/test/cases/compile_errors/passing_an_under-aligned_function_pointer.zig
@@ -4,7 +4,9 @@ export fn entry() void {
fn testImplicitlyDecreaseFnAlign(ptr: *const fn () align(8) i32, answer: i32) void {
if (ptr() != answer) unreachable;
}
-fn alignedSmall() align(4) i32 { return 1234; }
+fn alignedSmall() align(4) i32 {
+ return 1234;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/pointer_to_noreturn.zig b/test/cases/compile_errors/pointer_to_noreturn.zig
index 0891fd3699..5d757f631b 100644
--- a/test/cases/compile_errors/pointer_to_noreturn.zig
+++ b/test/cases/compile_errors/pointer_to_noreturn.zig
@@ -1,5 +1,7 @@
fn a() *noreturn {}
-export fn entry() void { _ = a(); }
+export fn entry() void {
+ _ = a();
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/ptrFromInt_non_ptr_type.zig b/test/cases/compile_errors/ptrFromInt_non_ptr_type.zig
new file mode 100644
index 0000000000..f472789aff
--- /dev/null
+++ b/test/cases/compile_errors/ptrFromInt_non_ptr_type.zig
@@ -0,0 +1,15 @@
+pub export fn entry() void {
+ _ = @ptrFromInt(i32, 10);
+}
+
+pub export fn entry2() void {
+ _ = @ptrFromInt([]u8, 20);
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// :2:21: error: expected pointer type, found 'i32'
+// :6:21: error: integer cannot be converted to slice type '[]u8'
+// :6:21: note: slice length cannot be inferred from address
diff --git a/test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig b/test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig
new file mode 100644
index 0000000000..c45e998d82
--- /dev/null
+++ b/test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig
@@ -0,0 +1,10 @@
+pub export fn entry() void {
+ var y = @ptrFromInt([*]align(4) u8, 5);
+ _ = y;
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// :2:41: error: pointer type '[*]align(4) u8' requires aligned address
diff --git a/test/cases/compile_errors/ptrToInt_0_to_non_optional_pointer.zig b/test/cases/compile_errors/ptrToInt_0_to_non_optional_pointer.zig
deleted file mode 100644
index 86a5dd6dca..0000000000
--- a/test/cases/compile_errors/ptrToInt_0_to_non_optional_pointer.zig
+++ /dev/null
@@ -1,10 +0,0 @@
-export fn entry() void {
- var b = @intToPtr(*i32, 0);
- _ = b;
-}
-
-// error
-// backend=stage2
-// target=native
-//
-// :2:29: error: pointer type '*i32' does not allow address zero
diff --git a/test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig b/test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig
index 859197929c..99dd773f32 100644
--- a/test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig
+++ b/test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig
@@ -1,13 +1,13 @@
export fn entry() void {
foo(452) catch |err| switch (err) {
- error.Foo ... error.Bar => {},
+ error.Foo...error.Bar => {},
else => {},
};
}
fn foo(x: i32) !void {
switch (x) {
- 0 ... 10 => return error.Foo,
- 11 ... 20 => return error.Bar,
+ 0...10 => return error.Foo,
+ 11...20 => return error.Bar,
else => {},
}
}
@@ -17,4 +17,4 @@ fn foo(x: i32) !void {
// target=native
//
// :2:34: error: ranges not allowed when switching on type '@typeInfo(@typeInfo(@TypeOf(tmp.foo)).Fn.return_type.?).ErrorUnion.error_set'
-// :3:19: note: range here
+// :3:18: note: range here
diff --git a/test/cases/compile_errors/reassign_to_array_parameter.zig b/test/cases/compile_errors/reassign_to_array_parameter.zig
index 4927329970..380fd62154 100644
--- a/test/cases/compile_errors/reassign_to_array_parameter.zig
+++ b/test/cases/compile_errors/reassign_to_array_parameter.zig
@@ -1,8 +1,8 @@
fn reassign(a: [3]f32) void {
- a = [3]f32{4, 5, 6};
+ a = [3]f32{ 4, 5, 6 };
}
export fn entry() void {
- reassign(.{1, 2, 3});
+ reassign(.{ 1, 2, 3 });
}
// error
diff --git a/test/cases/compile_errors/reassign_to_struct_parameter.zig b/test/cases/compile_errors/reassign_to_struct_parameter.zig
index 963448f8fe..560de215b5 100644
--- a/test/cases/compile_errors/reassign_to_struct_parameter.zig
+++ b/test/cases/compile_errors/reassign_to_struct_parameter.zig
@@ -2,10 +2,10 @@ const S = struct {
x: u32,
};
fn reassign(s: S) void {
- s = S{.x = 2};
+ s = S{ .x = 2 };
}
export fn entry() void {
- reassign(S{.x = 3});
+ reassign(S{ .x = 3 });
}
// error
diff --git a/test/cases/compile_errors/redefinition_of_enums.zig b/test/cases/compile_errors/redefinition_of_enums.zig
index 641211872e..34d5efe8df 100644
--- a/test/cases/compile_errors/redefinition_of_enums.zig
+++ b/test/cases/compile_errors/redefinition_of_enums.zig
@@ -1,5 +1,5 @@
-const A = enum {x};
-const A = enum {x};
+const A = enum { x };
+const A = enum { x };
// error
// backend=stage2
diff --git a/test/cases/compile_errors/redefinition_of_global_variables.zig b/test/cases/compile_errors/redefinition_of_global_variables.zig
index ed0d6f3ed9..6f4ed225f7 100644
--- a/test/cases/compile_errors/redefinition_of_global_variables.zig
+++ b/test/cases/compile_errors/redefinition_of_global_variables.zig
@@ -1,5 +1,5 @@
-var a : i32 = 1;
-var a : i32 = 2;
+var a: i32 = 1;
+var a: i32 = 2;
// error
// backend=stage2
diff --git a/test/cases/compile_errors/redefinition_of_struct.zig b/test/cases/compile_errors/redefinition_of_struct.zig
index dc6d4abeeb..22852966db 100644
--- a/test/cases/compile_errors/redefinition_of_struct.zig
+++ b/test/cases/compile_errors/redefinition_of_struct.zig
@@ -1,5 +1,5 @@
-const A = struct { x : i32, };
-const A = struct { y : i32, };
+const A = struct { x: i32 };
+const A = struct { y: i32 };
// error
// backend=stage2
diff --git a/test/cases/compile_errors/reference_to_const_data.zig b/test/cases/compile_errors/reference_to_const_data.zig
index cbc0fe131c..e773cdb4a0 100644
--- a/test/cases/compile_errors/reference_to_const_data.zig
+++ b/test/cases/compile_errors/reference_to_const_data.zig
@@ -1,5 +1,5 @@
export fn foo() void {
- var ptr = &[_]u8{0,0,0,0};
+ var ptr = &[_]u8{ 0, 0, 0, 0 };
ptr[1] = 2;
}
export fn bar() void {
@@ -11,11 +11,11 @@ export fn baz() void {
ptr.* = false;
}
export fn qux() void {
- const S = struct{
+ const S = struct {
x: usize,
y: usize,
};
- var ptr = &S{.x=1,.y=2};
+ var ptr = &S{ .x = 1, .y = 2 };
ptr.x = 2;
}
export fn quux() void {
diff --git a/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig b/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig
index abdccdf36d..bb2c4bbe62 100644
--- a/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig
+++ b/test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig
@@ -8,7 +8,9 @@ const Foo = @Type(.{
.params = &.{},
},
});
-comptime { _ = Foo; }
+comptime {
+ _ = Foo;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig b/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig
index f3542d583a..a341435b36 100644
--- a/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig
+++ b/test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig
@@ -8,7 +8,9 @@ const Foo = @Type(.{
.params = &.{},
},
});
-comptime { _ = Foo; }
+comptime {
+ _ = Foo;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig b/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig
index 49335ab693..d348a0c908 100644
--- a/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig
+++ b/test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig
@@ -8,7 +8,9 @@ const Foo = @Type(.{
.params = &.{},
},
});
-comptime { _ = Foo; }
+comptime {
+ _ = Foo;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig
index 60c6ce9a59..9b140a0923 100644
--- a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig
+++ b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig
@@ -7,7 +7,7 @@ const Tag = @Type(.{
},
});
export fn entry() void {
- _ = @intToEnum(Tag, 0);
+ _ = @enumFromInt(Tag, 0);
}
// error
diff --git a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig
index 896d689046..b2cd8e1214 100644
--- a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig
+++ b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig
@@ -7,7 +7,7 @@ const Tag = @Type(.{
},
});
export fn entry() void {
- _ = @intToEnum(Tag, 0);
+ _ = @enumFromInt(Tag, 0);
}
// error
diff --git a/test/cases/compile_errors/reify_type_union_payload_is_undefined.zig b/test/cases/compile_errors/reify_type_union_payload_is_undefined.zig
index 410bb92658..886d443a00 100644
--- a/test/cases/compile_errors/reify_type_union_payload_is_undefined.zig
+++ b/test/cases/compile_errors/reify_type_union_payload_is_undefined.zig
@@ -1,7 +1,9 @@
const Foo = @Type(.{
.Struct = undefined,
});
-comptime { _ = Foo; }
+comptime {
+ _ = Foo;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/return_from_defer_expression.zig b/test/cases/compile_errors/return_from_defer_expression.zig
index 12aa08a11c..28d1b0c6c6 100644
--- a/test/cases/compile_errors/return_from_defer_expression.zig
+++ b/test/cases/compile_errors/return_from_defer_expression.zig
@@ -6,13 +6,15 @@ pub fn testTrickyDefer() !void {
const a = maybeInt() orelse return;
}
-fn canFail() anyerror!void { }
+fn canFail() anyerror!void {}
pub fn maybeInt() ?i32 {
return 0;
}
-export fn entry() usize { return @sizeOf(@TypeOf(testTrickyDefer)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(testTrickyDefer));
+}
// error
// backend=stage2
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 5949031fb9..39e9662679 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
@@ -4,7 +4,7 @@ const Foo = struct {
};
export fn f() void {
var x: u8 = 0;
- const foo = Foo { .Bar = x, .Baz = u8 };
+ const foo = Foo{ .Bar = x, .Baz = u8 };
_ = foo;
}
@@ -12,5 +12,5 @@ export fn f() void {
// backend=stage2
// target=native
//
-// :7:30: error: unable to resolve comptime value
-// :7:30: note: initializer of comptime only struct must be comptime-known
+// :7:29: error: unable to resolve comptime value
+// :7:29: note: initializer of comptime only struct must be comptime-known
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 04e2a97e7a..71a490bc2f 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,7 +4,7 @@ const Foo = union {
};
export fn f() void {
var x: u8 = 0;
- const foo = Foo { .Bar = x };
+ const foo = Foo{ .Bar = x };
_ = foo;
}
@@ -12,5 +12,5 @@ export fn f() void {
// backend=stage2
// target=native
//
-// :7:30: error: unable to resolve comptime value
-// :7:30: note: initializer of comptime only union must be comptime-known
+// :7:29: error: unable to resolve comptime value
+// :7:29: note: initializer of comptime only union must be comptime-known
diff --git a/test/cases/compile_errors/runtime_to_comptime_num.zig b/test/cases/compile_errors/runtime_to_comptime_num.zig
index 972adb59bb..8d4a3fb999 100644
--- a/test/cases/compile_errors/runtime_to_comptime_num.zig
+++ b/test/cases/compile_errors/runtime_to_comptime_num.zig
@@ -2,16 +2,16 @@ pub export fn entry() void {
var a: u32 = 0;
_ = @as(comptime_int, a);
}
-pub export fn entry2() void{
+pub export fn entry2() void {
var a: u32 = 0;
_ = @as(comptime_float, a);
}
-pub export fn entry3() void{
+pub export fn entry3() void {
comptime var aa: comptime_float = 0.0;
var a: f32 = 4;
aa = a;
}
-pub export fn entry4() void{
+pub export fn entry4() void {
comptime var aa: comptime_int = 0.0;
var a: f32 = 4;
aa = a;
diff --git a/test/cases/compile_errors/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig b/test/cases/compile_errors/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig
index c8e95e3969..e835db2cdf 100644
--- a/test/cases/compile_errors/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig
+++ b/test/cases/compile_errors/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig
@@ -1,12 +1,12 @@
export fn a() void {
comptime {
- var x = @as(i32, 1);
- x <<|= @as(i32, -2);
- }
+ var x = @as(i32, 1);
+ x <<|= @as(i32, -2);
+ }
}
// error
// backend=stage2
// target=native
//
-// :4:14: error: shift by negative amount '-2'
+// :4:16: error: shift by negative amount '-2'
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 3ce7571026..661a12df97 100644
--- a/test/cases/compile_errors/self_referential_struct_requires_comptime.zig
+++ b/test/cases/compile_errors/self_referential_struct_requires_comptime.zig
@@ -7,7 +7,6 @@ pub export fn entry() void {
_ = s;
}
-
// error
// backend=stage2
// target=native
diff --git a/test/cases/compile_errors/setAlignStack_in_inline_function.zig b/test/cases/compile_errors/setAlignStack_in_inline_function.zig
index 62bbb3865c..a84424e368 100644
--- a/test/cases/compile_errors/setAlignStack_in_inline_function.zig
+++ b/test/cases/compile_errors/setAlignStack_in_inline_function.zig
@@ -1,7 +1,7 @@
export fn entry() void {
foo();
}
-fn foo() callconv(.Inline) void {
+inline fn foo() void {
@setAlignStack(16);
}
@@ -12,7 +12,6 @@ fn bar() void {
@setAlignStack(16);
}
-
// error
// backend=stage2
// target=native
diff --git a/test/cases/compile_errors/slice_passed_as_array_init_type_with_elems.zig b/test/cases/compile_errors/slice_passed_as_array_init_type_with_elems.zig
index 7af505e20d..91dc5f5128 100644
--- a/test/cases/compile_errors/slice_passed_as_array_init_type_with_elems.zig
+++ b/test/cases/compile_errors/slice_passed_as_array_init_type_with_elems.zig
@@ -1,5 +1,5 @@
export fn entry() void {
- const x = []u8{1, 2};
+ const x = []u8{ 1, 2 };
_ = x;
}
diff --git a/test/cases/compile_errors/slice_sentinel_mismatch-2.zig b/test/cases/compile_errors/slice_sentinel_mismatch-2.zig
index ea34805e32..42c1328bb6 100644
--- a/test/cases/compile_errors/slice_sentinel_mismatch-2.zig
+++ b/test/cases/compile_errors/slice_sentinel_mismatch-2.zig
@@ -2,7 +2,9 @@ fn foo() [:0]u8 {
var x: []u8 = undefined;
return x;
}
-comptime { _ = &foo; }
+comptime {
+ _ = &foo;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/slice_used_as_extern_fn_param.zig b/test/cases/compile_errors/slice_used_as_extern_fn_param.zig
index 8391c3e21b..e6b065cd62 100644
--- a/test/cases/compile_errors/slice_used_as_extern_fn_param.zig
+++ b/test/cases/compile_errors/slice_used_as_extern_fn_param.zig
@@ -1,4 +1,4 @@
-extern fn Text(str: []const u8, num: i32) callconv(.C) void;
+extern fn Text(str: []const u8, num: i32) callconv(.C) void;
export fn entry() void {
_ = Text;
}
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 d878bec18b..3024f1dee8 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
@@ -1,4 +1,4 @@
-const Small = enum (u2) {
+const Small = enum(u2) {
One,
Two,
Three,
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 f2ff3e2cd1..4fa7691a11 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
@@ -1,4 +1,4 @@
-const Small = enum (f32) {
+const Small = enum(f32) {
One,
Two,
Three,
@@ -13,4 +13,4 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :1:21: error: expected integer tag type, found 'f32'
+// :1:20: error: expected integer tag type, found 'f32'
diff --git a/test/cases/compile_errors/src_fields_runtime.zig b/test/cases/compile_errors/src_fields_runtime.zig
index 0bdb5af81c..a982831123 100644
--- a/test/cases/compile_errors/src_fields_runtime.zig
+++ b/test/cases/compile_errors/src_fields_runtime.zig
@@ -4,7 +4,10 @@ pub export fn entry1() void {
comptime var b: []const u8 = s.fn_name;
comptime var c: u32 = s.column;
comptime var d: u32 = s.line;
- _ = a; _ = b; _ = c; _ = d;
+ _ = a;
+ _ = b;
+ _ = c;
+ _ = d;
}
// error
diff --git a/test/cases/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig b/test/cases/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig
index c8d31ec8df..75f43ed914 100644
--- a/test/cases/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig
+++ b/test/cases/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig
@@ -1,10 +1,8 @@
fn Foo(comptime T: type) Foo(T) {
- return struct{ x: T };
+ return struct { x: T };
}
export fn entry() void {
- const t = Foo(u32) {
- .x = 1
- };
+ const t = Foo(u32){ .x = 1 };
_ = t;
}
diff --git a/test/cases/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig b/test/cases/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig
index 7c70fc5095..5bcf30547b 100644
--- a/test/cases/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig
+++ b/test/cases/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig
@@ -1,6 +1,10 @@
export fn foo() void {
var bar: u32 = 3;
- asm volatile ("" : [baz]"+r"(bar) : : "");
+ asm volatile (""
+ : [baz] "+r" (bar),
+ :
+ : ""
+ );
}
// error
diff --git a/test/cases/compile_errors/std.fmt_error_for_unused_arguments.zig b/test/cases/compile_errors/std.fmt_error_for_unused_arguments.zig
index a20f2798bc..6661fe54eb 100644
--- a/test/cases/compile_errors/std.fmt_error_for_unused_arguments.zig
+++ b/test/cases/compile_errors/std.fmt_error_for_unused_arguments.zig
@@ -1,5 +1,5 @@
export fn entry() void {
- @import("std").debug.print("{d} {d} {d} {d} {d}", .{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15});
+ @import("std").debug.print("{d} {d} {d} {d} {d}", .{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 });
}
// error
diff --git a/test/cases/compile_errors/struct_type_mismatch_in_arg.zig b/test/cases/compile_errors/struct_type_mismatch_in_arg.zig
index d051966c52..32bbc65648 100644
--- a/test/cases/compile_errors/struct_type_mismatch_in_arg.zig
+++ b/test/cases/compile_errors/struct_type_mismatch_in_arg.zig
@@ -1,18 +1,18 @@
const Foo = struct { i: i32 };
const Bar = struct { j: i32 };
-pub fn helper(_: Foo, _: Bar) void { }
+pub fn helper(_: Foo, _: Bar) void {}
comptime {
- helper(Bar { .j = 10 }, Bar { .j = 10 });
- helper(Bar { .i = 10 }, Bar { .j = 10 });
+ helper(Bar{ .j = 10 }, Bar{ .j = 10 });
+ helper(Bar{ .i = 10 }, Bar{ .j = 10 });
}
// error
// backend=stage2
// target=native
//
-// :7:16: error: expected type 'tmp.Foo', found 'tmp.Bar'
+// :7:15: error: expected type 'tmp.Foo', found 'tmp.Bar'
// :2:13: note: struct declared here
// :1:13: note: struct declared here
// :4:18: note: parameter type declared here
diff --git a/test/cases/compile_errors/struct_type_returned_from_non-generic_function.zig b/test/cases/compile_errors/struct_type_returned_from_non-generic_function.zig
index 27e2b7b1db..f5647625dd 100644
--- a/test/cases/compile_errors/struct_type_returned_from_non-generic_function.zig
+++ b/test/cases/compile_errors/struct_type_returned_from_non-generic_function.zig
@@ -1,5 +1,5 @@
pub export fn entry(param: usize) usize {
- return struct{ param };
+ return struct { param };
}
// error
diff --git a/test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig b/test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig
index 81864160dc..f0a2463228 100644
--- a/test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig
+++ b/test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig
@@ -1,5 +1,7 @@
export fn entry() void {
- _ = @Type(@typeInfo(struct { const foo = 1; }));
+ _ = @Type(@typeInfo(struct {
+ const foo = 1;
+ }));
}
// error
diff --git a/test/cases/compile_errors/struct_with_invalid_field.zig b/test/cases/compile_errors/struct_with_invalid_field.zig
index aa24b029bb..dbcf5243c2 100644
--- a/test/cases/compile_errors/struct_with_invalid_field.zig
+++ b/test/cases/compile_errors/struct_with_invalid_field.zig
@@ -1,10 +1,10 @@
-const std = @import("std",);
+const std = @import(
+ "std",
+);
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
-const HeaderWeight = enum {
- H1, H2, H3, H4, H5, H6,
-};
+const HeaderWeight = enum { H1, H2, H3, H4, H5, H6 };
const MdText = ArrayList(u8);
@@ -16,7 +16,7 @@ const MdNode = union(enum) {
};
export fn entry() void {
- const a = MdNode.Header {
+ const a = MdNode.Header{
.text = MdText.init(std.testing.allocator),
.weight = HeaderWeight.H1,
};
diff --git a/test/cases/compile_errors/sub_overflow_in_function_evaluation.zig b/test/cases/compile_errors/sub_overflow_in_function_evaluation.zig
index c87f998373..651ef34bdc 100644
--- a/test/cases/compile_errors/sub_overflow_in_function_evaluation.zig
+++ b/test/cases/compile_errors/sub_overflow_in_function_evaluation.zig
@@ -3,7 +3,9 @@ fn sub(a: u16, b: u16) u16 {
return a - b;
}
-export fn entry() usize { return @sizeOf(@TypeOf(&y)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&y));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/suspend_inside_suspend_block.zig b/test/cases/compile_errors/suspend_inside_suspend_block.zig
index 80436bd07f..29a7968e0b 100644
--- a/test/cases/compile_errors/suspend_inside_suspend_block.zig
+++ b/test/cases/compile_errors/suspend_inside_suspend_block.zig
@@ -3,8 +3,7 @@ export fn entry() void {
}
fn foo() void {
suspend {
- suspend {
- }
+ suspend {}
}
}
diff --git a/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong.zig b/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong.zig
index 7011f0a2d5..58f98a55f5 100644
--- a/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong.zig
+++ b/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong.zig
@@ -14,7 +14,9 @@ fn f(n: Number) i32 {
}
}
-export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&f));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong_when_else_present.zig b/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong_when_else_present.zig
index 89f1959375..045760e287 100644
--- a/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong_when_else_present.zig
+++ b/test/cases/compile_errors/switch_expression-duplicate_enumeration_prong_when_else_present.zig
@@ -15,7 +15,9 @@ fn f(n: Number) i32 {
}
}
-export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&f));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/switch_expression-duplicate_or_overlapping_integer_value.zig b/test/cases/compile_errors/switch_expression-duplicate_or_overlapping_integer_value.zig
index 60e361a47a..6e5bd53846 100644
--- a/test/cases/compile_errors/switch_expression-duplicate_or_overlapping_integer_value.zig
+++ b/test/cases/compile_errors/switch_expression-duplicate_or_overlapping_integer_value.zig
@@ -1,16 +1,18 @@
fn foo(x: u8) u8 {
return switch (x) {
- 0 ... 100 => @as(u8, 0),
- 101 ... 200 => 1,
- 201, 203 ... 207 => 2,
- 206 ... 255 => 3,
+ 0...100 => @as(u8, 0),
+ 101...200 => 1,
+ 201, 203...207 => 2,
+ 206...255 => 3,
};
}
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=stage2
// target=native
//
-// :6:13: error: duplicate switch value
-// :5:18: note: previous value here
+// :6:12: error: duplicate switch value
+// :5:17: note: previous value here
diff --git a/test/cases/compile_errors/switch_expression-duplicate_type.zig b/test/cases/compile_errors/switch_expression-duplicate_type.zig
index 59c9b0657a..44f745364c 100644
--- a/test/cases/compile_errors/switch_expression-duplicate_type.zig
+++ b/test/cases/compile_errors/switch_expression-duplicate_type.zig
@@ -7,7 +7,9 @@ fn foo(comptime T: type, x: T) u8 {
else => 3,
};
}
-export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(foo(u32, 0)));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/switch_expression-duplicate_type_struct_alias.zig b/test/cases/compile_errors/switch_expression-duplicate_type_struct_alias.zig
index 797d2bd50d..4420e575c9 100644
--- a/test/cases/compile_errors/switch_expression-duplicate_type_struct_alias.zig
+++ b/test/cases/compile_errors/switch_expression-duplicate_type_struct_alias.zig
@@ -11,7 +11,9 @@ fn foo(comptime T: type, x: T) u8 {
else => 3,
};
}
-export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(foo(u32, 0)));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/switch_expression-missing_enumeration_prong.zig b/test/cases/compile_errors/switch_expression-missing_enumeration_prong.zig
index 1075b837de..ca80d420ff 100644
--- a/test/cases/compile_errors/switch_expression-missing_enumeration_prong.zig
+++ b/test/cases/compile_errors/switch_expression-missing_enumeration_prong.zig
@@ -12,7 +12,9 @@ fn f(n: Number) i32 {
}
}
-export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&f));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/switch_expression-non_exhaustive_integer_prongs.zig b/test/cases/compile_errors/switch_expression-non_exhaustive_integer_prongs.zig
index 6770b5a055..83097f2733 100644
--- a/test/cases/compile_errors/switch_expression-non_exhaustive_integer_prongs.zig
+++ b/test/cases/compile_errors/switch_expression-non_exhaustive_integer_prongs.zig
@@ -3,7 +3,9 @@ fn foo(x: u8) void {
0 => {},
}
}
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/switch_expression-switch_on_pointer_type_with_no_else.zig b/test/cases/compile_errors/switch_expression-switch_on_pointer_type_with_no_else.zig
index bbad58c74c..32491170eb 100644
--- a/test/cases/compile_errors/switch_expression-switch_on_pointer_type_with_no_else.zig
+++ b/test/cases/compile_errors/switch_expression-switch_on_pointer_type_with_no_else.zig
@@ -4,7 +4,9 @@ fn foo(x: *u8) void {
}
}
var y: u8 = 100;
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_bool.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_bool.zig
index 5dfc839c13..859f97fa8a 100644
--- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_bool.zig
+++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_bool.zig
@@ -5,7 +5,9 @@ fn foo(x: bool) void {
else => {},
}
}
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_enum.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_enum.zig
index cc837b8b5e..e7bb8d392f 100644
--- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_enum.zig
+++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_enum.zig
@@ -1,4 +1,4 @@
-const TestEnum = enum{ T1, T2 };
+const TestEnum = enum { T1, T2 };
fn err(x: u8) TestEnum {
switch (x) {
@@ -15,7 +15,9 @@ fn foo(x: u8) void {
}
}
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=llvm
diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_i8.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_i8.zig
index bcb84eed12..861b0ceaee 100644
--- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_i8.zig
+++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_i8.zig
@@ -8,7 +8,9 @@ fn foo(x: i8) void {
else => {},
}
}
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_u8.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_u8.zig
index 2230434ea0..16fdea91ea 100644
--- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_u8.zig
+++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_range_u8.zig
@@ -8,7 +8,9 @@ fn foo(x: u8) void {
else => {},
}
}
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_u1.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_u1.zig
index 58458474a4..3d7988454e 100644
--- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_u1.zig
+++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_u1.zig
@@ -5,7 +5,9 @@ fn foo(x: u1) void {
else => {},
}
}
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/switch_expression-unreachable_else_prong_u2.zig b/test/cases/compile_errors/switch_expression-unreachable_else_prong_u2.zig
index 9e337cb200..dd8f315dcd 100644
--- a/test/cases/compile_errors/switch_expression-unreachable_else_prong_u2.zig
+++ b/test/cases/compile_errors/switch_expression-unreachable_else_prong_u2.zig
@@ -7,7 +7,9 @@ fn foo(x: u2) void {
else => {},
}
}
-export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&foo));
+}
// error
// backend=stage2
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 3dad0be9df..e3d09bc133 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
@@ -1,4 +1,4 @@
-const E = enum{
+const E = enum {
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 435d409dd4..5678102fc6 100644
--- a/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig
+++ b/test/cases/compile_errors/switching_with_non-exhaustive_enums.zig
@@ -22,7 +22,7 @@ pub export fn entry2() void {
}
}
pub export fn entry3() void {
- var u = U{.a = 2};
+ var 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_on_invalid_value_of_non-exhaustive_enum.zig b/test/cases/compile_errors/tagName_on_invalid_value_of_non-exhaustive_enum.zig
index 3523a36054..df454a38d0 100644
--- a/test/cases/compile_errors/tagName_on_invalid_value_of_non-exhaustive_enum.zig
+++ b/test/cases/compile_errors/tagName_on_invalid_value_of_non-exhaustive_enum.zig
@@ -1,6 +1,6 @@
test "enum" {
const E = enum(u8) { A, B, _ };
- _ = @tagName(@intToEnum(E, 5));
+ _ = @tagName(@enumFromInt(E, 5));
}
// error
@@ -8,5 +8,5 @@ test "enum" {
// target=native
// is_test=1
//
-// :3:9: error: no field with value '@intToEnum(tmp.test.enum.E, 5)' in enum 'test.enum.E'
+// :3:9: error: no field with value '@enumFromInt(tmp.test.enum.E, 5)' in enum 'test.enum.E'
// :2:15: note: declared here
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 cbe0f642a5..28eaa9bad8 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,7 +3,7 @@ const FloatInt = extern union {
Int: i32,
};
export fn entry() void {
- var fi = FloatInt{.Float = 123.45};
+ var fi = FloatInt{ .Float = 123.45 };
var tagName = @tagName(fi);
_ = tagName;
}
diff --git a/test/cases/compile_errors/top_level_decl_dependency_loop.zig b/test/cases/compile_errors/top_level_decl_dependency_loop.zig
index 8ba3d98ea2..5657ca52fe 100644
--- a/test/cases/compile_errors/top_level_decl_dependency_loop.zig
+++ b/test/cases/compile_errors/top_level_decl_dependency_loop.zig
@@ -1,5 +1,5 @@
-const a : @TypeOf(b) = 0;
-const b : @TypeOf(a) = 0;
+const a: @TypeOf(b) = 0;
+const b: @TypeOf(a) = 0;
export fn entry() void {
const c = a + b;
_ = c;
diff --git a/test/cases/compile_errors/try_in_function_with_non_error_return_type.zig b/test/cases/compile_errors/try_in_function_with_non_error_return_type.zig
index 44d8b9ee56..96b0982370 100644
--- a/test/cases/compile_errors/try_in_function_with_non_error_return_type.zig
+++ b/test/cases/compile_errors/try_in_function_with_non_error_return_type.zig
@@ -1,7 +1,7 @@
export fn f() void {
try something();
}
-fn something() anyerror!void { }
+fn something() anyerror!void {}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/tuple_init_edge_cases.zig b/test/cases/compile_errors/tuple_init_edge_cases.zig
index f093515a38..2ac275f2b7 100644
--- a/test/cases/compile_errors/tuple_init_edge_cases.zig
+++ b/test/cases/compile_errors/tuple_init_edge_cases.zig
@@ -1,44 +1,56 @@
pub export fn entry1() void {
const T = @TypeOf(.{ 123, 3 });
- var b = T{ .@"1" = 3 }; _ = b;
- var c = T{ 123, 3 }; _ = c;
- var d = T{}; _ = d;
+ var b = T{ .@"1" = 3 };
+ _ = b;
+ var c = T{ 123, 3 };
+ _ = c;
+ var d = T{};
+ _ = d;
}
pub export fn entry2() void {
var a: u32 = 2;
const T = @TypeOf(.{ 123, a });
- var b = T{ .@"1" = 3 }; _ = b;
- var c = T{ 123, 3 }; _ = c;
- var d = T{}; _ = d;
+ var b = T{ .@"1" = 3 };
+ _ = b;
+ var c = T{ 123, 3 };
+ _ = c;
+ var d = T{};
+ _ = d;
}
pub export fn entry3() void {
var a: u32 = 2;
const T = @TypeOf(.{ 123, a });
- var b = T{ .@"0" = 123 }; _ = b;
+ var b = T{ .@"0" = 123 };
+ _ = b;
}
comptime {
var a: u32 = 2;
const T = @TypeOf(.{ 123, a });
- var b = T{ .@"0" = 123 }; _ = b;
- var c = T{ 123, 2 }; _ = c;
- var d = T{}; _ = d;
+ var b = T{ .@"0" = 123 };
+ _ = b;
+ var c = T{ 123, 2 };
+ _ = c;
+ var d = T{};
+ _ = d;
}
pub export fn entry4() void {
var a: u32 = 2;
const T = @TypeOf(.{ 123, a });
- var b = T{ 123, 4, 5 }; _ = b;
+ var b = T{ 123, 4, 5 };
+ _ = b;
}
pub export fn entry5() void {
var a: u32 = 2;
const T = @TypeOf(.{ 123, a });
- var b = T{ .@"0" = 123, .@"2" = 123, .@"1" = 123 }; _ = b;
+ var b = T{ .@"0" = 123, .@"2" = 123, .@"1" = 123 };
+ _ = b;
}
// error
// backend=stage2
// target=native
//
-// :12:14: error: missing tuple field with index 1
// :17:14: error: missing tuple field with index 1
-// :29:14: error: expected at most 2 tuple fields; found 3
-// :34:30: error: index '2' out of bounds of tuple 'struct{comptime comptime_int = 123, u32}'
+// :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}'
diff --git a/test/cases/compile_errors/type_checking_function_pointers.zig b/test/cases/compile_errors/type_checking_function_pointers.zig
index f113309170..a0fea6b60f 100644
--- a/test/cases/compile_errors/type_checking_function_pointers.zig
+++ b/test/cases/compile_errors/type_checking_function_pointers.zig
@@ -1,7 +1,9 @@
fn a(b: *const fn (*const u8) void) void {
_ = b;
}
-fn c(d: u8) void {_ = d;}
+fn c(d: u8) void {
+ _ = d;
+}
export fn entry() void {
a(c);
}
@@ -10,6 +12,6 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :6:7: error: expected type '*const fn(*const u8) void', found '*const fn(u8) void'
-// :6:7: note: pointer type child 'fn(u8) void' cannot cast into pointer type child 'fn(*const u8) void'
-// :6:7: note: parameter 0 'u8' cannot cast into '*const u8'
+// :8:7: error: expected type '*const fn(*const u8) void', found '*const fn(u8) void'
+// :8:7: note: pointer type child 'fn(u8) void' cannot cast into pointer type child 'fn(*const u8) void'
+// :8:7: note: parameter 0 'u8' cannot cast into '*const u8'
diff --git a/test/cases/compile_errors/undeclared_identifier.zig b/test/cases/compile_errors/undeclared_identifier.zig
index 7edc0d2896..86ba2e2be0 100644
--- a/test/cases/compile_errors/undeclared_identifier.zig
+++ b/test/cases/compile_errors/undeclared_identifier.zig
@@ -1,11 +1,9 @@
export fn a() void {
- return
- b +
- c;
+ return b + c;
}
// error
// backend=stage2
// target=native
//
-// :3:5: error: use of undeclared identifier 'b'
+// :2:12: error: use of undeclared identifier 'b'
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 36b52c96b9..da2fefbad5 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 = {} };
+ var x = MultipleChoice{ .C = {} };
_ = x;
}
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 3c1e2d53ef..6b70c0eaf4 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};
+ var a = Payload{ .A = 1234 };
_ = a;
}
diff --git a/test/cases/compile_errors/unreachable_parameter.zig b/test/cases/compile_errors/unreachable_parameter.zig
index 3164974432..f00b24e07a 100644
--- a/test/cases/compile_errors/unreachable_parameter.zig
+++ b/test/cases/compile_errors/unreachable_parameter.zig
@@ -1,5 +1,9 @@
-fn f(a: noreturn) void { _ = a; }
-export fn entry() void { f(); }
+fn f(a: noreturn) void {
+ _ = a;
+}
+export fn entry() void {
+ f();
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/unreachable_with_return.zig b/test/cases/compile_errors/unreachable_with_return.zig
index 5293734c82..083f360873 100644
--- a/test/cases/compile_errors/unreachable_with_return.zig
+++ b/test/cases/compile_errors/unreachable_with_return.zig
@@ -1,9 +1,13 @@
-fn a() noreturn {return;}
-export fn entry() void { a(); }
+fn a() noreturn {
+ return;
+}
+export fn entry() void {
+ a();
+}
// error
// backend=stage2
// target=native
//
-// :1:18: error: function declared 'noreturn' returns
+// :2:5: error: function declared 'noreturn' returns
// :1:8: note: 'noreturn' declared here
diff --git a/test/cases/compile_errors/while_expected_bool_got_error_union.zig b/test/cases/compile_errors/while_expected_bool_got_error_union.zig
index ecf3dd0736..07b4411883 100644
--- a/test/cases/compile_errors/while_expected_bool_got_error_union.zig
+++ b/test/cases/compile_errors/while_expected_bool_got_error_union.zig
@@ -1,7 +1,9 @@
export fn foo() void {
while (bar()) {}
}
-fn bar() anyerror!i32 { return 1; }
+fn bar() anyerror!i32 {
+ return 1;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/while_expected_bool_got_optional.zig b/test/cases/compile_errors/while_expected_bool_got_optional.zig
index 3db4b7ae74..2a2af57ef3 100644
--- a/test/cases/compile_errors/while_expected_bool_got_optional.zig
+++ b/test/cases/compile_errors/while_expected_bool_got_optional.zig
@@ -1,7 +1,9 @@
export fn foo() void {
while (bar()) {}
}
-fn bar() ?i32 { return 1; }
+fn bar() ?i32 {
+ return 1;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/while_expected_error_union_got_bool.zig b/test/cases/compile_errors/while_expected_error_union_got_bool.zig
index f7960437ec..6d31d2055b 100644
--- a/test/cases/compile_errors/while_expected_error_union_got_bool.zig
+++ b/test/cases/compile_errors/while_expected_error_union_got_bool.zig
@@ -1,7 +1,13 @@
export fn foo() void {
- while (bar()) |x| {_ = x;} else |err| {_ = err;}
+ while (bar()) |x| {
+ _ = x;
+ } else |err| {
+ _ = err;
+ }
+}
+fn bar() bool {
+ return true;
}
-fn bar() bool { return true; }
// error
// backend=stage2
diff --git a/test/cases/compile_errors/while_expected_error_union_got_optional.zig b/test/cases/compile_errors/while_expected_error_union_got_optional.zig
index 5cabd76fce..6ebf96dc4c 100644
--- a/test/cases/compile_errors/while_expected_error_union_got_optional.zig
+++ b/test/cases/compile_errors/while_expected_error_union_got_optional.zig
@@ -1,7 +1,13 @@
export fn foo() void {
- while (bar()) |x| {_ = x;} else |err| {_ = err;}
+ while (bar()) |x| {
+ _ = x;
+ } else |err| {
+ _ = err;
+ }
+}
+fn bar() ?i32 {
+ return 1;
}
-fn bar() ?i32 { return 1; }
// error
// backend=stage2
diff --git a/test/cases/compile_errors/while_expected_optional_got_bool.zig b/test/cases/compile_errors/while_expected_optional_got_bool.zig
index 22b8c1e58c..5ced72b492 100644
--- a/test/cases/compile_errors/while_expected_optional_got_bool.zig
+++ b/test/cases/compile_errors/while_expected_optional_got_bool.zig
@@ -1,7 +1,11 @@
export fn foo() void {
- while (bar()) |x| {_ = x;}
+ while (bar()) |x| {
+ _ = x;
+ }
+}
+fn bar() bool {
+ return true;
}
-fn bar() bool { return true; }
// error
// backend=stage2
diff --git a/test/cases/compile_errors/while_expected_optional_got_error_union.zig b/test/cases/compile_errors/while_expected_optional_got_error_union.zig
index 38a8a0dd20..7bde2c866d 100644
--- a/test/cases/compile_errors/while_expected_optional_got_error_union.zig
+++ b/test/cases/compile_errors/while_expected_optional_got_error_union.zig
@@ -1,7 +1,11 @@
export fn foo() void {
- while (bar()) |x| {_ = x;}
+ while (bar()) |x| {
+ _ = x;
+ }
+}
+fn bar() anyerror!i32 {
+ return 1;
}
-fn bar() anyerror!i32 { return 1; }
// error
// backend=stage2
diff --git a/test/cases/compile_errors/write_to_const_global_variable.zig b/test/cases/compile_errors/write_to_const_global_variable.zig
index 5ffd3a305d..075854c454 100644
--- a/test/cases/compile_errors/write_to_const_global_variable.zig
+++ b/test/cases/compile_errors/write_to_const_global_variable.zig
@@ -1,8 +1,10 @@
-const x : i32 = 99;
+const x: i32 = 99;
fn f() void {
x = 1;
}
-export fn entry() void { f(); }
+export fn entry() void {
+ f();
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/wrong_function_type.zig b/test/cases/compile_errors/wrong_function_type.zig
index 867bdccc1a..6dfa9bd702 100644
--- a/test/cases/compile_errors/wrong_function_type.zig
+++ b/test/cases/compile_errors/wrong_function_type.zig
@@ -1,8 +1,16 @@
-const fns = [_]fn() void { a, b, c };
-fn a() i32 {return 0;}
-fn b() i32 {return 1;}
-fn c() i32 {return 2;}
-export fn entry() usize { return @sizeOf(@TypeOf(fns)); }
+const fns = [_]fn () void{ a, b, c };
+fn a() i32 {
+ return 0;
+}
+fn b() i32 {
+ return 1;
+}
+fn c() i32 {
+ return 2;
+}
+export fn entry() usize {
+ return @sizeOf(@TypeOf(fns));
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/wrong_number_of_arguments.zig b/test/cases/compile_errors/wrong_number_of_arguments.zig
index 05d761de18..b83a7a4a37 100644
--- a/test/cases/compile_errors/wrong_number_of_arguments.zig
+++ b/test/cases/compile_errors/wrong_number_of_arguments.zig
@@ -1,7 +1,11 @@
export fn a() void {
c(1);
}
-fn c(d: i32, e: i32, f: i32) void { _ = d; _ = e; _ = f; }
+fn c(d: i32, e: i32, f: i32) void {
+ _ = d;
+ _ = e;
+ _ = f;
+}
// error
// backend=stage2
diff --git a/test/cases/compile_errors/wrong_number_of_arguments_for_method_fn_call.zig b/test/cases/compile_errors/wrong_number_of_arguments_for_method_fn_call.zig
index da6a7be4fa..b0981e3d4d 100644
--- a/test/cases/compile_errors/wrong_number_of_arguments_for_method_fn_call.zig
+++ b/test/cases/compile_errors/wrong_number_of_arguments_for_method_fn_call.zig
@@ -1,15 +1,19 @@
const Foo = struct {
- fn method(self: *const Foo, a: i32) void {_ = self; _ = a;}
+ fn method(self: *const Foo, a: i32) void {
+ _ = self;
+ _ = a;
+ }
};
fn f(foo: *const Foo) void {
-
foo.method(1, 2);
}
-export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
+export fn entry() usize {
+ return @sizeOf(@TypeOf(&f));
+}
// error
// backend=stage2
// target=native
//
-// :6:8: error: member function expected 1 argument(s), found 2
+// :8:8: error: member function expected 1 argument(s), found 2
// :2:5: note: function declared here
diff --git a/test/cases/compile_errors/wrong_size_to_an_array_literal.zig b/test/cases/compile_errors/wrong_size_to_an_array_literal.zig
index a38d8d4d85..a58d6d9846 100644
--- a/test/cases/compile_errors/wrong_size_to_an_array_literal.zig
+++ b/test/cases/compile_errors/wrong_size_to_an_array_literal.zig
@@ -1,5 +1,5 @@
comptime {
- const array = [2]u8{1, 2, 3};
+ const array = [2]u8{ 1, 2, 3 };
_ = array;
}
diff --git a/test/cases/compile_errors/wrong_types_given_to_export.zig b/test/cases/compile_errors/wrong_types_given_to_export.zig
index 2ae55b4a63..6e688d33d6 100644
--- a/test/cases/compile_errors/wrong_types_given_to_export.zig
+++ b/test/cases/compile_errors/wrong_types_given_to_export.zig
@@ -1,11 +1,11 @@
-fn entry() callconv(.C) void { }
+fn entry() callconv(.C) void {}
comptime {
- @export(entry, .{.name = "entry", .linkage = @as(u32, 1234) });
+ @export(entry, .{ .name = "entry", .linkage = @as(u32, 1234) });
}
// error
// backend=stage2
// target=native
//
-// :3:50: error: expected type 'builtin.GlobalLinkage', found 'u32'
+// :3:51: error: expected type 'builtin.GlobalLinkage', found 'u32'
// :?:?: note: enum declared here
diff --git a/test/cases/comptime_var.2.zig b/test/cases/comptime_var.2.zig
index 7c99aba625..2d717cb802 100644
--- a/test/cases/comptime_var.2.zig
+++ b/test/cases/comptime_var.2.zig
@@ -8,7 +8,7 @@ pub fn main() void {
}
fn print(len: usize) void {
- _ = write(1, @ptrToInt("Hello, World!\n"), len);
+ _ = write(1, @intFromPtr("Hello, World!\n"), len);
}
// run
diff --git a/test/cases/comptime_var.6.zig b/test/cases/comptime_var.6.zig
index 3b655e381e..d4e96106bb 100644
--- a/test/cases/comptime_var.6.zig
+++ b/test/cases/comptime_var.6.zig
@@ -7,7 +7,7 @@ pub fn main() void {
}
}
fn print(len: usize) void {
- _ = write(1, @ptrToInt("Hello"), len);
+ _ = write(1, @intFromPtr("Hello"), len);
}
// run
diff --git a/test/cases/conditional_branches.0.zig b/test/cases/conditional_branches.0.zig
index 61c9fdd50e..d1fce95b2c 100644
--- a/test/cases/conditional_branches.0.zig
+++ b/test/cases/conditional_branches.0.zig
@@ -12,7 +12,7 @@ fn foo(x: u64) void {
fn print() void {
const str = "Hello, World!\n";
- _ = write(1, @ptrToInt(str.ptr), ptr.len);
+ _ = write(1, @intFromPtr(str.ptr), ptr.len);
}
// run
diff --git a/test/cases/conditional_branches.1.zig b/test/cases/conditional_branches.1.zig
index 2668133a7c..f402cd3bd4 100644
--- a/test/cases/conditional_branches.1.zig
+++ b/test/cases/conditional_branches.1.zig
@@ -15,7 +15,7 @@ fn foo(x: bool) void {
fn print() void {
const str = "Hello, World!\n";
- _ = write(1, @ptrToInt(str.ptr), ptr.len);
+ _ = write(1, @intFromPtr(str.ptr), ptr.len);
}
// run
diff --git a/test/cases/decl_value_arena.zig b/test/cases/decl_value_arena.zig
index 02062c4543..9c7c12903b 100644
--- a/test/cases/decl_value_arena.zig
+++ b/test/cases/decl_value_arena.zig
@@ -1,20 +1,20 @@
pub const Protocols: struct {
- list: *const fn(*Connection) void = undefined,
- handShake: type = struct {
- const stepStart: u8 = 0;
- },
+ list: *const fn (*Connection) void = undefined,
+ handShake: type = struct {
+ const stepStart: u8 = 0;
+ },
} = .{};
pub const Connection = struct {
- streamBuffer: [0]u8 = undefined,
- __lastReceivedPackets: [0]u8 = undefined,
+ streamBuffer: [0]u8 = undefined,
+ __lastReceivedPackets: [0]u8 = undefined,
- handShakeState: u8 = Protocols.handShake.stepStart,
+ handShakeState: u8 = Protocols.handShake.stepStart,
};
pub fn main() void {
- var conn: Connection = undefined;
- _ = conn;
+ var conn: Connection = undefined;
+ _ = conn;
}
// run
diff --git a/test/cases/enum_values.0.zig b/test/cases/enum_values.0.zig
index d96841dd8c..2c44a095dd 100644
--- a/test/cases/enum_values.0.zig
+++ b/test/cases/enum_values.0.zig
@@ -7,8 +7,8 @@ pub fn main() void {
number1;
number2;
}
- const number3 = @intToEnum(Number, 2);
- if (@enumToInt(number3) != 2) {
+ const number3 = @enumFromInt(Number, 2);
+ if (@intFromEnum(number3) != 2) {
unreachable;
}
return;
diff --git a/test/cases/enum_values.1.zig b/test/cases/enum_values.1.zig
index 47b9e21a27..1b5a9836db 100644
--- a/test/cases/enum_values.1.zig
+++ b/test/cases/enum_values.1.zig
@@ -3,12 +3,12 @@ const Number = enum { One, Two, Three };
pub fn main() void {
var number1 = Number.One;
var number2: Number = .Two;
- const number3 = @intToEnum(Number, 2);
+ const number3 = @enumFromInt(Number, 2);
assert(number1 != number2);
assert(number2 != number3);
- assert(@enumToInt(number1) == 0);
- assert(@enumToInt(number2) == 1);
- assert(@enumToInt(number3) == 2);
+ assert(@intFromEnum(number1) == 0);
+ assert(@intFromEnum(number2) == 1);
+ assert(@intFromEnum(number3) == 2);
var x: Number = .Two;
assert(number2 == x);
diff --git a/test/cases/error_in_nested_declaration.zig b/test/cases/error_in_nested_declaration.zig
index 3fff746909..710b821e65 100644
--- a/test/cases/error_in_nested_declaration.zig
+++ b/test/cases/error_in_nested_declaration.zig
@@ -5,7 +5,7 @@ const S = struct {
pub fn str(_: @This(), extra: []u32) []i32 {
return @bitCast([]i32, extra);
}
- },
+ },
};
pub export fn entry() void {
diff --git a/test/cases/hello_world_with_updates.2.zig b/test/cases/hello_world_with_updates.2.zig
index be6dc58c74..db5564e3a7 100644
--- a/test/cases/hello_world_with_updates.2.zig
+++ b/test/cases/hello_world_with_updates.2.zig
@@ -8,7 +8,7 @@ pub export fn main() noreturn {
}
fn print() void {
- const msg = @ptrToInt("Hello, World!\n");
+ const msg = @intFromPtr("Hello, World!\n");
const len = 14;
_ = write(1, msg, len);
}
diff --git a/test/cases/hello_world_with_updates.3.zig b/test/cases/hello_world_with_updates.3.zig
index f464c379aa..8c57d52924 100644
--- a/test/cases/hello_world_with_updates.3.zig
+++ b/test/cases/hello_world_with_updates.3.zig
@@ -5,7 +5,7 @@ pub fn main() void {
}
fn print() void {
- const msg = @ptrToInt("Hello, World!\n");
+ const msg = @intFromPtr("Hello, World!\n");
const len = 14;
_ = write(1, msg, len);
}
diff --git a/test/cases/hello_world_with_updates.4.zig b/test/cases/hello_world_with_updates.4.zig
index c9efbd0f35..54641a3ad5 100644
--- a/test/cases/hello_world_with_updates.4.zig
+++ b/test/cases/hello_world_with_updates.4.zig
@@ -8,7 +8,7 @@ pub fn main() void {
}
fn print() void {
- const msg = @ptrToInt("Hello, World!\n");
+ const msg = @intFromPtr("Hello, World!\n");
const len = 14;
_ = write(1, msg, len);
}
diff --git a/test/cases/hello_world_with_updates.5.zig b/test/cases/hello_world_with_updates.5.zig
index 5070ea457c..ae57d9b7b6 100644
--- a/test/cases/hello_world_with_updates.5.zig
+++ b/test/cases/hello_world_with_updates.5.zig
@@ -5,7 +5,7 @@ pub fn main() void {
}
fn print() void {
- const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
+ const msg = @intFromPtr("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
const len = 104;
_ = write(1, msg, len);
}
diff --git a/test/cases/hello_world_with_updates.6.zig b/test/cases/hello_world_with_updates.6.zig
index a33f2954e5..76f006992e 100644
--- a/test/cases/hello_world_with_updates.6.zig
+++ b/test/cases/hello_world_with_updates.6.zig
@@ -8,7 +8,7 @@ pub fn main() void {
}
fn print() void {
- const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
+ const msg = @intFromPtr("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
const len = 104;
_ = write(1, msg, len);
}
diff --git a/test/cases/int_to_ptr.0.zig b/test/cases/int_to_ptr.0.zig
index b7c70b90a4..ba14c03804 100644
--- a/test/cases/int_to_ptr.0.zig
+++ b/test/cases/int_to_ptr.0.zig
@@ -1,5 +1,5 @@
pub fn main() void {
- _ = @intToPtr(*u8, 0);
+ _ = @ptrFromInt(*u8, 0);
}
// error
diff --git a/test/cases/int_to_ptr.1.zig b/test/cases/int_to_ptr.1.zig
index 72c8c8c9d6..e75ae81f6f 100644
--- a/test/cases/int_to_ptr.1.zig
+++ b/test/cases/int_to_ptr.1.zig
@@ -1,5 +1,5 @@
pub fn main() void {
- _ = @intToPtr(*u32, 2);
+ _ = @ptrFromInt(*u32, 2);
}
// error
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 62db92668b..507362a937 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
@@ -20,7 +20,7 @@ fn getFs() c_ulong {
:
: [number] "{rax}" (158),
[code] "{rdi}" (0x1003),
- [ptr] "{rsi}" (@ptrToInt(&result)),
+ [ptr] "{rsi}" (@intFromPtr(&result)),
: "rcx", "r11", "memory"
);
return result;
@@ -31,10 +31,10 @@ var test_value: u64 = 12345;
pub fn main() void {
const orig_fs = getFs();
- setFs(@ptrToInt(&test_value));
- assert(getFs() == @ptrToInt(&test_value));
+ setFs(@intFromPtr(&test_value));
+ assert(getFs() == @intFromPtr(&test_value));
- var test_ptr = @intToPtr(*allowzero addrspace(.fs) u64, 0);
+ var test_ptr = @ptrFromInt(*allowzero addrspace(.fs) u64, 0);
assert(test_ptr.* == 12345);
test_ptr.* = 98765;
assert(test_value == 98765);
diff --git a/test/cases/safety/@alignCast misaligned.zig b/test/cases/safety/@alignCast misaligned.zig
index aed805cf66..538e0ecdf6 100644
--- a/test/cases/safety/@alignCast misaligned.zig
+++ b/test/cases/safety/@alignCast misaligned.zig
@@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
}
pub fn main() !void {
- var array align(4) = [_]u32{0x11111111, 0x11111111};
+ var array align(4) = [_]u32{ 0x11111111, 0x11111111 };
const bytes = std.mem.sliceAsBytes(array[0..]);
if (foo(bytes) != 0x11111111) return error.Wrong;
return error.TestFailed;
diff --git a/test/cases/safety/@intToEnum - no matching tag value.zig b/test/cases/safety/@enumFromInt - no matching tag value.zig
index c4967b413b..57f8954f93 100644
--- a/test/cases/safety/@intToEnum - no matching tag value.zig
+++ b/test/cases/safety/@enumFromInt - no matching tag value.zig
@@ -17,7 +17,7 @@ pub fn main() !void {
return error.TestFailed;
}
fn bar(a: u2) Foo {
- return @intToEnum(Foo, a);
+ return @enumFromInt(Foo, a);
}
fn baz(_: Foo) void {}
diff --git a/test/cases/safety/@errSetCast error not present in destination.zig b/test/cases/safety/@errSetCast error not present in destination.zig
index 2fd0a912e6..372bd80aa5 100644
--- a/test/cases/safety/@errSetCast error not present in destination.zig
+++ b/test/cases/safety/@errSetCast error not present in destination.zig
@@ -7,8 +7,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
}
std.process.exit(1);
}
-const Set1 = error{A, B};
-const Set2 = error{A, C};
+const Set1 = error{ A, B };
+const Set2 = error{ A, C };
pub fn main() !void {
foo(Set1.B) catch {};
return error.TestFailed;
diff --git a/test/cases/safety/@floatToInt cannot fit - negative out of range.zig b/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig
index fa7e628f4a..9a8853c0e9 100644
--- a/test/cases/safety/@floatToInt cannot fit - negative out of range.zig
+++ b/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig
@@ -12,9 +12,9 @@ pub fn main() !void {
return error.TestFailed;
}
fn bar(a: f32) i8 {
- return @floatToInt(i8, a);
+ return @intFromFloat(i8, a);
}
-fn baz(_: i8) void { }
+fn baz(_: i8) void {}
// run
// backend=llvm
// target=native
diff --git a/test/cases/safety/@floatToInt cannot fit - negative to unsigned.zig b/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig
index 5bab7710b1..caf7bbf0d6 100644
--- a/test/cases/safety/@floatToInt cannot fit - negative to unsigned.zig
+++ b/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig
@@ -12,9 +12,9 @@ pub fn main() !void {
return error.TestFailed;
}
fn bar(a: f32) u8 {
- return @floatToInt(u8, a);
+ return @intFromFloat(u8, a);
}
-fn baz(_: u8) void { }
+fn baz(_: u8) void {}
// run
// backend=llvm
// target=native
diff --git a/test/cases/safety/@floatToInt cannot fit - positive out of range.zig b/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig
index fe931e8751..d335238b65 100644
--- a/test/cases/safety/@floatToInt cannot fit - positive out of range.zig
+++ b/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig
@@ -12,9 +12,9 @@ pub fn main() !void {
return error.TestFailed;
}
fn bar(a: f32) u8 {
- return @floatToInt(u8, a);
+ return @intFromFloat(u8, a);
}
-fn baz(_: u8) void { }
+fn baz(_: u8) void {}
// run
// backend=llvm
// target=native
diff --git a/test/cases/safety/@intToPtr address zero to non-optional byte-aligned pointer.zig b/test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig
index 413959706f..345d5cfc74 100644
--- a/test/cases/safety/@intToPtr 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,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
}
pub fn main() !void {
var zero: usize = 0;
- var b = @intToPtr(*u8, zero);
+ var b = @ptrFromInt(*u8, zero);
_ = b;
return error.TestFailed;
}
diff --git a/test/cases/safety/@intToPtr address zero to non-optional pointer.zig b/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig
index 457b2d12c0..e7d3b66d6c 100644
--- a/test/cases/safety/@intToPtr address zero to non-optional pointer.zig
+++ b/test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig
@@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
}
pub fn main() !void {
var zero: usize = 0;
- var b = @intToPtr(*i32, zero);
+ var b = @ptrFromInt(*i32, zero);
_ = b;
return error.TestFailed;
}
diff --git a/test/cases/safety/intToPtr with misaligned address.zig b/test/cases/safety/@ptrFromInt with misaligned address.zig
index e53c7e9087..c2e1d351eb 100644
--- a/test/cases/safety/intToPtr with misaligned address.zig
+++ b/test/cases/safety/@ptrFromInt with misaligned address.zig
@@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
}
pub fn main() !void {
var x: usize = 5;
- var y = @intToPtr([*]align(4) u8, x);
+ var y = @ptrFromInt([*]align(4) u8, x);
_ = y;
return error.TestFailed;
}
diff --git a/test/cases/safety/bad union field access.zig b/test/cases/safety/bad union field access.zig
index fbe7718c66..c6706d4176 100644
--- a/test/cases/safety/bad union field access.zig
+++ b/test/cases/safety/bad union field access.zig
@@ -14,7 +14,7 @@ const Foo = union {
};
pub fn main() !void {
- var f = Foo { .int = 42 };
+ var f = Foo{ .int = 42 };
bar(&f);
return error.TestFailed;
}
diff --git a/test/cases/safety/cast []u8 to bigger slice of wrong size.zig b/test/cases/safety/cast []u8 to bigger slice of wrong size.zig
index 93d18178a8..a72b2fcca2 100644
--- a/test/cases/safety/cast []u8 to bigger slice of wrong size.zig
+++ b/test/cases/safety/cast []u8 to bigger slice of wrong size.zig
@@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
}
pub fn main() !void {
- const x = widenSlice(&[_]u8{1, 2, 3, 4, 5});
+ const x = widenSlice(&[_]u8{ 1, 2, 3, 4, 5 });
if (x.len == 0) return error.Whatever;
return error.TestFailed;
}
diff --git a/test/cases/safety/cast integer to global error and no code matches.zig b/test/cases/safety/cast integer to global error and no code matches.zig
index 466bf8d2ca..61daf07a2b 100644
--- a/test/cases/safety/cast integer to global error and no code matches.zig
+++ b/test/cases/safety/cast integer to global error and no code matches.zig
@@ -12,7 +12,7 @@ pub fn main() !void {
return error.TestFailed;
}
fn bar(x: u16) anyerror {
- return @intToError(x);
+ return @errorFromInt(x);
}
// run
// backend=llvm
diff --git a/test/cases/safety/error return trace across suspend points.zig b/test/cases/safety/error return trace across suspend points.zig
index 28c53cb6d1..2c31aacc9d 100644
--- a/test/cases/safety/error return trace across suspend points.zig
+++ b/test/cases/safety/error return trace across suspend points.zig
@@ -1,6 +1,5 @@
const std = @import("std");
-
pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
_ = message;
_ = stack_trace;
@@ -36,4 +35,4 @@ fn printTrace(p: anyframe->anyerror!void) void {
}
// run
// backend=stage1
-// target=native \ No newline at end of file
+// target=native
diff --git a/test/cases/safety/exact division failure - vectors.zig b/test/cases/safety/exact division failure - vectors.zig
index 3c515cbdf1..cc8c01db9e 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};
+ var a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 };
+ var 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_three.zig b/test/cases/safety/for_len_mismatch_three.zig
index 95bc244269..0cfcddbfee 100644
--- a/test/cases/safety/for_len_mismatch_three.zig
+++ b/test/cases/safety/for_len_mismatch_three.zig
@@ -21,4 +21,3 @@ pub fn main() !void {
// run
// backend=llvm
// target=native
-
diff --git a/test/cases/safety/integer division by zero - vectors.zig b/test/cases/safety/integer division by zero - vectors.zig
index ed7ac7777b..a376b66fdb 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};
+ var a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 };
+ var 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/pointer casting to null function pointer.zig b/test/cases/safety/pointer casting to null function pointer.zig
index bedbcdda85..7736cb5034 100644
--- a/test/cases/safety/pointer casting to null function pointer.zig
+++ b/test/cases/safety/pointer casting to null function pointer.zig
@@ -13,7 +13,7 @@ fn getNullPtr() ?*const anyopaque {
}
pub fn main() !void {
const null_ptr: ?*const anyopaque = getNullPtr();
- const required_ptr: *align(1) const fn() void = @ptrCast(*align(1) const fn() void, null_ptr);
+ const required_ptr: *align(1) const fn () void = @ptrCast(*align(1) const fn () void, null_ptr);
_ = required_ptr;
return error.TestFailed;
}
diff --git a/test/cases/safety/slice sentinel mismatch - optional pointers.zig b/test/cases/safety/slice sentinel mismatch - optional pointers.zig
index 6be303d9aa..33f4a1099b 100644
--- a/test/cases/safety/slice sentinel mismatch - optional pointers.zig
+++ b/test/cases/safety/slice sentinel mismatch - optional pointers.zig
@@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
}
pub fn main() !void {
- var buf: [4]?*i32 = .{ @intToPtr(*i32, 4), @intToPtr(*i32, 8), @intToPtr(*i32, 12), @intToPtr(*i32, 16) };
+ var buf: [4]?*i32 = .{ @ptrFromInt(*i32, 4), @ptrFromInt(*i32, 8), @ptrFromInt(*i32, 12), @ptrFromInt(*i32, 16) };
const slice = buf[0..3 :null];
_ = slice;
return error.TestFailed;
diff --git a/test/cases/safety/zero casted to error.zig b/test/cases/safety/zero casted to error.zig
index c1be6856a7..78340db316 100644
--- a/test/cases/safety/zero casted to error.zig
+++ b/test/cases/safety/zero casted to error.zig
@@ -12,7 +12,7 @@ pub fn main() !void {
return error.TestFailed;
}
fn bar(x: u16) anyerror {
- return @intToError(x);
+ return @errorFromInt(x);
}
// run
// backend=llvm
diff --git a/test/cases/unused_labels.3.zig b/test/cases/unused_labels.3.zig
index e4f3ac05a4..36c9aa2319 100644
--- a/test/cases/unused_labels.3.zig
+++ b/test/cases/unused_labels.3.zig
@@ -1,5 +1,7 @@
comptime {
- blk: {blk: {}}
+ blk: {
+ blk: {}
+ }
}
// error
diff --git a/test/cases/variable_shadowing.3.zig b/test/cases/variable_shadowing.3.zig
index 3d899e72cc..af16bccc14 100644
--- a/test/cases/variable_shadowing.3.zig
+++ b/test/cases/variable_shadowing.3.zig
@@ -1,7 +1,6 @@
pub fn main() void {
var i = 0;
- for ("n", 0..) |_, i| {
- }
+ for ("n", 0..) |_, i| {}
}
// error
diff --git a/test/cases/variable_shadowing.4.zig b/test/cases/variable_shadowing.4.zig
index ab9f93d17d..3653c2457d 100644
--- a/test/cases/variable_shadowing.4.zig
+++ b/test/cases/variable_shadowing.4.zig
@@ -1,7 +1,6 @@
pub fn main() void {
var i = 0;
- for ("n") |i| {
- }
+ for ("n") |i| {}
}
// error
diff --git a/test/cases/variable_shadowing.5.zig b/test/cases/variable_shadowing.5.zig
index 1a5676190a..78247e68fe 100644
--- a/test/cases/variable_shadowing.5.zig
+++ b/test/cases/variable_shadowing.5.zig
@@ -1,7 +1,6 @@
pub fn main() void {
var i = 0;
- while ("n") |i| {
- }
+ while ("n") |i| {}
}
// error
diff --git a/test/cases/variable_shadowing.6.zig b/test/cases/variable_shadowing.6.zig
index 894a398b61..a3ae7bc346 100644
--- a/test/cases/variable_shadowing.6.zig
+++ b/test/cases/variable_shadowing.6.zig
@@ -2,9 +2,7 @@ pub fn main() void {
var i = 0;
while ("n") |bruh| {
_ = bruh;
- } else |i| {
-
- }
+ } else |i| {}
}
// error
diff --git a/test/cases/x86_64-linux/inline_assembly.2.zig b/test/cases/x86_64-linux/inline_assembly.2.zig
index 1695265ab4..7958d0df71 100644
--- a/test/cases/x86_64-linux/inline_assembly.2.zig
+++ b/test/cases/x86_64-linux/inline_assembly.2.zig
@@ -2,7 +2,7 @@ pub fn main() void {
var bruh: u32 = 1;
asm (""
:
- : [bruh] "{rax}" (4)
+ : [bruh] "{rax}" (4),
: "memory"
);
}
diff --git a/test/cases/x86_64-linux/inline_assembly.3.zig b/test/cases/x86_64-linux/inline_assembly.3.zig
index 765eaeb97e..a6f57e832a 100644
--- a/test/cases/x86_64-linux/inline_assembly.3.zig
+++ b/test/cases/x86_64-linux/inline_assembly.3.zig
@@ -2,7 +2,7 @@ pub fn main() void {}
comptime {
asm (""
:
- : [bruh] "{rax}" (4)
+ : [bruh] "{rax}" (4),
: "memory"
);
}
diff --git a/test/cbe.zig b/test/cbe.zig
index 25ac3cb137..f0cf720fd3 100644
--- a/test/cbe.zig
+++ b/test/cbe.zig
@@ -71,22 +71,22 @@ pub fn addCases(ctx: *Cases) !void {
}
{
- var case = ctx.exeFromCompiledC("intToError", .{});
+ var case = ctx.exeFromCompiledC("errorFromInt", .{});
case.addCompareOutput(
\\pub export fn main() c_int {
\\ // comptime checks
\\ const a = error.A;
\\ const b = error.B;
- \\ const c = @intToError(2);
- \\ const d = @intToError(1);
+ \\ const c = @errorFromInt(2);
+ \\ const d = @errorFromInt(1);
\\ if (!(c == b)) unreachable;
\\ if (!(a == d)) unreachable;
\\ // runtime checks
\\ var x = error.A;
\\ var y = error.B;
- \\ var z = @intToError(2);
- \\ var f = @intToError(1);
+ \\ var z = @errorFromInt(2);
+ \\ var f = @errorFromInt(1);
\\ if (!(y == z)) unreachable;
\\ if (!(x == f)) unreachable;
\\ return 0;
@@ -94,13 +94,13 @@ pub fn addCases(ctx: *Cases) !void {
, "");
case.addError(
\\pub export fn main() c_int {
- \\ _ = @intToError(0);
+ \\ _ = @errorFromInt(0);
\\ return 0;
\\}
, &.{":2:21: error: integer value '0' represents no error"});
case.addError(
\\pub export fn main() c_int {
- \\ _ = @intToError(3);
+ \\ _ = @errorFromInt(3);
\\ return 0;
\\}
, &.{":2:21: error: integer value '3' represents no error"});
@@ -635,19 +635,19 @@ pub fn addCases(ctx: *Cases) !void {
":6:12: note: consider 'union(enum)' here to make it a tagged union",
});
- // @enumToInt, @intToEnum, enum literal coercion, field access syntax, comparison, switch
+ // @intFromEnum, @enumFromInt, enum literal coercion, field access syntax, comparison, switch
case.addCompareOutput(
\\const Number = enum { One, Two, Three };
\\
\\pub export fn main() c_int {
\\ var number1 = Number.One;
\\ var number2: Number = .Two;
- \\ const number3 = @intToEnum(Number, 2);
+ \\ const number3 = @enumFromInt(Number, 2);
\\ if (number1 == number2) return 1;
\\ if (number2 == number3) return 1;
- \\ if (@enumToInt(number1) != 0) return 1;
- \\ if (@enumToInt(number2) != 1) return 1;
- \\ if (@enumToInt(number3) != 2) return 1;
+ \\ if (@intFromEnum(number1) != 0) return 1;
+ \\ if (@intFromEnum(number2) != 1) return 1;
+ \\ if (@intFromEnum(number3) != 2) return 1;
\\ var x: Number = .Two;
\\ if (number2 != x) return 1;
\\ switch (x) {
@@ -728,7 +728,7 @@ pub fn addCases(ctx: *Cases) !void {
case.addError(
\\pub export fn main() c_int {
\\ const a = true;
- \\ _ = @enumToInt(a);
+ \\ _ = @intFromEnum(a);
\\}
, &.{
":3:20: error: expected enum or tagged union, found 'bool'",
@@ -737,7 +737,7 @@ pub fn addCases(ctx: *Cases) !void {
case.addError(
\\pub export fn main() c_int {
\\ const a = 1;
- \\ _ = @intToEnum(bool, a);
+ \\ _ = @enumFromInt(bool, a);
\\}
, &.{
":3:20: error: expected enum, found 'bool'",
@@ -746,7 +746,7 @@ pub fn addCases(ctx: *Cases) !void {
case.addError(
\\const E = enum { a, b, c };
\\pub export fn main() c_int {
- \\ _ = @intToEnum(E, 3);
+ \\ _ = @enumFromInt(E, 3);
\\}
, &.{
":3:9: error: enum 'tmp.E' has no tag with value '3'",
diff --git a/test/compare_output.zig b/test/compare_output.zig
index ad14152e76..66b5624443 100644
--- a/test/compare_output.zig
+++ b/test/compare_output.zig
@@ -229,8 +229,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
\\ }
\\ const small: f32 = 3.25;
\\ const x: f64 = small;
- \\ const y = @floatToInt(i32, x);
- \\ const z = @intToFloat(f64, y);
+ \\ const y = @intFromFloat(i32, x);
+ \\ const z = @floatFromInt(f64, y);
\\ _ = c.printf("%.2f\n%d\n%.2f\n%.2f\n", x, y, z, @as(f64, -0.4));
\\ return 0;
\\}
diff --git a/test/gen_h.zig b/test/gen_h.zig
index c00abf320b..a41f4d6f82 100644
--- a/test/gen_h.zig
+++ b/test/gen_h.zig
@@ -137,7 +137,7 @@ pub fn addCases(cases: *tests.GenHContext) void {
\\};
\\
\\export fn a(s: *E) u8 {
- \\ return @enumToInt(s.*);
+ \\ return @intFromEnum(s.*);
\\}
, &[_][]const u8{
\\enum E;
diff --git a/test/link/common_symbols_alignment/main.zig b/test/link/common_symbols_alignment/main.zig
index 3d3457c764..06316b40fa 100644
--- a/test/link/common_symbols_alignment/main.zig
+++ b/test/link/common_symbols_alignment/main.zig
@@ -4,6 +4,6 @@ extern var foo: i32;
extern var bar: i32;
test {
- try std.testing.expect(@ptrToInt(&foo) % 4 == 0);
- try std.testing.expect(@ptrToInt(&bar) % 4096 == 0);
+ try std.testing.expect(@intFromPtr(&foo) % 4 == 0);
+ try std.testing.expect(@intFromPtr(&bar) % 4096 == 0);
}
diff --git a/test/standalone/pie/main.zig b/test/standalone/pie/main.zig
index 6a49c45e97..89d204aa1c 100644
--- a/test/standalone/pie/main.zig
+++ b/test/standalone/pie/main.zig
@@ -5,7 +5,7 @@ threadlocal var foo: u8 = 42;
test "Check ELF header" {
// PIE executables are marked as ET_DYN, regular exes as ET_EXEC.
- const header = @intToPtr(*elf.Ehdr, std.process.getBaseAddress());
+ const header = @ptrFromInt(*elf.Ehdr, std.process.getBaseAddress());
try std.testing.expectEqual(elf.ET.DYN, header.e_type);
}
diff --git a/test/translate_c.zig b/test/translate_c.zig
index 6caf69dcdb..966f3e2785 100644
--- a/test/translate_c.zig
+++ b/test/translate_c.zig
@@ -300,7 +300,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
, &[_][]const u8{
\\pub const FOO = (foo + @as(c_int, 2)).*;
,
- \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @boolToInt(@as(c_int, 8) == @as(c_int, 9));
+ \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @intFromBool(@as(c_int, 8) == @as(c_int, 9));
,
\\pub inline fn _AL_READ3BYTES(p: anytype) @TypeOf((@import("std").zig.c_translation.cast([*c]u8, p).* | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16))) {
\\ return (@import("std").zig.c_translation.cast([*c]u8, p).* | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16));
@@ -439,8 +439,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\#define FOO(x) ((x >= 0) + (x >= 0))
\\#define BAR 1 && 2 > 4
, &[_][]const u8{
- \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0))) {
- \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0));
+ \\pub inline fn FOO(x: anytype) @TypeOf(@intFromBool(x >= @as(c_int, 0)) + @intFromBool(x >= @as(c_int, 0))) {
+ \\ return @intFromBool(x >= @as(c_int, 0)) + @intFromBool(x >= @as(c_int, 0));
\\}
,
\\pub const BAR = (@as(c_int, 1) != 0) and (@as(c_int, 2) > @as(c_int, 4));
@@ -905,7 +905,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub extern fn foo() void;
\\pub export fn bar() void {
\\ var func_ptr: ?*anyopaque = @ptrCast(?*anyopaque, &foo);
- \\ var typed_func_ptr: ?*const fn () callconv(.C) void = @intToPtr(?*const fn () callconv(.C) void, @intCast(c_ulong, @ptrToInt(func_ptr)));
+ \\ var typed_func_ptr: ?*const fn () callconv(.C) void = @ptrFromInt(?*const fn () callconv(.C) void, @intCast(c_ulong, @intFromPtr(func_ptr)));
\\ _ = @TypeOf(typed_func_ptr);
\\}
});
@@ -1719,10 +1719,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\ var a: c_int = undefined;
\\ var b: f32 = undefined;
\\ var c: ?*anyopaque = undefined;
- \\ return @boolToInt(!(a == @as(c_int, 0)));
- \\ return @boolToInt(!(a != 0));
- \\ return @boolToInt(!(b != 0));
- \\ return @boolToInt(!(c != null));
+ \\ return @intFromBool(!(a == @as(c_int, 0)));
+ \\ return @intFromBool(!(a != 0));
+ \\ return @intFromBool(!(b != 0));
+ \\ return @intFromBool(!(c != null));
\\}
});
@@ -2238,7 +2238,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
, &[_][]const u8{
\\pub export var a: f32 = @floatCast(f32, 3.1415);
\\pub export var b: f64 = 3.1415;
- \\pub export var c: c_int = @floatToInt(c_int, 3.1415);
+ \\pub export var c: c_int = @intFromFloat(c_int, 3.1415);
\\pub export var d: f64 = 3;
});
@@ -2417,13 +2417,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
});
cases.add("c style cast",
- \\int float_to_int(float a) {
+ \\int int_from_float(float a) {
\\ return (int)a;
\\}
, &[_][]const u8{
- \\pub export fn float_to_int(arg_a: f32) c_int {
+ \\pub export fn int_from_float(arg_a: f32) c_int {
\\ var a = arg_a;
- \\ return @floatToInt(c_int, a);
+ \\ return @intFromFloat(c_int, a);
\\}
});
@@ -2534,18 +2534,18 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\ var b = arg_b;
\\ var c = arg_c;
\\ var d: enum_Foo = @bitCast(c_uint, FooA);
- \\ var e: c_int = @boolToInt((a != 0) and (b != 0));
- \\ var f: c_int = @boolToInt((b != 0) and (c != null));
- \\ var g: c_int = @boolToInt((a != 0) and (c != null));
- \\ var h: c_int = @boolToInt((a != 0) or (b != 0));
- \\ var i: c_int = @boolToInt((b != 0) or (c != null));
- \\ var j: c_int = @boolToInt((a != 0) or (c != null));
- \\ var k: c_int = @boolToInt((a != 0) or (@bitCast(c_int, d) != 0));
- \\ var l: c_int = @boolToInt((@bitCast(c_int, d) != 0) and (b != 0));
- \\ var m: c_int = @boolToInt((c != null) or (d != 0));
+ \\ var e: c_int = @intFromBool((a != 0) and (b != 0));
+ \\ var f: c_int = @intFromBool((b != 0) and (c != null));
+ \\ var g: c_int = @intFromBool((a != 0) and (c != null));
+ \\ var h: c_int = @intFromBool((a != 0) or (b != 0));
+ \\ var i: c_int = @intFromBool((b != 0) or (c != null));
+ \\ var j: c_int = @intFromBool((a != 0) or (c != null));
+ \\ var k: c_int = @intFromBool((a != 0) or (@bitCast(c_int, d) != 0));
+ \\ var l: c_int = @intFromBool((@bitCast(c_int, d) != 0) and (b != 0));
+ \\ var m: c_int = @intFromBool((c != null) or (d != 0));
\\ var td: SomeTypedef = 44;
- \\ var o: c_int = @boolToInt((td != 0) or (b != 0));
- \\ var p: c_int = @boolToInt((c != null) and (td != 0));
+ \\ var o: c_int = @intFromBool((td != 0) or (b != 0));
+ \\ var p: c_int = @intFromBool((c != null) and (td != 0));
\\ return (((((((((e + f) + g) + h) + i) + j) + k) + l) + m) + o) + p;
\\}
,
@@ -2605,13 +2605,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub export fn test_comparisons(arg_a: c_int, arg_b: c_int) c_int {
\\ var a = arg_a;
\\ var b = arg_b;
- \\ var c: c_int = @boolToInt(a < b);
- \\ var d: c_int = @boolToInt(a > b);
- \\ var e: c_int = @boolToInt(a <= b);
- \\ var f: c_int = @boolToInt(a >= b);
- \\ var g: c_int = @boolToInt(c < d);
- \\ var h: c_int = @boolToInt(e < f);
- \\ var i: c_int = @boolToInt(g < h);
+ \\ var c: c_int = @intFromBool(a < b);
+ \\ var d: c_int = @intFromBool(a > b);
+ \\ var e: c_int = @intFromBool(a <= b);
+ \\ var f: c_int = @intFromBool(a >= b);
+ \\ var g: c_int = @intFromBool(c < d);
+ \\ var h: c_int = @intFromBool(e < f);
+ \\ var i: c_int = @intFromBool(g < h);
\\ return i;
\\}
});
@@ -3258,11 +3258,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub extern fn fn_bool(x: bool) void;
\\pub extern fn fn_ptr(x: ?*anyopaque) void;
\\pub export fn call() void {
- \\ fn_int(@floatToInt(c_int, 3.0));
- \\ fn_int(@floatToInt(c_int, 3.0));
+ \\ fn_int(@intFromFloat(c_int, 3.0));
+ \\ fn_int(@intFromFloat(c_int, 3.0));
\\ fn_int(@as(c_int, 1094861636));
- \\ fn_f32(@intToFloat(f32, @as(c_int, 3)));
- \\ fn_f64(@intToFloat(f64, @as(c_int, 3)));
+ \\ fn_f32(@floatFromInt(f32, @as(c_int, 3)));
+ \\ fn_f64(@floatFromInt(f64, @as(c_int, 3)));
\\ fn_char(@bitCast(u8, @truncate(i8, @as(c_int, '3'))));
\\ fn_char(@bitCast(u8, @truncate(i8, @as(c_int, '\x01'))));
\\ fn_char(@bitCast(u8, @truncate(i8, @as(c_int, 0))));
@@ -3270,9 +3270,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\ fn_f64(3.0);
\\ fn_bool(@as(c_int, 123) != 0);
\\ fn_bool(@as(c_int, 0) != 0);
- \\ fn_bool(@ptrToInt(&fn_int) != 0);
- \\ fn_int(@intCast(c_int, @ptrToInt(&fn_int)));
- \\ fn_ptr(@intToPtr(?*anyopaque, @as(c_int, 42)));
+ \\ fn_bool(@intFromPtr(&fn_int) != 0);
+ \\ fn_int(@intCast(c_int, @intFromPtr(&fn_int)));
+ \\ fn_ptr(@ptrFromInt(?*anyopaque, @as(c_int, 42)));
\\}
});
@@ -3473,11 +3473,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\}
\\pub export fn bar(arg_a: [*c]const c_int) void {
\\ var a = arg_a;
- \\ foo(@intToPtr([*c]c_int, @ptrToInt(a)));
+ \\ foo(@ptrFromInt([*c]c_int, @intFromPtr(a)));
\\}
\\pub export fn baz(arg_a: [*c]volatile c_int) void {
\\ var a = arg_a;
- \\ foo(@intToPtr([*c]c_int, @ptrToInt(a)));
+ \\ foo(@ptrFromInt([*c]c_int, @intFromPtr(a)));
\\}
});
@@ -3491,10 +3491,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
, &[_][]const u8{
\\pub export fn foo(arg_x: bool) bool {
\\ var x = arg_x;
- \\ var a: bool = @as(c_int, @boolToInt(x)) != @as(c_int, 1);
- \\ var b: bool = @as(c_int, @boolToInt(a)) != @as(c_int, 0);
- \\ var c: bool = @ptrToInt(&foo) != 0;
- \\ return foo(@as(c_int, @boolToInt(c)) != @as(c_int, @boolToInt(b)));
+ \\ var a: bool = @as(c_int, @intFromBool(x)) != @as(c_int, 1);
+ \\ var b: bool = @as(c_int, @intFromBool(a)) != @as(c_int, 0);
+ \\ var c: bool = @intFromPtr(&foo) != 0;
+ \\ return foo(@as(c_int, @intFromBool(c)) != @as(c_int, @intFromBool(b)));
\\}
});
@@ -3910,7 +3910,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub export fn foo() void {
\\ var a: c_int = undefined;
\\ if ((blk: {
- \\ const tmp = @boolToInt(@as(c_int, 1) > @as(c_int, 0));
+ \\ const tmp = @intFromBool(@as(c_int, 1) > @as(c_int, 0));
\\ a = tmp;
\\ break :blk tmp;
\\ }) != 0) {}
@@ -3928,7 +3928,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub export fn foo() void {
\\ var a: S = undefined;
\\ var b: S = undefined;
- \\ var c: c_longlong = @divExact(@bitCast(c_longlong, @ptrToInt(a) -% @ptrToInt(b)), @sizeOf(u8));
+ \\ var c: c_longlong = @divExact(@bitCast(c_longlong, @intFromPtr(a) -% @intFromPtr(b)), @sizeOf(u8));
\\ _ = @TypeOf(c);
\\}
});
@@ -3943,7 +3943,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub export fn foo() void {
\\ var a: S = undefined;
\\ var b: S = undefined;
- \\ var c: c_long = @divExact(@bitCast(c_long, @ptrToInt(a) -% @ptrToInt(b)), @sizeOf(u8));
+ \\ var c: c_long = @divExact(@bitCast(c_long, @intFromPtr(a) -% @intFromPtr(b)), @sizeOf(u8));
\\ _ = @TypeOf(c);
\\}
});